Wrap helper and token creation in transaction
This commit is contained in:
parent
f1494e3382
commit
777a616921
|
@ -1,5 +1,6 @@
|
||||||
from django.shortcuts import render, redirect, get_object_or_404
|
from django.shortcuts import render, redirect, get_object_or_404
|
||||||
from .models import Shift, LoginToken, Helper, ShiftRegistration
|
from .models import Shift, LoginToken, Helper, ShiftRegistration
|
||||||
|
from django.db import transaction
|
||||||
from django.db.models import F, Count, Q, ExpressionWrapper
|
from django.db.models import F, Count, Q, ExpressionWrapper
|
||||||
from .forms import RegisterForm, EmptyForm
|
from .forms import RegisterForm, EmptyForm
|
||||||
from django.db.models.fields import DateTimeField
|
from django.db.models.fields import DateTimeField
|
||||||
|
@ -118,8 +119,10 @@ def register(request):
|
||||||
helper = Helper(
|
helper = Helper(
|
||||||
name=form.cleaned_data["name"], phone=form.cleaned_data["phone"]
|
name=form.cleaned_data["name"], phone=form.cleaned_data["phone"]
|
||||||
)
|
)
|
||||||
helper.save()
|
with transaction.atomic():
|
||||||
token = helper.send_confirmation()
|
helper.save()
|
||||||
|
token = helper.send_confirmation()
|
||||||
|
|
||||||
request.session["token"] = token.pk
|
request.session["token"] = token.pk
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
messages.add_message(
|
messages.add_message(
|
||||||
|
|
Loading…
Reference in New Issue