From 326d836daa8f2f61229909932781d3d73f64041c Mon Sep 17 00:00:00 2001 From: Samuel Gaist <samuel.gaist@idiap.ch> Date: Wed, 9 Sep 2020 13:42:25 +0200 Subject: [PATCH] [backend][templatetags] Pre-commit cleanup --- beat/web/backend/templatetags/backend_tags.py | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/beat/web/backend/templatetags/backend_tags.py b/beat/web/backend/templatetags/backend_tags.py index 0e31aa0fe..f180a1fb6 100755 --- a/beat/web/backend/templatetags/backend_tags.py +++ b/beat/web/backend/templatetags/backend_tags.py @@ -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() -- GitLab