summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6735023)
raw | patch | inline | side by side (parent: 6735023)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 13 Feb 2004 01:32:37 +0000 (01:32 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 13 Feb 2004 01:32:37 +0000 (01:32 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@2078 57a73879-2fb5-44c3-a270-3262357dd7e2
diff --git a/CHANGES.txt b/CHANGES.txt
index d7d1620367a354af9a6cf7c51700f10a572ac596..3faf2752d0ad8ed1c931be29c338e0b3a09d8f5c 100644 (file)
--- a/CHANGES.txt
+++ b/CHANGES.txt
- fix re-enabling queries (sf bug 861940)
- use supplied content-type on file uploads before trying filename)
- fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
+- fixed edit action / parsePropsFromForm to handle index-page edits better
2003-12-17 0.6.4
diff --git a/roundup/cgi/actions.py b/roundup/cgi/actions.py
index 994a96f5aa681b889b7bfdab198a2807f816fc22..afc6a107424355b92bc719231f47013d242b9e67 100755 (executable)
--- a/roundup/cgi/actions.py
+++ b/roundup/cgi/actions.py
self.db.commit()
# redirect to the item's edit page
- raise Redirect, '%s%s%s?@ok_message=%s&@template=%s'%(self.base,
- self.classname, self.client.nodeid,
- urllib.quote(message),
- urllib.quote(self.template))
+ # redirect to finish off
+ url = self.base + self.classname
+ # note that this action might have been called by an index page, so
+ # we will want to include index-page args in this URL too
+ if self.nodeid is not None:
+ url += self.nodeid
+ url += '?@ok_message=%s&@template=%s'%(urllib.quote(message),
+ urllib.quote(self.template))
+ if self.nodeid is None:
+ req = templating.HTMLRequest(self)
+ url += '&' + req.indexargs_href('', {})[1:]
+ raise Redirect, url
def editItemPermission(self, props):
"""Determine whether the user has permission to edit this item.
return 1
return 0
+ def newItemAction(self):
+ ''' Add a new item to the database.
+
+ This follows the same form as the editItemAction, with the same
+ special form values.
+ '''
+ # parse the props from the form
+ try:
+ props, links = self.parsePropsFromForm(create=True)
+ except (ValueError, KeyError), message:
+ self.error_message.append(_('Error: ') + str(message))
+ return
+
+ # handle the props - edit or create
+ try:
+ # when it hits the None element, it'll set self.nodeid
+ messages = self._editnodes(props, links)
+
+ except (ValueError, KeyError, IndexError), message:
+ # these errors might just be indicative of user dumbness
+ self.error_message.append(_('Error: ') + str(message))
+ return
+
+ # commit now that all the tricky stuff is done
+ self.db.commit()
+
+ # redirect to the new item's page
+ raise Redirect, '%s%s%s?@ok_message=%s&@template=%s'%(self.base,
+ self.classname, self.nodeid, urllib.quote(messages),
+ urllib.quote(self.template))
+
def newItemPermission(self, props):
"""Determine whether the user has permission to create (edit) this item.
diff --git a/roundup/cgi/client.py b/roundup/cgi/client.py
index f02e62f7d531a282345171d884fda739a9372f39..c15b3f1fd3a62a4757065c0e8adaffd2ecceeba5 100644 (file)
--- a/roundup/cgi/client.py
+++ b/roundup/cgi/client.py
-# $Id: client.py,v 1.156 2004-02-11 23:55:09 richard Exp $
+# $Id: client.py,v 1.157 2004-02-13 01:32:37 richard Exp $
"""WWW request handler (also used in the stand-alone server).
"""
except MessageSendError, e:
self.error_message.append(str(e))
- def parsePropsFromForm(self):
- return FormParser(self).parse()
+ def parsePropsFromForm(self, create=False):
+ return FormParser(self).parse(create=create)
+
index ded96e4dad3cd930ee459df042bf88f5b532afdd..8ef534d6c260cb9b2f48394aa6c03437a5910409 100755 (executable)
self.classname = client.classname
self.nodeid = client.nodeid
- def parse(self, num_re=re.compile('^\d+$')):
+ def parse(self, create=False, num_re=re.compile('^\d+$')):
""" Item properties and their values are edited with html FORM
variables and their values. You can:
# the thing this value relates to is...
this = (cn, nodeid)
+ # skip implicit create if this isn't a create action
+ if not create and nodeid is None:
+ continue
+
# get more info about the class, and the current set of
# form props for it
if not all_propdef.has_key(cn):
index aab6a95fb5ac30883d44bb54689a3d0eddeeee42..dc1530951eb343f35c932b4a84b14cfb5a9682c0 100644 (file)
''' Get an item of this class by its item id.
'''
# make sure we're looking at an itemid
- if not num_re.match(itemid):
+ if not isinstance(itemid, type(1)) and not num_re.match(itemid):
itemid = self._klass.lookup(itemid)
if self.classname == 'user':