Unset font if the mediafile is deleted
This commit is contained in:
parent
f54360290f
commit
648aabc310
@ -77,12 +77,21 @@ class MediafileViewSet(ModelViewSet):
|
||||
# on server via Django methods (file, open(), save(), ...).
|
||||
mediafile = self.get_object()
|
||||
mediafile.mediafile.storage.delete(mediafile.mediafile.name)
|
||||
|
||||
# check if the file was used as a logo or font
|
||||
for logo in config["logos_available"]:
|
||||
if config[logo]["path"] == mediafile.mediafile.url:
|
||||
config[logo] = {
|
||||
"display_name": config[logo]["display_name"],
|
||||
"path": "",
|
||||
}
|
||||
for font in config["fonts_available"]:
|
||||
if config[font]["path"] == mediafile.mediafile.url:
|
||||
config[font] = {
|
||||
"display_name": config[font]["display_name"],
|
||||
"default": config[font]["default"],
|
||||
"path": "",
|
||||
}
|
||||
return super().destroy(request, *args, **kwargs)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user