admin.py 1.34 KB
Newer Older
Tom van Bussel's avatar
Tom van Bussel committed
1
from django import forms
Joost Rijneveld's avatar
Joost Rijneveld committed
2
3
from django.contrib import admin

Tom van Bussel's avatar
Tom van Bussel committed
4
5
6
7
from documents.models import (AnnualDocument, AssociationDocument,
                              GeneralMeeting, Minutes,
                              MiscellaneousDocument)
from utils.translation import TranslatedModelAdmin
Joost Rijneveld's avatar
Joost Rijneveld committed
8
9


Tom van Bussel's avatar
Tom van Bussel committed
10
11
12
13
14
15
16
17
18
19
20
21
22
class MinutesInline(admin.StackedInline):
    model = Minutes
    fields = ('file',)


class GeneralMeetingForm(forms.ModelForm):
    class Meta:
        model = GeneralMeeting
        exclude = ()
        widgets = {
            'documents': admin.widgets.FilteredSelectMultiple(
                'documents', is_stacked=False)
        }
Joost Rijneveld's avatar
Joost Rijneveld committed
23
24
25


@admin.register(GeneralMeeting)
Tom van Bussel's avatar
Tom van Bussel committed
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class GeneralMeetingAdmin(TranslatedModelAdmin):
    form = GeneralMeetingForm
    inlines = [
        MinutesInline,
    ]
    list_filter = ('datetime',)


@admin.register(AnnualDocument)
class AnnualDocument(TranslatedModelAdmin):
    fields = ('file', 'subcategory', 'year',)
    list_filter = ('year', 'created', 'last_updated',)


@admin.register(AssociationDocument)
class AssociationDocumentAdmin(TranslatedModelAdmin):
    fields = ('name', 'file', 'members_only',)
    list_filter = ('created', 'last_updated',)
Joost Rijneveld's avatar
Joost Rijneveld committed
44
45


Tom van Bussel's avatar
Tom van Bussel committed
46
47
48
49
@admin.register(MiscellaneousDocument)
class MiscellaneousDocumentAdmin(TranslatedModelAdmin):
    fields = ('name', 'file', 'members_only',)
    list_filter = ('created', 'last_updated',)