Linted wagtailusers

pull/3/head
Neal Todd 2014-02-06 12:29:11 +00:00
rodzic 47ebe83c6f
commit c548b391d5
3 zmienionych plików z 23 dodań i 11 usunięć

Wyświetl plik

@ -6,9 +6,11 @@ from django.utils.translation import ugettext_lazy as _
# extend Django's UserCreationForm with an 'is_superuser' field
class UserCreationForm(BaseUserCreationForm):
required_css_class = "required"
is_superuser = forms.BooleanField(label=_("Administrator"), required=False,
is_superuser = forms.BooleanField(
label=_("Administrator"),
required=False,
help_text=_("If ticked, this user has the ability to manage user accounts.")
)
first_name = forms.CharField(required=True)
@ -43,26 +45,32 @@ class UserEditForm(forms.ModelForm):
'duplicate_username': _("A user with that username already exists."),
'password_mismatch': _("The two password fields didn't match."),
}
username = forms.RegexField(label=_("Username"), max_length=30,
username = forms.RegexField(
label=_("Username"),
max_length=30,
regex=r'^[\w.@+-]+$',
help_text=_("Required. 30 characters or fewer. Letters, digits and "
"@/./+/-/_ only."),
help_text=_("Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only."),
error_messages={
'invalid': _("This value may contain only letters, numbers and "
"@/./+/-/_ characters.")})
'invalid': _("This value may contain only letters, numbers and @/./+/-/_ characters.")
})
email = forms.EmailField(required=True)
first_name = forms.CharField(required=True)
last_name = forms.CharField(required=True)
password1 = forms.CharField(label=_("Password"), required=False,
password1 = forms.CharField(
label=_("Password"),
required=False,
widget=forms.PasswordInput,
help_text=_("Leave blank if not changing."))
password2 = forms.CharField(label=_("Password confirmation"), required=False,
password2 = forms.CharField(
label=_("Password confirmation"), required=False,
widget=forms.PasswordInput,
help_text=_("Enter the same password as above, for verification."))
is_superuser = forms.BooleanField(label=_("Administrator"), required=False,
is_superuser = forms.BooleanField(
label=_("Administrator"),
required=False,
help_text=_("Administrators have the ability to manage user accounts.")
)

Wyświetl plik

@ -1,6 +1,7 @@
from django.conf.urls import patterns, url
urlpatterns = patterns('wagtail.wagtailusers.views',
urlpatterns = patterns(
'wagtail.wagtailusers.views',
url(r'^$', 'users.index', name='wagtailusers_index'),
url(r'^new/$', 'users.create', name='wagtailusers_create'),
url(r'^(\d+)/$', 'users.edit', name='wagtailusers_edit'),

Wyświetl plik

@ -5,6 +5,7 @@ from django.contrib import messages
from wagtail.wagtailusers.forms import UserCreationForm, UserEditForm
@permission_required('auth.change_user')
def index(request):
users = User.objects.order_by('last_name', 'first_name')
@ -13,6 +14,7 @@ def index(request):
'users': users,
})
@permission_required('auth.change_user')
def create(request):
if request.POST:
@ -30,6 +32,7 @@ def create(request):
'form': form,
})
@permission_required('auth.change_user')
def edit(request, user_id):
user = get_object_or_404(User, id=user_id)