mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
Patched the migrations and wagtailusers app to add better support for custom AUTH_USER_MODEL
This commit is contained in:
parent
d562659fff
commit
8e7cb95012
11
wagtail/wagtailcore/compat.py
Normal file
11
wagtail/wagtailcore/compat.py
Normal file
@ -0,0 +1,11 @@
|
||||
from django.conf import settings
|
||||
|
||||
# A setting that can be used in foreign key declarations
|
||||
AUTH_USER_MODEL = getattr(settings, 'AUTH_USER_MODEL', 'auth.User')
|
||||
# Two additional settings that are useful in South migrations when
|
||||
# specifying the user model in the FakeORM
|
||||
try:
|
||||
AUTH_USER_APP_LABEL, AUTH_USER_MODEL_NAME = AUTH_USER_MODEL.rsplit('.', 1)
|
||||
except ValueError:
|
||||
raise ImproperlyConfigured("AUTH_USER_MODEL must be of the form"
|
||||
" 'app_label.model_name'")
|
@ -4,6 +4,8 @@ from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
from wagtail.wagtailcore.compat import AUTH_USER_MODEL, AUTH_USER_MODEL_NAME
|
||||
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
@ -30,7 +32,7 @@ class Migration(SchemaMigration):
|
||||
('live', self.gf('django.db.models.fields.BooleanField')(default=True)),
|
||||
('has_unpublished_changes', self.gf('django.db.models.fields.BooleanField')(default=False)),
|
||||
('url_path', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
|
||||
('owner', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='owned_pages', null=True, to=orm['auth.User'])),
|
||||
('owner', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='owned_pages', null=True, to=orm[AUTH_USER_MODEL])),
|
||||
('seo_title', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
|
||||
('show_in_menus', self.gf('django.db.models.fields.BooleanField')(default=False)),
|
||||
('search_description', self.gf('django.db.models.fields.TextField')(blank=True)),
|
||||
@ -43,7 +45,7 @@ class Migration(SchemaMigration):
|
||||
('page', self.gf('django.db.models.fields.related.ForeignKey')(related_name='revisions', to=orm['wagtailcore.Page'])),
|
||||
('submitted_for_moderation', self.gf('django.db.models.fields.BooleanField')(default=False)),
|
||||
('created_at', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
|
||||
('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], null=True, blank=True)),
|
||||
('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm[AUTH_USER_MODEL], null=True, blank=True)),
|
||||
('content_json', self.gf('django.db.models.fields.TextField')()),
|
||||
))
|
||||
db.send_create_signal(u'wagtailcore', ['PageRevision'])
|
||||
@ -86,8 +88,8 @@ class Migration(SchemaMigration):
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
},
|
||||
u'auth.user': {
|
||||
'Meta': {'object_name': 'User'},
|
||||
AUTH_USER_MODEL: {
|
||||
'Meta': {'object_name': AUTH_USER_MODEL_NAME},
|
||||
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
@ -124,7 +126,7 @@ class Migration(SchemaMigration):
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'live': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
'numchild': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
|
||||
'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'owned_pages'", 'null': 'True', 'to': u"orm['auth.User']"}),
|
||||
'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'owned_pages'", 'null': 'True', 'to': u"orm['%s']" % AUTH_USER_MODEL}),
|
||||
'path': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
|
||||
'search_description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||
'seo_title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
|
||||
@ -140,7 +142,7 @@ class Migration(SchemaMigration):
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'page': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'revisions'", 'to': u"orm['wagtailcore.Page']"}),
|
||||
'submitted_for_moderation': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True', 'blank': 'True'})
|
||||
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['%s']" % AUTH_USER_MODEL, 'null': 'True', 'blank': 'True'})
|
||||
},
|
||||
u'wagtailcore.site': {
|
||||
'Meta': {'object_name': 'Site'},
|
||||
|
@ -5,6 +5,9 @@ from south.v2 import DataMigration
|
||||
from django.db import models, connection
|
||||
from django.db.transaction import set_autocommit
|
||||
|
||||
from wagtail.wagtailcore.compat import AUTH_USER_MODEL, AUTH_USER_MODEL_NAME
|
||||
|
||||
|
||||
class Migration(DataMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
@ -71,8 +74,8 @@ class Migration(DataMigration):
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
},
|
||||
u'auth.user': {
|
||||
'Meta': {'object_name': 'User'},
|
||||
AUTH_USER_MODEL: {
|
||||
'Meta': {'object_name': AUTH_USER_MODEL_NAME},
|
||||
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
@ -109,7 +112,7 @@ class Migration(DataMigration):
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'live': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
'numchild': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
|
||||
'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'owned_pages'", 'null': 'True', 'to': u"orm['auth.User']"}),
|
||||
'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'owned_pages'", 'null': 'True', 'to': u"orm['%s']" % AUTH_USER_MODEL}),
|
||||
'path': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
|
||||
'search_description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||
'seo_title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
|
||||
@ -125,7 +128,7 @@ class Migration(DataMigration):
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'page': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'revisions'", 'to': u"orm['wagtailcore.Page']"}),
|
||||
'submitted_for_moderation': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True', 'blank': 'True'})
|
||||
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['%s']" % AUTH_USER_MODEL, 'null': 'True', 'blank': 'True'})
|
||||
},
|
||||
u'wagtailcore.site': {
|
||||
'Meta': {'object_name': 'Site'},
|
||||
|
@ -4,6 +4,8 @@ from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
from wagtail.wagtailcore.compat import AUTH_USER_MODEL, AUTH_USER_MODEL_NAME
|
||||
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
@ -20,7 +22,7 @@ class Migration(SchemaMigration):
|
||||
('created_at', self.gf('django.db.models.fields.DateTimeField')
|
||||
(auto_now_add=True, blank=True)),
|
||||
('uploaded_by_user', self.gf('django.db.models.fields.related.ForeignKey')
|
||||
(to=orm['auth.User'], null=True, blank=True)),
|
||||
(to=orm[AUTH_USER_MODEL], null=True, blank=True)),
|
||||
))
|
||||
db.send_create_signal(u'wagtaildocs', ['Document'])
|
||||
|
||||
@ -42,8 +44,8 @@ class Migration(SchemaMigration):
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
},
|
||||
u'auth.user': {
|
||||
'Meta': {'object_name': 'User'},
|
||||
AUTH_USER_MODEL: {
|
||||
'Meta': {'object_name': AUTH_USER_MODEL_NAME},
|
||||
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
@ -71,7 +73,7 @@ class Migration(SchemaMigration):
|
||||
'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}),
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'uploaded_by_user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True', 'blank': 'True'})
|
||||
'uploaded_by_user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['%s']" % AUTH_USER_MODEL, 'null': 'True', 'blank': 'True'})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,9 @@ from south.v2 import DataMigration
|
||||
from django.db import models, connection
|
||||
from django.db.transaction import set_autocommit
|
||||
|
||||
from wagtail.wagtailcore.compat import AUTH_USER_MODEL, AUTH_USER_MODEL_NAME
|
||||
|
||||
|
||||
class Migration(DataMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
@ -50,8 +53,8 @@ class Migration(DataMigration):
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
},
|
||||
u'auth.user': {
|
||||
'Meta': {'object_name': 'User'},
|
||||
AUTH_USER_MODEL: {
|
||||
'Meta': {'object_name': AUTH_USER_MODEL_NAME},
|
||||
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
@ -79,7 +82,7 @@ class Migration(DataMigration):
|
||||
'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}),
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'uploaded_by_user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True', 'blank': 'True'})
|
||||
'uploaded_by_user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['%s']" % AUTH_USER_MODEL, 'null': 'True', 'blank': 'True'})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@ from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
from wagtail.wagtailcore.compat import AUTH_USER_MODEL, AUTH_USER_MODEL_NAME
|
||||
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
@ -22,7 +24,7 @@ class Migration(SchemaMigration):
|
||||
('created_at', self.gf('django.db.models.fields.DateTimeField')
|
||||
(auto_now_add=True, blank=True)),
|
||||
('uploaded_by_user', self.gf('django.db.models.fields.related.ForeignKey')
|
||||
(to=orm['auth.User'], null=True, blank=True)),
|
||||
(to=orm[AUTH_USER_MODEL], null=True, blank=True)),
|
||||
))
|
||||
db.send_create_signal(u'wagtailimages', ['Image'])
|
||||
|
||||
@ -77,8 +79,8 @@ class Migration(SchemaMigration):
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
},
|
||||
u'auth.user': {
|
||||
'Meta': {'object_name': 'User'},
|
||||
AUTH_USER_MODEL: {
|
||||
'Meta': {'object_name': AUTH_USER_MODEL_NAME},
|
||||
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
@ -112,7 +114,7 @@ class Migration(SchemaMigration):
|
||||
'height': ('django.db.models.fields.IntegerField', [], {}),
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'uploaded_by_user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True', 'blank': 'True'}),
|
||||
'uploaded_by_user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['%s']" % AUTH_USER_MODEL, 'null': 'True', 'blank': 'True'}),
|
||||
'width': ('django.db.models.fields.IntegerField', [], {})
|
||||
},
|
||||
u'wagtailimages.rendition': {
|
||||
|
@ -5,6 +5,9 @@ from south.v2 import DataMigration
|
||||
from django.db import models, connection
|
||||
from django.db.transaction import set_autocommit
|
||||
|
||||
from wagtail.wagtailcore.compat import AUTH_USER_MODEL, AUTH_USER_MODEL_NAME
|
||||
|
||||
|
||||
class Migration(DataMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
@ -50,8 +53,8 @@ class Migration(DataMigration):
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
},
|
||||
u'auth.user': {
|
||||
'Meta': {'object_name': 'User'},
|
||||
AUTH_USER_MODEL: {
|
||||
'Meta': {'object_name': AUTH_USER_MODEL_NAME},
|
||||
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
@ -85,7 +88,7 @@ class Migration(DataMigration):
|
||||
'height': ('django.db.models.fields.IntegerField', [], {}),
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'uploaded_by_user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True', 'blank': 'True'}),
|
||||
'uploaded_by_user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['%s']" % AUTH_USER_MODEL, 'null': 'True', 'blank': 'True'}),
|
||||
'width': ('django.db.models.fields.IntegerField', [], {})
|
||||
},
|
||||
u'wagtailimages.rendition': {
|
||||
|
@ -4,6 +4,8 @@ from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
from wagtail.wagtailcore.compat import AUTH_USER_MODEL, AUTH_USER_MODEL_NAME
|
||||
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
@ -98,8 +100,8 @@ class Migration(SchemaMigration):
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
},
|
||||
u'auth.user': {
|
||||
'Meta': {'object_name': 'User'},
|
||||
AUTH_USER_MODEL: {
|
||||
'Meta': {'object_name': AUTH_USER_MODEL_NAME},
|
||||
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
@ -129,7 +131,7 @@ class Migration(SchemaMigration):
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'live': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
'numchild': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
|
||||
'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'owned_pages'", 'null': 'True', 'to': u"orm['auth.User']"}),
|
||||
'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'owned_pages'", 'null': 'True', 'to': u"orm['%s']" % AUTH_USER_MODEL}),
|
||||
'path': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
|
||||
'search_description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||
'seo_title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
|
||||
|
@ -4,6 +4,8 @@ from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
from wagtail.wagtailcore.compat import AUTH_USER_MODEL, AUTH_USER_MODEL_NAME
|
||||
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
@ -33,8 +35,8 @@ class Migration(SchemaMigration):
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
},
|
||||
u'auth.user': {
|
||||
'Meta': {'object_name': 'User'},
|
||||
AUTH_USER_MODEL: {
|
||||
'Meta': {'object_name': AUTH_USER_MODEL_NAME},
|
||||
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
@ -64,7 +66,7 @@ class Migration(SchemaMigration):
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'live': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
'numchild': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
|
||||
'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'owned_pages'", 'null': 'True', 'to': u"orm['auth.User']"}),
|
||||
'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'owned_pages'", 'null': 'True', 'to': u"orm['%s']" % AUTH_USER_MODEL}),
|
||||
'path': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
|
||||
'search_description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||
'seo_title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
|
||||
|
@ -1,8 +1,10 @@
|
||||
from django import forms
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.forms import UserCreationForm as BaseUserCreationForm
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
# extend Django's UserCreationForm with an 'is_superuser' field
|
||||
class UserCreationForm(BaseUserCreationForm):
|
||||
@ -25,6 +27,22 @@ class UserCreationForm(BaseUserCreationForm):
|
||||
'groups': forms.CheckboxSelectMultiple
|
||||
}
|
||||
|
||||
def clean_username(self):
|
||||
# Method copied from parent
|
||||
|
||||
username = self.cleaned_data["username"]
|
||||
try:
|
||||
# When called from BaseUserCreationForm, the method fails if using a AUTH_MODEL_MODEL,
|
||||
# This is because the following line tries to perform a lookup on
|
||||
# the default "auth_user" table.
|
||||
User._default_manager.get(username=username)
|
||||
except User.DoesNotExist:
|
||||
return username
|
||||
raise forms.ValidationError(
|
||||
self.error_messages['duplicate_username'],
|
||||
code='duplicate_username',
|
||||
)
|
||||
|
||||
def save(self, commit=True):
|
||||
user = super(UserCreationForm, self).save(commit=False)
|
||||
|
||||
|
@ -8,10 +8,14 @@ from django.utils.translation import ugettext as _
|
||||
|
||||
from wagtail.wagtailadmin.forms import SearchForm
|
||||
from wagtail.wagtailusers.forms import UserCreationForm, UserEditForm
|
||||
from wagtail.wagtailcore.compat import AUTH_USER_APP_LABEL, AUTH_USER_MODEL_NAME
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
@permission_required('auth.change_user')
|
||||
change_user_perm = "{0}.change_{1}".format(AUTH_USER_APP_LABEL, AUTH_USER_MODEL_NAME.lower())
|
||||
|
||||
|
||||
@permission_required(change_user_perm)
|
||||
def index(request):
|
||||
q = None
|
||||
p = request.GET.get("p", 1)
|
||||
@ -66,7 +70,7 @@ def index(request):
|
||||
'query_string': q,
|
||||
})
|
||||
|
||||
@permission_required('auth.change_user')
|
||||
@permission_required(change_user_perm)
|
||||
def create(request):
|
||||
if request.POST:
|
||||
form = UserCreationForm(request.POST)
|
||||
@ -84,7 +88,7 @@ def create(request):
|
||||
})
|
||||
|
||||
|
||||
@permission_required('auth.change_user')
|
||||
@permission_required(change_user_perm)
|
||||
def edit(request, user_id):
|
||||
user = get_object_or_404(User, id=user_id)
|
||||
if request.POST:
|
||||
|
Loading…
Reference in New Issue
Block a user