Skip to content

Commit d91cf9f

Browse files
authored
Merge pull request #150 from UCL-ARC/sm-feature/buttons-fields
Adding new fields
2 parents 41af8cb + 05c4943 commit d91cf9f

File tree

6 files changed

+185
-0
lines changed

6 files changed

+185
-0
lines changed

mod_app/admin/film_admin.py

+9
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
import html
77

88
from mod_app.admin.link_admin import (
9+
CardImageInline,
910
DrawingInline,
1011
OtherLinkInline,
1112
PostcardInline,
1213
PosterInline,
1314
PressBookInline,
1415
ProgrammeInline,
16+
PublicVisualInfluenceInline,
1517
PublicityInline,
1618
ScriptInline,
1719
SourceInline,
@@ -85,6 +87,8 @@ class Media:
8587
PostcardInline,
8688
PosterInline,
8789
DrawingInline,
90+
CardImageInline,
91+
PublicVisualInfluenceInline,
8892
]
8993
list_display = [
9094
"title",
@@ -174,6 +178,7 @@ def preview_video(self, obj):
174178
),
175179
(None, {"classes": ("placeholder Source_film-group",), "fields": ()}),
176180
(None, {"classes": ("placeholder videos-group",), "fields": ()}),
181+
(None, {"classes": ("placeholder cardimages-group",), "fields": ()}),
177182
(
178183
"Technical Section",
179184
{
@@ -216,6 +221,10 @@ def preview_video(self, obj):
216221
"Visual & Written Influences",
217222
{"fields": []},
218223
),
224+
(
225+
None,
226+
{"classes": ("placeholder publicvisualinfluences-group",), "fields": ()},
227+
),
219228
(
220229
None,
221230
{

mod_app/admin/link_admin.py

+36
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,30 @@ class DrawingInline(PreviewMixin, s3BrowserButtonMixin, admin.TabularInline):
106106
]
107107

108108

109+
class CardImageInline(PreviewMixin, s3BrowserButtonMixin, admin.TabularInline):
110+
model = CardImage
111+
extra = 1
112+
max_num = 1
113+
classes = [
114+
"inline-inline",
115+
"grp-collapse",
116+
"grp-closed",
117+
]
118+
verbose_name_plural = "Card Image"
119+
120+
121+
class PublicVisualInfluenceInline(
122+
PreviewMixin, s3BrowserButtonMixin, admin.TabularInline
123+
):
124+
model = PublicVisualInfluence
125+
extra = 1
126+
classes = [
127+
"inline-inline",
128+
"grp-collapse",
129+
"grp-closed",
130+
]
131+
132+
109133
class OtherLinkInline(PreviewMixin, admin.TabularInline):
110134
model = OtherLink
111135
extra = 1
@@ -189,6 +213,18 @@ class DrawingAdmin(PreviewMixin, s3BrowserButtonMixin, admin.ModelAdmin):
189213
list_display = ["description", "film", "file", "url", "preview"]
190214

191215

216+
@admin.register(CardImage)
217+
class CardImageAdmin(PreviewMixin, s3BrowserButtonMixin, admin.ModelAdmin):
218+
search_fields = ["description", "url"]
219+
list_display = ["description", "film", "file", "url", "preview"]
220+
221+
222+
@admin.register(PublicVisualInfluence)
223+
class PublicVisualInfluenceAdmin(PreviewMixin, s3BrowserButtonMixin, admin.ModelAdmin):
224+
search_fields = ["description", "url"]
225+
list_display = ["description", "film", "file", "url", "preview"]
226+
227+
192228
@admin.register(Tag)
193229
class TagAdmin(admin.ModelAdmin):
194230
search_fields = ["name"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Generated by Django 4.2.5 on 2025-03-03 15:56
2+
3+
from django.db import migrations, models
4+
import django.db.models.deletion
5+
import mod_app.models.support_models
6+
7+
8+
class Migration(migrations.Migration):
9+
dependencies = [
10+
("mod_app", "0031_splitting_vwis"),
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name="PublicVisualInfluence",
16+
fields=[
17+
(
18+
"id",
19+
models.BigAutoField(
20+
auto_created=True,
21+
primary_key=True,
22+
serialize=False,
23+
verbose_name="ID",
24+
),
25+
),
26+
(
27+
"url",
28+
models.URLField(
29+
blank=True,
30+
help_text="url to the item you'd like to link",
31+
max_length=500,
32+
),
33+
),
34+
(
35+
"description",
36+
models.CharField(
37+
help_text="short description, required", max_length=250
38+
),
39+
),
40+
(
41+
"file",
42+
models.FileField(
43+
blank=True,
44+
null=True,
45+
upload_to=mod_app.models.support_models.FileLink.upload_to,
46+
validators=[
47+
mod_app.models.support_models.FileLink.validate_max_size
48+
],
49+
),
50+
),
51+
(
52+
"film",
53+
models.ForeignKey(
54+
null=True,
55+
on_delete=django.db.models.deletion.SET_NULL,
56+
related_name="%(class)ss",
57+
to="mod_app.film",
58+
),
59+
),
60+
],
61+
options={
62+
"verbose_name": "Public Visual Influence",
63+
},
64+
),
65+
migrations.CreateModel(
66+
name="CardImage",
67+
fields=[
68+
(
69+
"id",
70+
models.BigAutoField(
71+
auto_created=True,
72+
primary_key=True,
73+
serialize=False,
74+
verbose_name="ID",
75+
),
76+
),
77+
(
78+
"url",
79+
models.URLField(
80+
blank=True,
81+
help_text="url to the item you'd like to link",
82+
max_length=500,
83+
),
84+
),
85+
(
86+
"description",
87+
models.CharField(
88+
help_text="short description, required", max_length=250
89+
),
90+
),
91+
(
92+
"file",
93+
models.FileField(
94+
blank=True,
95+
null=True,
96+
upload_to=mod_app.models.support_models.FileLink.upload_to,
97+
validators=[
98+
mod_app.models.support_models.FileLink.validate_max_size
99+
],
100+
),
101+
),
102+
(
103+
"film",
104+
models.ForeignKey(
105+
null=True,
106+
on_delete=django.db.models.deletion.SET_NULL,
107+
related_name="%(class)ss",
108+
to="mod_app.film",
109+
),
110+
),
111+
],
112+
options={
113+
"verbose_name": "Card Image",
114+
},
115+
),
116+
]

mod_app/models/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
Drawing,
1919
OtherLink,
2020
Video,
21+
CardImage,
22+
PublicVisualInfluence,
2123
)
2224
from .teaching_analysis_models import (
2325
Analysis,
@@ -49,4 +51,6 @@
4951
"Feedback",
5052
"VisualInfluences",
5153
"WrittenInfluences",
54+
"CardImage",
55+
"PublicVisualInfluence",
5256
]

mod_app/models/support_models.py

+10
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ class Meta:
118118
verbose_name = "Drawing"
119119

120120

121+
class CardImage(FileLink):
122+
class Meta:
123+
verbose_name = "Card Image"
124+
125+
126+
class PublicVisualInfluence(FileLink):
127+
class Meta:
128+
verbose_name = "Public Visual Influence"
129+
130+
121131
class Location(models.Model):
122132
def __str__(self):
123133
return f"{self.address}"

mod_app/static/admin/css/custom.css

+10
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,13 @@ th.column-safe_alt_titles,
1111
.field-safe_alt_titles {
1212
max-width: 10rem;
1313
}
14+
15+
a.grp-change-related[title="Change selected analysis"] {
16+
width: 8rem;
17+
padding-left: 2rem;
18+
&::before {
19+
content: "Edit Analysis";
20+
position: absolute;
21+
top: 15%;
22+
}
23+
}

0 commit comments

Comments
 (0)