From febe21db1bad1585aaa24483985cdc9002e77570 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sat, 24 Jan 2015 14:25:31 -0400 Subject: [PATCH] Improve document related views titles messages, improve pluralization. --- mayan/apps/checkouts/views.py | 4 ++-- mayan/apps/document_comments/views.py | 4 ++-- mayan/apps/document_indexing/views.py | 4 ++-- mayan/apps/document_signatures/views.py | 10 +++++----- mayan/apps/document_states/views.py | 2 +- mayan/apps/documents/views.py | 18 +++++++++--------- mayan/apps/folders/views.py | 15 +++++++++------ mayan/apps/linking/views.py | 6 +++--- mayan/apps/metadata/views.py | 2 +- mayan/apps/tags/views.py | 24 ++++++++++++++++-------- 10 files changed, 50 insertions(+), 39 deletions(-) diff --git a/mayan/apps/checkouts/views.py b/mayan/apps/checkouts/views.py index da2f754613..64e8be4980 100644 --- a/mayan/apps/checkouts/views.py +++ b/mayan/apps/checkouts/views.py @@ -58,7 +58,7 @@ def checkout_info(request, document_pk): return render_to_response('main/generic_template.html', { 'paragraphs': paragraphs, 'object': document, - 'title': _('Document check out details') + 'title': _('Check out details for document: %s') % document }, context_instance=RequestContext(request)) @@ -91,7 +91,7 @@ def checkout_document(request, document_pk): return render_to_response('main/generic_form.html', { 'form': form, 'object': document, - 'title': _('Document check out') + 'title': _('Check out document: %s') % document }, context_instance=RequestContext(request)) diff --git a/mayan/apps/document_comments/views.py b/mayan/apps/document_comments/views.py index f178463690..ab12bebb40 100644 --- a/mayan/apps/document_comments/views.py +++ b/mayan/apps/document_comments/views.py @@ -104,7 +104,7 @@ def comment_add(request, document_id): return render_to_response('main/generic_form.html', { 'form': form, - 'title': _('Add comment to document'), + 'title': _('Add comment to document: %s') % document, 'next': next, 'object': document, }, context_instance=RequestContext(request)) @@ -124,7 +124,7 @@ def comments_for_document(request, document_id): return render_to_response('main/generic_list.html', { 'object': document, 'access_object': document, - 'title': _('Document comments'), + 'title': _('Comments for document: %s') % document, 'object_list': Comment.objects.for_model(document).order_by('-submit_date'), 'hide_link': True, 'hide_object': True, diff --git a/mayan/apps/document_indexing/views.py b/mayan/apps/document_indexing/views.py index 3a999db428..c121c681c0 100644 --- a/mayan/apps/document_indexing/views.py +++ b/mayan/apps/document_indexing/views.py @@ -402,8 +402,8 @@ def document_index_list(request, document_id): object_list.append(get_breadcrumbs(index_instance, single_link=True, include_count=True)) return render_to_response('main/generic_list.html', { - 'title': _('Indexes containing this document'), 'object_list': object_list, + 'object': document, 'hide_link': True, - 'object': document + 'title': _('Indexes containing document: %s') % document, }, context_instance=RequestContext(request)) diff --git a/mayan/apps/document_signatures/views.py b/mayan/apps/document_signatures/views.py index dec04c9e66..ac5c20a139 100644 --- a/mayan/apps/document_signatures/views.py +++ b/mayan/apps/document_signatures/views.py @@ -68,10 +68,10 @@ def document_verify(request, document_pk): ) return render_to_response('main/generic_template.html', { - 'title': _('Document signature properties'), - 'object': document, 'document': document, + 'object': document, 'paragraphs': paragraphs, + 'title': _('Signature properties for document: %s') % document, }, context_instance=RequestContext(request)) @@ -103,11 +103,11 @@ def document_signature_upload(request, document_pk): form = DetachedSignatureForm() return render_to_response('main/generic_form.html', { - 'title': _('Upload detached signature'), - 'next': next, 'form': form, - 'previous': previous, + 'next': next, 'object': document, + 'previous': previous, + 'title': _('Upload detached signature for document: %s') % document, }, context_instance=RequestContext(request)) diff --git a/mayan/apps/document_states/views.py b/mayan/apps/document_states/views.py index e98fd88460..79d0c66a6f 100644 --- a/mayan/apps/document_states/views.py +++ b/mayan/apps/document_states/views.py @@ -56,7 +56,7 @@ class DocumentWorkflowInstanceListView(SingleObjectListView): { 'hide_link': True, 'object': self.get_document(), - 'title': _('Document workflows'), + 'title': _('Workflows for document: %s') % self.get_document(), 'list_object_variable_name': 'workflow_instance', } ) diff --git a/mayan/apps/documents/views.py b/mayan/apps/documents/views.py index e8ddc4b4df..927ddc3dca 100644 --- a/mayan/apps/documents/views.py +++ b/mayan/apps/documents/views.py @@ -128,7 +128,7 @@ def document_properties(request, document_id): 'form': document_properties_form, 'document': document, 'object': document, - 'title': _('Document properties'), + 'title': _('Properties for document: %s') % document, }, context_instance=RequestContext(request)) @@ -149,7 +149,7 @@ def document_preview(request, document_id): 'form': preview_form, 'hide_labels': True, 'object': document, - 'title': _('Document preview'), + 'title': _('Preview of document: %s') % document, }, context_instance=RequestContext(request)) @@ -170,7 +170,7 @@ def document_content(request, document_id): 'form': content_form, 'hide_labels': True, 'object': document, - 'title': _('Document content'), + 'title': _('Content of document: %s') % document, }, context_instance=RequestContext(request)) @@ -258,7 +258,7 @@ def document_edit(request, document_id): return render_to_response('main/generic_form.html', { 'form': form, 'object': document, - 'title': _('Edit document properties'), + 'title': _('Edit properties of document: %s') % document, }, context_instance=RequestContext(request)) @@ -1111,10 +1111,6 @@ def document_version_list(request, document_pk): document.add_as_recent_document_for_user(request.user) context = { - 'object_list': document.versions.order_by('-timestamp'), - 'title': _('Document versions'), - 'hide_object': True, - 'object': document, 'access_object': document, 'extra_columns': [ { @@ -1133,7 +1129,11 @@ def document_version_list(request, document_pk): 'name': _('Comment'), 'attribute': 'comment', }, - ] + ], + 'hide_object': True, + 'object': document, + 'object_list': document.versions.order_by('-timestamp'), + 'title': _('Versions of document: %s') % document, } return render_to_response('main/generic_list.html', context, diff --git a/mayan/apps/folders/views.py b/mayan/apps/folders/views.py index 09e99f5301..d9e21f26e4 100644 --- a/mayan/apps/folders/views.py +++ b/mayan/apps/folders/views.py @@ -8,7 +8,7 @@ from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect from django.shortcuts import get_object_or_404, render_to_response from django.template import RequestContext -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import ugettext_lazy as _, ungettext from acls.models import AccessEntry from acls.utils import apply_default_acls @@ -191,9 +191,12 @@ def folder_add_document(request, document_id=None, document_id_list=None): if len(documents) == 1: context['object'] = documents[0] - context['title'] = _('Add document: %s to folder.') % documents[0] - elif len(documents) > 1: - context['title'] = _('Add documents: %s to folder.') % ', '.join([unicode(d) for d in documents]) + + context['title'] = ungettext( + 'Add document to folder', + 'Add documents to folder', + len(documents) + ) return render_to_response('main/generic_form.html', context, context_instance=RequestContext(request)) @@ -208,9 +211,9 @@ def document_folder_list(request, document_id): AccessEntry.objects.check_access(PERMISSION_DOCUMENT_VIEW, request.user, document) context = { - 'title': _('Folders containing this document'), - 'object': document, 'hide_link': True, + 'object': document, + 'title': _('Folders containing document: %s') % document, } queryset = document.folders.all() diff --git a/mayan/apps/linking/views.py b/mayan/apps/linking/views.py index 4ecf16a85b..75d1c9a210 100644 --- a/mayan/apps/linking/views.py +++ b/mayan/apps/linking/views.py @@ -77,9 +77,6 @@ def smart_link_instances_for_document(request, document_id): context = { 'document': document, - 'object': document, - 'object_list': smart_links, - 'title': _('Document smart links'), 'extra_columns': [ {'name': _('Indentifier'), 'attribute': encapsulate(lambda resolved_smart_link: resolved_smart_link.smart_link.get_dynamic_title(document))}, {'name': _('Documents'), 'attribute': encapsulate(lambda resolved_smart_link: resolved_smart_link.queryset.count())} @@ -94,6 +91,9 @@ def smart_link_instances_for_document(request, document_id): }, 'hide_object': True, 'hide_link': True, + 'object': document, + 'object_list': smart_links, + 'title': _('Smart links for document: %s') % document, } return render_to_response('main/generic_list.html', context, diff --git a/mayan/apps/metadata/views.py b/mayan/apps/metadata/views.py index 54bf4720fd..8251804f48 100644 --- a/mayan/apps/metadata/views.py +++ b/mayan/apps/metadata/views.py @@ -327,7 +327,7 @@ def metadata_view(request, document_id): AccessEntry.objects.check_access(PERMISSION_METADATA_DOCUMENT_VIEW, request.user, document) return render_to_response('main/generic_list.html', { - 'title': _('Document metadata'), + 'title': _('Metadata for document: %s') % document, 'object_list': document.metadata.all(), 'extra_columns': [ {'name': _('Value'), 'attribute': 'value'}, diff --git a/mayan/apps/tags/views.py b/mayan/apps/tags/views.py index c66282eee0..ae756090bd 100644 --- a/mayan/apps/tags/views.py +++ b/mayan/apps/tags/views.py @@ -171,13 +171,21 @@ def tag_delete(request, tag_id=None, tag_id_list=None): 'previous': previous, 'next': next, } - if len(tags) == 1: + + context = { + 'form': form, + 'previous': previous, + 'message': _('Will be removed from all documents.'), + 'next': next, + 'title': ungettext( + 'Are you sure you wish to delete the selected tag?', + 'Are you sure you wish to delete the selected tags?', + len(tags) + ) + } + + if len(documents) == 1: context['object'] = tags[0] - context['title'] = _('Are you sure you wish to delete the tag: %s?') % ', '.join([unicode(d) for d in tags]) - context['message'] = _('Will be removed from all documents.') - elif len(tags) > 1: - context['title'] = _('Are you sure you wish to delete the tags: %s?') % ', '.join([unicode(d) for d in tags]) - context['message'] = _('Will be removed from all documents.') return render_to_response('main/generic_confirm.html', context, context_instance=RequestContext(request)) @@ -222,7 +230,7 @@ class TagTaggedItemListView(DocumentListView): def get_extra_context(self): return { - 'title': _('Documents with the tag "%s"') % self.get_tag(), + 'title': _('Documents with the tag: %s') % self.get_tag(), 'hide_links': True, 'object': self.get_tag(), } @@ -239,7 +247,7 @@ def document_tags(request, document_id): context = { 'object': document, 'document': document, - 'title': _('Document tags'), + 'title': _('Tags for document: %s') % document, } return tag_list(request, queryset=document.tags.all(), extra_context=context)