Skip to content

Commit

Permalink
navigation: don't show Settings link if current user is not admin
Browse files Browse the repository at this point in the history
  • Loading branch information
a1ex4 committed Apr 28, 2024
1 parent cd29707 commit c2316a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class User(UserMixin, db.Model):
shop_access = db.Column(db.Boolean)
backup_access = db.Column(db.Boolean)

@property
def is_admin(self):
return self.admin_access

def has_shop_access(self):
return self.shop_access

Expand Down
8 changes: 8 additions & 0 deletions app/templates/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
<li class="nav-item">
<a class="nav-link{% if title == 'Library' %} active" aria-current="page"{% else %}"{% endif %} href="/">Library</a>
</li>
{% if current_user.is_admin or admin_account_created == false %}
<li class="nav-item">
<a class="nav-link{% if title == 'Settings' %} active" aria-current="page"{% else %}"{% endif %}" href="/settings">Settings</a>
</li>
{% endif %}
<li class="nav-item">
<a class="nav-link{% if title == 'Setup' %} active" aria-current="page"{% else %}"{% endif %}" href="#">Setup</a>
</li>
Expand All @@ -23,6 +25,12 @@
<a class="btn btn-outline-secondary me-2" href="/logout" role="button">Logout</a>
</li>
</ul>
{% else %}
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="btn btn-outline-secondary me-2" href="/login" role="button">Login</a>
</li>
</ul>
{% endif %}
</div>
</div>
Expand Down

0 comments on commit c2316a6

Please sign in to comment.