Pablo Vazquez
871c07f471
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.
28 lines
724 B
Python
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"
|