3
3
from django .db import models
4
4
from django .template .defaultfilters import truncatechars_html
5
5
from django .utils .html import format_html
6
+ import html
6
7
7
8
from mod_app .admin .link_admin import (
8
9
DrawingInline ,
@@ -29,6 +30,8 @@ class FilmAnalysisInline(admin.TabularInline):
29
30
"grp-collapse" ,
30
31
"grp-open" ,
31
32
]
33
+ verbose_name = "Analysis"
34
+ verbose_name_plural = "Analyses"
32
35
33
36
34
37
class TRInline (admin .TabularInline ):
@@ -38,6 +41,8 @@ class TRInline(admin.TabularInline):
38
41
"grp-collapse" ,
39
42
"grp-open" ,
40
43
]
44
+ verbose_name = "Teaching Resources"
45
+ verbose_name_plural = "Teaching Resources"
41
46
42
47
43
48
@admin .register (Film )
@@ -49,7 +54,13 @@ class Media:
49
54
js = ("admin/js/mentionsPluginConfig.js" ,)
50
55
51
56
autocomplete_fields = ["genre" ]
52
- search_fields = ["title" , "alt_titles" ]
57
+ search_fields = [
58
+ "title" ,
59
+ "alt_titles" ,
60
+ "production_company" ,
61
+ "production_country" ,
62
+ "release_date" ,
63
+ ]
53
64
formfield_overrides = {
54
65
models .TextField : {
55
66
"widget" : CKEditorWidget (),
@@ -112,18 +123,30 @@ def safe_temporary_images(self, obj):
112
123
safe_temporary_images .allow_tags = True
113
124
safe_temporary_images .short_description = "List Images"
114
125
126
+ def safe_bibliography (self , obj ):
127
+ bib_items = obj .bibliography .all ()
128
+ formatted_items = [
129
+ format_html (
130
+ "<li>{}</li>" , format_html (html .unescape (bib_item .full_citation ))
131
+ )
132
+ for bib_item in bib_items
133
+ ]
134
+ return format_html ("<ul>{}</ul>" , format_html ("" .join (formatted_items )))
135
+
136
+ safe_bibliography .short_description = "Bibliography"
137
+ safe_bibliography .allow_tags = True
138
+
115
139
def preview_video (self , obj ):
116
140
if obj .videos .first ():
117
- # format for working with mediacentral embeds
141
+ # format for working with mediacentral embeds and youtube embeds
118
142
return format_html (
119
143
'<div"><iframe src="{}" frameborder="0" scrolling="no" allowfullscreen></iframe></div>' ,
120
144
obj .videos .first (),
121
145
)
122
- # previously tried to use youtube but that seems to be more tricky than expected and may not be used
123
146
else :
124
147
return "-"
125
148
126
- readonly_fields = ("bibliography " ,)
149
+ readonly_fields = ("safe_bibliography " ,)
127
150
fieldsets = (
128
151
(
129
152
"Main Information (Filmic Section)" ,
@@ -140,7 +163,7 @@ def preview_video(self, obj):
140
163
),
141
164
},
142
165
),
143
- (None , {"classes" : ("placeholder sources -group" ,), "fields" : ()}),
166
+ (None , {"classes" : ("placeholder Source_film -group" ,), "fields" : ()}),
144
167
(None , {"classes" : ("placeholder videos-group" ,), "fields" : ()}),
145
168
(
146
169
"Technical Section" ,
@@ -188,13 +211,14 @@ def preview_video(self, obj):
188
211
"comments" ,
189
212
"temporary_images" ,
190
213
),
214
+ "description" : "Mentions are available here and will contibute to the bibliography." ,
191
215
},
192
216
),
193
217
(
194
218
"Bibliography" ,
195
219
{
196
220
"classes" : ("grp-collapse" ,),
197
- "fields" : ("bibliography " ,),
221
+ "fields" : ("safe_bibliography " ,),
198
222
"description" : "Note: This section updates on save, and some items may not be visible immediately." ,
199
223
},
200
224
),
0 commit comments