Merge branch 'cart' of git.2li.ch:ibz/web_AI-5 into cart

This commit is contained in:
Andreas Zweili 2018-02-18 20:31:37 +01:00
commit 84b24501fb
3 changed files with 28 additions and 24 deletions

View File

@ -5,7 +5,7 @@ from webshop.models import (
Picture, Picture,
Article, Article,
Option, Option,
OrderPosition CartPosition
) )
@ -69,9 +69,9 @@ class AddToCartForm(forms.Form):
class CartForm(forms.Form): class CartForm(forms.Form):
print('CartForm') print('CartForm')
def ChangeAmount(self): def ChangeAmount(self, _article_id):
print('CartForm.ChangeAmount') print('CartForm.ChangeAmount')
article = OrderPosition.objects.filter(pk=self.id) article = CartPosition.objects.filter(pk=_article_id)
amountfield = forms.IntegerField( amountfield = forms.IntegerField(
label='pce', label='pce',
help_text='Enter a Value between 1 and 99.', help_text='Enter a Value between 1 and 99.',

View File

@ -197,7 +197,6 @@ def cart(request):
article_view = True article_view = True
currency_name = "CHF" currency_name = "CHF"
message = "" message = ""
cart_id = False
articles_list = "" articles_list = ""
prices_in_cart = [] prices_in_cart = []
totalprice_list = [] totalprice_list = []
@ -212,6 +211,7 @@ def cart(request):
print(request.POST) print(request.POST)
# here we react to a currency dropdown change: # here we react to a currency dropdown change:
if 'currencies' in request.POST: if 'currencies' in request.POST:
print('currencies')
currencies_form = CurrenciesForm(request.POST) currencies_form = CurrenciesForm(request.POST)
if currencies_form.is_valid(): if currencies_form.is_valid():
cf = currencies_form.cleaned_data cf = currencies_form.cleaned_data
@ -223,9 +223,9 @@ def cart(request):
else: else:
request.session['currency'] = None request.session['currency'] = None
# here we react to a change of amount per item in the Cart: # here we react to a change of amount per item in the Cart:
if 'amount_in_cart' in request.POST: if 'amountfield' in request.POST:
print('yes amount post') print('yes amount post')
amount = CartForm.ChangeAmount(request.POST)
if amount.is_valid(): if amount.is_valid():
amount = amount.cleaned_data['amount'] amount = amount.cleaned_data['amount']
article = Article.objects.get(id=article_id) article = Article.objects.get(id=article_id)
@ -244,6 +244,7 @@ def cart(request):
amount = CartForm.ChangeAmount() amount = CartForm.ChangeAmount()
if 'checkout' in request.POST: if 'checkout' in request.POST:
print('checkout')
checkout_form = CheckoutForm(request.POST) checkout_form = CheckoutForm(request.POST)
if checkout_form.is_valid(): if checkout_form.is_valid():
checkout_form = checkout_form.cleaned_data['checkout'] checkout_form = checkout_form.cleaned_data['checkout']
@ -253,6 +254,8 @@ def cart(request):
order = '' order = ''
else: else:
message = 'Plese accept our General Terms and Conditions!' message = 'Plese accept our General Terms and Conditions!'
print('else')
checkout_form = CheckoutForm() checkout_form = CheckoutForm()
# if the cart_id is set the user has already added items to cart. # if the cart_id is set the user has already added items to cart.
try: try:
@ -261,7 +264,6 @@ def cart(request):
message = "You have no items in the Basket" message = "You have no items in the Basket"
if cart_id: if cart_id:
print(cart_id)
articles = CartPosition.objects.filter(cart=cart_id) articles = CartPosition.objects.filter(cart=cart_id)
articles_list = list(articles) articles_list = list(articles)
# scrap out the details to calculate Total of item and Summ of All: # scrap out the details to calculate Total of item and Summ of All:
@ -276,7 +278,7 @@ def cart(request):
article.price_in_chf = rate.exchange( article.price_in_chf = rate.exchange(
currency, currency,
article.price_in_chf) article.price_in_chf)
amount = Decimal.from_float(article.amount) amount = CartForm.ChangeAmount(request.POST, article.id)
totalprice_list.append(article.position_price) totalprice_list.append(article.position_price)
articles_list[idx] = article articles_list[idx] = article

View File

@ -341,31 +341,33 @@ Am ende des Projekts die nicht lauffähigen teile ausgrenzen. :-)
#+NAME: fig:Organigram #+NAME: fig:Organigram
#+BEGIN_EXPORT latex #+BEGIN_EXPORT latex
\begin{tikzpicture}[ \begin{tikzpicture}[
auto, node distance = 0.4cm, auto,
node distance = 0.4cm,
thick, thick,
every node/.style = { every node/.style = {
rectangle, rectangle,
font = \sffamily, font = \sffamily,
white, white,
top color = green!90!black, top color = green!90!black,
bottom color = green!60!black, bottom color = green!60!black,
text width = 2.7cm, text width = 2.4cm,
align = center, align = center,
minimum height = 1cm minimum height = 1cm
} }
] ]
\node (PL) {\textbf{PL}\\Projektleiter}; \node (CH) {\textbf{CH}\\Christian Herren};
\coordinate [below = 0.2cm of PL] (Unten); \coordinate [below = 0.9cm of CH] (Mitte);
\node (FD) [below = of PL] {\textbf{FD}\\Frontenddeveloper}; \coordinate [below = 1.6cm of CH] (Unten);
\node (SE) [left = of FD] {\textbf{SE}\\Softwareengineer}; \node (CV) [right = 2mm of Mitte] {\textbf{CV}\\Christian Vögeli};
\node (BD) [right = of FD] {\textbf{BD}\\Backenddeveloper}; \node (AZ) [below = of CV] {\textbf{AZ}\\Andreas Zweili};
\draw [green!60!black,thick] \node (IH) [left = of AZ] {\textbf{IH}\\Ivan Hörler};
(PL) -- (Unten) -| (FD) \draw [green!60!black,thick]
(Unten) -| (SE) (CH) -- (Mitte)
(Unten) -| (BD); (CV) -- (Mitte) -- (Unten) -| (IH)
\end{tikzpicture} (Unten) -| (IH)
#+END_EXPORT (Unten) -| (AZ);
\end{tikzpicture}
#+END_EXPORT
** Projektstrukturplan ** Projektstrukturplan
** Varianten ** Varianten