[Mpuls-commits] r2828 - in base/trunk: . mpulsweb/controllers mpulsweb/lib mpulsweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon May 31 12:04:41 CEST 2010


Author: torsten
Date: 2010-05-31 12:04:37 +0200 (Mon, 31 May 2010)
New Revision: 2828

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/controllers/evaluate.py
   base/trunk/mpulsweb/lib/helpers.py
   base/trunk/mpulsweb/model/phase.py
Log:
Merged



Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-05-31 10:04:21 UTC (rev 2827)
+++ base/trunk/ChangeLog	2010-05-31 10:04:37 UTC (rev 2828)
@@ -1,3 +1,25 @@
+2010-05-28  Bernhard Herzog  <bh at intevation.de>
+
+	* mpulsweb/model/phase.py: Remove unused imports.
+
+2010-05-28  Bernhard Herzog  <bh at intevation.de>
+
+	* mpulsweb/model/phase.py (Field.get_link): Use h.url_for
+	consistently for all-intra application URLs.
+
+2010-05-28  Bernhard Herzog  <bh at intevation.de>
+
+	* mpulsweb/model/phase.py (Field.get_link): Use the tag function
+	to generate tags with attributes.
+
+2010-05-28  Bernhard Herzog  <bh at intevation.de>
+
+	* mpulsweb/controllers/evaluate.py (get_phasesuccessors): New.
+	Moved here from helpers.
+
+	* mpulsweb/lib/helpers.py (get_phasesuccessors): Removed.  It's
+	now in controllers/evaluate.py
+
 2010-05-27  Bernhard Herzog  <bh at intevation.de>
 
 	* mpulsweb/lib/helpers.py (tag): Moved here from renderer because

Modified: base/trunk/mpulsweb/controllers/evaluate.py
===================================================================
--- base/trunk/mpulsweb/controllers/evaluate.py	2010-05-31 10:04:21 UTC (rev 2827)
+++ base/trunk/mpulsweb/controllers/evaluate.py	2010-05-31 10:04:37 UTC (rev 2828)
@@ -49,6 +49,20 @@
     log.debug('sdate: %s, edate: %s' % (sdate, edate))
     return sdate, edate
 
+
+def get_phasesuccessors(p):
+    suc = []
+    phaselist = PhaseFactory().build()
+    for phase in phaselist:
+        if p == phase.id:
+            suc.append(phase.start.id)
+            suc.append(phase.end.id)
+            for ppid in phase.end.suc:
+                pp = phaselist.get_phase(ppid)
+                suc.extend(get_phasesuccessors(pp.phase))
+    return suc
+
+
 def get_search_options(soptions=None, id=None):
     options = {}
     options['id'] = id

Modified: base/trunk/mpulsweb/lib/helpers.py
===================================================================
--- base/trunk/mpulsweb/lib/helpers.py	2010-05-31 10:04:21 UTC (rev 2827)
+++ base/trunk/mpulsweb/lib/helpers.py	2010-05-31 10:04:37 UTC (rev 2828)
@@ -51,7 +51,6 @@
 
 from mpulsweb.lib.navigation import get_pagename, render_navigation
 from mpulsweb.lib.helper.filters import shorten, nl_to_br, NA
-from mpulsweb.model.phase import PhaseFactory 
 
 
 PRINTABLE = frozenset(printable)
@@ -328,23 +327,4 @@
         return empty
     return dd_mm_YYYY(d) + " " + HH_MM(d)
 
-# Phases helpers. Used in evaluation
-
-# TODO: The functions are currently only used in lib.evaluation and are
-# basically a copy of those functions in model/phase_transition.py with the
-# difference that these function load phases from g.mpuls. The longterm
-# solution would be to transfer phase functionality into the libformed. So
-# these functions should be moved away from this place
-
-def get_phasesuccessors(p):
-    suc = []
-    phaselist = PhaseFactory().build()
-    for phase in phaselist:
-        if p == phase.id:
-            suc.append(phase.start.id)
-            suc.append(phase.end.id)
-            for ppid in phase.end.suc:
-                pp = phaselist.get_phase(ppid)
-                suc.extend(get_phasesuccessors(pp.phase))
-    return suc
 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

Modified: base/trunk/mpulsweb/model/phase.py
===================================================================
--- base/trunk/mpulsweb/model/phase.py	2010-05-31 10:04:21 UTC (rev 2827)
+++ base/trunk/mpulsweb/model/phase.py	2010-05-31 10:04:37 UTC (rev 2828)
@@ -3,13 +3,14 @@
 import logging
 import re
 
-from pylons import session, g, c
+from pylons import g, c
 from pylons.i18n import _
 
 from formed.instance.backends.postgres import DBFactory as InstanceFactory
 from formed.instance.backends.common import RuleEvalContext
-from formed.instance.tree import InstanceLeaf, PageInstanceNode, RepeatInstanceContainerNode 
+from formed.instance.tree import InstanceLeaf, PageInstanceNode
 
+from mpulsweb.lib.helpers import tag, url_for
 from mpulsweb.lib.db import PostgresDBInterface
 
 
@@ -363,8 +364,11 @@
         out = []
         style = self.is_ok() and "ok" or "error"
         element_id = ":".join(self.id.split(':')[1:])
-        out.append('<a class="%s" href="/formularpage/select/%s:%s#%s:%s">'
-                   % (style, self.page, element_id, self.name, element_id))
+        out.append(tag("a", class_=style,
+                       href=url_for(controller='/formularpage', action='select',
+                                    id=('%s:%s' % (self.page, element_id)),
+                                    anchor=('%s:%s' % (self.name,
+                                                       element_id)))))
         out.append('%s' % self.label)
         out.append('</a>')
         return "".join(out)



More information about the Mpuls-commits mailing list