summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7d122f6)
raw | patch | inline | side by side (parent: 7d122f6)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Tue, 15 Oct 2002 06:37:21 +0000 (06:37 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Tue, 15 Oct 2002 06:37:21 +0000 (06:37 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1350 57a73879-2fb5-44c3-a270-3262357dd7e2
CHANGES.txt | patch | blob | history | |
roundup/cgi/client.py | patch | blob | history | |
roundup/templates/classic/html/user.index | patch | blob | history |
diff --git a/CHANGES.txt b/CHANGES.txt
index 38675c4815d9abe88c723b28bf3c96e45f0e08f1..640c57493e81e32f130dbf84ddb45b8e08375fda 100644 (file)
--- a/CHANGES.txt
+++ b/CHANGES.txt
- added ability to implement new templating utility methods
- expose the Date.pretty method to templating
- made form table cell alignment consistent (sf bug 621887)
+- include stylesheet in docs (sf bug 623183)
+- store PIPE messages so we can re-send them on errors (sf bug 623082)
+- implemented "retire" cgi action, added to user index (sf bug 618612)
2002-10-02 0.5.0
diff --git a/roundup/cgi/client.py b/roundup/cgi/client.py
index 8ac665d32243a1b2dc0c0a68035e5118e3154179..c01fc9942b573f9a45b7bbd45331a2bb4d3ab891 100644 (file)
--- a/roundup/cgi/client.py
+++ b/roundup/cgi/client.py
-# $Id: client.py,v 1.52 2002-10-09 01:00:40 richard Exp $
+# $Id: client.py,v 1.53 2002-10-15 06:37:21 richard Exp $
__doc__ = """
WWW request handler (also used in the stand-alone server).
('login', 'loginAction'),
('logout', 'logout_action'),
('search', 'searchAction'),
+ ('retire', 'retireAction'),
)
def handle_action(self):
''' Determine whether there should be an _action called.
"login" -> self.loginAction
"logout" -> self.logout_action
"search" -> self.searchAction
-
+ "retire" -> self.retireAction
'''
if not self.form.has_key(':action'):
return None
return 0
return 1
- def remove_action(self, dre=re.compile(r'([^\d]+)(\d+)')):
- # XXX I believe this could be handled by a regular edit action that
- # just sets the multilink...
- target = self.index_arg(':target')[0]
- m = dre.match(target)
- if m:
- classname = m.group(1)
- nodeid = m.group(2)
- cl = self.db.getclass(classname)
- cl.retire(nodeid)
- # now take care of the reference
- parentref = self.index_arg(':multilink')[0]
- parent, prop = parentref.split(':')
- m = dre.match(parent)
- if m:
- self.classname = m.group(1)
- self.nodeid = m.group(2)
- cl = self.db.getclass(self.classname)
- value = cl.get(self.nodeid, prop)
- value.remove(nodeid)
- cl.set(self.nodeid, **{prop:value})
- func = getattr(self, 'show%s'%self.classname)
- return func()
- else:
- raise NotFound, parent
- else:
- raise NotFound, target
+ def retireAction(self):
+ ''' Retire the context item.
+ '''
+ # if we want to view the index template now, then unset the nodeid
+ # context info (a special-case for retire actions on the index page)
+ nodeid = self.nodeid
+ if self.template == 'index':
+ self.nodeid = None
+
+ # generic edit is per-class only
+ if not self.retirePermission():
+ self.error_message.append(
+ _('You do not have permission to retire %s' %self.classname))
+ return
+
+ # make sure we don't try to retire admin or anonymous
+ if self.classname == 'user' and \
+ self.db.user.get(nodeid, 'username') in ('admin', 'anonymous'):
+ self.error_message.append(
+ _('You may not retire the admin or anonymous user'))
+ return
+
+ # do the retire
+ self.db.getclass(self.classname).retire(nodeid)
+ self.db.commit()
+
+ self.ok_message.append(
+ _('%(classname)s %(itemid)s has been retired')%{
+ 'classname': self.classname.capitalize(), 'itemid': nodeid})
+
+ def retirePermission(self):
+ ''' Determine whether the user has permission to retire this class.
+
+ Base behaviour is to check the user can edit this class.
+ '''
+ if not self.db.security.hasPermission('Edit', self.userid,
+ self.classname):
+ return 0
+ return 1
+
#
# Utility methods for editing
index cb371b5ea332e3f15a9763dcd4aa20acf24e17f3..7c70042ae1ec69505526d3f8d22ae37738796d3b 100644 (file)
<th>Organisation</th>
<th>Email address</th>
<th>Phone number</th>
+ <th tal:condition="context/is_edit_ok">Retire</th>
</tr>
<tr tal:repeat="user context/list"
tal:attributes="class python:['normal', 'alt'][repeat['user'].index%6/3]">
<td tal:content="user/organisation">organisation</td>
<td tal:content="python:user.address.email()">address</td>
<td tal:content="user/phone">phone</td>
+ <td tal:condition="context/is_edit_ok">
+ <a tal:attributes="href string:user${user/id}?:action=retire&:template=index">
+ retire</a>
+ </td>
</tr>
</table>
</td>