From b75e9b25c4395af48c6d47e5bf417adc06536630 Mon Sep 17 00:00:00 2001 From: Jonathan Zernik Date: Sat, 6 Aug 2022 01:26:13 -0700 Subject: [PATCH] Hide new listing button and prepare order button when admin (#577) * Hide new listing button and prepare order button when admin * Fix template context for listings index page --- src/listings.rs | 4 ++++ templates/listing.html.tera | 2 ++ templates/listingsindex.html.tera | 2 ++ 3 files changed, 8 insertions(+) diff --git a/src/listings.rs b/src/listings.rs index e2c994d..23edaf1 100644 --- a/src/listings.rs +++ b/src/listings.rs @@ -18,6 +18,8 @@ struct Context { flash: Option<(String, String)>, listing_cards: Vec, page_num: u32, + user: Option, + admin_user: Option, } impl Context { @@ -40,6 +42,8 @@ impl Context { flash, listing_cards, page_num, + user, + admin_user, }) } } diff --git a/templates/listing.html.tera b/templates/listing.html.tera index 12ccbee..0c6a76b 100644 --- a/templates/listing.html.tera +++ b/templates/listing.html.tera @@ -96,6 +96,7 @@

Description: {{ listing_display.listing.description }}

{% if listing_display.listing.approved %} + {% if not admin_user %}
@@ -113,6 +114,7 @@
{% endif %} + {% endif %} diff --git a/templates/listingsindex.html.tera b/templates/listingsindex.html.tera index 5a61392..e60f9bb 100644 --- a/templates/listingsindex.html.tera +++ b/templates/listingsindex.html.tera @@ -3,7 +3,9 @@ {% include "search_form" %} +{% if not admin_user %} Add New Listing +{% endif %}