Commit fde24369 authored by Johannes Knödtel's avatar Johannes Knödtel 🎶
Browse files

don't show order form when session is locked

parent 9c5f1d9e
......@@ -9,6 +9,9 @@
<div class="tab-label-content" id="tab1-content">
<label id="nav-label" for="tab1">Eintragen</label>
<div class="tab-content">
{% if locked %}
<h4>$menschen sind schon einkaufen. Es kann nichts mehr bestellt werden.</h4>
{% else %}
<div class="row card-panel">
<h4 class="col s12">Bestellen</h4>
<form method="POST" action="{{servlet-context}}/add-food" class="col s12">
......@@ -54,6 +57,7 @@
</div>
</form>
</div>
{% endif %}
<div class="row">
<div class=" col s12">
......@@ -61,7 +65,9 @@
<table class="highlight">
<thead>
<tr>
{% if not locked %}
<th></th>
{% endif %}
<th>#</th>
<th>Fressen</th>
<th>Extras</th>
......@@ -71,6 +77,7 @@
<tbody>
{% for item in items %}
<tr>
{% if not locked %}
<td style="white-space:nowrap;width:1px;">
<div class="horizontal">
<a title="Diese Bestellung ändern." class="btn-floating btn-small cyan modal-trigger" href="#edit-food-modal-{{ item|item-hash }}">
......@@ -82,11 +89,13 @@
</a>
</div>
</td>
{% endif %}
<td style="white-space:nowrap;width:1px;">{{item.quantity}}</td>
<td>{{item.food_name}}</td>
<td>{{item.comment}}</td>
<td>{{item.customer}}</td>
</tr>
{% if not locked %}
<div class="modal" id="delete-food-modal-{{ item|item-hash }}">
<form method="POST" action="{{servlet-context}}/delete-order" style="display:inline;">
{% csrf-field %}
......@@ -148,6 +157,7 @@
</div>
</form>
</div>
{% endif %}
{% endfor %}
</tbody>
</table>
......
......@@ -12,7 +12,8 @@
(defn list-page
([session headers] (list-page [] session headers))
([food-options session headers]
(let [items (db/run db/get-food {:session session})
(let [locked (:locked (db/run db/session-locked? {:session session}))
items (db/run db/get-food {:session session})
numbers (util/group-numbers (db/run db/get-food-numbers {:session session}))
summed-numbers (util/add-difference (db/run db/get-summed-food-numbers {:session session}))
paid (apply hash-set (mapcat vals (db/run db/get-already-paid {:session session})))
......@@ -36,7 +37,8 @@
:too_much too-much
:too_little too-little
:food_options food-options
:bills bills})))))
:bills bills
:locked locked})))))
(defn list-tex-pdf [session]
(util/serve-pdf (io/input-stream
......
......@@ -93,10 +93,9 @@
:or {session-lockable? false}}]
(let [args (request-transformation-fn request)
validation-errors (first (validataion-fn args))]
(if (and session-lockable? (db/run db/session-locked? args))
(if (and session-lockable? (:locked (db/run db/session-locked? args)))
(do
(session-locked)
(redirect-to-referrer headers))
(session-locked))
(if validation-errors
(validation-error validation-errors)
(do
......
Supports Markdown
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