@@ -520,20 +520,23 @@ def __init__(self, client, classname, anonymous=0):
520520 def is_edit_ok (self ):
521521 """ Is the user allowed to Create the current class?
522522 """
523- return self ._db .security .hasPermission ('Create' , self ._client .userid ,
524- self ._classname )
523+ perm = self ._db .security .hasPermission
524+ return perm ('Web Access' , self ._client .userid ) and perm ('Create' ,
525+ self ._client .userid , self ._classname )
525526
526527 def is_retire_ok (self ):
527528 """ Is the user allowed to retire items of the current class?
528529 """
529- return self ._db .security .hasPermission ('Retire' , self ._client .userid ,
530- self ._classname )
530+ perm = self ._db .security .hasPermission
531+ return perm ('Web Access' , self ._client .userid ) and perm ('Retire' ,
532+ self ._client .userid , self ._classname )
531533
532534 def is_view_ok (self ):
533535 """ Is the user allowed to View the current class?
534536 """
535- return self ._db .security .hasPermission ('View' , self ._client .userid ,
536- self ._classname )
537+ perm = self ._db .security .hasPermission
538+ return perm ('Web Access' , self ._client .userid ) and perm ('View' ,
539+ self ._client .userid , self ._classname )
537540
538541 def is_only_view_ok (self ):
539542 """ Is the user only allowed to View (ie. not Create) the current class?
@@ -620,6 +623,8 @@ def list(self, sort_on=None):
620623 # check perms
621624 check = self ._client .db .security .hasPermission
622625 userid = self ._client .userid
626+ if not check ('Web Access' , userid ):
627+ return []
623628
624629 l = [HTMLItem (self ._client , self ._classname , id ) for id in l
625630 if check ('View' , userid , self ._classname , itemid = id )]
@@ -634,11 +639,14 @@ def csv(self):
634639 writer = csv .writer (s )
635640 writer .writerow (props )
636641 check = self ._client .db .security .hasPermission
642+ userid = self ._client .userid
643+ if not check ('Web Access' , userid ):
644+ return ''
637645 for nodeid in self ._klass .list ():
638646 l = []
639647 for name in props :
640648 # check permission to view this property on this item
641- if not check ('View' , self . _client . userid , itemid = nodeid ,
649+ if not check ('View' , userid , itemid = nodeid ,
642650 classname = self ._klass .classname , property = name ):
643651 raise Unauthorised ('view' , self ._klass .classname ,
644652 translator = self ._client .translator )
@@ -672,6 +680,8 @@ def filter(self, request=None, filterspec={}, sort=[], group=[]):
672680
673681 check = self ._db .security .hasPermission
674682 userid = self ._client .userid
683+ if not check ('Web Access' , userid ):
684+ return []
675685
676686 l = [HTMLItem (self ._client , self .classname , id )
677687 for id in self ._klass .filter (None , filterspec , sort , group )
@@ -801,20 +811,23 @@ def __init__(self, client, classname, nodeid, anonymous=0):
801811 def is_edit_ok (self ):
802812 """ Is the user allowed to Edit this item?
803813 """
804- return self ._db .security .hasPermission ('Edit' , self ._client .userid ,
805- self ._classname , itemid = self ._nodeid )
814+ perm = self ._db .security .hasPermission
815+ return perm ('Web Access' , self ._client .userid ) and perm ('Edit' ,
816+ self ._client .userid , self ._classname , itemid = self ._nodeid )
806817
807818 def is_retire_ok (self ):
808819 """ Is the user allowed to Reture this item?
809820 """
810- return self ._db .security .hasPermission ('Retire' , self ._client .userid ,
811- self ._classname , itemid = self ._nodeid )
821+ perm = self ._db .security .hasPermission
822+ return perm ('Web Access' , self ._client .userid ) and perm ('Retire' ,
823+ self ._client .userid , self ._classname , itemid = self ._nodeid )
812824
813825 def is_view_ok (self ):
814826 """ Is the user allowed to View this item?
815827 """
816- if self ._db .security .hasPermission ('View' , self ._client .userid ,
817- self ._classname , itemid = self ._nodeid ):
828+ perm = self ._db .security .hasPermission
829+ if perm ('Web Access' , self ._client .userid ) and perm ('View' ,
830+ self ._client .userid , self ._classname , itemid = self ._nodeid ):
818831 return 1
819832 return self .is_edit_ok ()
820833
@@ -1289,19 +1302,22 @@ def is_edit_ok(self):
12891302 property. Check "Create" for new items, or "Edit" for existing
12901303 ones.
12911304 """
1305+ perm = self ._db .security .hasPermission
1306+ userid = self ._client .userid
1307+ if not perm ('Web Access' , userid ):
1308+ return False
12921309 if self ._nodeid :
1293- return self ._db .security .hasPermission ('Edit' , self ._client .userid ,
1294- self ._classname , self ._name , self ._nodeid )
1295- return self ._db .security .hasPermission ('Create' , self ._client .userid ,
1296- self ._classname , self ._name ) or \
1297- self ._db .security .hasPermission ('Register' , self ._client .userid ,
1298- self ._classname , self ._name )
1310+ return perm ('Edit' , userid , self ._classname , self ._name ,
1311+ self ._nodeid )
1312+ return perm ('Create' , userid , self ._classname , self ._name ) or \
1313+ perm ('Register' , userid , self ._classname , self ._name )
12991314
13001315 def is_view_ok (self ):
13011316 """ Is the user allowed to View the current class?
13021317 """
1303- if self ._db .security .hasPermission ('View' , self ._client .userid ,
1304- self ._classname , self ._name , self ._nodeid ):
1318+ perm = self ._db .security .hasPermission
1319+ if perm ('Web Access' , self ._client .userid ) and perm ('View' ,
1320+ self ._client .userid , self ._classname , self ._name , self ._nodeid ):
13051321 return 1
13061322 return self .is_edit_ok ()
13071323
@@ -2071,9 +2087,10 @@ def viewableGenerator(self, values):
20712087 check = self ._db .security .hasPermission
20722088 userid = self ._client .userid
20732089 classname = self ._prop .classname
2074- for value in values :
2075- if check ('View' , userid , classname , itemid = value ):
2076- yield HTMLItem (self ._client , classname , value )
2090+ if check ('Web Access' , userid ):
2091+ for value in values :
2092+ if check ('View' , userid , classname , itemid = value ):
2093+ yield HTMLItem (self ._client , classname , value )
20772094
20782095 def __iter__ (self ):
20792096 """ iterate and return a new HTMLItem
@@ -2649,6 +2666,12 @@ def base_javascript(self):
26492666 def batch (self ):
26502667 """ Return a batch object for results from the "current search"
26512668 """
2669+ check = self ._client .db .security .hasPermission
2670+ userid = self ._client .userid
2671+ if not check ('Web Access' , userid ):
2672+ return Batch (self .client , [], self .pagesize , self .startwith ,
2673+ classname = self .classname )
2674+
26522675 filterspec = self .filterspec
26532676 sort = self .sort
26542677 group = self .group
@@ -2665,8 +2688,6 @@ def batch(self):
26652688 matches = None
26662689
26672690 # filter for visibility
2668- check = self ._client .db .security .hasPermission
2669- userid = self ._client .userid
26702691 l = [id for id in klass .filter (matches , filterspec , sort , group )
26712692 if check ('View' , userid , self .classname , itemid = id )]
26722693
0 commit comments