Show More
@@ -168,7 +168,10 b' class SettingsManager:' | |||||
168 | def get_attachment_by_alias(self, alias): |
|
168 | def get_attachment_by_alias(self, alias): | |
169 | images = self.get_setting(SETTING_IMAGES) |
|
169 | images = self.get_setting(SETTING_IMAGES) | |
170 | if images and alias in images: |
|
170 | if images and alias in images: | |
|
171 | try: | |||
171 | return Attachment.objects.get(id=images.get(alias)) |
|
172 | return Attachment.objects.get(id=images.get(alias)) | |
|
173 | except Attachment.DoesNotExist: | |||
|
174 | self.remove_attachment_alias(alias) | |||
172 |
|
175 | |||
173 | def add_attachment_alias(self, alias, attachment): |
|
176 | def add_attachment_alias(self, alias, attachment): | |
174 | images = self.get_setting(SETTING_IMAGES) |
|
177 | images = self.get_setting(SETTING_IMAGES) | |
@@ -184,10 +187,15 b' class SettingsManager:' | |||||
184 |
|
187 | |||
185 | def get_stickers(self): |
|
188 | def get_stickers(self): | |
186 | images = self.get_setting(SETTING_IMAGES) |
|
189 | images = self.get_setting(SETTING_IMAGES) | |
|
190 | stickers = [] | |||
187 | if images: |
|
191 | if images: | |
188 | return [AttachmentSticker(name=key, |
|
192 | for key, value in images.items(): | |
189 | attachment=Attachment.objects.get(id=value)) |
|
193 | try: | |
190 | for key, value in images.items()] |
|
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 | class SessionSettingsManager(SettingsManager): |
|
201 | class SessionSettingsManager(SettingsManager): |
General Comments 0
You need to be logged in to leave comments.
Login now