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:
parent
86da46ee3a
commit
9757b1b78c
3 changed files with 89 additions and 24 deletions
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue