I've splited the flow and assigned several tasks to different users. How can I:
- stop all the tasks after a certain time?
- collect the available responses?
I've splited the flow and assigned several tasks to different users. How can I:
At least once you will have to acess some view in order to verify if the flow has or hasn't ended. There you could implements a piece of the snippet provided in the views.py bellow.
Using the @property tag in your model allows you to perform, among many other things, some validation on the fly and returns it whenever requested as if a model attribute.
Reference: https://docs.djangoproject.com/en/3.0/glossary/#term-property
Example: https://docs.djangoproject.com/en/3.0/topics/db/models/#model-methods
models.py
from django.db import models
from django.utils import timezone
class Flow(models.Model):
ends = models.DateTimeField
@property
def is_active(self):
return timezone.now() < self.ends
views.py
from django.http import HttpResponse
def interact_with_flow(request, pk)
if Flow.is_active:
status = 'Flow Active'
else:
status = 'Flow Ended'
return HttpResponse(request, status)