Last active
March 19, 2018 17:06
-
-
Save colonelrascals/e1ff637366e49735da21a034084ff6b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| from __future__ import unicode_literals | |
| from django.shortcuts import render, redirect | |
| from django.views import View | |
| from django.contrib import messages | |
| from ..forms import contact_form | |
| class IndexView(View): | |
| def get(self, request): | |
| if request.user.is_authenticated(): | |
| return redirect("search") | |
| return render(request, "index.html") | |
| class AboutView(View): | |
| def get(self, request): | |
| return render(request, "about.html") | |
| class ContactView(View): | |
| def get(self, request): | |
| return render(request, "contact.html", {"form": contact_form.ContactForm()}) | |
| def post(self, request): | |
| print request.POST | |
| form = contact_form.ContactForm(request.POST) | |
| print form | |
| if form.is_valid(): | |
| form.send_to_admins() | |
| messages.add_message(request, messages.SUCCESS, 'Thanks for contacting us. We will be in touch!') | |
| return redirect("index") | |
| return render(request, 'contact.html', { "form": form }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {% extends "base.html" %} | |
| {% block title%}Sign Up{% endblock %} | |
| {% block content %} | |
| <div class="modal hide" id="{{ editor_dialog_id }}"></div> | |
| <div class="row"> | |
| <div class="col-xs-12 col-sm-offset-4 col-sm-4"> | |
| <h2>Sign Up</h2> | |
| <p>Step {{ wizard.steps.step1 }} of {{ wizard.steps.count }}</p> | |
| <form action="" method="post"> | |
| {% csrf_token %} | |
| {{ wizard.management_form }} | |
| {{ wizard.form.management_form }} | |
| {% if wizard.form.non_field_errors %} | |
| {% for error in wizard.form.non_field_errors %} | |
| <p class="text-danger">{{ error }}</p> | |
| {% endfor %} | |
| {% endif %} | |
| <div class="form-group"> | |
| <label>Invitation Code</label> | |
| {% with invite_code=request.GET.invite|default:"" %} | |
| <input type="text" class="form-control" name="{{ wizard.form.invite_code.html_name }}" value="{{ wizard.form.invite_code.value|default:invite_code }}"> | |
| {% endwith %} | |
| <p class="help-block">Please copy and paste the invite code from your invitation email here. Don't have an invitation? <a href="{% url 'contact_page' %}"> Click Here</a></p> | |
| {% if wizard.form.invite_code.errors %} | |
| {% for error in wizard.form.invite_code.errors %} | |
| <p class="text-danger">{{ error }}</p> | |
| {% endfor %} | |
| {% endif %} | |
| </div> | |
| <div class="form-group"> | |
| <button type="submit" class="btn btn-fill">Next</button> | |
| </div> | |
| </form> | |
| <div class="modal hide" id="contactModal"> | |
| </div> | |
| <a data-toggle="modal" data-target="#exampleModal"> Click Here</a> | |
| <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-hidden="true"> | |
| <div class="modal-dialog modal-dialog-centered" role="document"> | |
| <div class="modal-content"> | |
| <div class="modal-header"> | |
| <h5 class="modal-title" id="exampleModalLabel">Leave Us Your Info</h5> | |
| <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |
| <span aria-hidden="true">×</span> | |
| </button> | |
| </div> | |
| <div class="modal-body"> | |
| <form method="post" class="form" action="/contact/"> | |
| {% csrf_token %} | |
| {% if form.non_field_errors %} | |
| {% for error in form.non_field_errors %} | |
| <p class="text-danger">{{ error }}</p> | |
| {% endfor %} | |
| {% endif %} | |
| <div class="form-group"> | |
| <label for="{{ form.name.html_name }}">Your name</label> | |
| {% with name=request.user.full_name|default:"" %} | |
| <input type="text" class="form-control" name="{{ form.name.html_name }}" value="{{ form.name.value|default:name }}"> | |
| {% endwith %} | |
| {% if form.name.errors %} | |
| {% for error in form.name.errors %} | |
| <p class="text-danger">{{ error }}</p> | |
| {% endfor %} | |
| {% endif %} | |
| </div> | |
| <div class="form-group"> | |
| <label for="{{ form.email.html_name }}">Your email</label> | |
| {% with email=request.user.email|default:"" %} | |
| <input type="email" class="form-control" name="{{ form.email.html_name }}" value="{{ form.email.value|default:email }}"> | |
| {% endwith %} | |
| {% if form.email.errors %} | |
| {% for error in form.email.errors %} | |
| <p class="text-danger">{{ error }}</p> | |
| {% endfor %} | |
| {% endif %} | |
| </div> | |
| <div class="form-group"> | |
| <label for="{{ form.message.html_name }}">Your message</label> | |
| <textarea class="form-control" name="{{ form.message.html_name }}"></textarea> | |
| {% if form.message.errors %} | |
| {% for error in form.message.errors %} | |
| <p class="text-danger">{{ error }}</p> | |
| {% endfor %} | |
| {% endif %} | |
| </div> | |
| <div class="form-group"> | |
| <button type="submit" class="btn btn-fill chill-btn">Send</button> | |
| </div> | |
| </form> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| {% endblock %} | |
| </div> | |
| </div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment