Skip to content

Commit

Permalink
Top-level log in
Browse files Browse the repository at this point in the history
  • Loading branch information
pehala committed Sep 16, 2023
1 parent 8947e2e commit f8a3b66
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
14 changes: 6 additions & 8 deletions backend/menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,19 @@
)

account_children = (
MenuItem(
_("Log in"),
reverse("login"),
check=lambda request: not request.user.is_authenticated,
),
MenuItem(
_("Logout"),
reverse("logout"),
check=lambda request: request.user.is_authenticated,
),
MenuItem(
_("Change password"),
reverse("password_change"),
check=lambda request: request.user.is_authenticated,
),
)

Menu.add_item("account", MenuItem(_("Account"), reverse("login"), children=account_children))
Menu.add_item(
"account",
MenuItem(
_("Account"), reverse("login"), children=account_children, check=lambda request: request.user.is_authenticated
),
)
5 changes: 4 additions & 1 deletion frontend/static/styles.sass
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,7 @@ p
/* Set the fixed height of the footer here */
.footer
height: 60px
background-color: #f5f5f5
background-color: #f5f5f5

.custom-link
color: $colDefault
8 changes: 5 additions & 3 deletions frontend/templates/base/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,14 @@
</div>
</li>
</ul>
{% if user.is_authenticated %}
<span class="navbar-text mr-2">{% trans "Logged as" %} <b>{{ user.username }}</b></span>
{% endif %}
<ul class="my-lg-0 navbar-nav navbar-right">
{% include "menu/bootstrap4-menu.html" with menu=menus.account %}
</ul>
{% if user.is_authenticated %}
<span class="navbar-text mr-2">{% trans "Logged as" %} <b>{{ user.username }}</b></span>
{% else %}
<a href="{% url 'login' %}" class="btn btn-link custom-link" role="button">{% trans "Log in" %}</a>
{% endif %}

</div>
</nav>
Expand Down

0 comments on commit f8a3b66

Please sign in to comment.