extensions-website/teams/admin.py
Pablo Vazquez 871c07f471 Admin: Add Save buttons top bar
Add Save topbar to the following forms:
* Extension
* Version
* Abuse Report
* Teams

The other forms are quite short so no point in having a duplicate topbar.
2024-05-17 19:16:08 +02:00

28 lines
724 B
Python

from django.contrib import admin
import teams.models
class TeamsUsersInline(admin.TabularInline):
model = teams.models.TeamsUsers
raw_id_fields = ('user',)
extra = 0
@admin.register(teams.models.Team)
class TeamAdmin(admin.ModelAdmin):
save_on_top = True
list_display = ('name', 'slug', 'user_count', 'date_created')
list_display_links = ['name']
list_filter = ['date_created']
search_fields = ('id', '^slug', 'name')
inlines = [TeamsUsersInline]
prepopulated_fields = {'slug': ('name',)}
view_on_site = True
def user_count(self, obj):
"""Display number of users in the team."""
return obj.users.all().count()
user_count.short_description = "Users"