admin.py 1.69 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# coding: utf-8

# This file is part of memopol.
#
# memopol is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or any later version.
#
# memopol is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Affero Public
# License along with django-representatives.
# If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2015 Arnaud Fabre <af@laquadrature.net>
Arnaud Fabre's avatar
Arnaud Fabre committed
20
21
from __future__ import absolute_import

luxcem's avatar
luxcem committed
22
from django.contrib import admin
23

Jamesie Pic's avatar
Quality    
Jamesie Pic committed
24
from representatives.models import Address, Country, Email, Phone, WebSite
25

Arnaud Fabre's avatar
Arnaud Fabre committed
26
from .models import MemopolRepresentative
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48


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
49
50
51
class CountryInline(admin.TabularInline):
    model = Country
    extra = 0
Arnaud Fabre's avatar
Arnaud Fabre committed
52
53


Arnaud Fabre's avatar
Arnaud Fabre committed
54
class MemopolRepresentativeAdmin(admin.ModelAdmin):
Arnaud Fabre's avatar
Arnaud Fabre committed
55
    list_display = ('full_name', 'country', 'score', 'main_mandate')
56
    search_fields = ('first_name', 'last_name', 'birth_place')
Arnaud Fabre's avatar
Arnaud Fabre committed
57
    list_filter = ('gender', 'active')
58
59
60
61
62
63
64
    inlines = [
        PhoneInline,
        EmailInline,
        WebsiteInline,
        AdressInline,
    ]

Arnaud Fabre's avatar
Arnaud Fabre committed
65

Arnaud Fabre's avatar
Arnaud Fabre committed
66
admin.site.register(MemopolRepresentative, MemopolRepresentativeAdmin)