Make it possible to delete orders from the cart
This commit is contained in:
		
							parent
							
								
									86828a67d0
								
							
						
					
					
						commit
						dd7288d1c2
					
				| @ -200,7 +200,7 @@ suggestedGrossPrice netPrice percentage = | ||||
| view { globals, state } = case state of | ||||
|   ItemSearch model -> | ||||
|     fieldset [] | ||||
|       [ legend [] [ text "Vorlage für neuen Inventareintrag" ] | ||||
|       [ legend [] [ text "Vorlage für Auftrag wählen" ] | ||||
|       , Html.form [ onSubmit SubmitSearch ] | ||||
|         [ div [ class "form-input" ] | ||||
|           [ label [ for "search-term", title "Barcode oder Name" ] [ text "Suchbegriff" ] | ||||
|  | ||||
							
								
								
									
										18
									
								
								jon/entry.py
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								jon/entry.py
									
									
									
									
									
								
							| @ -9,13 +9,27 @@ bp = Blueprint("entry", __name__, url_prefix="/entry") | ||||
| 
 | ||||
| @bp.route("/", methods=["GET", "POST"]) | ||||
| def index(): | ||||
|     cart = session["cart"] | ||||
|     cart = session.get("cart", default=[]) | ||||
|     return render_template( | ||||
|         "entry/index.html", | ||||
|         cart=cart | ||||
|     ) | ||||
| 
 | ||||
| 
 | ||||
| @bp.post("/delete-order") | ||||
| def delete_order(): | ||||
|     try: | ||||
|         order_index = int(request.form["order-index"]) | ||||
|     except: | ||||
|         return f"Incomplete or mistyped form", 400 | ||||
| 
 | ||||
|     cart = session.get("cart", default=[]) | ||||
|     del cart[order_index] | ||||
|     session["cart"] = cart | ||||
| 
 | ||||
|     return redirect(request.referrer) | ||||
| 
 | ||||
| 
 | ||||
| @bp.route("/new-order", methods=["GET", "POST"]) | ||||
| def new_order(): | ||||
|     if request.method == "POST": | ||||
| @ -28,7 +42,7 @@ def new_order(): | ||||
|             tax_group_id = int(request.form["tax-group"]) | ||||
|             net_unit_price = float(request.form["net-unit-price"]) | ||||
|             gross_unit_price = float(request.form["gross-unit-price"]) | ||||
|         except Exception as e: | ||||
|         except: | ||||
|             return f"Incomplete or mistyped form", 400 | ||||
|          | ||||
|         cart = session.get("cart", default=[]) | ||||
|  | ||||
| @ -11949,7 +11949,7 @@ var $author$project$Entry$view = function (_v0) { | ||||
| 					_List_Nil, | ||||
| 					_List_fromArray( | ||||
| 						[ | ||||
| 							$elm$html$Html$text('Vorlage für neuen Inventareintrag') | ||||
| 							$elm$html$Html$text('Vorlage für Auftrag wählen') | ||||
| 						])), | ||||
| 					A2( | ||||
| 					$elm$html$Html$form, | ||||
|  | ||||
| @ -13,6 +13,7 @@ | ||||
|     <th>Steuergruppen-ID</th> | ||||
|     <th>EK-Preis (Netto)</th> | ||||
|     <th>VK-Preis (Brutto)</th> | ||||
|     <th>Aktionen</th> | ||||
|   </tr> | ||||
|   {% for cart_item in cart %} | ||||
|   <tr> | ||||
| @ -24,6 +25,12 @@ | ||||
|     <td class="--align-right">{{ cart_item.tax_group_id }}</td> | ||||
|     <td class="--align-right">{{ format_currency(cart_item.net_unit_price) }}</td> | ||||
|     <td class="--align-right">{{ format_currency(cart_item.gross_unit_price) }}</td> | ||||
|     <td> | ||||
|       <form method="POST" action="/entry/delete-order"> | ||||
|         <input type="hidden" name="order-index" value="{{ loop.index0 }}"> | ||||
|         <button>Löschen</button> | ||||
|       </form> | ||||
|     </td> | ||||
|   </tr> | ||||
|   {% endfor %} | ||||
| </table> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user