diff --git a/alplora/templates/alplora/index.html b/alplora/templates/alplora/index.html index 9bc12a53..66b7e1ec 100644 --- a/alplora/templates/alplora/index.html +++ b/alplora/templates/alplora/index.html @@ -415,7 +415,7 @@

{% trans 'How do I get Alplora?'%}

{% trans 'Click the below button and leave us your contact.'%}

{% trans 'Team Alplora will contact you and visit you with tracking device. '%}


- {% trans 'Contact'%} + {% trans 'Contact'%} @@ -423,6 +423,62 @@ + + + + + + + @@ -510,7 +566,15 @@ -
- + + + - \ No newline at end of file diff --git a/alplora/views.py b/alplora/views.py index 46b9ce76..8722823a 100644 --- a/alplora/views.py +++ b/alplora/views.py @@ -1,8 +1,17 @@ from django.views.generic import TemplateView -from django.utils.translation import get_language, get_language_info -class IndexView(TemplateView): +from django.utils.translation import get_language, get_language_info +from django.utils.translation import ugettext_lazy as _ +from django.views.generic.edit import FormView +from django.contrib import messages +from django.core.urlresolvers import reverse_lazy, reverse + +from utils.forms import ContactUsForm + +class IndexView(FormView): template_name = "alplora/index.html" + form_class = ContactUsForm + success_message = _('Message Successfully Sent') def get_context_data(self, *args, **kwargs): context = super(IndexView, self).get_context_data(**kwargs) @@ -10,6 +19,17 @@ class IndexView(TemplateView): context.update(languages) return context + def get_success_url(self): + success_url = reverse('alplora:index') + success_url += "#requestformsuccess" + return success_url + + def form_valid(self, form): + form.save() + form.send_email() + messages.add_message(self.request, messages.SUCCESS, self.success_message) + return super(IndexView, self).form_valid(form) + class LoginView(TemplateView): template_name = "alplora/login.html" diff --git a/utils/migrations/0005_auto_20170322_1443.py b/utils/migrations/0005_auto_20170322_1443.py new file mode 100644 index 00000000..62a77c69 --- /dev/null +++ b/utils/migrations/0005_auto_20170322_1443.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2017-03-22 14:43 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('utils', '0004_auto_20161013_0253'), + ] + + operations = [ + migrations.AlterField( + model_name='contactmessage', + name='phone_number', + field=models.CharField(blank=True, max_length=200), + ), + ] diff --git a/utils/models.py b/utils/models.py index aadb4e72..d5592d74 100644 --- a/utils/models.py +++ b/utils/models.py @@ -43,7 +43,7 @@ class UserBillingAddress(BaseBillingAddress): class ContactMessage(models.Model): name = models.CharField(max_length=200) email = models.EmailField() - phone_number = models.CharField(max_length=200) + phone_number = models.CharField(max_length=200, blank=True) message = models.TextField() received_date = models.DateTimeField(auto_now_add=True)