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
b9affcaa
Commit
b9affcaa
authored
4 years ago
by
Hangzhi Yu
Browse files
Options
Downloads
Patches
Plain Diff
Let GlobalPermissionModel pass through checks
parent
7893c465
No related branches found
No related tags found
1 merge request
!453
Resolve "Reinvestigate how to do global permissions"
Pipeline
#5768
passed
4 years ago
Stage: test
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/core/checks.py
+17
-7
17 additions, 7 deletions
aleksis/core/checks.py
with
17 additions
and
7 deletions
aleksis/core/checks.py
+
17
−
7
View file @
b9affcaa
...
...
@@ -3,7 +3,7 @@ from typing import Optional
import
django.apps
from
django.core.checks
import
Tags
,
Warning
,
register
from
.mixins
import
ExtensibleModel
,
PureDjangoModel
from
.mixins
import
ExtensibleModel
,
GlobalPermissionModel
,
PureDjangoModel
from
.util.apps
import
AppConfig
...
...
@@ -39,7 +39,10 @@ def check_app_configs_base_class(
def
check_app_models_base_class
(
app_configs
:
Optional
[
django
.
apps
.
registry
.
Apps
]
=
None
,
**
kwargs
)
->
list
:
"""
Check whether all app models derive from AlekSIS
'
s base ExtensibleModel.
"""
"""
Check whether all app models derive from AlekSIS
'
s allowed base models.
Does only allow ExtensibleModel, GlobalPermissionModel and PureDjangoModel.
"""
results
=
[]
if
app_configs
is
None
:
...
...
@@ -47,14 +50,21 @@ def check_app_models_base_class(
for
app_config
in
filter
(
lambda
c
:
c
.
name
.
startswith
(
"
aleksis.
"
),
app_configs
):
for
model
in
app_config
.
get_models
():
if
ExtensibleModel
not
in
model
.
__mro__
and
PureDjangoModel
not
in
model
.
__mro__
:
if
(
ExtensibleModel
not
in
model
.
__mro__
and
PureDjangoModel
not
in
model
.
__mro__
and
GlobalPermissionModel
not
in
model
.
__mro__
):
results
.
append
(
Warning
(
f
"
Model
{
model
.
_meta
.
object_name
}
in app config
{
app_config
.
name
}
does
"
"
not derive from aleksis.core.mixins.ExtensibleModel.
"
,
f
"
Model
{
model
.
_meta
.
object_name
}
in app config
{
app_config
.
name
}
does
"
"
not derive from aleksis.core.mixins.ExtensibleModel
"
"
or aleksis.core.mixins.GlobalPermissionModel.
"
,
hint
=
(
"
Ensure all models in AlekSIS use ExtensibleModel as base.
"
"
If your deviation is intentional, you can add the PureDjangoModel
"
"
Ensure all models in AlekSIS use ExtensibleModel (or
"
"
GlobalPermissionModel, if you want to define global permissions)
"
"
as base.
"
"
If your deviation is intentional, you can add the PureDjangoModel
"
"
mixin instead to silence this warning.
"
),
obj
=
model
,
...
...
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