Skip to content

Commit ade6ad1

Browse files
authored
Expand Image model fields (open5e#725)
* added 'alt_text' to /images endpoint * added 'name' field to ImageSerializer * added 'attribution' field to Image model * updated tests
1 parent 4e56c65 commit ade6ad1

File tree

8 files changed

+125
-2
lines changed

8 files changed

+125
-2
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 5.1.2 on 2025-05-07 09:07
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api_v2', '0035_document_weight_unit'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='image',
15+
name='alt_text',
16+
field=models.TextField(default='', help_text='A short textual description of the image. Important for accessibility'),
17+
),
18+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 5.1.2 on 2025-05-07 09:13
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api_v2', '0036_image_alt_text'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='image',
15+
name='alt_text',
16+
field=models.TextField(help_text='A short textual description of the image. Important for accessibility'),
17+
),
18+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 5.1.2 on 2025-05-07 09:36
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api_v2', '0037_alter_image_alt_text'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='image',
15+
name='attribution',
16+
field=models.TextField(default='', help_text='Attribution information for this image. Who drew it and where we can find more of thier work?'),
17+
),
18+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 5.1.2 on 2025-05-07 09:38
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api_v2', '0038_image_attribution'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='image',
15+
name='attribution',
16+
field=models.TextField(help_text='Attribution information for this image. Who drew it and where we can find more of thier work?'),
17+
),
18+
]

api_v2/models/image.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ class Image(HasName, FromDocument):
1515
help_text='Relative path of the file, to be used in static file resolution.'
1616
)
1717

18+
alt_text = models.TextField(
19+
help_text='A short textual description of the image. Important for accessibility',
20+
)
21+
22+
attribution = models.TextField(
23+
help_text='Attribution information for this image. Who drew it and where we can find more of thier work?',
24+
)
25+
1826
type = models.CharField(
1927
blank=True,
2028
null=True,

api_v2/serializers/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ class ImageSerializer(GameContentSerializer):
1111

1212
class Meta:
1313
model = models.Image
14-
fields = ['key','file_url']
14+
fields = ['name', 'key', 'file_url', 'alt_text', 'attribution']

api_v2/tests/responses/TestObjects.test_condition_example.approved.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
}
1717
},
1818
"icon": {
19+
"alt_text": "An icon representing the Stunned condition. A black-and-white silhouette of a figure visible from the shoulders up faces the viewer. They are surrounded by stars that sit on rings which suggest orbits.",
20+
"attribution": "Designed with love by Anaislalovi (@anaislalovi) for Elderberry Inn.",
1921
"file_url": "/static/img/object_icons/elderberry-inn-icons/conditions/stunned.svg",
20-
"key": "elderberry_stunned"
22+
"key": "elderberry_stunned",
23+
"name": "Stunned"
2124
},
2225
"key": "stunned",
2326
"name": "Stunned",

