[Mpuls-commits] r5060 - in base/trunk: . mpulsweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Jun 3 11:49:40 CEST 2011


Author: ludwig
Date: 2011-06-03 11:49:38 +0200 (Fri, 03 Jun 2011)
New Revision: 5060

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/controllers/case.py
   base/trunk/mpulsweb/controllers/case_bundle.py
   base/trunk/mpulsweb/controllers/casedocument.py
Log:
Issue1005: Move translated msgs inline.
(case_bundle.py casedocument.py case.py)

Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2011-06-03 09:26:08 UTC (rev 5059)
+++ base/trunk/ChangeLog	2011-06-03 09:49:38 UTC (rev 5060)
@@ -1,5 +1,12 @@
 2011-06-03  Ludwig Reiter <ludwig.reiter at intevation.de>
 
+	* mpulsweb/controllers/case_bundle.py,
+	mpulsweb/controllers/casedocument.py,
+	mpulsweb/controllers/case.py:
+	Issue1005: Move translated msgs inline.
+
+2011-06-03  Ludwig Reiter <ludwig.reiter at intevation.de>
+
 	* mpulsweb/controllers/annotations.py,
 	mpulsweb/controllers/appointment.py:
 	Issue1005: Move translated msgs inline.

Modified: base/trunk/mpulsweb/controllers/case.py
===================================================================
--- base/trunk/mpulsweb/controllers/case.py	2011-06-03 09:26:08 UTC (rev 5059)
+++ base/trunk/mpulsweb/controllers/case.py	2011-06-03 09:49:38 UTC (rev 5060)
@@ -27,62 +27,7 @@
 
 from mpulsweb.controllers.formularpage import get_rendered_page
 
-ANONYMIZE_CONFIRM = _(u"""Do make anonymous?""")
-MARKANONYMIZE_CONFIRM_TEXT = _(u"""\
-<p>Do you really want to free the case document to be made anonymous? The
-case document can then no longer be edited and is given to the administrator
-to make anonymous.</p>
-<p><b>The case document is going to make anonymous in phase </b>%s<b>!</b>""")
-ANONYMIZE_CONFIRM_TEXT = _("""Do you really want to anonymise the case and
-irrecovably lose the associated personal data? After it the case will
-not be available you. The anonymised case will still be considered for
-the analysis.""")
-ANONYMIZE_SUCCESS = _(u"""Case document anonymised!""")
-ANONYMIZE_SUCCESS_TEXT = _(u"""\
-The personal data of the case document has been deleted and the case document
-is removed from the overview. Please click on OK, to get back to the overview.""")
-MARKANONYMIZE_FAILED = _(u"""Anonymising not possible.""")
-MARKANONYMIZE_FAILED_TEXT = _(u"""\
-To anonymise this case document was not possible, because of following 
-reason:</p><p><i>%s</i></p><p>Please click on OK to geht back to the overview.
-</p>""")
-MARKANONYMIZE_SUCCESS = _(u"""Freed case document to anonymise.""")
-MARKANONYMIZE_SUCCESS_TEXT = _(u"""\
-The case document has been freed to be anonymised and has been given to
-the admininstration. Please click on OK, to get back to the overview.""")
 
-# Use ungettext here because in the po file this translation is ready for
-# ungettext. As the case controller only handles single cases provide constant
-# 1
-DELETE_CONFIRM = ungettext('Delete case?', 'Delete cases?', 1)
-DELETE_CONFIRM_TEXT = _("""Warning! On deleting the case all data will be erased
-irrecoverable!<br>Only delete the case if this case is <b>not needed for
-evaluations</b> anymore.<br><br>Do you want to delete the case from the
-server?""")
-MARKDELETE_CONFIRM_TEXT = _("""Do you really want to mark this case for deletion?
-The case will not be editable afterwards, and submited to the administration
-for deletion.""")
-
-DELETE_SUCCESS = _("""Case document deleted!""")
-DELETE_SUCCESS_TEXT = _("""The case document is given to the administrator for deletion.""")
-CLICK_OK_CONTINUE = _("""Click on OK to continue.""")
-
-# Use ungettext here because in the po file this translation is ready for
-# ungettext. As the case controller only handles single cases provide constant
-# 1
-RESTORE_CONFIRM = ungettext('Restore case?', 'Restore cases?', 1)
-RESTORE_CONFIRM_TEXT = _("""Do you really want to restore the case? The case
-will be editable afterwards again for the users.""")
-
-IMPORT_XML_SUCCESS = _("Case(s) imported!""")
-IMPORT_XML_SUCCESS_TEXT = _("""The file was imported successfully.
-Click on "OK" to open the case overview.""")
-
-IMPORT_FAILED = _("Case(s) not imported!")
-IMPORT_FAILED_TEXT = _("""An error occurred during the import.
-Click 'OK' to return to the import dialog.""")
-
-
 log = logging.getLogger(__name__)
 
 class CaseController(BaseController):
