See #170: subscriptions management UI

This commit is contained in:
Eliot Berriot 2020-03-23 10:44:09 +01:00
parent 926a5cfc83
commit be067b9ee3
13 changed files with 414 additions and 185 deletions

View file

@ -410,15 +410,15 @@ def get_audio_mimetype(mt):
return aliases.get(mt, mt)
def update_modification_date(obj, field="modification_date"):
def update_modification_date(obj, field="modification_date", date=None):
IGNORE_DELAY = 60
current_value = getattr(obj, field)
now = timezone.now()
ignore = current_value is not None and current_value < now - datetime.timedelta(
date = date or timezone.now()
ignore = current_value is not None and current_value < date - datetime.timedelta(
seconds=IGNORE_DELAY
)
if ignore:
setattr(obj, field, now)
obj.__class__.objects.filter(pk=obj.pk).update(**{field: now})
setattr(obj, field, date)
obj.__class__.objects.filter(pk=obj.pk).update(**{field: date})
return now
return date