Add organization indicator

This commit is contained in:
Tobias Kunze 2025-03-17 09:51:52 +01:00
parent 024eae0e1a
commit a780d31c15
3 changed files with 38 additions and 3 deletions

View file

@ -0,0 +1,5 @@
def add_organizations(request):
if not request.user.is_authenticated:
return {"user_organizations": []}
return {"user_organizations": request.user.organizations.all()}

View file

@ -56,6 +56,36 @@
</div>
<div class="sidebar-menu">
<ul class="menu">
{% if request.user.is_authenticated %}
<li class="sidebar-item active">
{% if user_organizations.count > 1 %}
<button class="btn btn-primary dropdown-toggle me-1"
type="button"
id="organizationDropdown"
data-bs-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false">
{% if current_organization %}
{{ current_organization.name }}
{% else %}
{% translate "Organizations" %}
{% endif %}
</button>
<div class="dropdown-menu" aria-labelledby="organizationDropdown">
{% for organization in user_organizations %}
<a class="dropdown-item" href="#TODO">{{ organization.name }}</a>
{% endfor %}
</div>
{% elif current_organization %}
{% translate "Organization" %}: {{ current_organization.name }}
{% else %}
<a href="#TODO" class="sidebar-link">
<i class="bi bi-plus-square"></i>
<span>{% translate "Create organization" %}</span>
</a>
{% endif %}
</li>
{% endif %}
<li class="sidebar-item active">
<a href="index.html" class='sidebar-link'>
<i class="bi bi-grid-fill"></i>

View file

@ -144,6 +144,7 @@ TEMPLATES = [
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"django.template.context_processors.static",
"servala.frontend.context_processors.add_organizations",
],
"loaders": template_loaders,
},
@ -156,10 +157,9 @@ MESSAGE_TAGS = {
AUTH_USER_MODEL = "core.User"
ACCOUNT_USER_MODEL_USERNAME_FIELD = None
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_AUTHENTICATION_METHOD = "email"
ACCOUNT_LOGIN_METHODS = {"email"}
ACCOUNT_SIGNUP_FIELDS = ["email*", "password1*", "password2*"]
AUTHENTICATION_BACKENDS = [
# Needed to login by username in Django admin, regardless of `allauth`