Navigation and dashboard: Hide useless items (#5995)

* Navigation and dashboard: Hide useless items

If a user has access to *no organizer teams*, hide a number of things
from navigation and dashboard. This happens e.g. if a user only has
permissions in scope of the pretix-resellers or pretix-scheduling
plugins.

* New mechanism
This commit is contained in:
Raphael Michel
2026-03-17 10:26:22 +01:00
committed by GitHub
parent b939b63606
commit bf80dc37c5
3 changed files with 65 additions and 52 deletions

View File

@@ -340,38 +340,43 @@ def get_global_navigation(request):
'active': (url.url_name == 'index'),
'icon': 'dashboard',
},
{
'label': _('Events'),
'url': reverse('control:events'),
'active': 'events' in url.url_name,
'icon': 'calendar',
},
{
'label': _('Organizers'),
'url': reverse('control:organizers'),
'active': 'organizers' in url.url_name,
'icon': 'group',
},
{
'label': _('Search'),
'url': reverse('control:search.orders'),
'active': False,
'icon': 'search',
'children': [
{
'label': _('Orders'),
'url': reverse('control:search.orders'),
'active': 'search.orders' in url.url_name,
'icon': 'search',
},
{
'label': _('Payments'),
'url': reverse('control:search.payments'),
'active': 'search.payments' in url.url_name,
'icon': 'search',
},
]
},
]
if request.user.is_in_any_teams:
nav += [
{
'label': _('Events'),
'url': reverse('control:events'),
'active': 'events' in url.url_name,
'icon': 'calendar',
},
{
'label': _('Organizers'),
'url': reverse('control:organizers'),
'active': 'organizers' in url.url_name,
'icon': 'group',
},
{
'label': _('Search'),
'url': reverse('control:search.orders'),
'active': False,
'icon': 'search',
'children': [
{
'label': _('Orders'),
'url': reverse('control:search.orders'),
'active': 'search.orders' in url.url_name,
'icon': 'search',
},
{
'label': _('Payments'),
'url': reverse('control:search.payments'),
'active': 'search.payments' in url.url_name,
'icon': 'search',
},
]
},
]
nav += [
{
'label': _('User settings'),
'url': reverse('control:user.settings'),

View File

@@ -12,27 +12,29 @@
class="event-dropdown dropdown-menu">
</ul>
</div>
<h2>{% trans "Your upcoming events" %}</h2>
<div class="dashboard">
{% if can_create_event %}
<div class="widget-small widget-container">
<a href="{% url "control:events.add" %}" class="widget">
<div class="newevent"><span class="fa fa-plus-circle"></span>{% trans "Create a new event" %}</div>
</a>
</div>
{% endif %}
{% for w in upcoming %}
<div class="widget-{{ w.display_size|default:"small" }} {{ w.container_class|default:"widget-container" }} {% if w.lazy %}widget-lazy-loading{% endif %}" data-lazy-id="{{ w.lazy }}">
<div class="widget">
{% if w.lazy %}
<span class="fa fa-cog fa-4x"></span>
{% else %}
{{ w.content|safe }}
{% endif %}
{% if upcoming or can_create_event %}
<h2>{% trans "Your upcoming events" %}</h2>
<div class="dashboard">
{% if can_create_event %}
<div class="widget-small widget-container">
<a href="{% url "control:events.add" %}" class="widget">
<div class="newevent"><span class="fa fa-plus-circle"></span>{% trans "Create a new event" %}</div>
</a>
</div>
</div>
{% endfor %}
</div>
{% endif %}
{% for w in upcoming %}
<div class="widget-{{ w.display_size|default:"small" }} {{ w.container_class|default:"widget-container" }} {% if w.lazy %}widget-lazy-loading{% endif %}" data-lazy-id="{{ w.lazy }}">
<div class="widget">
{% if w.lazy %}
<span class="fa fa-cog fa-4x"></span>
{% else %}
{{ w.content|safe }}
{% endif %}
</div>
</div>
{% endfor %}
</div>
{% endif %}
{% if upcoming %}
<p class="">
<a href="{% url "control:events" %}?ordering=date_from&status=date_future" class="">