first commit
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
from django.db import transaction
|
||||
from django.utils import timezone
|
||||
from events.models import Event
|
||||
@transaction.atomic
|
||||
def review(event,reviewer,approve,reason=''):
|
||||
if event.status!=Event.Status.PENDING: return event
|
||||
event.status=Event.Status.APPROVED if approve else Event.Status.REJECTED
|
||||
event.reviewed_at=timezone.now();event.reviewed_by=reviewer;event.rejection_reason=reason
|
||||
if not approve and event.audio_file:
|
||||
file=event.audio_file;event.audio_file='';event.save();transaction.on_commit(file.delete)
|
||||
else: event.save()
|
||||
return event
|
||||
Reference in New Issue
Block a user