diff --git a/apps/access/admin.py b/apps/access/admin.py index 5fe46a1948..9022b94690 100644 --- a/apps/access/admin.py +++ b/apps/access/admin.py @@ -1,17 +1,17 @@ from django.contrib import admin -from .models import Group +from .models import Group, GroupUser -# XXX: needs Django 1.2 -# class UserInline(admin.TabularInline): -# Group.users.through -# raw_id_fields = ('user_id',) +class GroupUserInline(admin.TabularInline): + model = GroupUser + raw_id_fields = ('user',) class GroupAdmin(admin.ModelAdmin): raw_id_fields = ('users',) ordering = ('name',) list_display = ('name', 'rules') + inlines = (GroupUserInline,) admin.site.register(Group, GroupAdmin) diff --git a/apps/users/admin.py b/apps/users/admin.py index ceb4fa48aa..6e430827f9 100644 --- a/apps/users/admin.py +++ b/apps/users/admin.py @@ -1,11 +1,13 @@ from django.contrib import admin +from access.admin import GroupUserInline from .models import UserProfile class UserAdmin(admin.ModelAdmin): list_display = ('__unicode__', 'email') search_fields = ('^email',) + inlines = (GroupUserInline,) admin.site.register(UserProfile, UserAdmin) diff --git a/apps/users/models.py b/apps/users/models.py index e11b50d424..598114944f 100644 --- a/apps/users/models.py +++ b/apps/users/models.py @@ -34,7 +34,8 @@ class UserProfile(amo.models.ModelBase): averagerating = models.CharField(max_length=255, blank=True) bio = TranslatedField() - confirmationcode = models.CharField(max_length=255, default='') + confirmationcode = models.CharField(max_length=255, default='', + blank=True) deleted = models.BooleanField(default=True) display_collections = models.BooleanField(default=False) display_collections_fav = models.BooleanField(default=False) @@ -44,13 +45,14 @@ class UserProfile(amo.models.ModelBase): notes = models.TextField(blank=True) notifycompat = models.BooleanField(default=True) notifyevents = models.BooleanField(default=True) - occupation = models.CharField(max_length=765, default='') - picture_type = models.CharField(max_length=75, default='') - resetcode = models.CharField(max_length=255, default='') - resetcode_expires = models.DateTimeField(default=datetime.now) + occupation = models.CharField(max_length=765, default='', blank=True) + picture_type = models.CharField(max_length=75, default='', blank=True) + resetcode = models.CharField(max_length=255, default='', blank=True) + resetcode_expires = models.DateTimeField(default=datetime.now, + blank=True) sandboxshown = models.BooleanField(default=False) - user = models.ForeignKey(DjangoUser, null=True) + user = models.ForeignKey(DjangoUser, null=True, editable=False, blank=True) class Meta: db_table = 'users'