data/v2/open5e/elderberry/Image.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"name": "Blinded",
77
"document": "elderberry",
88
"file_path": "/img/object_icons/elderberry-inn-icons/conditions/blinded.svg",
9+
"alt_text": "An icon representing the blinded condition in an RPG. A simple, abstract black-and-white icon of an eye with a line crossed through it.",
10+
"attribution": "Designed with love by Anaislalovi (@anaislalovi) for Elderberry Inn.",
911
"type": "icon"
1012
}
1113
},
@@ -16,6 +18,8 @@
1618
"name": "Charmed",
1719
"document": "elderberry",
1820
"file_path": "/img/object_icons/elderberry-inn-icons/conditions/charmed.svg",
21+
"alt_text": "An icon representing the charmed condition in an RPG. A simple black-and-white silhouette of a humanoid facing the viewer. There is a heart where their face should be.",
22+
"attribution": "Designed with love by Anaislalovi (@anaislalovi) for Elderberry Inn.",
1923
"type": "icon"
2024
}
2125
},
@@ -26,6 +30,8 @@
2630
"name": "Deaftened",
2731
"document": "elderberry",
2832
"file_path": "/img/object_icons/elderberry-inn-icons/conditions/deaftened.svg",
33+
"alt_text": "An icon representing the deafened condition in an RPG. A simple black-and-white outline of an ear with a diagonal line passing through it, as if it were crossed out.",
34+
"attribution": "Designed with love by Anaislalovi (@anaislalovi) for Elderberry Inn.",
2935
"type": "icon"
3036
}
3137
},
@@ -36,6 +42,8 @@
3642
"name": "Exhaustion1",
3743
"document": "elderberry",
3844
"file_path": "/img/object_icons/elderberry-inn-icons/conditions/exhaustion1.svg",
45+
"alt_text": "An icon representing the Exhaustion (one level) condition. A simple black-and-white diagram of a standing figure hunched over in exhaustion with a large numeral '1'.",
46+
"attribution": "Designed with love by Anaislalovi (@anaislalovi) for Elderberry Inn.",
3947
"type": "icon"
4048
}
4149
},
@@ -46,6 +54,8 @@
4654
"name": "Exhaustion2",
4755
"document": "elderberry",
4856
"file_path": "/img/object_icons/elderberry-inn-icons/conditions/exhaustion2.svg",
57+
"alt_text": "An icon representing the Exhaustion (two levels) condition. A simple black-and-white diagram of a standing figure hunched over in exhaustion with a large numeral '2'.",
58+
"attribution": "Designed with love by Anaislalovi (@anaislalovi) for Elderberry Inn.",
4959
"type": "icon"
5060
}
5161
},
@@ -56,6 +66,8 @@
5666
"name": "Exhaustion3",
5767
"document": "elderberry",
5868
"file_path": "/img/object_icons/elderberry-inn-icons/exhaustion3.svg",
69+
"alt_text": "An icon representing the Exhaustion (three levels) condition. A simple black-and-white diagram of a standing figure hunched over in exhaustion with a large numeral '3'.",
70+
"attribution": "Designed with love by Anaislalovi (@anaislalovi) for Elderberry Inn.",
5971
"type": "icon"
6072
}
6173
},
@@ -66,6 +78,8 @@
6678
"name": "Exhaustion4",
6779
"document": "elderberry",
6880
"file_path": "/img/object_icons/elderberry-inn-icons/conditions/exhaustion4.svg",
81+
"alt_text": "An icon representing the Exhaustion (four levels) condition. A simple black-and-white diagram of a standing figure hunched over in exhaustion with a large numeral '4'.",
82+
"attribution": "Designed with love by Anaislalovi (@anaislalovi) for Elderberry Inn.",
6983
"type": "icon"
7084
}
7185
},
@@ -76,6 +90,8 @@
7690
"name": "Exhaustion5",
7791
"document": "elderberry",
7892
"file_path": "/img/object_icons/elderberry-inn-icons/conditions/exhaustion5.svg",
93+
"alt_text": "An icon representing the Exhaustion (five levels) condition. A simple black-and-white diagram of a standing figure hunched over in exhaustion with a large numeral '5'.",
94+
"attribution": "Designed with love by Anaislalovi (@anaislalovi) for Elderberry Inn.",
7995
"type": "icon"
8096
}
8197
},
@@ -86,6 +102,8 @@
86102
"name": "Exhaustion6",
87103
"document": "elderberry",
88104
"file_path": "/img/object_icons/elderberry-inn-icons/conditions/exhaustion6.svg",
105+
"alt_text": "An icon representing the Exhaustion (six levels) condition. A simple black-and-white diagram of a standing figure hunched over in exhaustion with a large numeral '6'.",
106+
"attribution": "Designed with love by Anaislalovi (@anaislalovi) for Elderberry Inn.",
89107
"type": "icon"
90108
}
91109
},
@@ -96,6 +114,8 @@
96114
"name": "Frightened",
97115
"document": "elderberry",
98116
"file_path": "/img/object_icons/elderberry-inn-icons/conditions/frightened.svg",
117+
"alt_text": "An icon representing the Frightened condition. A simple black-and-white silhouette figure from the shoulders up facing the viewer. Their hands are raised to their head and they are screaming.",
118+
"attribution": "Designed with love by Anaislalovi (@anaislalovi) for Elderberry Inn.",
99119
"type": "icon"
100120
}
101121
},
@@ -106,6 +126,8 @@
106126
"name": "Grappled",
107127
"document": "elderberry",
108128
"file_path": "/img/object_icons/elderberry-inn-icons/conditions/grappled.svg",
129+
"alt_text": "An icon representing the Grappled condition. A simple black-and-white image of an arm staining against a chain and shackle attached to the wrist.",
130+
"attribution": "Designed with love by Anaislalovi (@anaislalovi) for Elderberry Inn.",
109131
"type": "icon"
110132
}
111133
},
@@ -116,6 +138,8 @@
116138
"name": "Incapacitated",
117139
"document": "elderberry",
118140
"file_path": "/img/object_icons/elderberry-inn-icons/conditions/incapacitated.svg",
141+
"alt_text": "An icon representing the Incapacitated condition. A black-and-white silhouetted figure visible from the shoulders up faces the viewer. There is an X where thier face should be, and a shirling figure over thier head.",
142+
"attribution": "Designed with love by Anaislalovi (@anaislalovi) for Elderberry Inn.",
119143
"type": "icon"
120144
}
121145
},
@@ -126,6 +150,8 @@
126150
"name": "Inconscious",
127151
"document": "elderberry",
128152
"file_path": "/img/object_icons/elderberry-inn-icons/conditions/inconscious.svg",
153+
"alt_text": "An icon representing the Inconscious condition. A black-and-white silhouetted figure visible from the shoulders up faces the viewer. Where its eyes should be are swirls",
154+
"attribution": "Designed with love by Anaislalovi (@anaislalovi) for Elderberry Inn.",
129155
"type": "icon"
130156
}
131157
},
@@ -136,6 +162,8 @@
136162
"name": "Invisible",
137163
"document": "elderberry",
138164
"file_path": "/img/object_icons/elderberry-inn-icons/conditions/invisible.svg",
165+
"alt_text": "An icon representing the Invisible condition. A black-and-white silhouette of a figure visible from the shoulders up faces the viewer. They are drawn with a dashed outline to indicate that they are invisible.",
166+
"attribution": "Designed with love by Anaislalovi (@anaislalovi) for Elderberry Inn.",
139167
"type": "icon"
140168
}
141169
},
@@ -146,6 +174,8 @@
146174
"name": "Paralyzed",
147175
"document": "elderberry",
148176
"file_path": "/img/object_icons/elderberry-inn-icons/conditions/paralyzed.svg",
177+
"alt_text": "An icon representing the Paralyzed condition. A black-and-white silhouette of a figure visible from the shoulders up faces the viewer. They are surrounded by a chain.",
178+
"attribution": "Designed with love by Anaislalovi (@anaislalovi) for Elderberry Inn.",
149179
"type": "icon"
150180
}
151181
},
@@ -156,6 +186,8 @@
156186
"name": "Petrified",
157187
"document": "elderberry",
158188
"file_path": "/img/object_icons/elderberry-inn-icons/conditions/petrified.svg",
189+
"alt_text": "An icon representing the Petrified condition. A black-and-white silhouette of a figure visible from the shoulders up faces the viewer. They are covered in numerous broad cracks as if they were an old, crumbling statue.",
190+
"attribution": "Designed with love by Anaislalovi (@anaislalovi) for Elderberry Inn.",
159191
"type": "icon"
160192
}
161193
},
@@ -166,6 +198,8 @@
166198
"name": "Poisoned",
167199
"document": "elderberry",
168200
"file_path": "/img/object_icons/elderberry-inn-icons/conditions/poisoned.svg",
201+
"alt_text": "An icon representing the Poisoned condition. A simple black-and-white drawing of a bottle with a stopper and a skull on its front.",
202+
"attribution": "Designed with love by Anaislalovi (@anaislalovi) for Elderberry Inn.",
169203
"type": "icon"
170204
}
171205
},
@@ -176,6 +210,8 @@
176210
"name": "Prone",
177211
"document": "elderberry",
178212
"file_path": "/img/object_icons/elderberry-inn-icons/conditions/prone.svg",
213+
"alt_text": "An icon representing the Prone condition.",
214+
"attribution": "Designed with love by Anaislalovi (@anaislalovi) for Elderberry Inn.",
179215
"type": "icon"
180216
}
181217
},
@@ -186,6 +222,8 @@
186222
"name": "Restrained",
187223
"document": "elderberry",
188224
"file_path": "/img/object_icons/elderberry-inn-icons/conditions/restrained.svg",
225+
"alt_text": "An icon representing the Restrained condition. A simple black-and-white silouetted figure is on all fours, as if crawling. Three large arrows above the figure point downward.",
226+
"attribution": "Designed with love by Anaislalovi (@anaislalovi) for Elderberry Inn.",
189227
"type": "icon"
190228
}
191229
},
@@ -196,6 +234,8 @@
196234
"name": "Stunned",
197235
"document": "elderberry",
198236
"file_path": "/img/object_icons/elderberry-inn-icons/conditions/stunned.svg",
237+
"alt_text": "An icon representing the Stunned condition. A black-and-white silhouette of a figure visible from the shoulders up faces the viewer. They are surrounded by stars that sit on rings which suggest orbits.",
238+
"attribution": "Designed with love by Anaislalovi (@anaislalovi) for Elderberry Inn.",
199239
"type": "icon"
200240
}
201241
}

0 commit comments

Comments
 (0)