Changeset - a6cf86f82654
[Not reviewed]
0 3 1
Christopher Neugebauer - 3 years ago 2017-08-18 15:46:51
chrisjrn@gmail.com
Adds new combined login & signup view
4 files changed with 80 insertions and 0 deletions:
0 comments (0 inline, 0 general)
pinaxcon/settings.py
Show inline comments
...
 
@@ -261,6 +261,8 @@ EMAIL_HOST_PASSWORD = os.environ.get("DJANGO_EMAIL_HOST_PASSWORD", "")
 
EMAIL_USE_TLS = bool(int(os.environ.get("DJANGO_EMAIL_USE_TLS", "0")))
 
EMAIL_USE_SSL = bool(int(os.environ.get("DJANGO_EMAIL_USE_SSL", "0")))
 

	
 
ACCOUNT_LOGIN_URL = "nbpy_login"
 
LOGIN_URL = "nbpy_login"
 

	
 
# We need to explicitly switch on signups.
 
ACCOUNT_OPEN_SIGNUP = bool(int(os.environ.get("DJANGO_ACCOUNT_OPEN_SIGNUP", "0")))
pinaxcon/templates/account_login.html
Show inline comments
 
new file 100644
 
{% extends "page_with_title_and_lede.html" %}
 

	
 
{% load bootstrap %}
 
{% load i18n %}
 

	
 
{% block head_title %}Log In{% endblock %}
 

	
 
{% block heading %}Log In or Sign Up{% endblock %}
 

	
 
{% block body_class %}login{% endblock %}
 

	
 
{% block content %}
 

	
 
  <div class="container">
 
    <div class="row">
 
      <div class="col-md-4">
 

	
 
        <form action="{% url 'account_login' %}" method="POST">
 
          <div class="panel panel-primary">
 
            <div class="panel-heading">
 
              <h3 class="panel-title">
 
                Log into an existing account
 
              </h3>
 
            </div>
 
            <div class="panel-body">
 
              {% csrf_token %}
 
              {{ login_form| bootstrap }}
 
            </div>
 
            <div class="panel-footer">
 
              <button role="submit" class="btn btn-primary">Log In</button>
 
            </div>
 
          </div>
 
        </form>
 

	
 
      </div>
 
      {% if signup_open %}
 
        <div class="col-md-4">
 
          <form action="{% url 'account_signup' %}" method="POST">
 
            <div class="panel panel-default">
 
              <div class="panel-heading">
 
                <h3 class="panel-title">
 
                  Sign up for a new account
 
                </h3>
 
              </div>
 
              <div class="panel-body">
 
                {% csrf_token %}
 
                {{ signup_form|bootstrap }}
 
              </div>
 
              <div class="panel-footer">
 
                <button role="submit" class="btn btn-primary">Sign Up</button>
 
              </div>
 
            </div>
 
          </form>
 
        </div>
 
      {% endif %}
 
    </div>
 
  </div>
 

	
 
{% endblock %}
pinaxcon/urls.py
Show inline comments
...
 
@@ -52,6 +52,7 @@ urlpatterns = [
 

	
 
    url(r"^admin/", include(admin.site.urls)),
 

	
 
    url(r"^login$", views.account_login, name="nbpy_login"),
 
    url(r"^account/", include("account.urls")),
 

	
 
    url(r"^dashboard/", symposion.views.dashboard, name="dashboard"),
pinaxcon/views.py
Show inline comments
 
from django.conf import settings
 
from django.http import HttpResponseServerError
 
from django.shortcuts import render
 
from django.template import RequestContext
 
from django.template import Template
 
from django.template.loader import get_template
 
from django.views import defaults
 

	
 
from account.forms import LoginEmailForm, LoginUsernameForm, SignupForm
 

	
 
def server_error(request, template_name=defaults.ERROR_500_TEMPLATE_NAME):
 
    t = Template("{%% include '%s' %%}" % template_name)
 
    return HttpResponseServerError(t.render(RequestContext(request)))
 

	
 

	
 
def account_login(request):
 

	
 
    d = {
 
        "login_form": LoginEmailForm(),
 
        "signup_form": SignupForm(),
 
        "signup_open": getattr(settings, "ACCOUNT_OPEN_SIGNUP", True),
 
    }
 

	
 
    print d["signup_open"], settings.ACCOUNT_OPEN_SIGNUP
 
    return render(request, "account_login.html", d)
 

	
 

	
0 comments (0 inline, 0 general)