Skip to content
Snippets Groups Projects
Commit f21a9fd0 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Merge branch '346-do-not-allow-to-add-hidden-dashboard-widgets-to-personal-dashboard' into 'master'

Resolve "Do not allow to add hidden dashboard widgets to personal dashboard"

Closes #346

See merge request !444
parents cc90f91b 27caf0ef
No related branches found
No related tags found
1 merge request!444Resolve "Do not allow to add hidden dashboard widgets to personal dashboard"
Pipeline #5327 passed
...@@ -239,7 +239,10 @@ class Person(ExtensibleModel): ...@@ -239,7 +239,10 @@ class Person(ExtensibleModel):
@property @property
def dashboard_widgets(self): def dashboard_widgets(self):
return [ return [
w.widget for w in DashboardWidgetOrder.objects.filter(person=self).order_by("order") w.widget
for w in DashboardWidgetOrder.objects.filter(person=self, widget__active=True).order_by(
"order"
)
] ]
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
...@@ -749,7 +752,12 @@ class DashboardWidgetOrder(ExtensibleModel): ...@@ -749,7 +752,12 @@ class DashboardWidgetOrder(ExtensibleModel):
@classproperty @classproperty
def default_dashboard_widgets(cls): def default_dashboard_widgets(cls):
"""Get default order for dashboard widgets.""" """Get default order for dashboard widgets."""
return [w.widget for w in cls.objects.filter(person=None, default=True).order_by("order")] return [
w.widget
for w in cls.objects.filter(person=None, default=True, widget__active=True).order_by(
"order"
)
]
class Meta: class Meta:
verbose_name = _("Dashboard widget order") verbose_name = _("Dashboard widget order")
......
...@@ -868,7 +868,9 @@ class EditDashboardView(View): ...@@ -868,7 +868,9 @@ class EditDashboardView(View):
if not self.default_dashboard if not self.default_dashboard
else DashboardWidgetOrder.default_dashboard_widgets else DashboardWidgetOrder.default_dashboard_widgets
) )
not_used_widgets = DashboardWidget.objects.exclude(pk__in=[w.pk for w in widgets]) not_used_widgets = DashboardWidget.objects.exclude(pk__in=[w.pk for w in widgets]).filter(
active=True
)
context["widgets"] = widgets context["widgets"] = widgets
context["not_used_widgets"] = not_used_widgets context["not_used_widgets"] = not_used_widgets
......
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