def _has_user_permission_for_groups(user_id, permission, group_ids, capacity=None):
 if (not group_ids):
  return False
 q = model.Session.query(model.Member).filter(model.Member.group_id.in_(group_ids)).filter((model.Member.table_name == 'user')).filter((model.Member.state == 'active')).filter((model.Member.table_id == user_id))
 if capacity:
  q = q.filter((model.Member.capacity == capacity))
 for row in q.all():
  perms = ROLE_PERMISSIONS.get(row.capacity, [])
  if (('admin' in perms) or (permission in perms)):
   return True
 return False

def _has_user_permission_for_groups ( user_id , permission , group_ids , capacity = None ) : if ( not group_ids ) : return False q = model . Session . query ( model . Member ) . filter ( model . Member . group_id . in_ ( group_ids ) ) . filter ( ( model . Member . table_name == 'user' ) ) . filter ( ( model . Member . state == 'active' ) ) . filter ( ( model . Member . table_id == user_id ) ) if capacity : q = q . filter ( ( model . Member . capacity == capacity ) ) for row in q . all ( ) : perms = ROLE_PERMISSIONS . get ( row . capacity , [ ] ) if ( ( 'admin' in perms ) or ( permission in perms ) ) : return True return False
check if the user has the given permissions for the particular group .