Skip to content

Commit 69a7f8a

Browse files
author
Richard Jones
committed
merge from HEAD
1 parent 519b689 commit 69a7f8a

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Fixed:
1313
- fix Date: header generation to be LOCALE-agnostic (sf bug 1352624)
1414
- fix admin doc description of roundup-server config file
1515
- fix redirect after instant registration (sf bug 1381676)
16+
- fix permission checks in cgi interface (sf bug 1289557)
17+
- fix permission check on RetireAction (sf bug 1407342)
1618

1719

1820
2005-10-07 0.8.5

doc/index.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ J Vickroy,
155155
William (Wilk),
156156
Tue Wennerberg,
157157
Matt Wilbert,
158-
Chris Withers.
158+
Chris Withers,
159+
Milan Zamazal.
159160

160161

161162

roundup/cgi/actions.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#$Id: actions.py,v 1.40.2.9 2006-01-13 03:34:34 richard Exp $
1+
#$Id: actions.py,v 1.40.2.10 2006-01-20 02:13:51 richard Exp $
22

33
import re, cgi, StringIO, urllib, Cookie, time, random, csv
44

@@ -124,6 +124,11 @@ def handle(self):
124124
self._('%(classname)s %(itemid)s has been retired')%{
125125
'classname': self.classname.capitalize(), 'itemid': nodeid})
126126

127+
def hasPermission(self, permission, classname=Action._marker, itemid=None):
128+
if itemid is None:
129+
itemid = self.nodeid
130+
return self.hasPermission(permission, classname, itemid)
131+
127132
class SearchAction(Action):
128133
name = 'search'
129134
permissionType = 'View'
@@ -435,7 +440,7 @@ def _editnodes(self, all_props, all_links):
435440
def _changenode(self, cn, nodeid, props):
436441
"""Change the node based on the contents of the form."""
437442
# check for permission
438-
if not self.editItemPermission(props):
443+
if not self.editItemPermission(props, classname=cn, itemid=nodeid):
439444
raise exceptions.Unauthorised, self._(
440445
'You do not have permission to edit %(class)s'
441446
) % {'class': cn}
@@ -447,7 +452,7 @@ def _changenode(self, cn, nodeid, props):
447452
def _createnode(self, cn, props):
448453
"""Create a node based on the contents of the form."""
449454
# check for permission
450-
if not self.newItemPermission(props):
455+
if not self.newItemPermission(props, classname=cn):
451456
raise exceptions.Unauthorised, self._(
452457
'You do not have permission to create %(class)s'
453458
) % {'class': cn}
@@ -461,7 +466,8 @@ def isEditingSelf(self):
461466
return (self.nodeid == self.userid
462467
and self.db.user.get(self.nodeid, 'username') != 'anonymous')
463468

464-
def editItemPermission(self, props):
469+
_cn_marker = []
470+
def editItemPermission(self, props, classname=_cn_marker, itemid=None):
465471
"""Determine whether the user has permission to edit this item.
466472
467473
Base behaviour is to check the user can edit this class. If we're
@@ -475,17 +481,23 @@ def editItemPermission(self, props):
475481
"You do not have permission to edit user roles")
476482
if self.isEditingSelf():
477483
return 1
478-
if self.hasPermission('Edit', itemid=self.nodeid):
484+
if itemid is None:
485+
itemid = self.nodeid
486+
if classname is self._cn_marker:
487+
classname = self.classname
488+
if self.hasPermission('Edit', itemid=itemid, classname=classname):
479489
return 1
480490
return 0
481491

482-
def newItemPermission(self, props):
492+
def newItemPermission(self, props, classname=None):
483493
"""Determine whether the user has permission to create this item.
484494
485495
Base behaviour is to check the user can edit this class. No additional
486496
property checks are made.
487497
"""
488-
return self.hasPermission('Create')
498+
if not classname :
499+
classname = self.client.classname
500+
return self.hasPermission('Create', classname=classname)
489501

490502
class EditItemAction(EditCommon):
491503
def lastUserActivity(self):

0 commit comments

Comments
 (0)