login form now remembers the username you picked [#23965785]
parent
a2329de3b1
commit
cc2623e196
|
@ -2,6 +2,7 @@ from datetime import timedelta
|
|||
from django import forms
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.forms import AuthenticationForm
|
||||
from django.conf import settings
|
||||
from django.conf.global_settings import LANGUAGES
|
||||
from django.core.validators import validate_email
|
||||
|
@ -444,3 +445,11 @@ class FeedbackForm(forms.Form):
|
|||
raise forms.ValidationError(_("Whoops, try that sum again."))
|
||||
|
||||
return cleaned_data
|
||||
|
||||
class AuthForm(AuthenticationForm):
|
||||
def __init__(self, request=None, *args, **kwargs):
|
||||
if request.method == 'GET':
|
||||
saved_un= request.COOKIES.get('un', None)
|
||||
super(AuthForm, self).__init__(initial={"username":saved_un},*args, **kwargs)
|
||||
else:
|
||||
super(AuthForm, self).__init__(*args, **kwargs)
|
||||
|
|
|
@ -15,7 +15,11 @@
|
|||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($) {
|
||||
$('.listview').addClass("panelview").removeClass("listview");
|
||||
});
|
||||
});
|
||||
function put_un_in_cookie(){
|
||||
$j.cookie('un', $j('#id_username_pop').val(), {path: '/'});
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="/static/js/definitions.js"></script>
|
||||
|
@ -41,7 +45,7 @@
|
|||
<h3 class="module-title">Start Ungluing Now!</h3>
|
||||
<div class="jsmod-content">
|
||||
{% if not request.user.is_authenticated %}
|
||||
<form action='{% url registration_register %}' method='post'>{% csrf_token %}
|
||||
<form action="{% url registration_register %}" method="post" onsubmit="return put_un_in_cookie();" >{% csrf_token %}
|
||||
<div class="user-name">
|
||||
<label>Username</label>
|
||||
<input id="id_username_pop" type="text" class="required" name="username" maxlength="30" size="30" />
|
||||
|
|
|
@ -1,13 +1,21 @@
|
|||
{% extends "registration/registration_base.html" %}
|
||||
|
||||
{% block title %}Register for an account{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
{{ block.super }}
|
||||
<script type="text/javascript">
|
||||
function put_un_in_cookie(){
|
||||
$j.cookie('un', $j('#id_username').val(), {path: '/'});
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% block doccontent %}
|
||||
{% if not user.is_authenticated %}
|
||||
|
||||
<h3>Sign up for a Unglue.it account:</h3>
|
||||
|
||||
<form method='post' action=''>{% csrf_token %}
|
||||
<form method='post' action='' onsubmit="return put_un_in_cookie();">{% csrf_token %}
|
||||
{{ form }}
|
||||
<input type="submit" value="Send activation email" />
|
||||
</form>
|
||||
|
|
|
@ -50,7 +50,7 @@ from regluit.frontend.forms import UserData, UserEmail, ProfileForm, CampaignPle
|
|||
from regluit.frontend.forms import RightsHolderForm, UserClaimForm, LibraryThingForm, OpenCampaignForm
|
||||
from regluit.frontend.forms import getManageCampaignForm, DonateForm, CampaignAdminForm, EmailShareForm, FeedbackForm
|
||||
from regluit.frontend.forms import EbookForm, CustomPremiumForm, EditManagersForm, EditionForm, PledgeCancelForm
|
||||
from regluit.frontend.forms import getTransferCreditForm, CCForm, CloneCampaignForm, PlainCCForm, WorkForm, OtherWorkForm
|
||||
from regluit.frontend.forms import getTransferCreditForm, CCForm, CloneCampaignForm, PlainCCForm, WorkForm, OtherWorkForm, AuthForm
|
||||
from regluit.payment.manager import PaymentManager
|
||||
from regluit.payment.models import Transaction, Account
|
||||
from regluit.payment import baseprocessor
|
||||
|
@ -143,7 +143,7 @@ def superlogin(request, **kwargs):
|
|||
extra_context={"socials":user.profile.social_auths}
|
||||
except:
|
||||
pass
|
||||
return login(request, extra_context=extra_context)
|
||||
return login(request, extra_context=extra_context, authentication_form=AuthForm)
|
||||
|
||||
def work(request, work_id, action='display'):
|
||||
work = safe_get_work(work_id)
|
||||
|
|
3
urls.py
3
urls.py
|
@ -1,11 +1,12 @@
|
|||
from django.conf.urls.defaults import *
|
||||
from frontend.forms import ProfileForm
|
||||
from frontend.views import superlogin
|
||||
from django.views.generic.simple import direct_to_template
|
||||
from regluit.admin import admin_site
|
||||
import notification.urls
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^accounts/activate/complete/$','django.contrib.auth.views.login',
|
||||
url(r'^accounts/activate/complete/$',superlogin,
|
||||
{'template_name': 'registration/activation_complete.html'}),
|
||||
(r'^accounts/edit/$', 'regluit.frontend.views.edit_user'),
|
||||
(r'^accounts/', include('registration.backends.default.urls')),
|
||||
|
|
Loading…
Reference in New Issue