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
638f7624
Verified
Commit
638f7624
authored
5 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Document ExtensbleModel.
parent
3b0989c5
Branches
616-docs-document-dashboard-and-dashboard-widgets
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
biscuit/core/mixins.py
+28
-1
28 additions, 1 deletion
biscuit/core/mixins.py
with
28 additions
and
1 deletion
biscuit/core/mixins.py
+
28
−
1
View file @
638f7624
...
...
@@ -10,7 +10,34 @@ from .util.core_helpers import get_current_school
class
ExtensibleModel
(
object
):
"""
Mixin that adds class methods for glrofied monkey-patching.
"""
"""
Allow injection of code from BiscuIT apps to extend model functionality.
After all apps have been loaded, the code in the `model_extensions` module
in every app is executed. All code that shall be injected into a model goes there.
:Example:
.. code-block:: python
from datetime import date, timedelta
from biscuit.core.models import Person
@Person.property
def is_cool(self) -> bool:
return True
@Person.property
def age(self) -> timedelta:
return self.date_of_birth - date.today()
For a more advanced example, using features from the ORM, see BiscuIT-App-Chronos
and BiscuIT-App-Alsijil.
:Date: 2019-11-07
:Authors:
- Dominik George <dominik.george@teckids.org>
"""
@classmethod
def
_safe_add
(
cls
,
obj
:
Any
,
name
:
Optional
[
str
])
->
None
:
...
...
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