comparison roundup/cgi/templating.py @ 2651:17bab083c8a0

Couple of fixes - make the interface just be is_edit_ok... ...so template writing is easier. Will check for Edit or Create permission as appropriate.
author Richard Jones <richard@users.sourceforge.net>
date Wed, 28 Jul 2004 05:10:45 +0000
parents 1df7d4a41da4
children 8348373b4361
comparison
equal deleted inserted replaced
2650:d68a444fcce3 2651:17bab083c8a0
409 ''' 409 '''
410 if not self.is_view_ok(): 410 if not self.is_view_ok():
411 raise Unauthorised("view", self._classname, 411 raise Unauthorised("view", self._classname,
412 translator=self._client.translator) 412 translator=self._client.translator)
413 413
414 def create_check(self):
415 ''' Raise the Unauthorised exception if the user's not permitted to
416 create items of this class.
417 '''
418 if not self.is_create_ok():
419 raise Unauthorised("create", self._classname,
420 translator=self._client.translator)
421
422 def edit_check(self): 414 def edit_check(self):
423 ''' Raise the Unauthorised exception if the user's not permitted to 415 ''' Raise the Unauthorised exception if the user's not permitted to
424 edit items of this class. 416 edit items of this class.
425 ''' 417 '''
426 if not self.is_edit_ok(): 418 if not self.is_edit_ok():
453 ''' Is the user allowed to View the current class? 445 ''' Is the user allowed to View the current class?
454 ''' 446 '''
455 if self._db.security.hasPermission('View', self._client.userid, 447 if self._db.security.hasPermission('View', self._client.userid,
456 self._classname): 448 self._classname):
457 return 1 449 return 1
458 return self.is_create_ok() 450 return self.is_edit_ok()
459 451
460 def is_only_view_ok(self): 452 def is_only_view_ok(self):
461 ''' Is the user only allowed to View (ie. not Create) the current class? 453 ''' Is the user only allowed to View (ie. not Create) the current class?
462 ''' 454 '''
463 return self.is_view_ok() and not self.is_create_ok() 455 return self.is_view_ok() and not self.is_edit_ok()
464 456
465 def __repr__(self): 457 def __repr__(self):
466 return '<HTMLClass(0x%x) %s>'%(id(self), self.classname) 458 return '<HTMLClass(0x%x) %s>'%(id(self), self.classname)
467 459
468 def __getitem__(self, item): 460 def __getitem__(self, item):

Roundup Issue Tracker: http://roundup-tracker.org/