-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.py
168 lines (116 loc) · 5.67 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
from django.contrib import admin
from legal_editions import models as edition_models
class EditionsInline (admin.TabularInline):
model = edition_models.Edition.editors.through
verbose_name = 'Edited Edition'
verbose_name_plural = 'Edited Editions'
class EditorsInline (admin.TabularInline):
model = edition_models.Edition.editors.through
verbose_name = 'Editor'
verbose_name_plural = 'Editors'
class HyperarchetypeInline (admin.TabularInline):
model = edition_models.Hyperarchetype
class TextAttributeInline (admin.TabularInline):
model = edition_models.Work.text_attributes.through
verbose_name = 'Work-Text Attribute Relationship'
verbose_name_plural = 'Work-Text Attribute relationships'
class VersionLanguagesInline (admin.TabularInline):
model = edition_models.Version.languages.through
class WitnessInline (admin.TabularInline):
model = edition_models.Version.witnesses.through
class WitnessLanguagesInline (admin.TabularInline):
model = edition_models.Witness.languages.through
class WitnessTranscriptionInline (admin.TabularInline):
model = edition_models.WitnessTranscription
class EditionAdmin (admin.ModelAdmin):
fieldsets = (
(None, {'fields': ('abbreviation', 'version', 'date', 'status')}),
('Introduction', {'fields': ('introduction',)}),
('Texts', {'fields': ('text', 'translation')}),
('Further information', {'fields': ('internal_notes',)}),)
inlines = [EditorsInline, HyperarchetypeInline, WitnessTranscriptionInline]
class EditorAdmin (admin.ModelAdmin):
fieldsets = (
('Name', {'fields': ('abbreviation', 'last_name', 'first_name')}),)
list_display = ('id', 'abbreviation', 'last_name', 'first_name')
list_display_links = list_display
ordering = ('last_name',)
inlines = [EditionsInline]
search_fields = list_display
class FolioImageAdmin (admin.ModelAdmin):
fieldsets = (
('Image file', {'fields': ('filename', 'batch', 'path', 'filepath')}),
('Manuscript', {'fields': ('manuscript', 'folio_number', 'folio_side',
'page', 'display_order')}),
('Archival', {'fields': ('archived',)}),
('Notes', {'fields': ('internal_notes',)}))
list_display = ('id', 'batch', 'path', 'filename', 'folio_number', 'page',
'archived')
list_display_links = list_display
list_per_page = 300
ordering = ('batch', 'path', 'filename')
search_fields = ('archived', 'batch', 'manuscript', 'path')
class ManuscriptAdmin (admin.ModelAdmin):
fieldsets = (
('Sigla', {'fields': ('sigla', 'sigla_provenance')}),
('Archive', {'fields': ('archive', 'shelf_mark')}),
('Others', {'fields': ('description', 'hide_from_listings',
'checked_folios', 'single_sheet',
'standard_edition')}))
list_display = ('id', 'sigla', 'shelf_mark', 'archive', 'single_sheet')
list_display_links = list_display
list_filter = ('single_sheet', 'hide_from_listings', 'checked_folios',
'sigla_provenance', 'archive')
ordering = ('archive', 'shelf_mark')
search_fields = ('id', 'shelf_mark', 'sigla')
class VersionAdmin (admin.ModelAdmin):
fieldsets = (
('Info', {'fields': ('standard_abbreviation', 'slug', 'name', 'work',
'date')}),
('Synopsis', {'fields': ('synopsis', 'synopsis_manuscripts',
'print_editions')}))
inlines = [VersionLanguagesInline, WitnessInline]
list_display = ('id', 'standard_abbreviation', 'slug', 'get_name')
list_display_links = list_display
ordering = ('standard_abbreviation',)
readonly_fields = ('slug',)
search_fields = ('id', 'standard_abbreviation')
class VersionRelationshipAdmin (admin.ModelAdmin):
fieldsets = ((None, {'fields': ('relationship_type', 'source', 'target',
'description')}),)
class WitnessAdmin (admin.ModelAdmin):
fieldsets = (
('Work', {'fields': ('work',)}),
('Location', {'fields': ('manuscript', 'range_start', 'range_end',
'page')}),
('Description', {'fields': ('description',)}),)
inlines = [WitnessLanguagesInline, WitnessInline]
list_display = ('id', 'work', 'manuscript', 'range_start', 'range_end')
list_display_links = list_display
ordering = ('work',)
search_fields = ('id', 'range_start', 'range_end')
class WorkAdmin (admin.ModelAdmin):
fieldsets = ((None, {'fields': ('name', 'king', 'date')}),)
inlines = [TextAttributeInline]
list_display = ('id', 'name')
list_display_links = list_display
list_filter = ['text_attributes']
admin.site.register(edition_models.Archive)
admin.site.register(edition_models.Commentary)
admin.site.register(edition_models.Edition, EditionAdmin)
admin.site.register(edition_models.EditionStatus)
admin.site.register(edition_models.Editor, EditorAdmin)
admin.site.register(edition_models.FolioImage, FolioImageAdmin)
admin.site.register(edition_models.FolioSide)
admin.site.register(edition_models.Hyperarchetype)
admin.site.register(edition_models.King)
admin.site.register(edition_models.Language)
admin.site.register(edition_models.Manuscript, ManuscriptAdmin)
admin.site.register(edition_models.Person)
admin.site.register(edition_models.TextAttribute)
admin.site.register(edition_models.Version, VersionAdmin)
admin.site.register(edition_models.VersionRelationship,
VersionRelationshipAdmin)
admin.site.register(edition_models.VersionRelationshipType)
admin.site.register(edition_models.Witness, WitnessAdmin)
admin.site.register(edition_models.Work, WorkAdmin)