Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AKPlanning
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Felix Blanke
AKPlanning
Commits
a2853bb1
Commit
a2853bb1
authored
1 year ago
by
Benjamin Hättasch
Browse files
Options
Downloads
Patches
Plain Diff
Improve documentation and resolve quality issues for AKDashboard
parent
27d1b665
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
AKDashboard/admin.py
+3
-0
3 additions, 0 deletions
AKDashboard/admin.py
AKDashboard/apps.py
+3
-0
3 additions, 0 deletions
AKDashboard/apps.py
AKDashboard/models.py
+11
-0
11 additions, 0 deletions
AKDashboard/models.py
AKDashboard/views.py
+35
-15
35 additions, 15 deletions
AKDashboard/views.py
with
52 additions
and
15 deletions
AKDashboard/admin.py
+
3
−
0
View file @
a2853bb1
...
...
@@ -4,6 +4,9 @@ from AKDashboard.models import DashboardButton
@admin.register
(
DashboardButton
)
class
DashboardButtonAdmin
(
admin
.
ModelAdmin
):
"""
Admin interface for dashboard buttons
"""
list_display
=
[
'
text
'
,
'
url
'
,
'
event
'
]
list_filter
=
[
'
event
'
]
search_fields
=
[
'
text
'
,
'
url
'
]
...
...
This diff is collapsed.
Click to expand it.
AKDashboard/apps.py
+
3
−
0
View file @
a2853bb1
...
...
@@ -2,4 +2,7 @@ from django.apps import AppConfig
class
AkdashboardConfig
(
AppConfig
):
"""
App configuration for dashboard (default)
"""
name
=
'
AKDashboard
'
This diff is collapsed.
Click to expand it.
AKDashboard/models.py
+
11
−
0
View file @
a2853bb1
...
...
@@ -6,6 +6,17 @@ from AKModel.models import Event
class
DashboardButton
(
models
.
Model
):
"""
Model for a single dashboard button
Allows to specify
* a text (currently without possibility to translate),
* a color (based on predefined design colors)
* a url the button should point to (internal or external)
* an icon (from the collection of fontawesome)
Each button is associated with a single event and will be deleted when the event is deleted.
"""
class
Meta
:
verbose_name
=
_
(
"
Dashboard Button
"
)
verbose_name_plural
=
_
(
"
Dashboard Buttons
"
)
...
...
This diff is collapsed.
Click to expand it.
AKDashboard/views.py
+
35
−
15
View file @
a2853bb1
from
django.apps
import
apps
from
django.urls
import
reverse_lazy
from
django.utils.decorators
import
method_decorator
from
django.views.decorators.csrf
import
ensure_csrf_cookie
from
django.views.generic
import
TemplateView
,
DetailView
...
...
@@ -10,6 +9,11 @@ from AKPlanning import settings
class
DashboardView
(
TemplateView
):
"""
Index view of dashboard and therefore the main entry point for AKPlanning
Displays information and buttons for all public events
"""
template_name
=
'
AKDashboard/dashboard.html
'
@method_decorator
(
ensure_csrf_cookie
)
...
...
@@ -23,6 +27,14 @@ class DashboardView(TemplateView):
class
DashboardEventView
(
DetailView
):
"""
Dashboard view for a single event
In addition to the basic information and the buttons,
an overview over recent events (new and changed AKs, moved AKSlots) for the given event is shown.
The event dashboard also exists for non-public events (one only needs to know the URL/slug of the event).
"""
template_name
=
'
AKDashboard/dashboard_event.html
'
context_object_name
=
'
event
'
model
=
Event
...
...
@@ -32,11 +44,16 @@ class DashboardEventView(DetailView):
# Show feed of recent changes (if activated)
if
settings
.
DASHBOARD_SHOW_RECENT
:
# Create a list of chronically sorted events (both AK and plan changes):
recent_changes
=
[]
# Newest AKs
# Newest AKs
(if AKSubmission is used)
if
apps
.
is_installed
(
"
AKSubmission
"
):
submission_changes
=
AK
.
history
.
filter
(
event
=
context
[
'
event
'
])[:
int
(
settings
.
DASHBOARD_RECENT_MAX
)]
# Get the latest x changes (if there are that many),
# where x corresponds to the entry threshold configured in the settings
# (such that the list will be completely filled even if there are no (newer) plan changes)
submission_changes
=
AK
.
history
.
filter
(
event
=
context
[
'
event
'
])[:
int
(
settings
.
DASHBOARD_RECENT_MAX
)]
# pylint: disable=no-member, line-too-long
# Create textual representation including icons
for
s
in
submission_changes
:
if
s
.
history_type
==
'
+
'
:
text
=
_
(
'
New AK: %(ak)s.
'
)
%
{
'
ak
'
:
s
.
name
}
...
...
@@ -48,18 +65,21 @@ class DashboardEventView(DetailView):
text
=
_
(
'
AK
"
%(ak)s
"
deleted.
'
)
%
{
'
ak
'
:
s
.
name
}
icon
=
(
'
times
'
,
'
fas
'
)
recent_changes
.
append
({
'
icon
'
:
icon
,
'
text
'
:
text
,
'
link
'
:
s
.
instance
.
detail_url
,
'
timestamp
'
:
s
.
history_date
})
# Changes in plan
if
apps
.
is_installed
(
"
AKPlan
"
):
if
not
context
[
'
event
'
].
plan_hidden
:
last_changed_slots
=
AKSlot
.
objects
.
select_related
(
'
ak
'
).
filter
(
event
=
context
[
'
event
'
],
start__isnull
=
False
).
order_by
(
'
-updated
'
)[
:
int
(
settings
.
DASHBOARD_RECENT_MAX
)]
for
changed_slot
in
last_changed_slots
:
recent_changes
.
append
({
'
icon
'
:
(
'
clock
'
,
'
far
'
),
'
text
'
:
_
(
'
AK
"
%(ak)s
"
(re-)scheduled.
'
)
%
{
'
ak
'
:
changed_slot
.
ak
.
name
},
'
link
'
:
changed_slot
.
ak
.
detail_url
,
'
timestamp
'
:
changed_slot
.
updated
})
# Store representation in change list (still unsorted)
recent_changes
.
append
(
{
'
icon
'
:
icon
,
'
text
'
:
text
,
'
link
'
:
s
.
instance
.
detail_url
,
'
timestamp
'
:
s
.
history_date
}
)
# Changes in plan (if AKPlan is used and plan is publicly visible)
if
apps
.
is_installed
(
"
AKPlan
"
)
and
not
context
[
'
event
'
].
plan_hidden
:
# Get the latest plan changes (again using a threshold, see above)
last_changed_slots
=
AKSlot
.
objects
.
select_related
(
'
ak
'
).
filter
(
event
=
context
[
'
event
'
],
start__isnull
=
False
).
order_by
(
'
-updated
'
)[:
int
(
settings
.
DASHBOARD_RECENT_MAX
)]
#pylint: disable=line-too-long
for
changed_slot
in
last_changed_slots
:
# Create textual representation including icons and links and store in list (still unsorted)
recent_changes
.
append
({
'
icon
'
:
(
'
clock
'
,
'
far
'
),
'
text
'
:
_
(
'
AK
"
%(ak)s
"
(re-)scheduled.
'
)
%
{
'
ak
'
:
changed_slot
.
ak
.
name
},
'
link
'
:
changed_slot
.
ak
.
detail_url
,
'
timestamp
'
:
changed_slot
.
updated
})
# Sort by change date...
recent_changes
.
sort
(
key
=
lambda
x
:
x
[
'
timestamp
'
],
reverse
=
True
)
...
...
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