Skip to content

Commit

Permalink
Hide new listing button and prepare order button when admin (#577)
Browse files Browse the repository at this point in the history
* Hide new listing button and prepare order button when admin

* Fix template context for listings index page
  • Loading branch information
yzernik authored Aug 6, 2022
1 parent 6298893 commit b75e9b2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/listings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ struct Context {
flash: Option<(String, String)>,
listing_cards: Vec<ListingCardDisplay>,
page_num: u32,
user: Option<User>,
admin_user: Option<AdminUser>,
}

impl Context {
Expand All @@ -40,6 +42,8 @@ impl Context {
flash,
listing_cards,
page_num,
user,
admin_user,
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions templates/listing.html.tera
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
<p><b>Description</b>: {{ listing_display.listing.description }}</p>

{% if listing_display.listing.approved %}
{% if not admin_user %}
<form action="/prepare_order/{{ listing_display.listing.public_id }}" method="get">

<label for="shipping_options">Choose a shipping option:</label>
Expand All @@ -113,6 +114,7 @@
<input type="submit" value="Prepare Order">
</form>
{% endif %}
{% endif %}

</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions templates/listingsindex.html.tera
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

{% include "search_form" %}

{% if not admin_user %}
<a href="/new_listing">Add New Listing</a>
{% endif %}

<div class="container">
<p><!--Nothing to see here --></p>
Expand Down

0 comments on commit b75e9b2

Please sign in to comment.