[Mpuls-commits] r5356 - base/trunk/mpulsweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Sep 15 19:17:28 CEST 2011


Author: bh
Date: 2011-09-15 19:17:28 +0200 (Thu, 15 Sep 2011)
New Revision: 5356

Modified:
   base/trunk/mpulsweb/controllers/case.py
Log:
Fix formatting.
This also changes the internal formatting of some internationalized
string, so translations will have to be updated.


Modified: base/trunk/mpulsweb/controllers/case.py
===================================================================
--- base/trunk/mpulsweb/controllers/case.py	2011-09-15 16:47:43 UTC (rev 5355)
+++ base/trunk/mpulsweb/controllers/case.py	2011-09-15 17:17:28 UTC (rev 5356)
@@ -14,7 +14,7 @@
 from mpulsweb.lib.security import checkRole
 from mpulsweb.lib.dialogs import checkPrivacyStatement
 from mpulsweb.lib.validators import SetStandinForm, SetEditorForm, NewCaseForm
-from mpulsweb.lib.export import FormletterExport 
+from mpulsweb.lib.export import FormletterExport
 from mpulsweb.lib.anonymize import determineAnonymizedCaseEndPhaseName, \
      determineAnonymizedCaseEndPhase
 from mpulsweb.lib.db import  PostgresDBInterface
@@ -25,14 +25,15 @@
      MPulsXMLImporter, XMLImportException
 from mpulsweb.model.user import UserGroupList, UserListObject
 from mpulsweb.model.logbook import LogbookEntry
-from mpulsweb.model.statement import PrivacyStatement 
-from mpulsweb.model.agencysettings import Agency 
+from mpulsweb.model.statement import PrivacyStatement
+from mpulsweb.model.agencysettings import Agency
 
 from mpulsweb.controllers.formularpage import get_rendered_page
 
 
 log = logging.getLogger(__name__)
 
+
 class CaseController(BaseController):
 
     def init_case(self, id):
@@ -104,8 +105,9 @@
             case = self._loadCase(id)
             case.markDelete()
             case.checkValidity()
-            c.dialog_title = _("""Case document deleted!""")
-            c.dialog_text = _("""The case document is given to the administrator for deletion.""")
+            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()
@@ -113,9 +115,10 @@
         else:
             c.context = "../main.mako"
             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.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)
@@ -488,8 +491,9 @@
         else:
             c.context = "../main.mako"
             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.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')
@@ -566,7 +570,7 @@
     def new2(self):
         c.case = session.get('case')
         form_errors = {}
