Commit 121466d5 authored by Willard's avatar Willard

Add individual dish controller/view

parent 1bf797d9
......@@ -4,7 +4,6 @@ from canteeneo import app, db
from canteeneo.models import Stall, Dish
from canteeneo.forms import DishRegisterForm
from canteeneo.views import flash_form_errors, stall_validate, dish_validate
from flask import render_template, redirect, url_for, request
from flask_login import login_required
from werkzeug.utils import secure_filename
......@@ -29,6 +28,12 @@ def new_dish(stall_id):
else:
return render_template('newdish.html', form=form, stall=stall)
@app.route('/stalls/<int:stall_id>/dishes/<int:dish_id>', methods=["GET"])
@login_required
@dish_validate
def dish(stall_id, dish_id):
return render_template('viewdish.html', stall=Stall.query.get(stall_id), dish=Dish.query.get(dish_id))
@app.route('/stalls/<int:stall_id>/dishes/<int:dish_id>/edit', methods=['GET', 'POST'])
@login_required
@dish_validate
......
{% extends "base.html" %} {% block title %} {{stall.name}} - {{dish.name}}{% endblock %} {% block content %}
<div class="dashboard-container">
<!--
<div class="dashboard-row">
<span style="font-size: 32pt; flex-grow: 2;">
{{stall.name}}
</span>
<a href="{{ url_for('new_dish', stall_id=stall.id) }}"><button class="link-button" style="flex-grow: 1;">Add Dish</button></a>
<a href="{{ url_for('edit_stall', stall_id=stall.id) }}"><button class="link-button" style="flex-grow: 1;">Edit Info</button></a>
</div>
<div class="dashboard-row">
<div class="list">
{% if dishes|length > 0 %} {% for dish in dishes %}
<div class="list-item">
<div class="list-image">
<img width="200px" height="200px" src="{{url_for('static', filename='uploads/'+dish.image_path)}}" alt="">
</div>
<div class="list-info">
<span class="list-name">{{dish.name}}</span>
<span class="list-price">Php{{dish.price}}</span>
<div>
<a href="{{ url_for('edit_dish', stall_id=stall.id, dish_id=dish.id) }}"><button class="list-button">Edit</button></a>
<form action="{{ url_for('delete_dish', stall_id=stall.id, dish_id=dish.id) }}" method="POST" onsubmit="return confirm('Are you sure you want to delete {{dish.name}}')">
<button type="submit" class="list-button button-delete">Delete</button></a>
</form>
</div>
</div>
</div>
{% endfor %} {% endif %}
</div>
</div>
<div class="dashboard-row">
<a href="{{ url_for('stalls') }}"><button class="link-button">Dashboard</button></a>
</div>
-->
Name: {{dish.name}}<br>
Description: {{dish.description}}<br>
Price: {{dish.price}}<br>
{{dish.favorites|length}} favorites<br>
Reviews<br>
{% for review in dish.reviews %}
Title: {{review.title}}<br>
Body: {{review.body}}
{% endfor %}
</div>
{% endblock %}
\ No newline at end of file
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