Skip to content

admin

django_spire.auth.group.admin

PortalGroupAdmin

Bases: ModelAdmin

list_display = ('id', 'name', 'view_group_detail_link', 'user_count') class-attribute instance-attribute

search_fields = ('id', 'name') class-attribute instance-attribute

ordering = ('name',) class-attribute instance-attribute

Source code in django_spire/auth/group/admin.py
def view_group_detail_link(self, group: models.AuthGroup) -> str:
    url = reverse('django_spire:auth:group:page:detail', kwargs={'pk': group.pk})
    return format_html(f'<a href="{url}">View Details</a>')

user_count

Source code in django_spire/auth/group/admin.py
def user_count(self, group: models.AuthGroup) -> int:
    return group.user_set.count()

PortalUserAdmin

Bases: ModelAdmin

actions = ['add_to_all_user_group'] class-attribute instance-attribute

list_display = ('id', 'username', 'email', 'full_name', 'is_active', 'view_user_profile_link') class-attribute instance-attribute

list_filter = ('is_active', 'is_staff') class-attribute instance-attribute

search_fields = ('id', 'username', 'email', 'first_name', 'last_name') class-attribute instance-attribute

ordering = ('username',) class-attribute instance-attribute

full_name

Source code in django_spire/auth/group/admin.py
def full_name(self, user: django_spire.auth.user.models.AuthUser) -> str:
    return user.get_full_name()
Source code in django_spire/auth/group/admin.py
def view_user_profile_link(self, user: django_spire.auth.user.models.AuthUser) -> str:
    url = reverse('django_spire:auth:user:page:detail', kwargs={'pk': user.pk})
    return format_html(f'<a href="{url}">Profile</a>')

add_to_all_user_group

Source code in django_spire/auth/group/admin.py
@admin.action(description='Add to All Users Group')
def add_to_all_user_group(self, request, queryset):
    for user in queryset:
        add_user_to_all_user_group(user)
    self.message_user(request, f'Updated {len(queryset)} users.')