Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.web
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
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
beat
beat.web
Commits
326d836d
Commit
326d836d
authored
4 years ago
by
Samuel GAIST
Committed by
Flavio TARSETTI
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[backend][templatetags] Pre-commit cleanup
parent
2230c92d
No related branches found
No related tags found
2 merge requests
!347
Cleanup backend
,
!342
Django 3 migration
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beat/web/backend/templatetags/backend_tags.py
+14
-22
14 additions, 22 deletions
beat/web/backend/templatetags/backend_tags.py
with
14 additions
and
22 deletions
beat/web/backend/templatetags/backend_tags.py
+
14
−
22
View file @
326d836d
...
...
@@ -27,17 +27,15 @@
from
django
import
template
from
django.contrib.auth.models
import
User
from
..models
import
JobSplit
register
=
template
.
Library
()
@register.inclusion_tag
(
'
backend/panels/environment_table.html
'
,
takes_context
=
True
)
@register.inclusion_tag
(
"
backend/panels/environment_table.html
"
,
takes_context
=
True
)
def
environment_table
(
context
,
objects
,
id
):
'''
Composes a environment list table
"""
Composes a environment list table
This panel primarily exists for user
'
s environment list page.
...
...
@@ -47,18 +45,14 @@ def environment_table(context, objects, id):
id: The HTML id to set on the generated table. This is handy for the
filter functionality normally available on list pages.
'''
"""
return
dict
(
request
=
context
[
'
request
'
],
objects
=
objects
,
panel_id
=
id
,
)
return
dict
(
request
=
context
[
"
request
"
],
objects
=
objects
,
panel_id
=
id
,)
@register.inclusion_tag
(
'
backend/panels/environment_actions.html
'
,
takes_context
=
True
)
@register.inclusion_tag
(
"
backend/panels/environment_actions.html
"
,
takes_context
=
True
)
def
environment_actions
(
context
,
object
,
display_count
):
'''
Composes the action buttons for a particular environment
"""
Composes the action buttons for a particular environment
This panel primarily exists for showing action buttons for a given
environment taking into consideration it is being displayed for a given user.
...
...
@@ -71,23 +65,21 @@ def environment_actions(context, object, display_count):
display the number of queues associated to this environment as a
button (useful for the list view)
'''
return
dict
(
request
=
context
[
'
request
'
],
object
=
object
,
display_count
=
display_count
,
)
"""
return
dict
(
request
=
context
[
"
request
"
],
object
=
object
,
display_count
=
display_count
,)
@register.simple_tag
(
takes_context
=
True
)
def
visible_queues
(
context
,
object
):
'''
Calculates the visible queues for an environment and requestor
'''
return
object
.
queues_for
(
context
[
'
request
'
].
user
)
"""
Calculates the visible queues for an environment and requestor
"""
return
object
.
queues_for
(
context
[
"
request
"
].
user
)
@register.filter
def
count_job_splits
(
xp
,
status
=
None
):
"""
Returns job splits for an experiment in a certain state
"""
if
status
==
'
A
'
:
return
xp
.
job_splits
(
status
=
JobSplit
.
QUEUED
).
filter
(
worker__isnull
=
False
).
count
()
if
status
==
"
A
"
:
return
(
xp
.
job_splits
(
status
=
JobSplit
.
QUEUED
).
filter
(
worker__isnull
=
False
).
count
()
)
return
xp
.
job_splits
(
status
=
status
).
count
()
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