mirror of
https://framagit.org/la-chariotte/la-chariotte.git
synced 2025-04-30 19:02:38 +02:00
Prevent inintended creation of OrderAuthor before ordering
When a grouped_order_detail view was called with authenticated user, when prefilling the firstName, lastName and email also inserted a new OrderAuthor object in the database. Now use SimpleNamespace, instead of OrderAuthor object, to carry those values to the template.
This commit is contained in:
parent
34d2db8623
commit
84dadd9147
1 changed files with 2 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
||||||
import csv
|
import csv
|
||||||
import json
|
import json
|
||||||
|
from types import SimpleNamespace
|
||||||
|
|
||||||
from django import http
|
from django import http
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
|
||||||
|
@ -118,12 +119,11 @@ class GroupedOrderDetailView(generic.DetailView):
|
||||||
prices_dict = {item.id: item.price for item in items}
|
prices_dict = {item.id: item.price for item in items}
|
||||||
|
|
||||||
if self.request.user.is_authenticated:
|
if self.request.user.is_authenticated:
|
||||||
order_author = OrderAuthor.objects.create(
|
order_author = SimpleNamespace(
|
||||||
first_name=self.request.user.first_name,
|
first_name=self.request.user.first_name,
|
||||||
last_name=self.request.user.last_name,
|
last_name=self.request.user.last_name,
|
||||||
email=self.request.user.username,
|
email=self.request.user.username,
|
||||||
)
|
)
|
||||||
order_author.save()
|
|
||||||
else:
|
else:
|
||||||
order_author = None
|
order_author = None
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue