Skip to content

Commit 370063b

Browse files
author
Richard Jones
committed
Remeber values in edit/new submission error pages.
Some work done on query editing (search refinement) Fixed logout link to work with cgi-bin
1 parent 25b3a0c commit 370063b

File tree

5 files changed

+46
-15
lines changed

5 files changed

+46
-15
lines changed

TODO.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ pending web: Quick help links next to the property labels giving a
4141
pending web: clicking on a group header should filter for that type of entry
4242
pending web: re-enable auth by basic http auth
4343
pending web: search "refinement"
44-
- pre-fill the search page with the current search parameters)
45-
- add a drop-down with all queries which fills form with selected
46-
query values
44+
- pre-fill the search page with the current search parameters
4745
pending web: UNIX init.d script for roundup-server
4846
pending web: rewritten documentation (can come after the beta though so stuff
4947
is settled) ... including relevant file names in customisation doc

roundup/cgi/templating.py

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,17 @@ def classes(self):
202202
l = self._client.db.classes.keys()
203203
l.sort()
204204
return [HTMLClass(self._client, cn) for cn in l]
205-
205+
206+
def lookupIds(db, prop, ids, num_re=re.compile('-?\d+')):
207+
cl = db.getclass(prop.classname)
208+
l = []
209+
for entry in ids:
210+
if num_re.match(entry):
211+
l.append(entry)
212+
else:
213+
l.append(cl.lookup(entry))
214+
return l
215+
206216
class HTMLClass:
207217
''' Accesses through a class (either through *class* or *db.<classname>*)
208218
'''
@@ -232,13 +242,29 @@ def __getitem__(self, item):
232242
prop = self._props[item]
233243

234244
# look up the correct HTMLProperty class
245+
form = self._client.form
235246
for klass, htmlklass in propclasses:
236-
if isinstance(prop, hyperdb.Multilink):
237-
value = []
247+
if not isinstance(prop, klass):
248+
continue
249+
if form.has_key(item):
250+
if isinstance(prop, hyperdb.Multilink):
251+
value = lookupIds(self._db, prop,
252+
handleListCGIValue(form[item]))
253+
elif isinstance(prop, hyperdb.Link):
254+
value = form[item].value.strip()
255+
if value:
256+
value = lookupIds(self._db, prop, [value])[0]
257+
else:
258+
value = None
259+
else:
260+
value = form[item].value.strip() or None
238261
else:
239-
value = None
240-
if isinstance(prop, klass):
241-
return htmlklass(self._client, '', prop, item, value)
262+
if isinstance(prop, hyperdb.Multilink):
263+
value = []
264+
else:
265+
value = None
266+
print (prop, value)
267+
return htmlklass(self._client, '', prop, item, value)
242268

243269
# no good
244270
raise KeyError, item
@@ -987,7 +1013,10 @@ def handleListCGIValue(value):
9871013
if isinstance(value, type([])):
9881014
return [value.value for value in value]
9891015
else:
990-
return value.value.split(',')
1016+
value = value.value.strip()
1017+
if not value:
1018+
return []
1019+
return value.split(',')
9911020

9921021
class ShowDict:
9931022
''' A convenience access to the :columns index parameters

roundup/templates/classic/html/issue.item

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
<td>
2424
<span tal:replace="structure python:context.superseder.field(showid=1, size=20)" />
2525
<span tal:replace="structure python:db.issue.classhelp('id,title', label='list', width=500)" />
26-
<span tal:condition="context/superseder">
27-
<br>View: <span tal:replace="structure python:context.superseder.link(showid=1)" />
26+
<span tal:condition="context/superseder" tal:repeat="sup context/superseder">
27+
<br>View: <a tal:attributes="href string:issue${sup/id}"
28+
tal:content="sup/id"></a>
2829
</span>
2930
</td>
3031
<th nowrap>Nosy List</th>

roundup/templates/classic/html/issue.search

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
<tr>
2020
<th>All text*:</th>
21-
<td><input name=":search_text"></td>
21+
<td><input name=":search_text"
22+
tal:attributes="value request/form/:search_text/value | nothing">
23+
</td>
2224
<td>&nbsp;</td>
2325
<td>&nbsp;</td>
2426
<td>&nbsp;</td>
@@ -137,7 +139,8 @@
137139

138140
<tr>
139141
<th>Query name**:</th>
140-
<td><input name=":queryname">
142+
<td><input name=":queryname"
143+
tal:attributes="value request/form/:queryname/value | nothing">
141144
</td>
142145
</tr>
143146

roundup/templates/classic/html/page

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
<b>Hello,</b><br><b tal:content="request/user/username">username</b><br>
6262
<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>
6363
<a tal:attributes="href string:user${request/user/id}">My Details</a><br>
64-
<a tal:attributes="href python:request.indexargs_href(request.url,
64+
<a tal:attributes="href python:request.indexargs_href('',
6565
{':action':'logout'})">Logout</a>
6666
</p>
6767
</td>

0 commit comments

Comments
 (0)