diff --git a/boards/abstracts/settingsmanager.py b/boards/abstracts/settingsmanager.py --- a/boards/abstracts/settingsmanager.py +++ b/boards/abstracts/settingsmanager.py @@ -168,7 +168,10 @@ class SettingsManager: def get_attachment_by_alias(self, alias): images = self.get_setting(SETTING_IMAGES) if images and alias in images: - return Attachment.objects.get(id=images.get(alias)) + try: + return Attachment.objects.get(id=images.get(alias)) + except Attachment.DoesNotExist: + self.remove_attachment_alias(alias) def add_attachment_alias(self, alias, attachment): images = self.get_setting(SETTING_IMAGES) @@ -184,10 +187,15 @@ class SettingsManager: def get_stickers(self): images = self.get_setting(SETTING_IMAGES) + stickers = [] if images: - return [AttachmentSticker(name=key, - attachment=Attachment.objects.get(id=value)) - for key, value in images.items()] + for key, value in images.items(): + try: + attachment = Attachment.objects.get(id=value) + stickers.append(AttachmentSticker(name=key, attachment=attachment)) + except Attachment.DoesNotExist: + self.remove_attachment_alias(key) + return stickers class SessionSettingsManager(SettingsManager):