admin.py 1.14 KB
Newer Older
Thom Wiggers's avatar
Thom Wiggers committed
1
from django.contrib import admin
2

3
from utils.translation import TranslatedModelAdmin
Thom Wiggers's avatar
Thom Wiggers committed
4
5
6

from . import models

7

8
9
10
11
12
13
14
class CommitteeMembershipInline(admin.StackedInline):
    model = models.CommitteeMembership
    can_delete = False
    ordering = ('since',)
    extra = 0


Thom Wiggers's avatar
Thom Wiggers committed
15
@admin.register(models.Committee)
16
class CommitteeAdmin(TranslatedModelAdmin):
17
    inlines = (CommitteeMembershipInline,)
Thom Wiggers's avatar
Thom Wiggers committed
18
19
    list_filter = ('until',)

20
    fields = ('name', 'description', 'photo', 'permissions',
Thom Wiggers's avatar
Thom Wiggers committed
21
              'since', 'until', 'contact_email', 'wiki_namespace', 'active')
22

Thom Wiggers's avatar
Thom Wiggers committed
23
24
25
26
27
28
    def get_queryset(self, request):
        qs = super().get_queryset(request)
        return qs.exclude(board__is_board=True)


@admin.register(models.Board)
29
class BoardAdmin(TranslatedModelAdmin):
30
    inlines = (CommitteeMembershipInline,)
Thom Wiggers's avatar
Thom Wiggers committed
31
    exclude = ('is_board',)
Thom Wiggers's avatar
Thom Wiggers committed
32

33
    fields = ('name', 'photo', 'permissions',
34
              'since', 'until',)
35

Thom Wiggers's avatar
Thom Wiggers committed
36
37

@admin.register(models.CommitteeMembership)
38
class CommitteeMembershipAdmin(TranslatedModelAdmin):
39
    list_display = ('member', 'committee', 'since', 'until', 'chair', 'role')
40
41
42
43
44


@admin.register(models.Mentorship)
class MentorsAdmin(admin.ModelAdmin):
    pass