From b9ad52955e457b80636fac66e4360cf564a1d054 Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Thu, 17 Feb 2011 00:35:44 -0800 Subject: [PATCH] Add RDFa data to our library pages. While doing that I discovered that the library_index page was spitting up seriously bad HTML, with two DOCTYPE & html tags. It looks like it was a combination of my simplifications with the leftovers of brandon's "app" templates I ended up putting in two base.html templates. I stripped out the app templates and tried to simplify the template inheritance. As a side effect the library detail page, now has a header and is using a css based font. There was also a minor issue where I discovered the paginator was showing "X libraries libraries" because the views was adding "libraries" to the changelist result count. (And the change list also adds in the name). I needed to replace the default admin pagination template, as RDFa uses xhtml, and xhtml doesn't support the   entity. (The solution is to use a unicode character for nbsp -- such as   -- unicode for non-breaking space. --- htsworkflow/frontend/samples/models.py | 20 ++- htsworkflow/frontend/samples/views.py | 12 +- .../frontend/templates/admin/pagination.html | 13 ++ htsworkflow/frontend/templates/app_base.html | 35 ----- htsworkflow/frontend/templates/base.html | 19 ++- .../templates/flowcell_libraries_app.html | 34 ----- .../templates/inventory/inventory_app.html | 21 --- .../templates/registration/login.html | 5 +- .../templates/registration/profile.html | 2 +- .../frontend/templates/samples/lanes_for.html | 1 - .../templates/samples/library_detail.html | 120 ++++++++++++------ .../templates/samples/library_index.html | 19 ++- 12 files changed, 143 insertions(+), 158 deletions(-) create mode 100644 htsworkflow/frontend/templates/admin/pagination.html delete mode 100644 htsworkflow/frontend/templates/app_base.html delete mode 100644 htsworkflow/frontend/templates/flowcell_libraries_app.html delete mode 100644 htsworkflow/frontend/templates/inventory/inventory_app.html diff --git a/htsworkflow/frontend/samples/models.py b/htsworkflow/frontend/samples/models.py index 59b4c24..8314c71 100644 --- a/htsworkflow/frontend/samples/models.py +++ b/htsworkflow/frontend/samples/models.py @@ -1,3 +1,4 @@ +import logging import urlparse from django.db import models from django.contrib.auth.models import User, UserManager @@ -6,7 +7,9 @@ from django.db import connection from htsworkflow.frontend import settings from htsworkflow.frontend.reports.libinfopar import * + # Create your models here. +logger = logging.getLogger(__name__) class Antibody(models.Model): antigene = models.CharField(max_length=500, db_index=True) @@ -166,6 +169,8 @@ class Library(models.Model): ('2A', 'Ligation, PCR, gel, PCR'), ('Done', 'Completed'), ) + PROTOCOL_END_POINTS_DICT = dict(PROTOCOL_END_POINTS) + stopping_point = models.CharField(max_length=25, choices=PROTOCOL_END_POINTS, default='Done') amplified_from_sample = models.ForeignKey('self', blank=True, null=True, related_name='amplified_into_sample') @@ -189,9 +194,9 @@ class Library(models.Model): return u'#%s: %s' % (self.id, self.library_name) class Meta: - verbose_name_plural = "libraries" - #ordering = ["-creation_date"] - ordering = ["-id"] + verbose_name_plural = "libraries" + #ordering = ["-creation_date"] + ordering = ["-id"] def antibody_name(self): str =''+self.antibody.nickname+'' @@ -218,6 +223,15 @@ class Library(models.Model): else: return False + def stopping_point_name(self): + end_points = Library.PROTOCOL_END_POINTS_DICT + name = end_points.get(self.stopping_point, None) + if name is None: + name = "Lookup Error" + logger.error("protocol stopping point in database didn't match names in library model") + return name + + def libtags(self): affs = self.tags.all().order_by('tag_name') ar = [] diff --git a/htsworkflow/frontend/samples/views.py b/htsworkflow/frontend/samples/views.py index afccc02..a6286d7 100644 --- a/htsworkflow/frontend/samples/views.py +++ b/htsworkflow/frontend/samples/views.py @@ -84,7 +84,7 @@ def create_library_context(cl): summary['lanes_run'] = lanes_run summary['is_archived'] = lib.is_archived() records.append(summary) - cl.result_count = unicode(cl.paginator._count) + u" libraries" + cl.result_count = unicode(cl.paginator._count) return {'library_list': records } def library(request): @@ -100,16 +100,8 @@ def library(request): context.update(create_library_context(fcl)) t = get_template('samples/library_index.html') c = RequestContext(request, context) + return HttpResponse( t.render(c) ) - app_context = { - 'page_name': 'Library Index', - 'body': t.render(c) - } - app_context.update(SAMPLES_CONTEXT_DEFAULTS) - - app_t = get_template('flowcell_libraries_app.html') - app_c = RequestContext(request, app_context) - return HttpResponse( app_t.render(app_c) ) def library_to_flowcells(request, lib_id): """ diff --git a/htsworkflow/frontend/templates/admin/pagination.html b/htsworkflow/frontend/templates/admin/pagination.html new file mode 100644 index 0000000..f7de053 --- /dev/null +++ b/htsworkflow/frontend/templates/admin/pagination.html @@ -0,0 +1,13 @@ + +{% load admin_list %} +{% load i18n %} +

+{% if pagination_required %} +{% for i in page_range %} + {% paginator_number cl i %} +{% endfor %} +{% endif %} +{{ cl.result_count }} {% ifequal cl.result_count 1 %}{{ cl.opts.verbose_name }}{% else %}{{ cl.opts.verbose_name_plural }}{% endifequal %} +{% if show_all_url %}  {% trans 'Show all' %}{% endif %} +{% if cl.formset and cl.result_count %}{% endif %} +

diff --git a/htsworkflow/frontend/templates/app_base.html b/htsworkflow/frontend/templates/app_base.html deleted file mode 100644 index 1babcf6..0000000 --- a/htsworkflow/frontend/templates/app_base.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - {% block title %}{{ app_name }} - {{ page_name }}{% endblock %} - - - {% block additional_css %} - {% endblock %} - - - - - - {% block additional_javascript %} - {% endblock %} - - - - - -
- {% block pretitle %}{% endblock %} - {% block content_title %}{% if title %}

{{ title }}

{% endif %}{% endblock %} - {% block content %} - {% block object-tools %}{% endblock %} - {{ body }} - {% endblock %} - {% block sidebar %}{% endblock %} -
-
- - - {% block footer %}{% endblock %} - - diff --git a/htsworkflow/frontend/templates/base.html b/htsworkflow/frontend/templates/base.html index b5e1c39..ba17cbd 100644 --- a/htsworkflow/frontend/templates/base.html +++ b/htsworkflow/frontend/templates/base.html @@ -1,6 +1,15 @@ -{% load i18n %} - - +{% load i18n %} + + + {% block title %}{{ app_name }} - {{ page_name }}{% endblock %} @@ -23,13 +32,11 @@ {% block branding %}{% endblock %} {% if user.is_authenticated and user.is_staff %} -
{% trans 'Welcome,' %} {% firstof user.first_name user.username %}. {% block userlinks %}{% url django-admindocs-docroot as docsroot %}{% if docsroot %}{% trans 'Documentation' %} / {% endif %}{% trans 'Change password' %} / {% trans 'Log out' %}{% endblock %} +
{% trans 'Welcome,' %} {% firstof user.first_name user.username %}. {% block userlinks %}{% url django-admindocs-docroot as docsroot %}{% if docsroot %}{% trans 'Documentation' %} / {% endif %}{% trans 'Change password' %} / {% trans 'Log out' %}{% endblock %}
{% endif %} {% block nav-global %}{% endblock %}
- - {% block breadcrumbs %}{% endblock %} {% endif %} {% if messages %} diff --git a/htsworkflow/frontend/templates/flowcell_libraries_app.html b/htsworkflow/frontend/templates/flowcell_libraries_app.html deleted file mode 100644 index 6e31b59..0000000 --- a/htsworkflow/frontend/templates/flowcell_libraries_app.html +++ /dev/null @@ -1,34 +0,0 @@ -{% extends "app_base.html" %} - -{% block additional_css %} - {% load adminmedia %} - {% if LANGUAGE_BIDI %}{% endif %} - {% block extrastyle %}{% endblock %} - {% block extrahead %}{% endblock %} - {% block blockbots %}{% endblock %} - -{% endblock %} - -{% block dynamic_panels %} - - -{% endblock %} - -{% block app_toolbar_west %} -
-
-{% endblock %} - -{% block app_toolbar_east %} - -{% endblock %} diff --git a/htsworkflow/frontend/templates/inventory/inventory_app.html b/htsworkflow/frontend/templates/inventory/inventory_app.html deleted file mode 100644 index b5271c6..0000000 --- a/htsworkflow/frontend/templates/inventory/inventory_app.html +++ /dev/null @@ -1,21 +0,0 @@ -{% extends "app_base.html" %} - -{% block additional_css %} -{% endblock %} - -{% block dynamic_panels %} - -{% endblock %} - -{% block app_toolbar_west %} -
-{% endblock %} - -{% block app_toolbar_east %} - -{% endblock %} diff --git a/htsworkflow/frontend/templates/registration/login.html b/htsworkflow/frontend/templates/registration/login.html index cd28d59..1f053df 100644 --- a/htsworkflow/frontend/templates/registration/login.html +++ b/htsworkflow/frontend/templates/registration/login.html @@ -1,10 +1,11 @@ -{% extends "app_base.html" %} +{% extends "base_site.html" %} {% load i18n %} {% block additional_css %}{% load adminmedia %}{{ block.super }} {% endblock %} + {% block title %}Login{% endblock %} {% block bodyclass %}login{% endblock %} @@ -13,9 +14,7 @@

{{ error_message }}

{% endif %}
-
diff --git a/htsworkflow/frontend/templates/registration/profile.html b/htsworkflow/frontend/templates/registration/profile.html index c53c4de..fec48b0 100644 --- a/htsworkflow/frontend/templates/registration/profile.html +++ b/htsworkflow/frontend/templates/registration/profile.html @@ -1,4 +1,4 @@ -{% extends "flowcell_libraries_app.html" %} +{% extends "base_site.html" %} {% block content %} diff --git a/htsworkflow/frontend/templates/samples/lanes_for.html b/htsworkflow/frontend/templates/samples/lanes_for.html index 90bce6a..152f322 100644 --- a/htsworkflow/frontend/templates/samples/lanes_for.html +++ b/htsworkflow/frontend/templates/samples/lanes_for.html @@ -1,5 +1,4 @@ {% extends "base_site.html" %} -{# extends "app_base.html" #} {% load adminmedia admin_list i18n %} {% block bodyclass %}change-list{% endblock %} diff --git a/htsworkflow/frontend/templates/samples/library_detail.html b/htsworkflow/frontend/templates/samples/library_detail.html index 6c6fa8d..1bbd65b 100644 --- a/htsworkflow/frontend/templates/samples/library_detail.html +++ b/htsworkflow/frontend/templates/samples/library_detail.html @@ -1,7 +1,13 @@ -{% extends "flowcell_libraries_app.html" %} -{% load humanize %} +{% extends "base_site.html" %} +{% load adminmedia humanize i18n %} +{% block extrahead %} + + + + + {% block additional_javascript %} + {% endblock %} -{% block additional_css %}