Skip to content

Commit e4bbfc8

Browse files
committed
fix issue2550502
1 parent 48a1da9 commit e4bbfc8

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

roundup/cgi/actions.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ def permission(self):
5959
'%(action)s the %(classname)s class.')%info
6060

6161
_marker = []
62-
def hasPermission(self, permission, classname=_marker, itemid=None):
62+
def hasPermission(self, permission, classname=_marker, itemid=None, property=None):
6363
"""Check whether the user has 'permission' on the current class."""
6464
if classname is self._marker:
6565
classname = self.client.classname
6666
return self.db.security.hasPermission(permission, self.client.userid,
67-
classname=classname, itemid=itemid)
67+
classname=classname, itemid=itemid, property=property)
6868

6969
def gettext(self, msgid):
7070
"""Return the localized translation of msgid"""
@@ -486,26 +486,22 @@ def isEditingSelf(self):
486486

487487
_cn_marker = []
488488
def editItemPermission(self, props, classname=_cn_marker, itemid=None):
489-
"""Determine whether the user has permission to edit this item.
490-
491-
Base behaviour is to check the user can edit this class. If we're
492-
editing the "user" class, users are allowed to edit their own details.
493-
Unless it's the "roles" property, which requires the special Permission
494-
"Web Roles".
495-
"""
496-
if self.classname == 'user':
497-
if props.has_key('roles') and not self.hasPermission('Web Roles'):
498-
raise exceptions.Unauthorised, self._(
499-
"You do not have permission to edit user roles")
500-
if self.isEditingSelf():
501-
return 1
489+
"""Determine whether the user has permission to edit this item."""
502490
if itemid is None:
503491
itemid = self.nodeid
504492
if classname is self._cn_marker:
505493
classname = self.classname
506-
if self.hasPermission('Edit', itemid=itemid, classname=classname):
507-
return 1
508-
return 0
494+
# The user must have permission to edit each of the properties
495+
# being changed.
496+
for p in props:
497+
if not self.hasPermission('Edit',
498+
itemid=itemid,
499+
classname=classname,
500+
property=p):
501+
return 0
502+
# Since the user has permission to edit all of the properties,
503+
# the edit is OK.
504+
return 1
509505

510506
def newItemPermission(self, props, classname=None):
511507
"""Determine whether the user has permission to create this item.

0 commit comments

Comments
 (0)