Skip to content
Snippets Groups Projects
Commit 326d836d authored by Samuel GAIST's avatar Samuel GAIST Committed by Flavio TARSETTI
Browse files

[backend][templatetags] Pre-commit cleanup

parent 2230c92d
No related branches found
No related tags found
2 merge requests!347Cleanup backend,!342Django 3 migration
...@@ -27,17 +27,15 @@ ...@@ -27,17 +27,15 @@
from django import template from django import template
from django.contrib.auth.models import User
from ..models import JobSplit from ..models import JobSplit
register = template.Library() 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): 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. This panel primarily exists for user's environment list page.
...@@ -47,18 +45,14 @@ def environment_table(context, objects, id): ...@@ -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 id: The HTML id to set on the generated table. This is handy for the
filter functionality normally available on list pages. filter functionality normally available on list pages.
''' """
return dict( return dict(request=context["request"], objects=objects, panel_id=id,)
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): 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 This panel primarily exists for showing action buttons for a given
environment taking into consideration it is being displayed for a given user. environment taking into consideration it is being displayed for a given user.
...@@ -71,23 +65,21 @@ def environment_actions(context, object, display_count): ...@@ -71,23 +65,21 @@ def environment_actions(context, object, display_count):
display the number of queues associated to this environment as a display the number of queues associated to this environment as a
button (useful for the list view) button (useful for the list view)
''' """
return dict( return dict(request=context["request"], object=object, display_count=display_count,)
request=context['request'],
object=object,
display_count=display_count,
)
@register.simple_tag(takes_context=True) @register.simple_tag(takes_context=True)
def visible_queues(context, object): def visible_queues(context, object):
'''Calculates the visible queues for an environment and requestor''' """Calculates the visible queues for an environment and requestor"""
return object.queues_for(context['request'].user) return object.queues_for(context["request"].user)
@register.filter @register.filter
def count_job_splits(xp, status=None): def count_job_splits(xp, status=None):
"""Returns job splits for an experiment in a certain state""" """Returns job splits for an experiment in a certain state"""
if status == 'A': if status == "A":
return xp.job_splits(status=JobSplit.QUEUED).filter(worker__isnull=False).count() return (
xp.job_splits(status=JobSplit.QUEUED).filter(worker__isnull=False).count()
)
return xp.job_splits(status=status).count() return xp.job_splits(status=status).count()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment