Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Top-level log in #71

Merged
merged 1 commit into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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