Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
629a3e71
Commit
629a3e71
authored
3 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Use instance_of only on parent class (polymorphic)
parent
b1852eeb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!477
Resolve "Handle broken DashboardWidgets correctly"
Pipeline
#10441
canceled
3 years ago
Stage: test
Stage: build
Stage: publish
Stage: docker
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/core/managers.py
+9
-2
9 additions, 2 deletions
aleksis/core/managers.py
with
9 additions
and
2 deletions
aleksis/core/managers.py
+
9
−
2
View file @
629a3e71
from
datetime
import
date
from
typing
import
Union
from
django.apps
import
apps
from
django.contrib.sites.managers
import
CurrentSiteManager
as
_CurrentSiteManager
from
django.db.models
import
QuerySet
from
django.db.models.manager
import
Manager
...
...
@@ -99,11 +100,17 @@ class UninstallRenitentPolymorphicManager(PolymorphicManager):
"""
A custom manager for django-polymorphic that filters out submodels of unavailable apps.
"""
def
get_queryset
(
self
):
return
super
().
get_queryset
().
instance_of
(
*
self
.
model
.
__subclasses__
())
DashboardWidget
=
apps
.
get_model
(
"
core
"
,
"
DashboardWidget
"
)
if
self
.
model
is
DashboardWidget
:
return
super
().
get_queryset
().
instance_of
(
*
self
.
model
.
__subclasses__
())
else
:
# Called on subclasses
return
super
().
get_queryset
()
class
InstalledWidgetsDashBoardWidgetOrderManager
(
Manager
):
"""
A custom manager that only returns DashboardWidgetOrder objects with an existing dashboard widget
"""
"""
A manager that only returns DashboardWidgetOrder objects with an existing widget.
"""
def
get_queryset
(
self
):
queryset
=
super
().
get_queryset
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment