|
@@ -50,8 +50,16 @@ class Attachment(models.Model):
|
|
thumb_path.unlink()
|
|
thumb_path.unlink()
|
|
except Exception:
|
|
except Exception:
|
|
pass
|
|
pass
|
|
|
|
+
|
|
super(Attachment, self).delete(*args, **kwargs)
|
|
super(Attachment, self).delete(*args, **kwargs)
|
|
|
|
|
|
|
|
+ def delete_from_post(self):
|
|
|
|
+ if self.post_id:
|
|
|
|
+ self.post.attachments = [attachment
|
|
|
|
+ for attachment in self.post.attachments
|
|
|
|
+ if attachment.pk != self.pk]
|
|
|
|
+ self.post.save(force_update=True)
|
|
|
|
+
|
|
@property
|
|
@property
|
|
def is_image(self):
|
|
def is_image(self):
|
|
IMAGES_EXTENSIONS = ('.png', '.gif', '.jpg', '.jpeg')
|
|
IMAGES_EXTENSIONS = ('.png', '.gif', '.jpg', '.jpeg')
|