##// END OF EJS Templates
Handle local stickers which attachments were deleted
neko259 -
r1941:8ea46883 default
parent child Browse files
Show More
@@ -168,7 +168,10 b' class SettingsManager:'
168 168 def get_attachment_by_alias(self, alias):
169 169 images = self.get_setting(SETTING_IMAGES)
170 170 if images and alias in images:
171 return Attachment.objects.get(id=images.get(alias))
171 try:
172 return Attachment.objects.get(id=images.get(alias))
173 except Attachment.DoesNotExist:
174 self.remove_attachment_alias(alias)
172 175
173 176 def add_attachment_alias(self, alias, attachment):
174 177 images = self.get_setting(SETTING_IMAGES)
@@ -184,10 +187,15 b' class SettingsManager:'
184 187
185 188 def get_stickers(self):
186 189 images = self.get_setting(SETTING_IMAGES)
190 stickers = []
187 191 if images:
188 return [AttachmentSticker(name=key,
189 attachment=Attachment.objects.get(id=value))
190 for key, value in images.items()]
192 for key, value in images.items():
193 try:
194 attachment = Attachment.objects.get(id=value)
195 stickers.append(AttachmentSticker(name=key, attachment=attachment))
196 except Attachment.DoesNotExist:
197 self.remove_attachment_alias(key)
198 return stickers
191 199
192 200
193 201 class SessionSettingsManager(SettingsManager):
General Comments 0
You need to be logged in to leave comments. Login now