Closed igorsimb closed 4 months ago
in ItemListView
's get_context_data
...
try:
existing_task = PeriodicTask.objects.get(name=f"scrape_interval_task_{self.request.user}")
except PeriodicTask.DoesNotExist:
existing_task = None
sku = None
...
context["existing_task"] = existing_task
return context
In template:
{% if existing_task %}
TASK YES! :)
{% else %}
TASK NO! :(
{% endif %}
For future reference, at least for now we should probably create a variable TASK_NAME
instead of hard coding scrape_interval_task_{self.request.user}
everywhere.
The logic should be: "If there is a scheduled task running for this user, do ..." and not "_If
scrape_interval_task
in the user's session, do ..._` Reason: if user logs out, the session breaking all the logic tied to it.Steps to reproduce
What actually happens "Delete existing" button disappears and there's a button "Create interval" as opposed to "Update interval".