Changeset 516
- Timestamp:
- 01/27/10 15:46:10 (6 weeks ago)
- Location:
- trunk/telemeta
- Files:
-
- 2 modified
-
templates/telemeta_default/collection_detail.html (modified) (5 diffs)
-
templatetags/telemeta_utils.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/telemeta/templates/telemeta_default/collection_detail.html
r513 r516 45 45 {% block general_info %} 46 46 <dl class="listing"> 47 {% dl_field collection .title%}48 {% dl_field collection .alt_title%}49 {% dl_field collection .creator%}47 {% dl_field collection "title" %} 48 {% dl_field collection "alt_title" %} 49 {% dl_field collection "creator" %} 50 50 {% if collection.recorded_from_year %} 51 51 <dt>{% trans "Recording year" %}</dt> 52 52 <dd>{{ collection.recorded_from_year }} {{ collection.recorded_to_year|prepend:" - " }}</dd> 53 53 {% endif %} 54 {% dl_field collection .year_published%}54 {% dl_field collection "year_published" %} 55 55 </dl> 56 56 {% endblock general_info %} … … 62 62 <div> 63 63 <dl class="listing"> 64 {% dl_field collection .countriesjoin with ", " %}65 {% dl_field collection .ethnic_groupsjoin with ", " %}64 {% dl_field collection "countries" join with ", " %} 65 {% dl_field collection "ethnic_groups" join with ", " %} 66 66 </dl> 67 67 </div> … … 77 77 {% if collection.collector_is_creator %} 78 78 {% if collection.creator %} 79 <dt>{% trans "Collector" %}</dt><dd>{{ collect or.creator }}</dd>79 <dt>{% trans "Collector" %}</dt><dd>{{ collection.creator }}</dd> 80 80 {% endif%} 81 81 {% else %} 82 {% dl_field collection .collector%}82 {% dl_field collection "collector" %} 83 83 {% endif %} 84 {% dl_field collection .publisher%}85 {% dl_field collection .publisher_collection%}86 {% dl_field collection .publisher_serial%}87 {% dl_field collection .booklet_author%}88 {% dl_field collection .external_references%}89 {% dl_field collection .doctype_code%}90 {% dl_field collection .public_access%}91 {% dl_field collection .legal_rights%}84 {% dl_field collection "publisher" %} 85 {% dl_field collection "publisher_collection" %} 86 {% dl_field collection "publisher_serial" %} 87 {% dl_field collection "booklet_author" %} 88 {% dl_field collection "external_references" %} 89 {% dl_field collection "doctype_code" %} 90 {% dl_field collection "public_access" %} 91 {% dl_field collection "legal_rights" %} 92 92 </dl> 93 93 </div> … … 101 101 <div> 102 102 <dl class="listing"> 103 {% dl_field collection .acquisition_mode%}104 {% dl_field collection .cnrs_contributor%}105 {% dl_field collection .metadata_writer%}106 {% dl_field collection .booklet_description%}107 {% dl_field collection .publishing_status%}108 {% dl_field collection .alt_ids%}109 {% dl_field collection .comment%}110 {% dl_field collection .metadata_writer%}111 {% dl_field collection .travail%}112 {% dl_field collection .items_done%}103 {% dl_field collection "acquisition_mode" %} 104 {% dl_field collection "cnrs_contributor" %} 105 {% dl_field collection "metadata_writer" %} 106 {% dl_field collection "booklet_description" %} 107 {% dl_field collection "publishing_status" %} 108 {% dl_field collection "alt_ids" %} 109 {% dl_field collection "comment" %} 110 {% dl_field collection "metadata_writer" %} 111 {% dl_field collection "travail" %} 112 {% dl_field collection "items_done" %} 113 113 </dl> 114 114 </div> … … 122 122 <div> 123 123 <dl class="listing"> 124 {% dl_field collection .code%}125 {% dl_field collection .old_code%}124 {% dl_field collection "code" %} 125 {% dl_field collection "old_code" %} 126 126 <dt>{% trans "Media type" %}</dt><dd>{% trans "Audio" %}</dd> 127 {% dl_field collection .approx_duration%}128 {% dl_field collection .computed_duration%}129 {% dl_field collection .physical_items_num%}127 {% dl_field collection "approx_duration" %} 128 {% dl_field collection "computed_duration" %} 129 {% dl_field collection "physical_items_num" %} 130 130 <dt>{% trans "Number of items" %}</dt><dd>{{ collection.items.count }}</dd> 131 {% dl_field collection .physical_format%}132 {% dl_field collection .ad_conversion%}131 {% dl_field collection "physical_format" %} 132 {% dl_field collection "ad_conversion" %} 133 133 </dl> 134 134 </div> -
trunk/telemeta/templatetags/telemeta_utils.py
r512 r516 99 99 100 100 class DescriptionListFieldNode(template.Node): 101 def __init__(self, variable, join_with = None): 102 cut = variable.split('.') 103 self.model = template.Variable('.'.join(cut[:-1])) 104 self.member = cut[-1] 101 def __init__(self, model, attr, join_with = None): 102 self.model = model 103 self.member = attr 105 104 self.join_with = join_with 106 105 … … 108 107 try: 109 108 model = self.model.resolve(context) 110 label = html.escape(capfirst(unicode(model.field_label(self.member)))) 109 if isinstance(self.member, template.Variable): 110 member = self.member.resolve(context) 111 else: 112 member = self.member 113 label = html.escape(capfirst(unicode(model.field_label(member)))) 111 114 try: 112 value = getattr(model, self.member)115 value = getattr(model, member) 113 116 except AttributeError: 114 117 value = '<ERROR: no such field>' … … 135 138 join_with = None 136 139 try: 137 tag_name, variable= cut140 tag_name, model, attr = cut 138 141 except ValueError: 139 142 try: 140 tag_name, variable, arg3, arg4, arg5 = cut143 tag_name, model, attr, arg3, arg4, arg5 = cut 141 144 if arg3 == 'join' and arg4 == 'with'and arg5[0] == arg5[-1] and arg5[0] in ('"', "'"): 142 145 join_with = arg5[1:-1] … … 147 150 % token.contents.split()[0]) 148 151 149 return DescriptionListFieldNode(variable, join_with=join_with) 152 if attr[0] == attr[-1] and attr[0] in ('"', "'"): 153 attr = attr[1:-1] 154 else: 155 attr = template.Variable(attr) 156 model = template.Variable(model) 157 return DescriptionListFieldNode(model, attr, join_with=join_with) 150 158 151 159 @register.filter