@@ -123,16 +68,19 @@
         if confirmed == 1:
             case = self._loadCase(id)
             case.setState(3)
-            c.dialog_title = DELETE_SUCCESS
-            c.dialog_text = DELETE_SUCCESS_TEXT
+            c.dialog_title = _("""Case document deleted!""")
+            c.dialog_text = _("""The case document is given to the administrator for deletion.""")
             c.url_ok = h.url_for(controller="/case_overview")
             session['render_mode'] = 'ro'
             session.save()
             return render('/casemanagement/dialogs/success_delete_cm.mako')
         else:
             c.context = "../main.mako"
-            c.dialog_title = DELETE_CONFIRM
-            c.dialog_text = MARKDELETE_CONFIRM_TEXT
+            c.dialog_title = ungettext('Delete case?', 'Delete cases?', 1)
+            c.dialog_text =  _("""Do you really want to mark this case for deletion?
+The case will not be editable afterwards, and submited to the administration
+for deletion.""")
+
             c.url_yes = h.url_for(controller='/case', action='markForDelete',
                                   id=id, confirmed=1)
             c.url_no = h.url_for(controller='/case_overview')
@@ -145,14 +93,18 @@
         if confirmed == 1:
             case = self._loadCase(id)
             case.delete()
-            c.dialog_title = DELETE_SUCCESS
-            c.dialog_text = CLICK_OK_CONTINUE
+            c.dialog_title = _("""Case document deleted!""")
+            c.dialog_text = _("""Click on OK to continue.""")
             c.url_ok = h.url_for(controller="/case_overview")
             return render('/casemanagement/dialogs/success_delete.mako')
         else:
             c.context = "../main.mako"
-            c.dialog_title = DELETE_CONFIRM
-            c.dialog_text = DELETE_CONFIRM_TEXT
+            c.dialog_title = ungettext('Delete case?', 'Delete cases?', 1)
+            c.dialog_text = _("""Warning! On deleting the case all data will be erased
+irrecoverable!<br>Only delete the case if this case is <b>not needed for
+evaluations</b> anymore.<br><br>Do you want to delete the case from the
+server?""")
+
             c.url_yes = h.url_for(controller='/case', action='delete',
                                   id=id, confirmed=1)
             c.url_no = h.url_for(controller='/case_overview')
@@ -179,7 +131,7 @@
         try:
             case.check_anonymizeability()
         except ConsistenceCheckException, e:
-            c.dialog_title = MARKANONYMIZE_FAILED
+            c.dialog_title = _(u"""Anonymising not possible.""")
             c.dialog_text = h.literal(e.value)
             c.url_ok = url
             return render('/casemanagement/dialogs/failed_markanonymize.mako')
@@ -187,8 +139,10 @@
         # case.
         if confirmed == 1:
             try:
-                c.dialog_title = MARKANONYMIZE_SUCCESS
-                c.dialog_text = MARKANONYMIZE_SUCCESS_TEXT
+                c.dialog_title = _(u"""Freed case document to anonymise.""")
+                c.dialog_text = _(u"""\
+The case document has been freed to be anonymised and has been given to
+the admininstration. Please click on OK, to get back to the overview.""")
                 c.url_ok = h.url_for(controller="/case_overview")
                 case.make_anonymizable()
                 state = case.getState().setState(4)
@@ -200,8 +154,11 @@
                 for k, values in e.errors.iteritems():
                     for v in values:
                         errors.append(v.msg)
