Skip to content

Commit

Permalink
show groups in change list
Browse files Browse the repository at this point in the history
  • Loading branch information
benzkji committed Oct 27, 2017
1 parent d52ebf5 commit e3faf8e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions separate_users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class FrontendUserAdmin(UserAdmin):
readonly_fields = ['date_joined', 'last_login', 'is_staff', 'is_superuser', 'groups', 'user_permissions', ]
list_filter = ['is_active', 'groups', ]
list_display = ['username', 'is_active', ]
list_display = ['username', 'is_active', 'get_groups', ]


admin.site.register(FrontendUser, FrontendUserAdmin)
Expand All @@ -25,7 +25,7 @@ class EditorAdmin(UserAdmin):
exclude = []
readonly_fields = ['date_joined', 'last_login', 'is_staff', 'is_superuser', 'user_permissions', ]
list_filter = ['is_active', 'groups', ]
list_display = ['username', 'is_active', ]
list_display = ['username', 'is_active', 'get_groups', ]


admin.site.register(Editor, EditorAdmin)
20 changes: 14 additions & 6 deletions separate_users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,27 @@ def get_queryset(self):
.filter(is_staff=True, is_superuser=False)


class FrontendUser(UserModel):
class SeparateUserBase(object):

class Meta:
proxy = True

def get_groups(self):
print self.groups.all()
return ', '.join([str(item) for item in self.groups.all()])

get_groups.short_description = ("Groups")


class FrontendUser(SeparateUserBase, UserModel):

objects = FrontendUserManager()

def save(self, *args, **kwargs):
self.is_staff = False
super(FrontendUser, self).save(*args, **kwargs)

class Meta:
proxy = True


class Editor(UserModel):
class Editor(SeparateUserBase, UserModel):

objects = EditorManager()

Expand Down

0 comments on commit e3faf8e

Please sign in to comment.