Code

Remeber values in edit/new submission error pages.
authorrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Tue, 10 Sep 2002 23:05:00 +0000 (23:05 +0000)
committerrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Tue, 10 Sep 2002 23:05:00 +0000 (23:05 +0000)
Some work done on query editing (search refinement)
Fixed logout link to work with cgi-bin

git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1125 57a73879-2fb5-44c3-a270-3262357dd7e2

TODO.txt
roundup/cgi/templating.py
roundup/templates/classic/html/issue.item
roundup/templates/classic/html/issue.search
roundup/templates/classic/html/page

index 542e3da0b2a30c2a81607a3eea13a2960dd9a7ec..8670986f1d94fc402cb622a4665de7543ecbb564 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -41,9 +41,7 @@ pending web: Quick help links next to the property labels giving a
 pending web: clicking on a group header should filter for that type of entry
 pending web: re-enable auth by basic http auth
 pending web: search "refinement"
-             - pre-fill the search page with the current search parameters)
-             - add a drop-down with all queries which fills form with selected
-               query values
+             - pre-fill the search page with the current search parameters
 pending web: UNIX init.d script for roundup-server
 pending web: rewritten documentation (can come after the beta though so stuff
              is settled) ... including relevant file names in customisation doc
index 3e34c043a1d916a98603cc85c7e17a48e3325e6a..b458c6c7e2a932fb8bf3cebe9f6c54b76c1f9a49 100644 (file)
@@ -202,7 +202,17 @@ class HTMLDatabase:
         l = self._client.db.classes.keys()
         l.sort()
         return [HTMLClass(self._client, cn) for cn in l]
-        
+
+def lookupIds(db, prop, ids, num_re=re.compile('-?\d+')):
+    cl = db.getclass(prop.classname)
+    l = []
+    for entry in ids:
+        if num_re.match(entry):
+            l.append(entry)
+        else:
+            l.append(cl.lookup(entry))
+    return l
+
 class HTMLClass:
     ''' Accesses through a class (either through *class* or *db.<classname>*)
     '''
@@ -232,13 +242,29 @@ class HTMLClass:
         prop = self._props[item]
 
         # look up the correct HTMLProperty class
+        form = self._client.form
         for klass, htmlklass in propclasses:
-            if isinstance(prop, hyperdb.Multilink):
-                value = []
+            if not isinstance(prop, klass):
+                continue
+            if form.has_key(item):
+                if isinstance(prop, hyperdb.Multilink):
+                    value = lookupIds(self._db, prop,
+                        handleListCGIValue(form[item]))
+                elif isinstance(prop, hyperdb.Link):
+                    value = form[item].value.strip()
+                    if value:
+                        value = lookupIds(self._db, prop, [value])[0]
+                    else:
+                        value = None
+                else:
+                    value = form[item].value.strip() or None
             else:
-                value = None
-            if isinstance(prop, klass):
-                return htmlklass(self._client, '', prop, item, value)
+                if isinstance(prop, hyperdb.Multilink):
+                    value = []
+                else:
+                    value = None
+            print (prop, value)
+            return htmlklass(self._client, '', prop, item, value)
 
         # no good
         raise KeyError, item
@@ -987,7 +1013,10 @@ def handleListCGIValue(value):
     if isinstance(value, type([])):
         return [value.value for value in value]
     else:
-        return value.value.split(',')
+        value = value.value.strip()
+        if not value:
+            return []
+        return value.split(',')
 
 class ShowDict:
     ''' A convenience access to the :columns index parameters
index 2d6d09ba7b1f5e7f69546841c7c5d168e5861ea6..8c653f6a27769dd56a02ff577519810cd02663b0 100644 (file)
@@ -23,8 +23,9 @@
  <td>
   <span tal:replace="structure python:context.superseder.field(showid=1, size=20)" />
   <span tal:replace="structure python:db.issue.classhelp('id,title', label='list', width=500)" />
-  <span tal:condition="context/superseder">
-   <br>View: <span tal:replace="structure python:context.superseder.link(showid=1)" />
+  <span tal:condition="context/superseder" tal:repeat="sup context/superseder">
+   <br>View: <a tal:attributes="href string:issue${sup/id}"
+                tal:content="sup/id"></a>
   </span>
  </td>
  <th nowrap>Nosy List</th>
index 0444c622cc572211283384de3c3adc2b3c320e46..c5899904a5709090d49c8a357c721a6b597aa961 100644 (file)
@@ -18,7 +18,9 @@
 
 <tr>
  <th>All text*:</th>
- <td><input name=":search_text"></td>
+ <td><input name=":search_text"
+            tal:attributes="value request/form/:search_text/value | nothing">
+ </td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
 
 <tr>
 <th>Query name**:</th>
-<td><input name=":queryname">
+<td><input name=":queryname"
+            tal:attributes="value request/form/:queryname/value | nothing">
 </td>
 </tr>
 
index 8a6404e155b5234d4539127b01a989c11cc91b0a..ff11246e6aa1a69a9550a1c11a60d46f40598dc0 100644 (file)
@@ -61,7 +61,7 @@
    <b>Hello,</b><br><b tal:content="request/user/username">username</b><br>
    <a tal:attributes="href string:issue?:sort=-activity&:group=priority&:filter=status,assignedto&:columns=id,activity,title,creator,status&status=-1,1,2,3,4,5,6,7&assignedto=${request/user/id}">My Issues</a><br>
    <a tal:attributes="href string:user${request/user/id}">My Details</a><br>
-   <a tal:attributes="href python:request.indexargs_href(request.url,
+   <a tal:attributes="href python:request.indexargs_href('',
        {':action':'logout'})">Logout</a>
   </p>
  </td>