diff --git a/sigl/templates/lists/addItem.html.j2 b/sigl/templates/lists/addItem.html.j2 index 0d7f0bf..5e38d91 100644 --- a/sigl/templates/lists/addItem.html.j2 +++ b/sigl/templates/lists/addItem.html.j2 @@ -3,11 +3,6 @@ {% block header %}
Add Item to {{ list.name }}
-
- - Cancel - -
{% endblock %} {% block main %} @@ -44,7 +39,12 @@ -
+
+
diff --git a/sigl/templates/lists/create.html.j2 b/sigl/templates/lists/create.html.j2 index 3c2ed20..b35f136 100644 --- a/sigl/templates/lists/create.html.j2 +++ b/sigl/templates/lists/create.html.j2 @@ -3,11 +3,6 @@ {% block header %}
Create New List
-
- - Cancel - -
{% endblock %} {% block main %} @@ -21,7 +16,12 @@ -
+
+
diff --git a/sigl/templates/lists/detail.html.j2 b/sigl/templates/lists/detail.html.j2 index 0f29b9e..5ac8c56 100644 --- a/sigl/templates/lists/detail.html.j2 +++ b/sigl/templates/lists/detail.html.j2 @@ -34,8 +34,8 @@ {% endblock %} {% block main %} -
-
+
+
+
+ +
{% if list.entries|length == 0 %}
@@ -66,7 +69,7 @@ -
{{ entry.product.name }}{% if entry.quantity %} | {{ entry.quantity }}{% endif %}
+
{{ entry.product.name }}{% if entry.quantity %} | {{ entry.quantity }}{% endif %}
{% if bin %}Bin {{ bin }}{% endif %}
@@ -87,11 +90,11 @@
-{% if entry.notes %} -
{{ entry.notes }}
-{% endif %} -{% if entry.product.notes %} -
{{ entry.product.notes }}
+{% if entry.notes or entry.product.notes %} +
+ {% if entry.notes %}

{{ entry.notes }}

{% endif %} + {% if entry.product.notes %}

{{ entry.product.notes }}

{% endif %} +
{% endif %} {%- endmacro %} @@ -124,6 +127,7 @@ {% endif %} {% endif %}
+
{% endblock %} \ No newline at end of file diff --git a/sigl/templates/lists/update.html.j2 b/sigl/templates/lists/update.html.j2 index e8f43c1..c20e485 100644 --- a/sigl/templates/lists/update.html.j2 +++ b/sigl/templates/lists/update.html.j2 @@ -3,17 +3,6 @@ {% block header %}
Edit {{ list.name }}
-
- - Cancel - -
{% endblock %} {% block main %} @@ -27,7 +16,18 @@
-
+
+
+ + Cancel + + +
diff --git a/sigl/views/lists.py b/sigl/views/lists.py index 7caf3a4..ff51ebb 100644 --- a/sigl/views/lists.py +++ b/sigl/views/lists.py @@ -13,8 +13,8 @@ from sigl.exc import DomainError, Error, NotFoundError from sigl.database import db from sigl.domain.service import ( list_entry_by_id, lists_all, list_by_id, list_create, list_delete, - list_update, list_addItem, list_editItem, list_stores, - list_entry_set_crossedOff, + list_update, list_addItem, list_deleteItem, list_editItem, list_stores, + list_deleteCrossedOff, list_entry_set_crossedOff, products_all, ) @@ -145,6 +145,17 @@ def delete(id): return redirect(url_for('lists.home')) +@bp.route('/lists//deleteCrossedOff', methods=('POST', )) +def deleteCrossedOff(id): + """Delete all Crossed-Off Items on a Shopping List.""" + try: + list_deleteCrossedOff(db.session, id) + except Error as e: + flash(str(e), 'error') + + return redirect(url_for('lists.detail', id=id)) + + @bp.route('/lists//crossOff', methods=('POST', )) def crossOff(id): """Cross Off an Item from a Shopping List. @@ -259,3 +270,16 @@ def editItem(listId, entryId): list=entry.shoppingList, entry=entry, ) + + +@bp.route('/lists//deleteItem/', methods=('POST', )) +def deleteItem(listId, entryId): + """Delete an Item from a Shopping List.""" + try: + list_deleteItem(db.session, listId, entryId) + return redirect(url_for('lists.detail', id=listId)) + + except Error as e: + flash(str(e), 'error') + + return redirect(url_for('lists.editItem', listId=listId, entryId=entryId))