admin.py 1.21 KB
Newer Older
luxcem's avatar
luxcem committed
1
from django.contrib import admin
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

from representatives.models import Email, WebSite, Address, Phone, Country, Constituency
from legislature.models import MMandate, MRepresentative, MGroup


class EmailInline(admin.TabularInline):
    model = Email
    extra = 0


class WebsiteInline(admin.TabularInline):
    model = WebSite
    extra = 0


class AdressInline(admin.StackedInline):
    model = Address
    extra = 0


class PhoneInline(admin.TabularInline):
    model = Phone
    extra = 0


class RepresentativeAdmin(admin.ModelAdmin):
    list_display = ('full_name', 'gender', 'birth_place')
    search_fields = ('first_name', 'last_name', 'birth_place')
    list_filter = ('gender', )
    inlines = [
        PhoneInline,
        EmailInline,
        WebsiteInline,
        AdressInline,
    ]


class MandateAdmin(admin.ModelAdmin):
    list_display = ('representative', 'group', 'role', 'constituency', 'begin_date', 'end_date', 'active')
    search_fields = ('representative', 'group', 'constituency')
    # list_filter = ('role',)


admin.site.register(MRepresentative, RepresentativeAdmin)

# admin.site.register(Country)

admin.site.register(MMandate, MandateAdmin)

admin.site.register(MGroup)
# admin.site.register(Constituency)