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
b528d806
Commit
b528d806
authored
4 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Plain Diff
Merge branch '352-provide-request-in-dashboardwidget-get_context' into 'master'
Resolve "Provide request in DashboardWidget.get_context" Closes
#352
See merge request
!452
parents
7a12491d
5fdf2b5a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!452
Resolve "Provide request in DashboardWidget.get_context"
Pipeline
#5790
passed
4 years ago
Stage: test
Stage: build
Changes
2
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/core/models.py
+3
-3
3 additions, 3 deletions
aleksis/core/models.py
aleksis/core/templatetags/dashboard.py
+4
-3
4 additions, 3 deletions
aleksis/core/templatetags/dashboard.py
with
7 additions
and
6 deletions
aleksis/core/models.py
+
3
−
3
View file @
b528d806
...
...
@@ -672,10 +672,10 @@ class DashboardWidget(PolymorphicModel, PureDjangoModel):
from aleksis.core.models import DashboardWidget
class MyWidget(D
h
asboardW
I
dget):
class MyWidget(Das
h
boardW
i
dget):
template =
"
myapp/widget.html
"
def get_context(self):
def get_context(self
, request
):
context = {
"
some_content
"
:
"
foo
"
}
return context
...
...
@@ -728,7 +728,7 @@ class DashboardWidget(PolymorphicModel, PureDjangoModel):
default
=
4
,
)
def
get_context
(
self
):
def
get_context
(
self
,
request
):
"""
Get the context dictionary to pass to the widget template.
"""
raise
NotImplementedError
(
"
A widget subclass needs to implement the get_context method.
"
)
...
...
This diff is collapsed.
Click to expand it.
aleksis/core/templatetags/dashboard.py
+
4
−
3
View file @
b528d806
...
...
@@ -3,10 +3,11 @@ from django.template import Library, loader
register
=
Library
()
@register.simple_tag
def
include_widget
(
widget
)
->
dict
:
@register.simple_tag
(
takes_context
=
True
)
def
include_widget
(
context
,
widget
)
->
dict
:
"""
Render a template with context from a defined widget.
"""
template
=
loader
.
get_template
(
widget
.
get_template
())
context
=
widget
.
get_context
()
request
=
context
[
"
request
"
]
context
=
widget
.
get_context
(
request
)
return
template
.
render
(
context
)
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