Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Right panel title #79

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions omero_mapr/templates/mapr/includes/right_panel_title.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

{% if title %}
<h1>{{ title }}</h1>
{% endif %}
8 changes: 8 additions & 0 deletions omero_mapr/templates/webclient/annotations/includes/name.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

{% extends "webclient/annotations/includes/name.html" %}

{% load mapr_tags %}

{% block right_panel_title %}
{% publication_title_from_kvp %}
{% endblock %}
30 changes: 30 additions & 0 deletions omero_mapr/templatetags/mapr_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,33 @@
@register.simple_tag
def mapr_menu_config():
return mark_safe(json.dumps(mapr_settings.CONFIG))


@register.inclusion_tag("mapr/includes/right_panel_title.html",
takes_context=True)
def publication_title_from_kvp(context):
"""
We try to load Key-Value pairs on an object in the 'manager' and show the
'Publication Title' value
"""

manager = context.get("manager", None)
if not hasattr(manager, "_get_object"):
return {}

obj = context["manager"]._get_object()
# We only try to show Publication Title for Projects/Screens
if obj is None or obj.OMERO_CLASS not in ("Project", "Screen"):
return {}

title = ""
for ann in obj.listAnnotations():
if "MapAnnotationI" in str(ann.OMERO_TYPE):
for kvp in ann.getValue():
if kvp[0] == "Publication Title":
title = kvp[1]
break

return {
"title": title
}