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
69e67cc1
Verified
Commit
69e67cc1
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Plain Diff
Merge branch 'fix-model-versioning'
parents
8fd01037
4561d59c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!249
Add metaclass for model versioning
Pipeline
#1963
failed
4 years ago
Stage: test
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/core/mixins.py
+21
-4
21 additions, 4 deletions
aleksis/core/mixins.py
aleksis/core/util/notifications.py
+0
-1
0 additions, 1 deletion
aleksis/core/util/notifications.py
with
21 additions
and
5 deletions
aleksis/core/mixins.py
+
21
−
4
View file @
69e67cc1
...
...
@@ -17,8 +17,25 @@ from material.base import Layout, LayoutNode
from
rules.contrib.admin
import
ObjectPermissionsModelAdmin
@reversion.register
class
ExtensibleModel
(
models
.
Model
):
class
_ExtensibleModelBase
(
models
.
base
.
ModelBase
):
"""
Ensure predefined behaviour on model creation.
This metaclass serves the following purposes:
- Register all AlekSIS models with django-reverseion
"""
def
__new__
(
mcls
,
name
,
bases
,
attrs
):
mcls
=
super
().
__new__
(
mcls
,
name
,
bases
,
attrs
)
if
"
Meta
"
not
in
attrs
or
not
attrs
[
"
Meta
"
].
abstract
:
# Register all non-abstract models with django-reversion
mcls
=
reversion
.
register
(
mcls
)
return
mcls
class
ExtensibleModel
(
models
.
Model
,
metaclass
=
_ExtensibleModelBase
):
"""
Base model for all objects in AlekSIS apps.
This base model ensures all objects in AlekSIS apps fulfill the
...
...
@@ -212,8 +229,8 @@ class PureDjangoModel(object):
class
_ExtensibleFormMetaclass
(
ModelFormMetaclass
):
def
__new__
(
cls
,
mcs
,
name
,
bases
,
dct
):
x
=
super
().
__new__
(
m
cs
,
name
,
bases
,
dct
)
def
__new__
(
cls
,
name
,
bases
,
dct
):
x
=
super
().
__new__
(
c
l
s
,
name
,
bases
,
dct
)
# Enforce a default for the base layout for forms that o not specify one
if
hasattr
(
x
,
"
layout
"
):
...
...
This diff is collapsed.
Click to expand it.
aleksis/core/util/notifications.py
+
0
−
1
View file @
69e67cc1
...
...
@@ -10,7 +10,6 @@ from django.utils.translation import gettext_lazy as _
from
templated_email
import
send_templated_mail
from
..models
import
Notification
from
.core_helpers
import
lazy_preference
try
:
...
...
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