Commit 10f3ed33 authored by Bengfort's avatar Bengfort
Browse files

use jobs instead of requests to ping castellum

parent b2901d6b
Pipeline #10979 passed with stages
in 2 minutes and 7 seconds
......@@ -16,6 +16,7 @@
# License along with Castellum. If not, see
# <http://www.gnu.org/licenses/>.
import json
from collections import OrderedDict
from django.conf import settings
......@@ -36,7 +37,7 @@ from django.views.generic import ListView
from django.views.generic import UpdateView
from django.views.generic import View
import requests
from scheduler.jobs import helpers as jobs
from .forms import ScheduleForm
from .models import Invitation
......@@ -124,12 +125,13 @@ class InvitationUpdateView(UpdateView):
def form_valid(self, form, *args):
ok = True
response = super().form_valid(form, *args)
if settings.PING_URL:
r = requests.post(settings.PING_URL.format(
schedule_id=self.object.schedule.id,
token=self.object.token,
))
ok = r.ok
try:
ok = jobs.request(json.dumps({
'schedule': self.object.schedule.id,
'token': self.object.token,
}))
except TimeoutError:
ok = False
if ok:
messages.success(self.request, _('Your booking has been saved.'))
else:
......
......@@ -11,7 +11,6 @@ install_requires =
Django == 3.2.6
django-bootstrap4 == 3.0.1
django-npm == 1.0.0
requests == 2.26.0
[options.extras_require]
test =
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment