added contact form in alplora

This commit is contained in:
Levi 2017-03-22 11:18:10 -04:00
parent c6120cf951
commit b4651cc337
4 changed files with 110 additions and 6 deletions

View file

@ -406,7 +406,7 @@
<h1>{% trans 'How do I get Alplora?'%}</h1>
<h3>{% trans 'Click the below button and leave us your contact.'%}<p></p>{% trans 'Team Alplora will contact you and visit you with tracking device. '%}</h3>
<hr class="intro-divider">
<a href="#howitworks" class="btn btn-default btn-lg"><i class="#Services"></i> <span class="network-name">{% trans 'Contact'%}</span></a>
<a href="#howitworks" class="btn btn-default btn-lg"><i class="#Services"></i> <span class="network-name" data-toggle="modal" data-target="#exampleModal" >{% trans 'Contact'%}</span></a>
</ul>
</div>
@ -414,6 +414,62 @@
</div>
</div>
<!-- CONTACT FORM MODAL -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" style="color:black;">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="exampleModalLabel">New message</h4>
</div>
<form method="POST" action="">
<div class="modal-body">
{% csrf_token %}
{{ form.non_field_errors }}
<div class="form-group text-left">
<label for="recipient-name" class="control-label ">Name:</label>
<input type="text" class="form-control" name="name" placeholder="What is your name ?" id="recipient-name" required>
</div>
<div class="form-group text-left">
<label for="recipient-name" class="control-label ">From:</label>
<input type="text" class="form-control" name="email" placeholder="You email" id="recipient-name" required>
{{ form.email.errors|striptags}}
</div>
<div class="form-group text-left">
<label for="message-text" class="control-label ">Message:</label>
<textarea class="form-control" name="message" placeholder="Leave us your message" id="message-text" required></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-warning">Send message</button>
</div>
</form>
</div>
</div>
</div>
<!-- SUCCESS MODAL MESSAGE -->
<div class="modal fade bs-example-modal-sm" style="color:black;" id="request-success-message" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">{% trans "Request Sent" %}</h4>
</div>
<div class="modal-body">
<p>{% trans "Thank you, we will contact you as soon as possible" %}</p>
</div>
<div class="modal-footer text-center">
<button type="submit" class="btn btn-primary" data-dismiss="modal">Ok</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- /.container -->
</div>
@ -501,7 +557,15 @@
<script src="/static/debug_toolbar/js/toolbar.js"></script>
<div id="feedly-mini" title="feedly Mini tookit"></div>
<script type="text/javascript">
window.onload=function(){
var hash = window.location.hash.substr(1);
if (hash == 'requestformsuccess'){
$('#request-success-message').modal('show');
}
};
</script>
</body>
</html>
<!DOCTYPE html>

View file

@ -1,8 +1,17 @@
from django.views.generic import TemplateView
from django.utils.translation import get_language
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
class IndexView(TemplateView):
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)
@ -12,6 +21,17 @@ class IndexView(TemplateView):
})
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"

View file

@ -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),
),
]

View file

@ -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)