-                c.dialog_title = MARKANONYMIZE_FAILED
-                c.dialog_text = MARKANONYMIZE_FAILED_TEXT % "<br>".join(errors) 
+                c.dialog_title = _(u"""Anonymising not possible.""")
+                c.dialog_text = _(u"""\
+To anonymise this case document was not possible, because of following 
+reason:</p><p><i>%s</i></p><p>Please click on OK to geht back to the overview.
+</p>""") % "<br>".join(errors) 
                 c.url_ok = h.url_for(controller='/case', action='select',
                                      id=case.id, confirmed=1)
                 return render('/casemanagement/dialogs/failed_markanonymize.mako')
@@ -219,8 +176,13 @@
                     else:
                         phase_name.append("(%s)" % _('Finished'))
             
-            c.dialog_title = ANONYMIZE_CONFIRM
-            c.dialog_text = MARKANONYMIZE_CONFIRM_TEXT % " ".join(phase_name) 
+            c.dialog_title = _(u"""Do make anonymous?""")
+            c.dialog_text =_(u"""\
+<p>Do you really want to free the case document to be made anonymous? The
+case document can then no longer be edited and is given to the administrator
+to make anonymous.</p>
+<p><b>The case document is going to make anonymous in phase </b>%s<b>!</b>""") \
+        % " ".join(phase_name) 
             c.url_yes = h.url_for(controller='/case', action='markForAnonymize',
                                   id=id, confirmed=1)
             c.url_no = url
@@ -236,7 +198,7 @@
         try:
             case.check_anonymizeability()
         except ConsistenceCheckException, e:
-            c.dialog_title = MARKANONYMIZE_FAILED
+            c.dialog_title =  _(u"""Anonymising not possible.""")
             c.dialog_text = h.literal(e.value)
             c.url_ok = h.url_for(controller='/case', action='digest', id=id)
             return render('/casemanagement/dialogs/failed_markanonymize.mako')
@@ -245,14 +207,19 @@
         # case.
         if confirmed == 1:
             case.anonymize()
-            c.dialog_title = ANONYMIZE_SUCCESS
-            c.dialog_text = ANONYMIZE_SUCCESS_TEXT
+            c.dialog_title = _(u"""Case document anonymised!""")
+            c.dialog_text = _(u"""\
+The personal data of the case document has been deleted and the case document
+is removed from the overview. Please click on OK, to get back to the overview.""")
             c.url_ok = h.url_for(controller="/case_overview")
             return render('/casemanagement/dialogs/success_anonymize.mako')
         else:
             c.context = "../main.mako"
-            c.dialog_title = ANONYMIZE_CONFIRM
-            c.dialog_text = ANONYMIZE_CONFIRM_TEXT
+            c.dialog_title = _(u"""Do make anonymous?""")
+            c.dialog_text =  _("""Do you really want to anonymise the case and
+irrecovably lose the associated personal data? After it the case will
+not be available you. The anonymised case will still be considered for
+the analysis.""")
             c.url_yes = h.url_for(controller='/case', action='anonymize',
                                   id=id, confirmed=1)
             c.url_no = h.url_for(controller='/case', action='digest', id=id)
@@ -275,8 +242,9 @@
             return render('/casemanagement/dialogs/success_restore.mako')
         else:
             c.context = "../main.mako"
-            c.dialog_title = RESTORE_CONFIRM
-            c.dialog_text = RESTORE_CONFIRM_TEXT
+            c.dialog_title = ungettext('Restore case?', 'Restore cases?', 1)
+            c.dialog_text = _("""Do you really want to restore the case? The case
+will be editable afterwards again for the users.""")
             c.url_yes = h.url_for(controller='/case', action='restore', id=id,
                                   confirmed=1)
             c.url_no = h.url_for(controller='/case_overview')
@@ -468,17 +436,19 @@
             finally:
                 xmlfile.file.close()
 
-            c.dialog_title = IMPORT_XML_SUCCESS
-            c.dialog_text = IMPORT_XML_SUCCESS_TEXT
+            c.dialog_title = _("Case(s) imported!""")
+            c.dialog_text =  _("""The file was imported successfully.
+Click on "OK" to open the case overview.""")
             c.url_ok = h.url_for(controller="/case_overview")
             return render('/casemanagement/dialogs/success_xml_import.mako')
         except Exception, e:
             log.exception("Exception during xml import")
-            c.dialog_title  = IMPORT_FAILED
+            c.dialog_title  = _("Case(s) not imported!")
             if isinstance(e, XMLImportException):
                 c.dialog_text = h.escape(e.message)
             else:
