[Mpuls-commits] r4981 - in wasko/trunk: . waskoweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu May 19 20:18:35 CEST 2011


Author: bh
Date: 2011-05-19 20:18:32 +0200 (Thu, 19 May 2011)
New Revision: 4981

Modified:
   wasko/trunk/ChangeLog
   wasko/trunk/waskoweb/controllers/caselifetime.py
Log:
* waskoweb/controllers/caselifetime.py: Fix formatting.


Modified: wasko/trunk/ChangeLog
===================================================================
--- wasko/trunk/ChangeLog	2011-05-19 13:40:41 UTC (rev 4980)
+++ wasko/trunk/ChangeLog	2011-05-19 18:18:32 UTC (rev 4981)
@@ -1,3 +1,7 @@
+2011-05-19  Bernhard Herzog  <bh at intevation.de>
+
+	* waskoweb/controllers/caselifetime.py: Fix formatting.
+
 2011-05-19  Ludwig Reiter <ludwig.reiter at intevation.de>
 
 	* waskoweb/controllers/mpuls.py:

Modified: wasko/trunk/waskoweb/controllers/caselifetime.py
===================================================================
--- wasko/trunk/waskoweb/controllers/caselifetime.py	2011-05-19 13:40:41 UTC (rev 4980)
+++ wasko/trunk/waskoweb/controllers/caselifetime.py	2011-05-19 18:18:32 UTC (rev 4981)
@@ -23,21 +23,25 @@
      ReopenFormValidator2, ReopenFormValidator2abgel, \
      RenewFormValidator
 
+
 log = logging.getLogger(__name__)
 
+
 REOPENOK_1_HEADER_CONFIRM = _(u"Reopen case?")
 REOPENOK_1_TEXT_CONFIRM = _(u"""\
-Do you want to reopen the case? Then the current case document will be 
-anonymized and important parts of the case document copied from phase A and 
+Do you want to reopen the case? Then the current case document will be
+anonymized and important parts of the case document copied from phase A and
 phase B in the new case document. You will work with the new case document.""")
 
 REOPENOK_2_HEADER_CONFIRM = _(u"Do you want to reopen the case for 3 months?")
 REOPENOK_2_TEXT_CONFIRM = _(u"""\
 Do you want to reopen the case for 3 months? You can edit the case document
-again.""")       
-REOPENNOTOK_HEADER_CONFIRM = _(u"Do you want to document not accepted reopening?")
+again.""")
+REOPENNOTOK_HEADER_CONFIRM = \
+_(u"Do you want to document not accepted reopening?")
 REOPENNOTOK_TEXT_CONFIRM = _(u"""\
