Skip to content
Snippets Groups Projects
Commit c5f67ac8 authored by Hangzhi Yu's avatar Hangzhi Yu Committed by Tom Teichler
Browse files

Deny access to dashboard edit page to superusers with dummy person

parent 433d97f7
No related branches found
No related tags found
1 merge request!888Resolve "Super admin without person fails to edit dashboard"
Pipeline #49465 passed
...@@ -25,6 +25,7 @@ Fixed ...@@ -25,6 +25,7 @@ Fixed
~~~~~ ~~~~~
* Changing the favicon did not result in all icons being replaced in some cases * Changing the favicon did not result in all icons being replaced in some cases
* Superusers with a dummy person were able to access the dashboard edit page.
* GroupManager.get_queryset() returned an incomplete QuerySet * GroupManager.get_queryset() returned an incomplete QuerySet
* OAuth was broken by a non-semver-adhering django-oauth-toolkit update * OAuth was broken by a non-semver-adhering django-oauth-toolkit update
* Too long texts in chips didn't result in a larger chip. * Too long texts in chips didn't result in a larger chip.
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
{% block content %} {% block content %}
{% has_perm "core.edit_dashboard_rule" user as can_edit_dashboard %} {% has_perm "core.edit_dashboard_rule" user as can_edit_dashboard %}
{% if can_edit_dashboard %} {% if can_edit_dashboard and show_edit_dashboard_button %}
<div class="row no-margin"> <div class="row no-margin">
<a class="btn-flat waves-effect waves-light right" href="{% url "edit_dashboard" %}"> <a class="btn-flat waves-effect waves-light right" href="{% url "edit_dashboard" %}">
<i class="material-icons left">edit</i> <i class="material-icons left">edit</i>
......
...@@ -232,9 +232,11 @@ def index(request: HttpRequest) -> HttpResponse: ...@@ -232,9 +232,11 @@ def index(request: HttpRequest) -> HttpResponse:
context["default_dashboard"] = True context["default_dashboard"] = True
media = DashboardWidget.get_media(widgets) media = DashboardWidget.get_media(widgets)
show_edit_dashboard_button = not getattr(person, "is_dummy", False)
context["widgets"] = widgets context["widgets"] = widgets
context["media"] = media context["media"] = media
context["show_edit_dashboard_button"] = show_edit_dashboard_button
return render(request, "core/index.html", context) return render(request, "core/index.html", context)
...@@ -993,7 +995,11 @@ class EditDashboardView(PermissionRequiredMixin, View): ...@@ -993,7 +995,11 @@ class EditDashboardView(PermissionRequiredMixin, View):
context = {} context = {}
self.default_dashboard = kwargs.get("default", False) self.default_dashboard = kwargs.get("default", False)
if self.default_dashboard and not request.user.has_perm("core.edit_default_dashboard_rule"): if (
self.default_dashboard
and not request.user.has_perm("core.edit_default_dashboard_rule")
or getattr(person, "is_dummy", False)
):
raise PermissionDenied() raise PermissionDenied()
context["default_dashboard"] = self.default_dashboard context["default_dashboard"] = self.default_dashboard
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment