[Mpuls-commits] r2721 - in base/trunk: . mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed May 19 16:12:21 CEST 2010


Author: bh
Date: 2010-05-19 16:12:20 +0200 (Wed, 19 May 2010)
New Revision: 2721

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/lib/renderer.py
Log:
* mpulsweb/lib/renderer.py: fix formatting.


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-05-19 09:51:04 UTC (rev 2720)
+++ base/trunk/ChangeLog	2010-05-19 14:12:20 UTC (rev 2721)
@@ -1,3 +1,7 @@
+2010-05-19  Bernhard Herzog  <bh at intevation.de>
+
+	* mpulsweb/lib/renderer.py: fix formatting.
+
 2010-05-17  Torsten Irländer <torsten.irlaender at intevation.de>
 
 	* mpulsweb/lib/config.py: Disabled tagging on default (Work in

Modified: base/trunk/mpulsweb/lib/renderer.py
===================================================================
--- base/trunk/mpulsweb/lib/renderer.py	2010-05-19 09:51:04 UTC (rev 2720)
+++ base/trunk/mpulsweb/lib/renderer.py	2010-05-19 14:12:20 UTC (rev 2721)
@@ -235,19 +235,15 @@
                        ' accept-charset="UTF-8" method="POST">\n')
             # Add submitbutton at the top of the page too
             out.append('<div class="widget formbuttons">')
-            out.append(tag("input",type="submit",
-                        name="save",
-                        class_="submit_button",
-                        value=_('Save'),
-                        tabindex=self.next_tabindex()))
+            out.append(tag("input", type="submit", name="save",
+                           class_="submit_button", value=_('Save'),
+                           tabindex=self.next_tabindex()))
             if showNext:
                 out.append("&nbsp;")
-                out.append(tag("input",
-                            type="submit",
-                            name="savenext",
-                            class_="submit_button",
-                            value=_('Save and proceed'),
-                            tabindex=self.next_tabindex()))
+                out.append(tag("input", type="submit", name="savenext",
+                               class_="submit_button",
+                               value=_('Save and proceed'),
+                               tabindex=self.next_tabindex()))
             out.append('</div>')
         out.append('<div>')
         #out.append('<div class="widget formfields">')
@@ -263,20 +259,15 @@
         out.append('</div>')
         if not self.ro_mode:
             out.append('<div class="widget formbuttons">')
