From 863c10789530a953e9c35b0d95e7c6473db84099 Mon Sep 17 00:00:00 2001 From: richard Date: Tue, 10 Sep 2002 23:05:00 +0000 Subject: [PATCH] Remeber values in edit/new submission error pages. 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 | 4 +- roundup/cgi/templating.py | 43 +++++++++++++++++---- roundup/templates/classic/html/issue.item | 5 ++- roundup/templates/classic/html/issue.search | 7 +++- roundup/templates/classic/html/page | 2 +- 5 files changed, 46 insertions(+), 15 deletions(-) diff --git a/TODO.txt b/TODO.txt index 542e3da..8670986 100644 --- 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 diff --git a/roundup/cgi/templating.py b/roundup/cgi/templating.py index 3e34c04..b458c6c 100644 --- a/roundup/cgi/templating.py +++ b/roundup/cgi/templating.py @@ -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.*) ''' @@ -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 diff --git a/roundup/templates/classic/html/issue.item b/roundup/templates/classic/html/issue.item index 2d6d09b..8c653f6 100644 --- a/roundup/templates/classic/html/issue.item +++ b/roundup/templates/classic/html/issue.item @@ -23,8 +23,9 @@ - -
View: + +
View:
Nosy List diff --git a/roundup/templates/classic/html/issue.search b/roundup/templates/classic/html/issue.search index 0444c62..c589990 100644 --- a/roundup/templates/classic/html/issue.search +++ b/roundup/templates/classic/html/issue.search @@ -18,7 +18,9 @@ All text*: - + +       @@ -137,7 +139,8 @@ Query name**: - + diff --git a/roundup/templates/classic/html/page b/roundup/templates/classic/html/page index 8a6404e..ff11246 100644 --- a/roundup/templates/classic/html/page +++ b/roundup/templates/classic/html/page @@ -61,7 +61,7 @@ Hello,
username
My Issues
My Details
- Logout

-- 2.30.2