admin.py 1.41 KB
Newer Older
Arnaud Fabre's avatar
Arnaud Fabre committed
1
2
from __future__ import absolute_import

luxcem's avatar
luxcem committed
3
from django.contrib import admin
4

Arnaud Fabre's avatar
Arnaud Fabre committed
5
6
from representatives.models import Email, WebSite, Address, Phone, Country
from .models import MemopolRepresentative
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28


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


Arnaud Fabre's avatar
Arnaud Fabre committed
29
30
31
class CountryInline(admin.TabularInline):
    model = Country
    extra = 0
Arnaud Fabre's avatar
Arnaud Fabre committed
32
33


Arnaud Fabre's avatar
Arnaud Fabre committed
34
class MemopolRepresentativeAdmin(admin.ModelAdmin):
Arnaud Fabre's avatar
Arnaud Fabre committed
35
    list_display = ('full_name', 'country', 'score', 'main_mandate')
36
    search_fields = ('first_name', 'last_name', 'birth_place')
Arnaud Fabre's avatar
Arnaud Fabre committed
37
    list_filter = ('gender', 'active')
38
39
40
41
42
43
44
    inlines = [
        PhoneInline,
        EmailInline,
        WebsiteInline,
        AdressInline,
    ]

Arnaud Fabre's avatar
Arnaud Fabre committed
45
46


Arnaud Fabre's avatar
Arnaud Fabre committed
47
48
49
# class MandateAdmin(admin.ModelAdmin):
    # list_display = ('representative', 'group', 'role', 'constituency', 'begin_date', 'end_date', 'active')
    # search_fields = ('representative', 'group', 'constituency')
50
51
52
    # list_filter = ('role',)


Arnaud Fabre's avatar
Arnaud Fabre committed
53
54
# admin.site.register(Representative, RepresentativeAdmin)
admin.site.register(MemopolRepresentative, MemopolRepresentativeAdmin)
55
56
# admin.site.register(Country)

Arnaud Fabre's avatar
Arnaud Fabre committed
57
# admin.site.register(MemopolMandate, MandateAdmin)
58

Arnaud Fabre's avatar
Arnaud Fabre committed
59
# admin.site.register(MemopolGroup)
60
# admin.site.register(Constituency)