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

[reports][templatetags] Pre-commit cleanup

parent d66b29de
......@@ -26,22 +26,19 @@
###############################################################################
from django import template
from django.conf import settings
from ..models import Report
from django.db.models.functions import Coalesce
register = template.Library()
#--------------------------------------------------
# --------------------------------------------------
@register.inclusion_tag('reports/panels/table.html', takes_context=True)
@register.inclusion_tag("reports/panels/table.html", takes_context=True)
def report_table(context, objects, owner, id):
'''Composes a report list table
"""Composes a report list table
This panel primarily exists for user's report list page.
......@@ -53,35 +50,32 @@ def report_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.
'''
objects = objects.annotate(updated=Coalesce('publication_date', 'creation_date',)).order_by('-updated')
"""
objects = objects.annotate(
updated=Coalesce("publication_date", "creation_date",)
).order_by("-updated")
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('reports/panels/breadcrumb.html', takes_context=True)
@register.inclusion_tag("reports/panels/breadcrumb.html", takes_context=True)
def report_breadcrumb(context, obj):
return {
'request': context['request'],
'owner': context['owner'],
'object': obj,
"request": context["request"],
"owner": context["owner"],
"object": obj,
}
#--------------------------------------------------
# --------------------------------------------------
@register.inclusion_tag('reports/panels/actions.html', takes_context=True)
@register.inclusion_tag("reports/panels/actions.html", takes_context=True)
def report_actions(context, object, display_count):
'''Composes the action buttons for a particular report
"""Composes the action buttons for a particular report
This panel primarily exists for showing action buttons for a given
report taking into consideration it is being displayed for a given user.
......@@ -93,20 +87,16 @@ def report_actions(context, object, display_count):
display_count (bool): If the set of buttons should include one with the
number of experiments using this report.
'''
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('reports/panels/viewer.html', takes_context=True)
@register.inclusion_tag("reports/panels/viewer.html", takes_context=True)
def report_viewer(context, object, owner, report_number):
'''Composes the search results for visualization
"""Composes the search results for visualization
Parameters:
......@@ -120,71 +110,68 @@ def report_viewer(context, object, owner, report_number):
and documentation, focusing on the results. Non-owner visualizations
collapse only the filter panel.
'''
"""
return dict(
request=context['request'],
request=context["request"],
object=object,
owner=owner,
exps=object.experiments.all(),
report_number=report_number,
URL_PREFIX=context['URL_PREFIX'],
URL_PREFIX=context["URL_PREFIX"],
)
#--------------------------------------------------
# --------------------------------------------------
@register.simple_tag(takes_context=True)
def visible_experiments(context, object):
'''Calculates the visible experiments for a given report and requestor'''
"""Calculates the visible experiments for a given report and requestor"""
return object.experiments.for_user(context['request'].user, True)
return object.experiments.for_user(context["request"].user, True)
#--------------------------------------------------
# --------------------------------------------------
def report_unlocking(id):
return { 'dialog_id': id,
'URL_PREFIX': settings.URL_PREFIX
}
return {"dialog_id": id, "URL_PREFIX": settings.URL_PREFIX}
register.inclusion_tag('reports/dialogs/unlocking.html')(report_unlocking)
register.inclusion_tag("reports/dialogs/unlocking.html")(report_unlocking)
#--------------------------------------------------
# --------------------------------------------------
def report_add_experiments(id):
return { 'dialog_id': id,
'URL_PREFIX': settings.URL_PREFIX
}
return {"dialog_id": id, "URL_PREFIX": settings.URL_PREFIX}
register.inclusion_tag('reports/dialogs/report_add_experiments.html')(report_add_experiments)
register.inclusion_tag("reports/dialogs/report_add_experiments.html")(
report_add_experiments
)
#--------------------------------------------------
# --------------------------------------------------
def report_creation(id):
return { 'dialog_id': id,
'URL_PREFIX': settings.URL_PREFIX
}
return {"dialog_id": id, "URL_PREFIX": settings.URL_PREFIX}
register.inclusion_tag('reports/dialogs/new_report_dialog.html')(report_creation)
register.inclusion_tag("reports/dialogs/new_report_dialog.html")(report_creation)
#--------------------------------------------------
# --------------------------------------------------
def report_deletion(id):
return { 'dialog_id': id,
'URL_PREFIX': settings.URL_PREFIX,
'contribution_label': 'report',
}
return {
"dialog_id": id,
"URL_PREFIX": settings.URL_PREFIX,
"contribution_label": "report",
}
register.inclusion_tag('ui/contribution_deletion.html')(report_deletion)
register.inclusion_tag("ui/contribution_deletion.html")(report_deletion)
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