-                c.dialog_text = IMPORT_FAILED_TEXT
+                c.dialog_text = _("""An error occurred during the import.
+Click 'OK' to return to the import dialog.""")
             c.url_ok = h.url_for(controller='/case', action='importCase')
             return render('/casemanagement/dialogs/failed_xml_import.mako')
 

Modified: base/trunk/mpulsweb/controllers/case_bundle.py
===================================================================
--- base/trunk/mpulsweb/controllers/case_bundle.py	2011-06-03 09:26:08 UTC (rev 5059)
+++ base/trunk/mpulsweb/controllers/case_bundle.py	2011-06-03 09:49:38 UTC (rev 5060)
@@ -26,21 +26,6 @@
 
 log = logging.getLogger(__name__)
 
-
-BUNDLE_NOTIFICATION_NOACTION_HEADER = _("No action specified for the selection")
-BUNDLE_NOTIFICATION_NOACTION = _("""You have not selected any action for the
-selection. Please click OK to go to the case overview and select there
-an action from the drop down menu.""")
-
-BUNDLE_NOTIFICATION_EMPTYLIST_HEADER = _("No valid cases in the selection!")
-BUNDLE_NOTIFICATION_EMPTYLIST = _(u"""The selected action can not be executed
-on any of the cases in your selection. Please make sure that the cases are
-in a state from which you can execute the selected action.""")
-
-OK_TO_CONTINUE = _("Please click OK to continue.")
-
-
-
 class CaseBundleController(BaseController):
 
     def index(self):
@@ -254,16 +239,21 @@
 
     def _empty_caselist(self):
         c.url_ok = url_for(controller='/case_overview')
-        c.dialog_title = BUNDLE_NOTIFICATION_EMPTYLIST_HEADER
-        c.dialog_text = BUNDLE_NOTIFICATION_EMPTYLIST
+        c.dialog_title = _("No valid cases in the selection!")
+        c.dialog_text = _(u"The selected action can not be executed"
+                u"\non any of the cases in your selection."
+                u" Please make sure that the cases are"
+                u"\nin a state from which you can execute the selected action.")
         return render('/casebundle/dialogs/error.mako')
 
     #
     # ACTIONS
     #
     def no_action(self):
-        c.dialog_title= BUNDLE_NOTIFICATION_NOACTION_HEADER
-        c.dialog_text = BUNDLE_NOTIFICATION_NOACTION
+        c.dialog_title= _("No action specified for the selection")
+        c.dialog_text = _("""You have not selected any action for the
+selection. Please click OK to go to the case overview and select there
+an action from the drop down menu.""")
         c.url_ok = url_for(controller='/case_overview')
         return render('/casebundle/dialogs/error.mako')
 
@@ -280,7 +270,7 @@
                                        u" deletion.",
                                        u"%s cases were successfully cleared for"
                                        u" deletion.", num) % num
-                             + " " + OK_TO_CONTINUE)
+                             + " " + _("Please click OK to continue."))
             c.url_ok = url_for(controller='/case_overview')
             del session['casebundle']
             return render ('/casebundle/dialogs/success_markdelete.mako')
@@ -312,7 +302,7 @@
             c.dialog_text = (ungettext(u"%s case was successfully deleted.",
                                        u"%s cases were successfully deleted.",
                                        num) % num
-                             + " " + OK_TO_CONTINUE)
+                             + " " + _("Please click OK to continue."))
             c.url_ok = url_for(controller='/case_overview')
             del session['casebundle']
             return render('/casebundle/dialogs/success_delete_admin.mako')
@@ -355,7 +345,7 @@
                           u"%s cases were cleared for anonymisation. They will"
                           u" be presented to the administrators for review for"
                           u" the definite anonymisation.", num) % num
-                + " " + OK_TO_CONTINUE)
+                + " " + _("Please click OK to continue."))
             c.url_ok = url_for(controller='/case_overview')
             del session['casebundle']
             return render ('/casebundle/dialogs/success_anonymize.mako')
@@ -394,7 +384,7 @@
             c.dialog_text = (ungettext(u"%s case was successfully anonymised.",
                                        u"%s cases were successfully anonymised.",
                                        num) % str(num)
-                             + " " + OK_TO_CONTINUE)
+                             + " " + _("Please click OK to continue."))
             c.url_ok = url_for(controller='/case_overview')
             del session['casebundle']
             return render ('/casebundle/dialogs/success_anonymize.mako')
