Skip to content

Commit

Permalink
Merge branch 'main' into issue_1797
Browse files Browse the repository at this point in the history
  • Loading branch information
JisanAR03 authored Feb 17, 2024
2 parents b96476e + 96dc8d8 commit ec280c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions website/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,12 @@ class IssueScreenshot(models.Model):
image = models.ImageField(upload_to="screenshots", validators=[validate_image])
issue = models.ForeignKey(Issue,on_delete=models.CASCADE,related_name="screenshots")

def delete (self, *args, **kwargs):
if self.image:
if os.path.isfile(self.image.path):
os.remove(self.image.path)
super(IssueScreenshot, self).delete(*args, **kwargs)


@receiver(post_save, sender=Issue)
def update_issue_image_access(sender, instance, **kwargs):
Expand Down
4 changes: 4 additions & 0 deletions website/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,10 @@ def delete_issue(request, id):
except:
tokenauth = False
issue = Issue.objects.get(id=id)
if request.user.is_superuser or request.user == issue.user or tokenauth:
screenshots = issue.screenshots.all()
for screenshot in screenshots:
screenshot.delete()
if request.user.is_superuser or request.user == issue.user:
issue.delete()
messages.success(request, "Issue deleted")
Expand Down

0 comments on commit ec280c0

Please sign in to comment.