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
05377dc3
Verified
Commit
05377dc3
authored
5 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Add template tag for better widget inclusion
parent
75a060c3
Branches
616-docs-document-dashboard-and-dashboard-widgets
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!142
Implement core functionality for dashboard widgets
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
aleksis/core/models.py
+3
-0
3 additions, 0 deletions
aleksis/core/models.py
aleksis/core/templates/core/index.html
+2
-4
2 additions, 4 deletions
aleksis/core/templates/core/index.html
aleksis/core/templatetags/dashboard.py
+13
-0
13 additions, 0 deletions
aleksis/core/templatetags/dashboard.py
with
18 additions
and
4 deletions
aleksis/core/models.py
+
3
−
0
View file @
05377dc3
...
...
@@ -262,6 +262,9 @@ class DashboardWidget(PolymorphicModel):
def
get_context
(
self
):
raise
NotImplementedError
(
"
A widget subclass needs to implement the get_context method.
"
)
def
get_template
(
self
):
return
self
.
template
def
__str__
(
self
):
return
self
.
title
...
...
This diff is collapsed.
Click to expand it.
aleksis/core/templates/core/index.html
+
2
−
4
View file @
05377dc3
{% extends 'core/base.html' %}
{% load i18n static %}
{% load i18n static
dashboard
%}
{% block browser_title %}{% blocktrans %}Home{% endblocktrans %}{% endblock %}
...
...
@@ -27,9 +27,7 @@
<div
class=
"row"
id=
"live_load"
>
{% for widget in widgets %}
<div
class=
"col s12 m12 l6 xl4"
>
{% with widget as d_widget %}
{% include widget.template %}
{% endwith %}
{% include_widget widget %}
</div>
{% endfor %}
</div>
...
...
This diff is collapsed.
Click to expand it.
aleksis/core/templatetags/dashboard.py
0 → 100644
+
13
−
0
View file @
05377dc3
from
django.template
import
Library
,
loader
register
=
Library
()
@register.simple_tag
def
include_widget
(
widget
)
->
dict
:
"""
Render a template with context from a defined widget
"""
template
=
loader
.
get_template
(
widget
.
get_template
())
context
=
widget
.
get_context
()
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