@@ -431,7 +421,7 @@
                                        num)
             c.dialog_text = ungettext(u"%s was successfully restored.",
                                       u"%s were successfully restored.",
-                                      num) % num + " " + OK_TO_CONTINUE
+                                      num) % num + " " + _("Please click OK to continue.")
             c.url_ok = url_for(controller='/case_overview')
             del session['casebundle']
             return render ('/casemanagement/dialogs/success_restore.mako')
@@ -465,7 +455,7 @@
                 ungettext(u"%s case was successfully transferred to %s %s",
                           u"%s cases were successfully transferred to %s %s",
                           num) % (num, user.first_name, user.last_name)
-                + " " + OK_TO_CONTINUE)
+                + " " +_("Please click OK to continue.") )
             c.url_ok = url_for(controller='/case_overview')
             del session['casebundle']
             return render('/casebundle/dialogs/success_editor.mako')
@@ -488,7 +478,7 @@
                 ungettext(u"%s case was successfully assigned to a substitute.",
                           u"%s cases were successfully assigned to a"
                           u" substitute.",
-                          num) % num + " " + OK_TO_CONTINUE)
+                          num) % num + " " + _("Please click OK to continue."))
             else:
                 del session['casebundle']
                 return self._empty_caselist()

Modified: base/trunk/mpulsweb/controllers/casedocument.py
===================================================================
--- base/trunk/mpulsweb/controllers/casedocument.py	2011-06-03 09:26:08 UTC (rev 5059)
+++ base/trunk/mpulsweb/controllers/casedocument.py	2011-06-03 09:49:38 UTC (rev 5060)
@@ -19,20 +19,6 @@
 
 log = logging.getLogger(__name__)
 
-OK_TO_CONTINUE = _(u"Please click OK to continue.")
-
-SET_ATTACHMENT_SUCCESS_HEADER = _(u"Attachment added!")
-
-SET_ATTACHMENT_FAILED_HEADER = _(u"No attachment added!")
-SET_ATTACHMENT_FAILED_TEXT = _(u"""Please make sure that the path is correct. Attachments
-can be viewed directly via the "Browse" button""") + " " + OK_TO_CONTINUE
-
-SET_ATTACHMENT_SUCCESS_DELETE_HEADER = _(u"Attachment deleted!""")
-
-SET_ATTACHMENT_CONFIRM_DELETE_HEADER = _(u"Delete attachment?")
-SET_ATTACHMENT_CONFIRM_DELETE_TEXT = _(u"Do you want to irrevocably delete the attachment?")
-
-
 class CasedocumentController(BaseController):
 
     @checkRole(('admin_ka', 'cm_ka'))
@@ -67,8 +53,8 @@
                 else:
                     filename = result['name']
             doc.create(filename, content, case)
-            c.dialog_title = SET_ATTACHMENT_SUCCESS_HEADER
-            c.dialog_text = OK_TO_CONTINUE
+            c.dialog_title = _(u"Attachment added!")
+            c.dialog_text = _(u"Please click OK to continue.")
             c.url_ok = h.url_for(controller="/casedocument", action="index",
                                  id=case)
             return render('/documents/dialogs/success_attachment.mako')
@@ -108,14 +94,14 @@
                 log.exception(e)
             c.url_ok = h.url_for(controller="/casedocument", action="index" ,
                                  id=session['case'].id)
-            c.success_for = SET_ATTACHMENT_SUCCESS_DELETE_HEADER
-            c.success_text = OK_TO_CONTINUE
+            c.success_for = _(u"Attachment deleted!")
+            c.success_text = _(u"Please click OK to continue.")
             return render('/casemanagement/dialogs/'
                           'success_delete_attachment.mako')
         else:
             c.context = "../main.mako"
-            c.confirm_for = SET_ATTACHMENT_CONFIRM_DELETE_HEADER
-            c.question = SET_ATTACHMENT_CONFIRM_DELETE_TEXT
+            c.confirm_for = _(u"Delete attachment?")
+            c.question = _(u"Do you want to irrevocably delete the attachment?")
             c.url_yes = h.url_for(controller='/casedocument', action='delete',
                                   id=id, confirmed=1)
             c.url_no = h.url_for(controller="/casedocument", action="index",



More information about the Mpuls-commits mailing list