From e49b47bbec282c2a932eb1f15242469a0a31c123 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sat, 19 Mar 2011 03:39:11 -0400 Subject: [PATCH] Changed message logic so that a message is displayed per document and not per document group --- apps/documents/views.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/documents/views.py b/apps/documents/views.py index 083e82fa8a..4e8a81bd8a 100644 --- a/apps/documents/views.py +++ b/apps/documents/views.py @@ -776,15 +776,14 @@ def document_clear_transformations(request, document_id=None, document_id_list=N if request.method == 'POST': for document in documents: - for document_page in document.documentpage_set.all(): - for transformation in document_page.documentpagetransformation_set.all(): - transformation.delete() + try: + for document_page in document.documentpage_set.all(): + for transformation in document_page.documentpagetransformation_set.all(): + transformation.delete() + messages.success(request, _(u'All the page transformations for document: %s, have been deleted successfully.') % document) + except Exception, e: + messages.error(request, _(u'Error deleting the page transformations for document: %s; %s.') % (document, e)) - if len(documents) == 1: - messages.success(request, _(u'All the page transformations for document: %s, have been deleted successfully.') % ', '.join([unicode(d) for d in documents])) - elif len(documents) > 1: - messages.success(request, _(u'All the page transformations for the documents: %s, have been deleted successfully.') % ', '.join([unicode(d) for d in documents])) - return HttpResponseRedirect(next) context = {