-            out.append(tag("input",
-                        type="submit",
-                        class_="submit_button",
-                        name="save",
-                        value=_('Save'),
+            out.append(tag("input", type="submit", class_="submit_button",
+                           name="save", value=_('Save'),
                            tabindex=self.next_tabindex()))
             if showNext:
                 out.append("&nbsp;")
-                out.append(tag("input",
-                            type="submit",
-                            name="savenext",
-                            class_="submit_button",
-                            value=_('Save and proceed'),
-                            tabindex=self.next_tabindex()))
+                out.append(tag("input", type="submit", name="savenext",
+                               class_="submit_button",
+                               value=_('Save and proceed'),
+                               tabindex=self.next_tabindex()))
             out.append('</div>')
             out.append('</form>\n')
 
@@ -308,7 +299,7 @@
         meta = self._getMeta(node)
         out = []
         warning = node.getIdentifier() in self.warnings and "warning" or ""
-        error   = node.hasErrors() and "error" or ""
+        error = node.hasErrors() and "error" or ""
         if labeltag:
             out.append(tag("label", for_=node.getIdentifier()))
             out.append(tag("a", class_=error or warning,
@@ -335,8 +326,8 @@
                            href="/annotations/required/%s" % meta.getName(),
                            target="_blank"))
             out.append('<img src="/images/icons/formular/required.png"'
-                        ' width="12"'
-                        ' height="12"'
+                       ' width="12"'
+                       ' height="12"'
                        ' alt="required">')
             out.append('</a>')
         if is_evaluation_relevant(meta.getFlags()):
@@ -361,11 +352,10 @@
             spanClass = 'error'
 
         out.append('<span class="%s">' % spanClass)
-        out.append(tag("form:%s" % spanClass,
-                name      = node.getIdentifier(),
-                format    = ''))
+        out.append(tag("form:%s" % spanClass, name=node.getIdentifier(),
+                       format=''))
         out.append('</span>')
-        
+
         return "".join(out)
 
     def _checkWarnings(self, node):
@@ -442,9 +432,9 @@
             out.append('</td>')
             out.append('<td class="vcontrol" width="15">')
             if not self.ro_mode:
-                out.append('''<input name="del_rg" 
-                            type="image" 
-                            src="/images/icons/delete_active_16.png" 
+                out.append('''<input name="del_rg"
+                            type="image"
+                            src="/images/icons/delete_active_16.png"
                             value="%s"
                             alt="%s"
                             title="%s">''' % (child.getIdentifier(),
@@ -459,9 +449,9 @@
             out.append('<tr>')
             out.append('<td class="hcontrol" style="text-align: right;"'
                        ' colspan="2">')
-            out.append('''<input width="16" 
-                        name="add_rg" 
-                        type="image" src="/images/icons/new_16.png" 
+            out.append('''<input width="16"
+                        name="add_rg"
+                        type="image" src="/images/icons/new_16.png"
                         value="%s"
                         alt="%s"
                         title="%s">''' % (node.getIdentifier(),
@@ -554,8 +544,8 @@
 
     def _renderText(self, node):
         meta = self._getMeta(node)
-        out  = []
-        id   = node.getIdentifier()
+        out = []
+        id = node.getIdentifier()
         out.append(self._renderLabel(node))
         out.append(self._renderAttributes(node))
         out.append('<br>')
@@ -649,22 +639,17 @@
         self.toTarget(Item("".join(out)), meta.getTarget())
 
     def _renderPlainBool(self, node):
-        meta   = self._getMeta(node)
-        id     = node.getIdentifier()
+        meta = self._getMeta(node)
+        id = node.getIdentifier()
         mvalue = meta.getValue()
-        value  = node.getValue()
+        value = node.getValue()
         #checked = self.stateStack[-1] == value and "checked" or ""
         #print "mvalue: %s value: %s" % (mvalue, value)
         out = []
-        out.append(tag("input",
-                        type   = "checkbox",
-                        class_ = "checkbox",
-                        id     = id,
-                        name   = id,
-                        value  = "1",
-                        disabled = self.ro_mode,
-                        checked  = (value == 1),
-                        tabindex = self.next_tabindex(),
+        out.append(tag("input", type="checkbox", class_="checkbox",
+                       id=id, name=id, value="1", disabled=self.ro_mode,
+                       checked=(value == 1),
+                       tabindex=self.next_tabindex(),
                        **SET_MODIFICATION_ATTRS))
         out.append(hidden_bool_tag(id))
         out.append(self._renderLabel(node))
@@ -719,7 +704,7 @@
         except:
             toSelect = None
         selected = toSelect == (value or value==0) and "selected" or ""
-        
+
         if selected:
             selected = selected + '="' + selected + '"'
 
@@ -750,7 +735,7 @@
 
         # write table header
         nr_of_children = len(self._getMeta(node.getChildren()[0]).children) + 1
-        
+
         out.append('<thead>')
         out.append('<tr>')
         out.append('<th class="label" colspan="%s">' % nr_of_children)
@@ -758,7 +743,7 @@
         out.append(self._renderAttributes(node))
         out.append('</th>')
         out.append('</tr>')
-        
+
         out.append('<tr>')
         out.append('<th></th>')
         for hcol in self._getMeta(node.getChildren()[0]).children:
@@ -839,18 +824,17 @@
 
     def _renderExternalChoiceList(self, choiceList):
         out = []
-        
+
         # Sort the list according to the target
         children = sorted(choiceList.getChildren(),
-                        key     = lambda child: child.getTarget(),
-                        reverse = True)
-        
+                          key=lambda child: child.getTarget(),
+                          reverse=True)
+
         if children:
             for child in children:
                 value = child.getValue()
-                out.append(tag("option",
-                               value    = value,
-                               selected = (value == self.stateStack[-1])))
+                out.append(tag("option", value=value,
+                               selected=(value == self.stateStack[-1])))
                 out.append(escape(child.getDescription()))
                 out.append("</option>")
         self.toTarget(Text("\n".join(out)),
@@ -935,7 +919,8 @@
         out = []
         case_id = rg.getIdentifier().split(':')[-1]
 
-        fields = self.rg_digests.get(self._getMeta(rg).getName(), []).get('fields')
+        fields = self.rg_digests.get(self._getMeta(rg).getName(),
+                                     []).get('fields')
         log.debug(fields)
 
         out.append('<table class="rgdigest">')
@@ -973,7 +958,7 @@
                     for child in childs:
                         if str(child.getValue()) == str(value):
                             value = child.getDescription()
-                            break;
+                            break
                 out.append('%s' % NA(value))
                 out.append('</a>')
                 out.append('</td>')
@@ -982,7 +967,6 @@
         return "".join(out)
 
     def render(self, showNext=False):
-
         out = []
         out.append('<div class="widget">')
         out.append('<table class="list">')
@@ -991,25 +975,33 @@
                       escape(_('Actions'))))
         items = self.page.getChildren()
 
-        # Sorting of RG. 
+        # Sorting of RG.
         class SortDummy:
             def __init__(self, rg, it, case_id, field):
                 self.rg = rg
-                self.value = str(it.getItem('%s:%s:%s' % (field, rg.getInternalIdentifier(), case_id)).getValue())
+                self.value = str(it.getItem('%s:%s:%s'
+                                            % (field,
+                                               rg.getInternalIdentifier(),
+                                               case_id)).getValue())
 
         unsorted_items = []
-        reverse_order = False 
+        reverse_order = False
         if len(items) > 0:
             rg = items[0]
             case_id = rg.getIdentifier().split(':')[-1]
-            fields = self.rg_digests.get(self._getMeta(rg).getName(), []).get('fields')
-            sort_field = self.rg_digests.get(self._getMeta(rg).getName(), []).get('sort_field', fields[0])
-            sort_order = self.rg_digests.get(self._getMeta(rg).getName(), []).get('sort_order')
+            fields = self.rg_digests.get(self._getMeta(rg).getName(),
+                                         []).get('fields')
+            sort_field = self.rg_digests.get(self._getMeta(rg).getName(),
+                                             []).get('sort_field', fields[0])
+            sort_order = self.rg_digests.get(self._getMeta(rg).getName(),
+                                             []).get('sort_order')
             for rg in items:
-                unsorted_items.append(SortDummy(rg, self.it, case_id, sort_field))
+                unsorted_items.append(SortDummy(rg, self.it, case_id,
+                                                sort_field))
             if sort_order == "desc":
                 reverse_order = True
-        sorted_items = sorted(unsorted_items, key=lambda rg: rg.value, reverse=reverse_order)
+        sorted_items = sorted(unsorted_items, key=lambda rg: rg.value,
+                              reverse=reverse_order)
 
         for num, rg in enumerate([sd.rg for sd in sorted_items]):
             out.append('<tr>')
@@ -1019,8 +1011,8 @@
             out.append('<td class="actions">')
             out.append(tag("a", href=("/navigation/select_branch/%s"
                                       % rg.getChildren()[0].getIdentifier())))
-            out.append(tag("img", src="/images/icons/open_active_22.png", border="0",
-                           alt=_('view'), title=_('view')))
+            out.append(tag("img", src="/images/icons/open_active_22.png",
+                           border="0", alt=_('view'), title=_('view')))
             out.append("</a>")
             if not self.ro_mode:
                 out.append(tag("a", href=("/repeatgroup/delete/%s"
@@ -1057,17 +1049,17 @@
 
         out = []
         out.append(self.render_items(self.error_items,
-                                    _('Formular errors'),
-                                    "/images/icons/info/alert.png",
-                                    tree))
+                                     _('Formular errors'),
+                                     "/images/icons/info/alert.png",
+                                     tree))
         out.append(self.render_items(self.warnings,
-                                    _('Formular warnings'),
-                                    "/images/icons/info/info.png",
-                                    tree,
-                                    css_class = 'warning-box'))
+                                     _('Formular warnings'),
+                                     "/images/icons/info/info.png",
+                                     tree,
+                                     css_class = 'warning-box'))
         return "".join(out)
 
-    def render_items(self, items, title, icon, tree, css_class = ""):
+    def render_items(self, items, title, icon, tree, css_class=""):
         if not items:
             return ""
 
@@ -1089,12 +1081,10 @@
             for v in values:
                 out.append('<li>')
                 out.append(tag("a", href="/formularpage/undo/%s" % k))
-                out.append(tag("img",
-                               src    = "/images/icons/formular/undo.png",
-                               border = "0",
-                               alt    = "undo",
-                               title  = _('Restore last valid value'),
-                               _close = True))
+                out.append(tag("img", src="/images/icons/formular/undo.png",
+                               border="0", alt="undo",
+                               title=_('Restore last valid value'),
+                               _close=True))
                 out.append('</a>')
                 out.append(tag("a", class_="error", href="#f_%s" % k))
                 out.append("%s:</a>" % escape(description))



More information about the Mpuls-commits mailing list