Commit d22f4296 authored by Samuel GAIST's avatar Samuel GAIST Committed by Flavio TARSETTI
Browse files

[toolchains][templatetags] Pre-commit cleanup

parent b13f1604
......@@ -36,9 +36,9 @@ from ..models import Toolchain
register = template.Library()
@register.inclusion_tag('toolchains/panels/table.html', takes_context=True)
@register.inclusion_tag("toolchains/panels/table.html", takes_context=True)
def toolchain_table(context, objects, owner, id):
'''Composes a toolchain list table
"""Composes a toolchain list table
This panel primarily exists for user's toolchain list page.
......@@ -50,19 +50,14 @@ def toolchain_table(context, objects, owner, 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,
owner=owner,
panel_id=id,
)
return dict(request=context["request"], objects=objects, owner=owner, panel_id=id,)
@register.inclusion_tag('toolchains/panels/actions.html', takes_context=True)
@register.inclusion_tag("toolchains/panels/actions.html", takes_context=True)
def toolchain_actions(context, object, display_count):
'''Composes the action buttons for a particular toolchain
"""Composes the action buttons for a particular toolchain
This panel primarily exists for showing action buttons for a given
toolchain taking into consideration it is being displayed for a given user.
......@@ -74,36 +69,32 @@ def toolchain_actions(context, object, display_count):
display_count (bool): If the set of buttons should include one with the
number of experiments using this toolchain.
'''
return dict(
request=context['request'],
object=object,
display_count=display_count,
)
"""
return dict(request=context["request"], object=object, display_count=display_count,)
@register.inclusion_tag('toolchains/panels/sharing.html', takes_context=True)
@register.inclusion_tag("toolchains/panels/sharing.html", takes_context=True)
def toolchain_sharing(context, obj):
'''Composes the current sharing properties and a form to change them
"""Composes the current sharing properties and a form to change them
Parameters:
obj (Toolchain): The toolchain object concerned for which the
sharing panel will be drawn
'''
"""
return {
'request': context['request'],
'object': obj,
'owner': context['request'].user == obj.author,
'users': context['users'],
'teams': context['teams'],
"request": context["request"],
"object": obj,
"owner": context["request"].user == obj.author,
"users": context["users"],
"teams": context["teams"],
}
@register.inclusion_tag('toolchains/panels/viewer.html', takes_context=True)
@register.inclusion_tag("toolchains/panels/viewer.html", takes_context=True)
def toolchain_viewer(context, obj, xp, id):
'''Composes a canvas with the toolchain (no further JS setup is
"""Composes a canvas with the toolchain (no further JS setup is
required)
Parameters:
......@@ -114,49 +105,50 @@ def toolchain_viewer(context, obj, xp, id):
components. If not given, just draw the toolchain.
id (str): The id of the canvas element that will be created
'''
"""
return {
'request': context['request'],
'object': obj,
'xp': xp,
'panel_id': id,
'URL_PREFIX': settings.URL_PREFIX,
"request": context["request"],
"object": obj,
"xp": xp,
"panel_id": id,
"URL_PREFIX": settings.URL_PREFIX,
}
@register.simple_tag(takes_context=True)
def random_toolchain(context):
'''Returns a random toolchain that is visible to the current user'''
candidates = Toolchain.objects.for_user(context['request'].user, True)
return candidates[random.randint(0, candidates.count()-1)]
"""Returns a random toolchain that is visible to the current user"""
candidates = Toolchain.objects.for_user(context["request"].user, True)
return candidates[random.randint(0, candidates.count() - 1)] # nosec: B311
@register.simple_tag(takes_context=True)
def visible_toolchains(context):
'''Calculates the visible toolchains for a given user'''
"""Calculates the visible toolchains for a given user"""
return Toolchain.objects.for_user(context['request'].user, True)
return Toolchain.objects.for_user(context["request"].user, True)
@register.simple_tag(takes_context=True)
def visible_experiments(context, object):
'''Calculates the visible experiments for a given toolchain and requestor'''
"""Calculates the visible experiments for a given toolchain and requestor"""
return object.experiments.for_user(context['request'].user, True)
return object.experiments.for_user(context["request"].user, True)
#----------------------------------------------------------------
# ----------------------------------------------------------------
@register.inclusion_tag('toolchains/panels/editor.html')
@register.inclusion_tag("toolchains/panels/editor.html")
def toolchain_editor(id):
return { 'editor_id': id,
}
return {
"editor_id": id,
}
@register.inclusion_tag('toolchains/dialogs/import_settings.html')
@register.inclusion_tag("toolchains/dialogs/import_settings.html")
def toolchain_import_settings(id):
return { 'dialog_id': id,
}
return {
"dialog_id": id,
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment