mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-29 04:51:11 +00:00
Re-use schedules rather than creating new ones
This commit is contained in:
parent
f36af42f41
commit
8be9e91d21
2 changed files with 6 additions and 4 deletions
|
@ -6,7 +6,7 @@ from django.template.response import TemplateResponse
|
|||
from django.utils.decorators import method_decorator
|
||||
from django.views import View
|
||||
from django.views.decorators.http import require_POST
|
||||
from django_celery_beat.models import PeriodicTask
|
||||
from django_celery_beat.models import PeriodicTask, IntervalSchedule
|
||||
|
||||
from bookwyrm import forms, models
|
||||
|
||||
|
@ -54,7 +54,7 @@ def schedule_automod_task(request):
|
|||
return TemplateResponse(request, "settings/automod/rules.html", data)
|
||||
|
||||
with transaction.atomic():
|
||||
schedule = form.save(request)
|
||||
schedule, _ = IntervalSchedule.objects.get_or_create(**form.cleaned_data)
|
||||
PeriodicTask.objects.get_or_create(
|
||||
interval=schedule,
|
||||
name="automod-task",
|
||||
|
|
|
@ -13,7 +13,7 @@ from django.template.response import TemplateResponse
|
|||
from django.utils import timezone
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views import View
|
||||
from django_celery_beat.models import PeriodicTask
|
||||
from django_celery_beat.models import PeriodicTask, IntervalSchedule
|
||||
|
||||
from csp.decorators import csp_update
|
||||
|
||||
|
@ -79,7 +79,9 @@ class Dashboard(View):
|
|||
schedule_form = forms.IntervalScheduleForm(request.POST)
|
||||
|
||||
with transaction.atomic():
|
||||
schedule = schedule_form.save(request)
|
||||
schedule, _ = IntervalSchedule.objects.get_or_create(
|
||||
**schedule_form.cleaned_data
|
||||
)
|
||||
PeriodicTask.objects.get_or_create(
|
||||
interval=schedule,
|
||||
name="check-for-updates",
|
||||
|
|
Loading…
Reference in a new issue