Added an edit feature. Base flavors and add ons (ingredients)

can now be updated.
The updated version moves to the bottom though.
Changed styling accordingly --made neater.
parent 5c38d050
...@@ -193,6 +193,20 @@ header { ...@@ -193,6 +193,20 @@ header {
cursor: pointer; cursor: pointer;
} }
.edit {
border: none;
border-radius: 10px;
padding: 10px;
background-color: #A4BEF3;
}
.delete {
border: none;
border-radius: 10px;
padding: 10px;
background-color: #F87060;
}
a:link { a:link {
text-decoration: none; text-decoration: none;
border: none; border: none;
......
...@@ -30,8 +30,6 @@ ...@@ -30,8 +30,6 @@
<th>Options</th> <th>Options</th>
</tr> </tr>
<!-- TABLE ROWS WITH INFO --> <!-- TABLE ROWS WITH INFO -->
{% for ingredient in inventory %} {% for ingredient in inventory %}
<tr> <tr>
...@@ -41,8 +39,8 @@ ...@@ -41,8 +39,8 @@
<td>{{ingredient.price_per_serving}}</td> <td>{{ingredient.price_per_serving}}</td>
<td>{{ingredient.replenished_stock}}</td> <td>{{ingredient.replenished_stock}}</td>
<td> <td>
<button class="edit-value edit">Edit</button> <button class="crud edit"><a class="crud-value edit" href="{% url 'update_ingredient' ingredient.ingredient_id %}">Edit</a></button>
<button class="delete-value delete">Delete</button> <button class="crud-value delete">Delete</button>
</td> </td>
</tr> </tr>
......
...@@ -29,8 +29,10 @@ ...@@ -29,8 +29,10 @@
<tr> <tr>
<td>{{bf.bf_name}}</td> <td>{{bf.bf_name}}</td>
<td> <td>
<button class="edit-value edit">Edit</button> <button class="crud edit">
<button class="delete-value delete">Delete</button> <a class="crud-value edit" href="{% url 'update_baseflavor' bf.bf_id %}">
Edit</a></button>
<button class="crud-value delete">Delete</button>
</td> </td>
</tr> </tr>
{%endfor%} {%endfor%}
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<form action="/addBaseFlavor" method="POST" style="text-align:center"> <form action="" method="POST" style="text-align:center">
{% csrf_token %} {% csrf_token %}
{{form.as_p}} {{form.as_p}}
<input type="submit" value="Submit"> <input type="submit" value="Submit">
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<form action="/addingredient" method="POST" style="text-align:center"> <form action="" method="POST" style="text-align:center">
{% csrf_token %} {% csrf_token %}
{{form.as_p}} {{form.as_p}}
<input type="submit" value="Submit"> <input type="submit" value="Submit">
......
...@@ -11,15 +11,6 @@ urlpatterns = [ ...@@ -11,15 +11,6 @@ urlpatterns = [
path('schedule', schedule, name='schedule'), path('schedule', schedule, name='schedule'),
path('report', report, name='report'), path('report', report, name='report'),
#forms
path('addorder', addorder, name='addorder'),
path('additem', additem, name='additem'),
path('addcustomer', addcustomer, name='addcustomer'),
path('addingredient', addingredient, name='addingredient'),
path('addBaseFlavor', addbaseflavor, name='addBaseFlavor'),
path('addinventory', addinventory, name='addinventory'),
#queries #queries
path('manager_query', manager_query, name='manager_query'), path('manager_query', manager_query, name='manager_query'),
path('week_query', week_query, name='week_query'), path('week_query', week_query, name='week_query'),
...@@ -32,4 +23,19 @@ urlpatterns = [ ...@@ -32,4 +23,19 @@ urlpatterns = [
path('receipt', receipt, name='receipt'), path('receipt', receipt, name='receipt'),
path('orderslip', orderSlip, name='orderslip'), path('orderslip', orderSlip, name='orderslip'),
#forms
path('addorder', addorder, name='addorder'),
path('additem', additem, name='additem'),
path('addcustomer', addcustomer, name='addcustomer'),
# CRUD - FOR ADD ONS
path('addingredient', addingredient, name='addingredient'),
path('update_ingredient/<str:pk>/', updateIngredient, name='update_ingredient'),
# CRUD - FOR BASE FLAVORS
path('addBaseFlavor', addbaseflavor, name='addBaseFlavor'),
path('update_baseflavor/<str:pk>/', updateBaseFlavor, name='update_baseflavor'),
path('addinventory', addinventory, name='addinventory'),
] ]
...@@ -42,8 +42,6 @@ def baseFlavors(request): ...@@ -42,8 +42,6 @@ def baseFlavors(request):
} }
return render(request, "blizzardblast/templates/filtered_views/baseFlavors.html", contexts) return render(request, "blizzardblast/templates/filtered_views/baseFlavors.html", contexts)
def schedule(request): def schedule(request):
all_values = EmployeeRole.objects.all() all_values = EmployeeRole.objects.all()
return render(request, return render(request,
...@@ -137,14 +135,40 @@ def addingredient(request): ...@@ -137,14 +135,40 @@ def addingredient(request):
return redirect('/inventory') return redirect('/inventory')
return render(request, "blizzardblast/templates/forms/addingredient.html", context) return render(request, "blizzardblast/templates/forms/addingredient.html", context)
def updateIngredient(request,pk):
ingredient = Ingredient.objects.get(ingredient_id=pk)
form = AddIngredient(instance=ingredient)
context = {'form':form}
# this handles updating the values in the form
if request.method == 'POST':
form = AddIngredient(request.POST, instance=ingredient)
if form.is_valid():
form.save()
return redirect('/inventory')
return render(request, "blizzardblast/templates/forms/addingredient.html", context)
def addbaseflavor(request): def addbaseflavor(request):
form = AddBaseFlavor() form = AddBaseFlavor()
context = {'form':form} context = {'form':form}
if request.method == 'POST': if request.method == 'POST':
form = AddBaseFlavor(request.POST) form = AddBaseFlavor(request.POST)
if form.is_valid(): if form.is_valid():
form.save() form.save()
return redirect('/inventory') return redirect('/inventory')
return render(request, "blizzardblast/templates/forms/addBaseFlavor.html", context)
def updateBaseFlavor(request,pk):
bf = BaseFlavor.objects.get(bf_id=pk)
form = AddBaseFlavor(instance=bf)
context = {'form':form}
# this handles updating the values in the form
if request.method == 'POST':
form = AddBaseFlavor(request.POST, instance=bf)
if form.is_valid():
form.save()
return redirect('/inventory')
return render(request, "blizzardblast/templates/forms/addBaseFlavor.html", context) return render(request, "blizzardblast/templates/forms/addBaseFlavor.html", context)
def addinventory(request): def addinventory(request):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment