This repository has been archived by the owner on Jan 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
admin.py
60 lines (55 loc) · 1.45 KB
/
admin.py
1
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
53
54
55
56
57
58
59
60
from __future__ import unicode_literals
from django.contrib import admin
from django.core.urlresolvers import reverse
from django.utils.text import slugify
from .models import ResultEvent
class ResultEventAdmin(admin.ModelAdmin):
list_display = (
'user',
'created',
'winner_id',
'person_link',
'winner_party_id',
'winner_party_name',
'post_id',
'post_name',
'constituency_link',
'source',
)
search_fields = (
'user__username',
'winner_id',
'winner_person_name',
'winner_party_id',
'post_id',
'post_name',
'source',
)
ordering = ('-created',)
def person_link(self, o):
url = reverse(
'person-view',
kwargs={
'person_id': o.person_id,
'ignored_slug': slugify(o.post_name),
}
)
return '<a href="{0}">{1}</a>'.format(
url,
o.winner_person_name,
)
person_link.allow_tags = True
def constituency_link(self, o):
url = reverse(
'constituency',
kwargs={
'post_id': o.post_id,
'ignored_slug': slugify(o.post_name),
}
)
return '<a href="{0}">{1}</a>'.format(
url,
o.post_name,
)
constituency_link.allow_tags = True
admin.site.register(ResultEvent, ResultEventAdmin)