correct queries which use the user object

This commit is contained in:
Andreas Zweili 2018-02-25 14:22:50 +01:00
parent 6e54bdec0d
commit 0d943106a0
1 changed files with 6 additions and 8 deletions

View File

@ -206,7 +206,6 @@ def cart(request):
amount_form_list = [] amount_form_list = []
totalprice_list = [] totalprice_list = []
total = 0 total = 0
user_id = request.user.id
cart_position_list_zip = [] cart_position_list_zip = []
# here we configure the users Currency: # here we configure the users Currency:
@ -240,7 +239,7 @@ def cart(request):
article_id = request.POST.get('article_id') article_id = request.POST.get('article_id')
operation = 'replace' operation = 'replace'
restrict_cart_to_one_article( restrict_cart_to_one_article(
user_id, request.user.id,
article_id, article_id,
amount, amount,
operation operation
@ -254,7 +253,7 @@ def cart(request):
amount = 1 amount = 1
operation = 'delete' operation = 'delete'
restrict_cart_to_one_article( restrict_cart_to_one_article(
user_id, request.user.id,
article_id, article_id,
amount, amount,
operation operation
@ -262,7 +261,7 @@ def cart(request):
# here we handle the normal cart view: # here we handle the normal cart view:
# if cart_id is not existent create a cart: # if cart_id is not existent create a cart:
cart_id, created_cart = ShoppingCart.objects.get_or_create(user=user_id) cart_id, created_cart = ShoppingCart.objects.get_or_create(user=request.user)
# get all items in the cart of this customer: # get all items in the cart of this customer:
cart_positions = CartPosition.objects.filter(cart=cart_id) cart_positions = CartPosition.objects.filter(cart=cart_id)
if (cart_positions.count()) > 0: if (cart_positions.count()) > 0:
@ -318,7 +317,6 @@ def checkout(request):
amount_form_list = [] amount_form_list = []
totalprice_list = [] totalprice_list = []
total = 0 total = 0
user_id = request.user.id
cart_position_list_zip = [] cart_position_list_zip = []
# here we configure the users Currency: # here we configure the users Currency:
if 'currency' not in request.session: if 'currency' not in request.session:
@ -350,7 +348,7 @@ def checkout(request):
article_id = request.POST.get('article_id') article_id = request.POST.get('article_id')
operation = 'replace' operation = 'replace'
restrict_cart_to_one_article( restrict_cart_to_one_article(
user_id, request.user.id,
article_id, article_id,
amount, amount,
operation operation
@ -364,14 +362,14 @@ def checkout(request):
amount = 1 amount = 1
operation = 'delete' operation = 'delete'
restrict_cart_to_one_article( restrict_cart_to_one_article(
user_id, request.user.id,
article_id, article_id,
amount, amount,
operation operation
) )
# here we handle the normal cart view: # here we handle the normal cart view:
# if cart_id is not existent create a cart: # if cart_id is not existent create a cart:
cart_id, created_cart = ShoppingCart.objects.get_or_create(user=user_id) cart_id, created_cart = ShoppingCart.objects.get_or_create(user=request.user)
# get all items in the cart of this customer: # get all items in the cart of this customer:
cart_positions = CartPosition.objects.filter(cart=cart_id) cart_positions = CartPosition.objects.filter(cart=cart_id)
if (cart_positions.count()) > 0: if (cart_positions.count()) > 0: