feat(api): implement file deletion (#2960)

This implements the file delete to the Django API. Previously, the code was only manipulating the database while leaving the file in place.

Co-authored-by: jo <ljonas@riseup.net>
This commit is contained in:
Thomas Göttgens 2024-05-05 22:44:30 +02:00 committed by GitHub
parent 86da46ee3a
commit 9757b1b78c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 89 additions and 24 deletions

View file

@ -1,4 +1,5 @@
from django.db import models
from django.utils.timezone import now
class Schedule(models.Model):
@ -115,6 +116,14 @@ class Schedule(models.Model):
return self.instance.ends_at
return self.ends_at
@staticmethod
def is_file_scheduled_in_the_future(file_id):
count = Schedule.objects.filter(
file_id=file_id,
ends_at__gt=now(),
).count()
return count > 0
class Meta:
managed = False
db_table = "cc_schedule"