Django

Code

Changeset 3520

Show
Ignore:
Timestamp:
08/03/06 23:18:12 (2 years ago)
Author:
adrian
Message:

Fixed #61 -- No more editing hashes when creating users via the admin. Created a special-case 'Add user' admin view. The change form still displays the hash, for the moment.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/admin/urls.py

    r3247 r3520  
    2929    ('^doc/templates/(?P<template>.*)/$', 'django.contrib.admin.views.doc.template_detail'), 
    3030 
     31    # "Add user" -- a special-case view 
     32    ('^auth/user/add/$', 'django.contrib.admin.views.auth.user_add_stage'), 
     33 
    3134    # Add/change/delete/history 
    3235    ('^([^/]+)/([^/]+)/$', 'django.contrib.admin.views.main.change_list'), 
  • django/trunk/django/contrib/auth/forms.py

    r3462 r3520  
    55from django.core import validators 
    66from django import forms 
     7 
     8class UserCreationForm(forms.Manipulator): 
     9    "A form that creates a user, with no privileges, from the given username and password." 
     10    def __init__(self): 
     11        self.fields = ( 
     12            forms.TextField(field_name='username', length=30, maxlength=30, is_required=True, 
     13                validator_list=[validators.isAlphaNumeric, self.isValidUsername]), 
     14            forms.PasswordField(field_name='password1', length=30, maxlength=60, is_required=True), 
     15            forms.PasswordField(field_name='password2', length=30, maxlength=60, is_required=True, 
     16                validator_list=[validators.AlwaysMatchesOtherField('password1', "The two password fields didn't match.")]), 
     17        ) 
     18 
     19    def isValidUsername(self, field_data, all_data): 
     20        try: 
     21            User.objects.get(username=field_data) 
     22        except User.DoesNotExist: 
     23            return 
     24        raise validators.ValidationError, 'A user with that username already exists.' 
     25 
     26    def save(self, new_data): 
     27        "Creates the user." 
     28        return User.objects.create_user(new_data['username'], '', new_data['password1']) 
    729 
    830class AuthenticationForm(forms.Manipulator):