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

[plotters][templatetags] Pre-commit cleanup

Removed unused plotterparameter_sampleplot_display
which code has several issues.
parent 42a1e5bf
......@@ -37,9 +37,9 @@ from ..models import Plotter
register = template.Library()
@register.inclusion_tag('plotters/panels/table.html', takes_context=True)
@register.inclusion_tag("plotters/panels/table.html", takes_context=True)
def plotter_table(context, objects, owner, id):
'''Composes a plotter list table
"""Composes a plotter list table
This panel primarily exists for user's plotter list page.
......@@ -51,18 +51,14 @@ def plotter_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('plotterparameters/panels/table.html', takes_context=True)
@register.inclusion_tag("plotterparameters/panels/table.html", takes_context=True)
def plotterparameter_table(context, objects, owner, id):
'''Composes a plotterparameter list table
"""Composes a plotterparameter list table
This panel primarily exists for user's plotterparameter list page.
......@@ -74,19 +70,14 @@ def plotterparameter_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('plotterparameters/panels/sample_plot.html', takes_context=True)
@register.inclusion_tag("plotterparameters/panels/sample_plot.html", takes_context=True)
def plotterparameter_sampleplot(context, plotterparameter):
'''Composes a plotterparameter list table
"""Composes a plotterparameter list table
This panel primarily exists for user's plotterparameter list page.
......@@ -98,48 +89,26 @@ def plotterparameter_sampleplot(context, plotterparameter):
id: The HTML id to set on the generated table. This is handy for the
filter functionality normally available on list pages.
'''
"""
plotter = plotterparameter.plotter
plotter_sample_data = plotterparameter.plotter.sample_data
return dict(
request=context['request'],
request=context["request"],
plotterparameter=plotterparameter,
plotter=plotter,
plotter_sample_data=plotter_sample_data.replace("\n",""),
plotter_sample_data=plotter_sample_data.replace("\n", ""),
panel_id=id,
URL_PREFIX=context['URL_PREFIX'],
URL_PREFIX=context["URL_PREFIX"],
)
@register.inclusion_tag('plotterparameters/panels/sample_plot.html', takes_context=True)
def plotterparameter_sampleplot_display(context, plotter):
'''Composes a plotterparameter list table
This panel primarily exists for user's plotterparameter list page.
Parameters:
objects (iterable): An iterable containing plotterparameter objects
owner (bool): A flag indicating if the list is being created for the
owner of his personal list page on the user-microsite or not.
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'],
plotterparameter=plotterparameter,
plotter=plotter,
plotter_sample_data=plotter_sample_data.replace("\n",""),
panel_id=id,
URL_PREFIX=context['URL_PREFIX'],
)
@register.inclusion_tag('plotterparameters/panels/viewer_editor_fork.html', takes_context=True)
@register.inclusion_tag(
"plotterparameters/panels/viewer_editor_fork.html", takes_context=True
)
def plotterparameter_viewer_editor_fork(context, plotterparameter):
'''Composes a plotterparameter viewer and editor
"""Composes a plotterparameter viewer and editor
This panel primarily exists for user's plotterparameter list page.
......@@ -151,27 +120,28 @@ def plotterparameter_viewer_editor_fork(context, plotterparameter):
id: The HTML id to set on the generated table. This is handy for the
filter functionality normally available on list pages.
'''
"""
plotter = plotterparameter.plotter
plotter_sample_data = plotterparameter.plotter.sample_data
plotterparameter = plotterparameter
parameters = context['parameters']
parameters = context["parameters"]
return dict(
request=context['request'],
request=context["request"],
parameters=parameters,
plotterparameter=plotterparameter,
plotter=plotter,
plotter_sample_data=plotter_sample_data,
panel_id=id,
URL_PREFIX=context['URL_PREFIX'],
URL_PREFIX=context["URL_PREFIX"],
)
@register.inclusion_tag('plotterparameters/panels/viewer_editor_new_version.html', takes_context=True)
@register.inclusion_tag(
"plotterparameters/panels/viewer_editor_new_version.html", takes_context=True
)
def plotterparameter_viewer_editor_new_version(context, plotterparameter):
'''Composes a plotterparameter viewer and editor
"""Composes a plotterparameter viewer and editor
This panel primarily exists for user's plotterparameter list page.
......@@ -183,26 +153,28 @@ def plotterparameter_viewer_editor_new_version(context, plotterparameter):
id: The HTML id to set on the generated table. This is handy for the
filter functionality normally available on list pages.
'''
"""
plotter = plotterparameter.plotter
plotter_sample_data = plotterparameter.plotter.sample_data
plotterparameter = plotterparameter
parameters = context['parameters']
parameters = context["parameters"]
return dict(
request=context['request'],
request=context["request"],
parameters=parameters,
plotterparameter=plotterparameter,
plotter=plotter,
plotter_sample_data=plotter_sample_data,
panel_id=id,
URL_PREFIX=context['URL_PREFIX'],
URL_PREFIX=context["URL_PREFIX"],
)
@register.inclusion_tag('plotterparameters/panels/viewer_editor.html', takes_context=True)
@register.inclusion_tag(
"plotterparameters/panels/viewer_editor.html", takes_context=True
)
def plotterparameter_viewer_editor(context, plotterparameter):
'''Composes a plotterparameter viewer and editor
"""Composes a plotterparameter viewer and editor
This panel primarily exists for user's plotterparameter list page.
......@@ -214,7 +186,7 @@ def plotterparameter_viewer_editor(context, plotterparameter):
id: The HTML id to set on the generated table. This is handy for the
filter functionality normally available on list pages.
'''
"""
if plotterparameter == "CREATION_MODE":
plotter = plotterparameter
......@@ -222,12 +194,12 @@ def plotterparameter_viewer_editor(context, plotterparameter):
plotter_sample_data = None
return dict(
request=context['request'],
request=context["request"],
plotterparameter=plotterparameter,
plotter=plotter,
plotter_sample_data=plotter_sample_data,
panel_id=id,
URL_PREFIX=context['URL_PREFIX'],
URL_PREFIX=context["URL_PREFIX"],
)
else:
......@@ -237,18 +209,20 @@ def plotterparameter_viewer_editor(context, plotterparameter):
plotter_sample_data = plotterparameter.plotter.sample_data
return dict(
request=context['request'],
request=context["request"],
plotterparameter=plotterparameter,
plotter=plotter,
plotter_sample_data=plotter_sample_data,
panel_id=id,
URL_PREFIX=context['URL_PREFIX'],
URL_PREFIX=context["URL_PREFIX"],
)
@register.inclusion_tag('plotterparameters/panels/viewer_editor_tuner.html', takes_context=True)
@register.inclusion_tag(
"plotterparameters/panels/viewer_editor_tuner.html", takes_context=True
)
def plotterparameter_viewer_editor_tuner(context, plotterparameter):
'''Composes a plotterparameter viewer and editor
"""Composes a plotterparameter viewer and editor
This panel primarily exists for user's plotterparameter list page.
......@@ -260,7 +234,7 @@ def plotterparameter_viewer_editor_tuner(context, plotterparameter):
id: The HTML id to set on the generated table. This is handy for the
filter functionality normally available on list pages.
'''
"""
plotter = plotterparameter.plotter
plotter_sample_data = None
......@@ -268,18 +242,18 @@ def plotterparameter_viewer_editor_tuner(context, plotterparameter):
plotter_sample_data = plotterparameter.plotter.sample_data
return dict(
request=context['request'],
request=context["request"],
plotterparameter=plotterparameter,
plotter=plotter,
plotter_sample_data=plotter_sample_data,
panel_id=id,
URL_PREFIX=context['URL_PREFIX'],
URL_PREFIX=context["URL_PREFIX"],
)
@register.inclusion_tag('plotters/panels/actions.html', takes_context=True)
@register.inclusion_tag("plotters/panels/actions.html", takes_context=True)
def plotter_actions(context, object, display_count):
'''Composes the action buttons for a particular plotter
"""Composes the action buttons for a particular plotter
This panel primarily exists for showing action buttons for a given
plotter taking into consideration it is being displayed for a given user.
......@@ -291,17 +265,13 @@ def plotter_actions(context, object, display_count):
display_count (bool): If the set of buttons should include one with the
number of experiments using this plotter.
'''
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('plotterparameters/panels/actions.html', takes_context=True)
@register.inclusion_tag("plotterparameters/panels/actions.html", takes_context=True)
def plotterparameter_actions(context, object, display_count):
'''Composes the action buttons for a particular plotter
"""Composes the action buttons for a particular plotter
This panel primarily exists for showing action buttons for a given
plotter taking into consideration it is being displayed for a given user.
......@@ -313,55 +283,51 @@ def plotterparameter_actions(context, object, display_count):
display_count (bool): If the set of buttons should include one with the
number of experiments using this plotter.
'''
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('plotterparameters/panels/sharing.html', takes_context=True)
@register.inclusion_tag("plotterparameters/panels/sharing.html", takes_context=True)
def plotterparameter_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 (plotter): The plotter 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('plotters/panels/sharing.html', takes_context=True)
@register.inclusion_tag("plotters/panels/sharing.html", takes_context=True)
def plotter_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 (plotter): The plotter 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('plotters/panels/viewer.html', takes_context=True)
@register.inclusion_tag("plotters/panels/viewer.html", takes_context=True)
def plotter_viewer(context, obj, xp, id):
'''Composes a canvas with the plotter (no further JS setup is
"""Composes a canvas with the plotter (no further JS setup is
required)
Parameters:
......@@ -372,97 +338,100 @@ def plotter_viewer(context, obj, xp, id):
components. If not given, just draw the plotter.
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_plotter(context):
'''Returns a random plotter that is visible to the current user'''
candidates = Plotter.objects.for_user(context['request'].user, True)
return candidates[random.randint(0, candidates.count()-1)]
"""Returns a random plotter that is visible to the current user"""
candidates = Plotter.objects.for_user(context["request"].user, True)
return candidates[random.randint(0, candidates.count() - 1)] # nosec
@register.simple_tag(takes_context=True)
def visible_plotters(context):
'''Calculates the visible plotters for a given user'''
"""Calculates the visible plotters for a given user"""
return Plotter.objects.for_user(context['request'].user, True)
return Plotter.objects.for_user(context["request"].user, True)
@register.simple_tag(takes_context=True)
def visible_reports(context, object):
'''Calculates the visible experiments for a given plotter and requestor'''
"""Calculates the visible experiments for a given plotter and requestor"""
from ...reports.models import Report
if context['request'].user.is_anonymous:
if context["request"].user.is_anonymous:
return object.reports.filter(Q(status=Report.PUBLISHED))
else:
return object.reports.filter(Q(author=context['request'].user) |
Q(status=Report.PUBLISHED))
return object.reports.filter(
Q(author=context["request"].user) | Q(status=Report.PUBLISHED)
)
#----------------------------------------------------------------
# ----------------------------------------------------------------
@register.inclusion_tag('plotters/panels/editor.html', takes_context=True)
@register.inclusion_tag("plotters/panels/editor.html", takes_context=True)
def plotter_editor(context, obj):
request = context['request']
request = context["request"]
return {
'owner': request.user == obj.author,
'object': obj,
'open_source': obj.open_source(request.user),
"owner": request.user == obj.author,
"object": obj,
"open_source": obj.open_source(request.user),
}
@register.inclusion_tag('plotters/dialogs/import_settings.html')
@register.inclusion_tag("plotters/dialogs/import_settings.html")
def plotter_import_settings(id):
return { 'dialog_id': id,
}
return {
"dialog_id": id,
}
#--------------------------------------------------
# --------------------------------------------------
def plotterparameter_saved(id):
return { 'dialog_id': id,
'URL_PREFIX': settings.URL_PREFIX
}
return {"dialog_id": id, "URL_PREFIX": settings.URL_PREFIX}
register.inclusion_tag("plotterparameters/dialogs/plotterparameter_saved.html")(
plotterparameter_saved
)
register.inclusion_tag('plotterparameters/dialogs/plotterparameter_saved.html')(plotterparameter_saved)
# --------------------------------------------------
#--------------------------------------------------
def plotterparameter_created(id):
return { 'dialog_id': id,
'URL_PREFIX': settings.URL_PREFIX
}
return {"dialog_id": id, "URL_PREFIX": settings.URL_PREFIX}
register.inclusion_tag('plotterparameters/dialogs/plotterparameter_created.html')(plotterparameter_created)
register.inclusion_tag("plotterparameters/dialogs/plotterparameter_created.html")(
plotterparameter_created
)
#----------------------------------------------------------------
# ----------------------------------------------------------------
@register.inclusion_tag('plotterparameters/panels/merged_parameters.html', takes_context=True)
@register.inclusion_tag(
"plotterparameters/panels/merged_parameters.html", takes_context=True
)
def plotterparameter_merged_parameters(context, plotter, plotterparameter):
request = context['request']
request = context["request"]
return {
'owner': request.user == plotter.author,
'object': plotter,
'plotterparameter': plotterparameter,
'open_source': plotter.open_source(request.user),
"owner": request.user == plotter.author,
"object": plotter,
"plotterparameter": plotterparameter,
"open_source": plotter.open_source(request.user),
}
Markdown is supported
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