admin.py 889 Bytes
Newer Older
1
from django.contrib import admin
2
from teams.models import Team, Role
3 4 5 6 7 8
from languages.models import Language

class LanguageInline(admin.TabularInline):
    model = Language
    # Languages are not supposed to be created in this form
    extra = 0
9 10 11

class TeamAdmin(admin.ModelAdmin):
    search_fields = ('name',)
12
    list_display = ('description', 'use_workflow')
13
    inlines = [ LanguageInline ]
14 15 16 17 18 19 20 21 22

    def formfield_for_dbfield(self, db_field, **kwargs):
        # Reduced text area for aliases
        field = super(TeamAdmin, self).formfield_for_dbfield(db_field, **kwargs)
        if db_field.name == 'description':
            field.widget.attrs['rows'] = '4'

        return field

23 24 25
class RoleAdmin(admin.ModelAdmin):
    search_fields = ('person__first_name', 'person__last_name', 'team__description', 'role')

26
admin.site.register(Team, TeamAdmin)
27
admin.site.register(Role, RoleAdmin)