-You have entered, that no acceptence is available. If you continue, reopening, extension or addition will not be possible.""")
+You have entered, that no acceptence is available.\
+If you continue, reopening, extension or addition will not be possible.""")
 
 REOPENOK_1_SUCCESS_HEADER = _(u"Case document successfully reopened.")
 REOPENOK_1_SUCCESS_TEXT = _(u'''\
@@ -46,17 +50,18 @@
 
 REOPENOK_2_SUCCESS_HEADER = _(u"Case document successfully reopened.")
 REOPENOK_2_SUCCESS_TEXT = _(u'''\
-The case document has been successfully reopened. Click on OK to get to the 
+The case document has been successfully reopened. Click on OK to get to the
 entry documentation of the case document.''')
 
 REOPENNOTOK_SUCCESS_HEADER = _(u"Not accepted reopening documented.")
 REOPENNOTOK_SUCCESS_TEXT = _(u'''\
-The not accepted reopening was documented. Click on OK to get to the 
+The not accepted reopening was documented. Click on OK to get to the
 entry documentation of the case document.''')
 
-RENEW_2_HEADER_CONFIRM = _(u"Do you want to document the not accepted new subscription?")
+RENEW_2_HEADER_CONFIRM =\
+_(u"Do you want to document the not accepted new subscription?")
 RENEW_2_TEXT_CONFIRM = _(u"""\
-You entered, that no acceptence of the new subscription is available. 
+You entered, that no acceptence of the new subscription is available.
 If you continue, no new addition of this case will be possible.""")
 
 RENEW_2_SUCCESS_HEADER = _(u"Not accepted new subscription documented.")
@@ -66,8 +71,8 @@
 
 RENEW_HEADER_CONFIRM = _(u"Do you want to renew the case?")
 RENEW_TEXT_CONFIRM = _(u"""\
-Do you want to renew the case? Then the current case document will be 
-anonymized and important parts of phase A and phase B will be copied into a  
+Do you want to renew the case? Then the current case document will be
+anonymized and important parts of phase A and phase B will be copied into a
 new case document. You will work on the new case document then.""")
 
 RENEW_SUCCESS_HEADER = _(u"The case document was renewed.")
@@ -79,11 +84,11 @@
 ABORT_SUCCESS_HEADER = _(u'Entry documentation aborted.')
 ABORT_SUCCESS_TEXT = _(u'''\
 The entry documentation was successfully aborted. The case document was given
-to the administration for deletion. Click on OK to get back to the 
+to the administration for deletion. Click on OK to get back to the
 case documents overview.''')
 
 ABORT_TEXT_CONFIRM = _(u'''\
-Do you really want to abort the entry documentation and free the case document 
+Do you really want to abort the entry documentation and free the case document
 for deletion? The case document will not be editable then and will be given to
 the administration for seletion.''')
 ABORT_HEADER_CONFIRM = _(u'Do you want to abort the entry documentation?')
@@ -118,28 +123,30 @@
     if mark:
         factory = InstanceFactory(g.formedTree, PostgresDBInterface())
         it = factory.loadInstanceTreeByIdentifier(id)
-        item =  it.getItem('fn:%s' % id)
+        item = it.getItem('fn:%s' % id)
         fn = item.getValue()
         if fn:
-            fn += '_%s' % mark 
+            fn += '_%s' % mark
             data['fn:%s' % id] = fn
         else:
-            data['fn:%s' % id] = '_%s' % mark 
+            data['fn:%s' % id] = '_%s' % mark
         it.setData(data)
         it.commit()
 
 
 def doc_abschluss(id, to_id=None):
-    if to_id is None: to_id = id
+    if to_id is None:
+        to_id = id
     data = {}
     factory = InstanceFactory(g.formedTree, PostgresDBInterface())
     oit = factory.loadInstanceTreeByIdentifier(id)
     nit = factory.loadInstanceTreeByIdentifier(to_id)
 
-    data['cm_dok_end_art:%s' % to_id]          = str(_get_value(oit, 'cm_end_art', id))
-    data['cm_dok_end_verm:%s' % to_id]         = str(_get_value(oit, 'cm_end_verm', id))
-    data['cm_dok_end_sonst:%s' % to_id]        = str(_get_value(oit, 'cm_end_sonst', id))
-    data['cm_dok_datum_beendigung:%s' % to_id] = h.dd_mm_YYYY(_get_value(oit, 'datum_cm_ende', id))
+    data['cm_dok_end_art:%s' % to_id] = str(_get_value(oit, 'cm_end_art', id))
+    data['cm_dok_end_verm:%s' % to_id] = str(_get_value(oit, 'cm_end_verm', id))
+    data['cm_dok_end_sonst:%s' % to_id] = str(_get_value(oit,'cm_end_sonst',id))
+    data['cm_dok_datum_beendigung:%s' % to_id] = \
+        h.dd_mm_YYYY(_get_value(oit, 'datum_cm_ende', id))
 
     nit.setData(data)
     nit.commit()
@@ -165,7 +172,8 @@
 def _convert4Formed(data, id):
     convertet_data = {}
     for key, value in data.iteritems():
-        if key == 'cm2c_t2': continue
+        if key == 'cm2c_t2':
+            continue
         if isinstance(value, date):
             value = h.format_date(value)
         convertet_data[":".join([str(key), str(id)])] = value
@@ -187,14 +195,13 @@
     log.error('Can not find item "%s"' % real_id)
 
 def checkcase(it, id):
-
     # Check if case is anonymizable
     case = g.case_factory.loadById(id)
     try:
         case.check_anonymizeability()
         c.is_anonymizable = True
     except:
-        c.is_anonymizable = False 
+        c.is_anonymizable = False
 
     case_id = id
     D = _get_value
@@ -214,7 +221,7 @@
     # Wieviele Wiederholungen?
     log.debug('Wiederaufnahme1: %s' % D(it, 'cm_wiederauf_genehm_1', case_id))
     log.debug('Wiederaufnahme2: %s' % D(it, 'cm_wiederauf_genehm_2', case_id))
-    if D(it, 'cm_wiederauf_genehm_2', case_id) in (1,0):
+    if D(it, 'cm_wiederauf_genehm_2', case_id) in (1, 0):
         c.num_wiederaufnahme = 2
     elif D(it, 'cm_wiederauf_genehm_1', case_id) in (1,):
         c.num_wiederaufnahme = 1
@@ -250,10 +257,10 @@
 
     # Wiedervorlage anzeigen
     if (not c.disable_all
-        and (c.phase in (3,4,5) 
-             and c.erfolgreiche_reintegration
-             and c.num_wiederaufnahme < 1
-             and c.is_anonymizable)
+        and (c.phase in (3, 4, 5)
+              and c.erfolgreiche_reintegration
+              and c.num_wiederaufnahme < 1
+              and c.is_anonymizable)
         or (c.num_wiederaufnahme == 1 and c.phase not in (-1, 0, 1, 3, 4, 5))):
         c.show_wiedervorlage = True
     else:
@@ -279,7 +286,7 @@
     def index(self, id=None):
         c.form_errors = {}
         c.form_result = {}
-        c.form_defaults= {}
+        c.form_defaults = {}
         factory = InstanceFactory(g.formedTree, PostgresDBInterface())
         it = factory.loadInstanceTreeByIdentifier(id)
         case_id = it.getRootNode().getIdentifier()
@@ -296,13 +303,18 @@
         if c.num_verlaengerung == 1 and not ende_verl2:
                 ende_verl2 = ende_verl1+timedelta(days=31*3)
 
-        c.form_defaults['datum_cm_ende'] = h.dd_mm_YYYY(D(it, 'datum_cm_ende', case_id))
+        c.form_defaults['datum_cm_ende'] = h.dd_mm_YYYY(D(it, 'datum_cm_ende',
+                                                          case_id))
         c.form_defaults['cm_datum_verlaengerung_1'] = h.dd_mm_YYYY(ende_verl1)
-        c.form_defaults['cm_bestaet_verlaengerung_1'] = D(it, 'cm_bestaet_verlaengerung_1', case_id)
-        c.form_defaults['cm_anmerk_verlaengerung_1'] = D(it, 'cm_anmerk_verlaengerung_1', case_id)
+        c.form_defaults['cm_bestaet_verlaengerung_1'] = \
+            D(it, 'cm_bestaet_verlaengerung_1', case_id)
+        c.form_defaults['cm_anmerk_verlaengerung_1'] = \
+            D(it, 'cm_anmerk_verlaengerung_1', case_id)
         c.form_defaults['cm_datum_verlaengerung_2'] = h.dd_mm_YYYY(ende_verl2)
-        c.form_defaults['cm_bestaet_verlaengerung_2'] = D(it, 'cm_bestaet_verlaengerung_2', case_id)
-        c.form_defaults['cm_anmerk_verlaengerung_2'] = D(it, 'cm_anmerk_verlaengerung_2', case_id)
+        c.form_defaults['cm_bestaet_verlaengerung_2'] = \
+            D(it, 'cm_bestaet_verlaengerung_2', case_id)
+        c.form_defaults['cm_anmerk_verlaengerung_2'] = \
+            D(it, 'cm_anmerk_verlaengerung_2', case_id)
 
         # Wiederaufnahme
         wieder1_date = D(it, 'cm_wiederauf_datum_bis_1', case_id)
@@ -311,18 +323,21 @@
             if wieder1_date and not wieder2_date:
                 wieder2_date = wieder1_date+timedelta(days=31*3)
 
-        c.form_defaults['cm_wiederauf_genehm_1'] = D(it, 'cm_wiederauf_genehm_1', case_id)
-        c.form_defaults['cm_wiederauf_genehm_datum_1'] = h.dd_mm_YYYY(D(it, 'cm_wiederauf_genehm_datum_1', case_id))
-        c.form_defaults['cm_wiederauf_datum_bis_1'] = h.dd_mm_YYYY(wieder1_date) 
-        c.form_defaults['cm_wiederauf_genehm_2'] = D(it, 'cm_wiederauf_genehm_2', case_id)
-        c.form_defaults['cm_wiederauf_datum_bis_2'] = h.dd_mm_YYYY(wieder2_date)
+        c.form_defaults['cm_wiederauf_genehm_1'] = \
+            D(it, 'cm_wiederauf_genehm_1', case_id)
+        c.form_defaults['cm_wiederauf_genehm_datum_1'] = \
+            h.dd_mm_YYYY(D(it, 'cm_wiederauf_genehm_datum_1', case_id))
+        c.form_defaults['cm_wiederauf_datum_bis_1'] = h.dd_mm_YYYY(wieder1_date)
+        c.form_defaults['cm_wiederauf_genehm_2'] = \
+            D(it, 'cm_wiederauf_genehm_2', case_id)
+        c.form_defaults['cm_wiederauf_datum_bis_2'] = \
+            h.dd_mm_YYYY(wieder2_date)
         c.form_defaults['cm2c_t'] = D(it, 'cm2c_t', case_id)
 
         form = render('/caselifetime/overview.mako')
         return formencode.htmlfill.render(form,
                                           defaults=c.form_defaults)
 
-
     def changeLifetime(self):
         if request.params.has_key('wiederaufnahme'):
             return self.reopenAction()
@@ -357,7 +372,6 @@
         return self.index(id)
 
     def extraTimeAction(self):
-
         factory = InstanceFactory(g.formedTree, PostgresDBInterface())
         it = factory.loadInstanceTreeByIdentifier(session['case'].id)
         case_id = it.getRootNode().getIdentifier()
@@ -378,11 +392,11 @@
             form_result = validator.to_python(request.params)
             try:
                 # Save method will also do semantic check (dates or in
-                # chronology correct order) 
+                # chronology correct order)
                 S(it, form_result, case_id)
                 create_logbook(header=_('Extension of the integration process'),
                                text=_('For this case a extension of the '
-                                      'integration process was documented.'))
+                                       'integration process was documented.'))
                 return self.index(session['case'].id)
             except SetDataException, err:
                 form_result_1, form_errors = toErrorDicts(err)
@@ -393,9 +407,9 @@
         form_errors = form_errors
         form_result = form_result
         form = render('/caselifetime/overview.mako')
-        return formencode.htmlfill.render(form, 
+        return formencode.htmlfill.render(form,
                                           defaults=form_result,
-                                          errors=form_errors) 
+                                          errors=form_errors)
 
     def renew_ok(self, id, confirmed='0'):
         factory = InstanceFactory(g.formedTree, PostgresDBInterface())
@@ -404,7 +418,8 @@
             new_case = None
             try:
                 it = factory.loadInstanceTreeByIdentifier(id)
-                # Lege neuen Fall an, es sollen aber nur bestimmte Felder kopiert werden
+                # Lege neuen Fall an, es sollen aber nur bestimmte
+                # Felder kopiert werden
                 fields = []
                 for section in ['ee', 'phase-a', 'group-5']:
                     node = it.getItem("%s:%s" % (section, id))
@@ -413,18 +428,19 @@
                         if name not in COPY_BLACK_LIST:
                             fields.append(name)
                         else:
-                            log.info('Not copying %s as it is in COPY_BLACK_LIST' % name)
-                new_it = copy_instance_tree(it,fields)
+                            log.info('Not copying %s as it is in'
+                                     ' COPY_BLACK_LIST' % name)
+                new_it = copy_instance_tree(it, fields)
                 new_id = new_it.getRootNode().getIdentifier()
                 data['phase'] = '-1'
                 data['cm2c'] = '1'
                 doc_abschluss(id, new_id)
-                # Dokumentiere Neuaufnahme in neuem Fall 
+                # Dokumentiere Neuaufnahme in neuem Fall
                 save_formdata(new_id, data)
                 mark_case(new_id, 'NA')
                 create_logbook(id=new_id, header=_('Addition'),
                                text=_('For this case an addition of the '
-                                     'integration process was documented.'))
+                                       'integration process was documented.'))
 
                 # markiere den alten Fall zur Anonymisierung
                 old_case = g.case_factory.loadById(id)
@@ -432,9 +448,9 @@
                 mark_case(old_case.id, 'NAU')
                 create_logbook(header=_('Addition'),
                                text=_('For this case an addition of the '
-                                     'integration process was documented.'))
+                                       'integration process was documented.'))
             except Exception, err:
-                traceback.print_exc(file = sys.stderr)
+                traceback.print_exc(file=sys.stderr)
 
             c.success_for = RENEW_SUCCESS_HEADER
             c.success_text = RENEW_SUCCESS_TEXT
@@ -454,8 +470,8 @@
                 save_formdata(id, data)
                 create_logbook(id=id, header=_('Addition'),
                                text=_('For this case a not accepted addition '
-                                      'of the integration process '
-                                      'was documented.'))
+                                       'of the integration process '
+                                       'was documented.'))
 
             except Exception, err:
                 log.exception('Error in renew_notok')
@@ -463,7 +479,7 @@
             c.success_for = RENEW_2_SUCCESS_HEADER
             c.success_text = RENEW_2_SUCCESS_TEXT
             c.url_ok = h.url_for(controller="formularpage",
-                                 action="select", 
+                                 action="select",
                                  id="page-0:%s" % id)
             return render('caselifetime/dialogs/success_reopen.mako')
         else:
@@ -479,31 +495,36 @@
         checkcase(it, id)
         if confirmed == '1':
             try:
-                data = session['lifetimeparams'] 
+                data = session['lifetimeparams']
                 if c.num_wiederaufnahme < 1:
                     ## Dokumentiere Daten im alten Fall!
                     #save_formdata(id, data)
                     ## Reload case after saving data
                     #it = factory.loadInstanceTreeByIdentifier(id)
 
-                    # Lege neuen Fall an, es sollen aber nur bestimmte Felder kopiert werden
+                    # Lege neuen Fall an, es sollen aber nur bestimmte
+                    # Felder kopiert werden
                     fields = []
-                    for section in ['ee', 'phase-a', 'group-5', 'group-18', 'group-27']:
+                    for section in ['ee', 'phase-a', 'group-5', 'group-18',
+                                    'group-27']:
                         node = it.getItem("%s:%s" % (section, id))
                         for field in walk_it(node):
                             name = field.getIdentifier().split(':')[0]
                             if name not in COPY_BLACK_LIST:
                                 fields.append(name)
                             else:
-                                log.info('Not copying %s as it is in COPY_BLACK_LIST' % name)
-                    new_it = copy_instance_tree(it,fields)
+                                log.info('Not copying %s as it is in'
+                                         ' COPY_BLACK_LIST' % name)
+                    new_it = copy_instance_tree(it, fields)
                     new_id = new_it.getRootNode().getIdentifier()
-                    
+
                     doc_abschluss(id, new_id)
-                    # Copy Datum der Wiederaufnahme in Erstgespräch und Beginn des CM 
+                    # Copy Datum der Wiederaufnahme in Erstgespräch und
+                    # Beginn des CM
                     data['datum_cm_start'] = data['cm_wiederauf_genehm_datum_1']
                     data['erstgespraech'] = data['cm_wiederauf_genehm_datum_1']
-                    # delete 'datum_cm_ende' as it must not be written in the new case
+                    # delete 'datum_cm_ende' as it must not be written
+                    # in the new case
                     del data['datum_cm_ende']
                     data = _convert4Formed(data, new_id)
                     data['phase:%s' % new_id] = '2'
@@ -515,18 +536,18 @@
                     mark_case(new_id, 'WA')
                     create_logbook(id=new_id, header=_('Reopening'),
                                    text=_('For this case an accepted reopening '
-                                         'of the integration process was '
-                                         'documented.'))
+                                           'of the integration process was '
+                                           'documented.'))
 
                     ## Markiere alten Fall zur Anonymisierung
                     old_case = g.case_factory.loadById(id)
                     old_case.setState(4)
                     mark_case(old_case.id, 'WAU')
                     create_logbook(id=id, header=_('Reopening'),
-                                   text=_('For this case a reopening of the ' 
-                                          'integration process was done '
-                                          'in a new case document.'
-                                         ))
+                                   text=_('For this case a reopening of the '
+                                           'integration process was done '
+                                           'in a new case document.'
+                                           ))
                 else:
 
 
@@ -535,21 +556,21 @@
                     save_formdata(id, data)
                     create_logbook(header=_('Extension reopening'),
                                    text=_('For this case an accepted extension '
-                                         'of the reopening of the '
-                                         'integration process was documented.'))
+                                           'of the reopening of the integration'
+                                           ' process was documented.'))
             except Exception, err:
                 log.exception(err.__dict__)
             if c.num_wiederaufnahme < 1:
                 id = new_it.getRootNode().getIdentifier()
                 c.success_for = REOPENOK_1_SUCCESS_HEADER
                 c.success_text = REOPENOK_1_SUCCESS_TEXT
-                c.url_ok = h.url_for(controller="/case", 
+                c.url_ok = h.url_for(controller="/case",
                                      action="select",
                                      id="%s" % id)
             else:
                 c.success_for = REOPENOK_2_SUCCESS_HEADER
                 c.success_text = REOPENOK_2_SUCCESS_TEXT
-                c.url_ok = h.url_for(controller="/formularpage", 
+                c.url_ok = h.url_for(controller="/formularpage",
                                      action="select",
                                      id="page-0:%s" % id)
             return render('caselifetime/dialogs/success_reopen.mako')
@@ -578,8 +599,8 @@
                 save_formdata(id, data)
                 create_logbook(header=_('Reopening'),
                                text=_('For this case a not accepted reopening '
-                                     'of the integration process '
-                                     'was documented.'))
+                                       'of the integration process '
+                                       'was documented.'))
             except Exception, err:
                 print err
 
@@ -638,12 +659,11 @@
             form_errors = error.error_dict or {}
 
         form = render('/caselifetime/overview.mako')
-        return formencode.htmlfill.render(form, 
+        return formencode.htmlfill.render(form,
                                           defaults=form_result,
                                           errors=form_errors)
 
     def renewAction(self):
-
         factory = InstanceFactory(g.formedTree, PostgresDBInterface())
         it = factory.loadInstanceTreeByIdentifier(session['case'].id)
         case_id = it.getRootNode().getIdentifier()
@@ -659,7 +679,7 @@
             session['lifetimeparams'] = form_result
             session.save()
             try:
-                S(it, form_result, case_id, do_write = False)
+                S(it, form_result, case_id, do_write=False)
                 if form_result.get('cm_neuauf_genehm') == '1':
                     return self.renew_ok(case_id)
                 else:
@@ -677,4 +697,3 @@
         return formencode.htmlfill.render(form,
                                           defaults=form_result,
                                           errors=form_errors)
-



More information about the Mpuls-commits mailing list