so much pain and duplication just to get the cursor into the right field using html5 autofocus attr
This commit is contained in:
parent
76d3dfebc2
commit
aa755d2ce2
@ -7,7 +7,4 @@ from .views import UserProfileView
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^profile/', UserProfileView.as_view(), name="account_profile"),
|
||||
url(r'^change_pw/', password_change, {
|
||||
'template_name': 'registration/password_change.html',
|
||||
'post_change_redirect': '/account/profile/', },
|
||||
name="password_change"), )
|
||||
)
|
||||
|
@ -62,7 +62,7 @@
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user fa-fw"></i> {{ request.user.username }} <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="{% url 'account_profile' %}"><i class="fa fa-cogs fa-fw"></i> Profile</a></li>
|
||||
<li><a href="{% url 'password_change' %}"><i class="fa fa-key fa-fw"></i> Change password</a></li>
|
||||
<li><a href="{% url 'auth_password_change' %}"><i class="fa fa-key fa-fw"></i> Change password</a></li>
|
||||
{% if request.user.is_staff %}
|
||||
<li><a href="/admin/"><i class="fa fa-wrench fa-fw"></i> Admin</a></li>
|
||||
{% endif %}
|
||||
|
@ -1,12 +1,99 @@
|
||||
from django.conf.urls import patterns, include, url
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.contrib import admin
|
||||
from django.views.generic.base import TemplateView
|
||||
from django.contrib.auth.forms import AuthenticationForm, PasswordChangeForm
|
||||
from django.contrib.auth import views as auth_views
|
||||
|
||||
admin.autodiscover()
|
||||
|
||||
from registration.backends.default.views import ActivationView
|
||||
from registration.backends.default.views import RegistrationView
|
||||
from registration.forms import RegistrationForm
|
||||
|
||||
|
||||
class Html5RegistrationForm(RegistrationForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Html5RegistrationForm, self).__init__(*args, **kwargs)
|
||||
self.fields['username'].widget.attrs.update(dict(autofocus=None))
|
||||
|
||||
|
||||
class Html5AuthenticationForm(AuthenticationForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Html5AuthenticationForm, self).__init__(*args, **kwargs)
|
||||
self.fields['username'].widget.attrs.update(dict(autofocus=None))
|
||||
|
||||
|
||||
def html5_login(*args, **kwargs):
|
||||
kwargs['authentication_form'] = Html5AuthenticationForm
|
||||
return auth_views.login(*args, **kwargs)
|
||||
|
||||
|
||||
class Html5PasswordChangeForm(PasswordChangeForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Html5PasswordChangeForm, self).__init__(*args, **kwargs)
|
||||
self.fields['old_password'].widget.attrs.update(dict(autofocus=None))
|
||||
|
||||
|
||||
def html5_password_change(*args, **kwargs):
|
||||
kwargs['password_change_form'] = Html5PasswordChangeForm
|
||||
kwargs['template_name'] = 'registration/password_change.html' # own template
|
||||
kwargs['post_change_redirect'] = reverse('account_profile')
|
||||
return auth_views.password_change(*args, **kwargs)
|
||||
|
||||
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url('', include('social.apps.django_app.urls', namespace='social')),
|
||||
url(r'^accounts/', include('registration.backends.default.urls')),
|
||||
# registration start
|
||||
# this is a modified copy of registration.backends.default.urls:
|
||||
url(r'^accounts/activate/complete/$',
|
||||
TemplateView.as_view(template_name='registration/activation_complete.html'),
|
||||
name='registration_activation_complete'),
|
||||
# Activation keys get matched by \w+ instead of the more specific
|
||||
# [a-fA-F0-9]{40} because a bad activation key should still get to the view;
|
||||
# that way it can return a sensible "invalid key" message instead of a
|
||||
# confusing 404.
|
||||
url(r'^accounts/activate/(?P<activation_key>\w+)/$',
|
||||
ActivationView.as_view(),
|
||||
name='registration_activate'),
|
||||
url(r'^accounts/register/$',
|
||||
RegistrationView.as_view(form_class=Html5RegistrationForm),
|
||||
name='registration_register'),
|
||||
url(r'^accounts/register/complete/$',
|
||||
TemplateView.as_view(template_name='registration/registration_complete.html'),
|
||||
name='registration_complete'),
|
||||
url(r'^accounts/register/closed/$',
|
||||
TemplateView.as_view(template_name='registration/registration_closed.html'),
|
||||
name='registration_disallowed'),
|
||||
# from registration.auth_urls:
|
||||
url(r'^accounts/login/$',
|
||||
html5_login,
|
||||
{'template_name': 'registration/login.html'},
|
||||
name='auth_login'),
|
||||
url(r'^accounts/logout/$',
|
||||
auth_views.logout,
|
||||
{'template_name': 'registration/logout.html'},
|
||||
name='auth_logout'),
|
||||
url(r'^accounts/password/change/$',
|
||||
html5_password_change,
|
||||
name='auth_password_change'),
|
||||
url(r'^accounts/password/change/done/$',
|
||||
auth_views.password_change_done,
|
||||
name='auth_password_change_done'),
|
||||
url(r'^accounts/password/reset/$',
|
||||
auth_views.password_reset,
|
||||
name='auth_password_reset'),
|
||||
url(r'^accounts/password/reset/confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
|
||||
auth_views.password_reset_confirm,
|
||||
name='auth_password_reset_confirm'),
|
||||
url(r'^accounts/password/reset/complete/$',
|
||||
auth_views.password_reset_complete,
|
||||
name='auth_password_reset_complete'),
|
||||
url(r'^accounts/password/reset/done/$',
|
||||
auth_views.password_reset_done,
|
||||
name='auth_password_reset_done'),
|
||||
# registration end
|
||||
url(r'^account/', include('nsupdate.accounts.urls')),
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
url(r'^', include('nsupdate.main.urls')),
|
||||
|
Loading…
x
Reference in New Issue
Block a user