summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fead1d2)
raw | patch | inline | side by side (parent: fead1d2)
author | jlgijsbers <jlgijsbers@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Sat, 14 Feb 2004 01:17:38 +0000 (01:17 +0000) | ||
committer | jlgijsbers <jlgijsbers@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Sat, 14 Feb 2004 01:17:38 +0000 (01:17 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@2080 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup/cgi/actions.py | patch | blob | history | |
roundup/cgi/client.py | patch | blob | history |
diff --git a/roundup/cgi/actions.py b/roundup/cgi/actions.py
index afc6a107424355b92bc719231f47013d242b9e67..de4143d4fa9b1ff07d39f1a487ac3420768ff480 100755 (executable)
--- a/roundup/cgi/actions.py
+++ b/roundup/cgi/actions.py
__all__ = ['Action', 'ShowAction', 'RetireAction', 'SearchAction',
'EditCSVAction', 'EditItemAction', 'PassResetAction',
- 'ConfRegoAction', 'RegisterAction', 'LoginAction', 'LogoutAction']
+ 'ConfRegoAction', 'RegisterAction', 'LoginAction', 'LogoutAction',
+ 'NewItemAction']
# used by a couple of routines
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
return self.db.security.hasPermission('Edit', self.client.userid,
self.client.classname)
-class EditItemAction(Action):
- def handle(self):
- """Perform an edit of an item in the database.
-
- See parsePropsFromForm and _editnodes for special variables.
-
- """
- props, links = self.client.parsePropsFromForm()
-
- # handle the props
- try:
- message = self._editnodes(props, links)
- except (ValueError, KeyError, IndexError), message:
- self.client.error_message.append(_('Apply Error: ') + str(message))
- return
-
- # commit now that all the tricky stuff is done
- self.db.commit()
-
- # redirect to the item's edit page
- # 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
-
+class _EditAction(Action):
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.
# make a new node
newid = self._createnode(cn, props)
if nodeid is None:
- self.client.nodeid = newid
+ self.nodeid = newid
nodeid = newid
# and some nice feedback for the user
# create the node and return its id
cl = self.db.classes[cn]
return cl.create(**props)
+
+class EditItemAction(_EditAction):
+ def handle(self):
+ """Perform an edit of an item in the database.
+
+ See parsePropsFromForm and _editnodes for special variables.
+
+ """
+ props, links = self.client.parsePropsFromForm()
+
+ # handle the props
+ try:
+ message = self._editnodes(props, links)
+ except (ValueError, KeyError, IndexError), message:
+ self.client.error_message.append(_('Apply Error: ') + str(message))
+ return
+
+ # commit now that all the tricky stuff is done
+ self.db.commit()
+
+ # redirect to the item's edit page
+ # 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
+
+class NewItemAction(_EditAction):
+ def handle(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.client.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))
class PassResetAction(Action):
def handle(self):
diff --git a/roundup/cgi/client.py b/roundup/cgi/client.py
index c15b3f1fd3a62a4757065c0e8adaffd2ecceeba5..7722865cb365af31b9568eaa4ec6861bec8713de 100644 (file)
--- a/roundup/cgi/client.py
+++ b/roundup/cgi/client.py
-# $Id: client.py,v 1.157 2004-02-13 01:32:37 richard Exp $
+# $Id: client.py,v 1.158 2004-02-14 01:17:38 jlgijsbers Exp $
"""WWW request handler (also used in the stand-alone server).
"""
actions = (
('edit', EditItemAction),
('editcsv', EditCSVAction),
- ('new', EditItemAction),
+ ('new', NewItemAction),
('register', RegisterAction),
('confrego', ConfRegoAction),
('passrst', PassResetAction),