Resolve conflicts in views

This commit is contained in:
HenryGBC 2017-03-23 22:37:15 -04:30
commit f3e26c9cbe
4 changed files with 111 additions and 7 deletions

View file

@ -415,7 +415,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>
@ -423,6 +423,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>
@ -510,7 +566,15 @@
<script src="/static/debug_toolbar/js/toolbar.js"></script>
<div id="feedly-mini" title="feedly Mini tookit"></div>
</body>
<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, 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"

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)