-        form_defaults = c.case.getData() 
+        form_defaults = c.case.getData()
         form = render('/casemanagement/new.mako')
         return formencode.htmlfill.render(form, defaults=form_defaults,
                                           auto_insert_errors=False,
@@ -584,7 +588,7 @@
         return NewCaseForm()
 
     def _convert_SetDataException2Formencode(self, err):
-        '''Will convert a SetDataException in a formencode compatible dictionary'''
+        """Convert a SetDataException into a formencode compatible dictionary"""
 
         # Expample SetDataException:
         # {'geburtsdatum:17': [type: 1, name: 'geburtsdatum:17', msg:
@@ -627,21 +631,21 @@
                 case = self._createCase(form_result)
             except SetDataException, err:
                 c.form_result = form_result
-                c.form_errors = self._convert_SetDataException2Formencode(err) 
+                c.form_errors = self._convert_SetDataException2Formencode(err)
                 form = render('/casemanagement/new.mako')
-                return formencode.htmlfill.render(form, 
-                                            defaults=c.form_result,
-                                            auto_insert_errors=False,
-                                            errors=c.form_errors)
+                return formencode.htmlfill.render(form,
+                                                  defaults=c.form_result,
+                                                  auto_insert_errors=False,
+                                                  errors=c.form_errors)
             except formencode.Invalid, error:
                 log.debug("Invalid form data: %r", error)
                 c.form_result = error.value
                 c.form_errors = error.error_dict or {}
                 form = render('/casemanagement/new.mako')
-                return formencode.htmlfill.render(form, 
-                                            defaults=c.form_result,
-                                            auto_insert_errors=False,
-                                            errors=c.form_errors)
+                return formencode.htmlfill.render(form,
+                                                  defaults=c.form_result,
+                                                  auto_insert_errors=False,
+                                                  errors=c.form_errors)
 
         return self.select(str(case.id))
 
@@ -650,7 +654,7 @@
         id = self._checkInt(id)
         confirmed = self._checkBool(confirmed)
         case = self._loadCase(id)
-        if confirmed: 
+        if confirmed:
             case.copy()
             case.checkValidity()
             c.dialog_title = _('Case copied!')
@@ -661,8 +665,8 @@
             return render('/casemanagement/dialogs/success_copy.mako')
         else:
             c.dialog_title = _('Copy case?')
-            c.dialog_text =  _('Do you really want to copy this case?'
-                               ' All data will be copied in the new case.')
+            c.dialog_text = _('Do you really want to copy this case?'
+                              ' All data will be copied in the new case.')
             c.url_yes = h.url_for(controller='/case', action='copy',
                                   id=id, confirmed=1)
             c.url_no = h.url_for(controller='/case', action='digest', id=id)
@@ -683,18 +687,18 @@
                 xmlfile.file.close()
 
             c.dialog_title = _("Case(s) imported!""")
-            c.dialog_text =  _("""The file was imported successfully.
-Click on "OK" to open the case overview.""")
+            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  = _("Case(s) not imported!")
+            c.dialog_title = _("Case(s) not imported!")
             if isinstance(e, XMLImportException):
                 c.dialog_text = h.escape(e.message)
             else:
-                c.dialog_text = _("""An error occurred during the import.
-Click 'OK' to return to the import dialog.""")
+                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')
 
@@ -775,12 +779,13 @@
         entry.setDate(datetime.now())
         entry.setKind(-2)
         form_defaults = {}
-        form_defaults['case_id'] = id 
+        form_defaults['case_id'] = id
         form_defaults['date'] = entry.getDate()
         form_defaults['time'] = entry.getTime()
         form_defaults['kind'] = entry.getKindAsInt()
         form_defaults['short_notice'] = _('Case storage extended')
-        form_defaults['notice'] = _('Please enter the reason for the case storage extension.')
+        form_defaults['notice'] = _('Please enter the reason for the case'
+                                    ' storage extension.')
         id = self._checkInt(id)
         case = self.init_case(id)
         c.entry = entry
@@ -794,17 +799,19 @@
         id = self._checkInt(id)
         case = self._loadCase(id)
         try:
-            # Temporarily switch the state of the case to force refreshing the last
-            # access date.
+            # Temporarily switch the state of the case to force
+            # refreshing the last access date.
             state = case.getState().getState()
             case.getState().setState(2)
             case.getState().setState(state)
             c.dialog_title = _('Case storage extended')
-            c.dialog_text = _('The max case storage has been extended. Please click on OK to continue') 
+            c.dialog_text = _('The max case storage has been extended.'
+                              ' Please click on OK to continue')
             c.url_ok = h.url_for(controller="/")
             return render('/casemanagement/dialogs/success_keepactive.mako')
         except:
-            log.exception('Can not refresh case in "_keep_active_without_logbook"')
+            log.exception('Can not refresh case in'
+                          ' "_keep_active_without_logbook"')
             raise
 
         pass
@@ -824,8 +831,8 @@
     def formletter(self, id, letterid=1):
         id = self._checkInt(id)
         case = self._loadCase(id)
-        d,o = case.formletter(letterid)
-        export = FormletterExport([d], o).export() 
+        d, o = case.formletter(letterid)
+        export = FormletterExport([d], o).export()
         return self._download_data(export, "application/msexcel", "xls")
 
 



More information about the Mpuls-commits mailing list