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
5ba8e8fc
Verified
Commit
5ba8e8fc
authored
5 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Document DashboardFeeds model
parent
dbf3c40f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!142
Implement core functionality for dashboard widgets
Pipeline
#756
failed
5 years ago
Stage: test
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/core/models.py
+26
-0
26 additions, 0 deletions
aleksis/core/models.py
with
26 additions
and
0 deletions
aleksis/core/models.py
+
26
−
0
View file @
5ba8e8fc
...
...
@@ -231,11 +231,37 @@ class Notification(models.Model):
class
DashboardWidget
(
PolymorphicModel
):
"""
Base class for dashboard widgets on the index page
To implement a widget, add a model that subclasses DashboardWidget, sets the template
and implements the get_context method to return a dictionary to be passed as context
to the template.
If your widget does not add any database fields, you should mark it as a proxy model.
Example::
from aleksis.core.models import DashboardWidget
class MyWidget(DhasboardWIdget):
template =
"
myapp/widget.html
"
def get_context(self):
context = {
"
some_content
"
:
"
foo
"
}
return context
class Meta:
proxy = True
"""
template
=
None
title
=
models
.
CharField
(
max_length
=
150
,
verbose_name
=
_
(
"
Widget Title
"
))
active
=
models
.
BooleanField
(
blank
=
True
,
verbose_name
=
_
(
"
Activate Widget
"
))
def
get_context
(
self
):
raise
NotImplementedError
(
"
A widget subclass needs to implement the get_context method.
"
)
def
__str__
(
self
):
return
self
.
title
...
...
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