parameters: (resource, members=None)
return_statement: return _perm_spec
docstring: assign all admin permissions to the owner
docstring_summary: assign all admin permissions to the owner
docstring_tokens: assign all admin permissions to the owner
function: def set_owner_permissions(resource, members=None):
      """assign all admin permissions to the owner"""
      from .permissions import (
          VIEW_PERMISSIONS,
          DOWNLOAD_PERMISSIONS,
          ADMIN_PERMISSIONS,
          SERVICE_PERMISSIONS,
          DOWNLOADABLE_RESOURCES,
          DATASET_ADMIN_PERMISSIONS,
          DATASET_EDIT_STYLE_PERMISSIONS)
      _perm_spec = {
          "users": {},
          "groups": {}
      }
      if resource.polymorphic_ctype:
          # Owner & Manager Admin Perms
          admin_perms = VIEW_PERMISSIONS + ADMIN_PERMISSIONS
          if resource.polymorphic_ctype.name in DOWNLOADABLE_RESOURCES:
              admin_perms += DOWNLOAD_PERMISSIONS
          for perm in admin_perms:
              if not settings.RESOURCE_PUBLISHING and not settings.ADMIN_MODERATE_UPLOADS:
                  assign_perm(perm, resource.owner, resource.get_self_resource())
                  _prev_perm = _perm_spec["users"].get(resource.owner, []) if "users" in _perm_spec else []
                  _perm_spec["users"][resource.owner] = set.union(perms_as_set(_prev_perm), perms_as_set(perm))
              elif perm not in {'change_resourcebase_permissions', 'publish_resourcebase'}:
                  assign_perm(perm, resource.owner, resource.get_self_resource())
                  _prev_perm = _perm_spec["users"].get(resource.owner, []) if "users" in _perm_spec else []
                  _perm_spec["users"][resource.owner] = set.union(perms_as_set(_prev_perm), perms_as_set(perm))
              if members:
                  for user in members:
                      assign_perm(perm, user, resource.get_self_resource())
                      _prev_perm = _perm_spec["users"].get(user, []) if "users" in _perm_spec else []
                      _perm_spec["users"][user] = set.union(perms_as_set(_prev_perm), perms_as_set(perm))
  
          # Set the GeoFence Owner Rule
          if resource.polymorphic_ctype.name == 'dataset':
              DATA_EDIT_PERMISSIONS = []
              if resource.get_real_instance().subtype == 'vector':
                  DATA_EDIT_PERMISSIONS = DATASET_ADMIN_PERMISSIONS
              elif resource.get_real_instance().subtype == 'raster':
                  DATA_EDIT_PERMISSIONS = DATASET_EDIT_STYLE_PERMISSIONS
              for perm in DATA_EDIT_PERMISSIONS:
                  assign_perm(perm, resource.owner, resource.dataset)
                  _prev_perm = _perm_spec["users"].get(resource.owner, []) if "users" in _perm_spec else []
                  _perm_spec["users"][resource.owner] = set.union(perms_as_set(_prev_perm), perms_as_set(perm))
                  if members:
                      for user in members:
                          assign_perm(perm, user, resource.dataset)
                          _prev_perm = _perm_spec["users"].get(user, []) if "users" in _perm_spec else []
                          _perm_spec["users"][user] = set.union(perms_as_set(_prev_perm), perms_as_set(perm))
  
          if resource.polymorphic_ctype.name == 'service':
              for perm in SERVICE_PERMISSIONS:
                  assign_perm(perm, resource.owner, resource.service)
                  _prev_perm = _perm_spec["users"].get(resource.owner, []) if "users" in _perm_spec else []
                  _perm_spec["users"][resource.owner] = set.union(perms_as_set(_prev_perm), perms_as_set(perm))
                  if members:
                      for user in members:
                          assign_perm(perm, user, resource.service)
                          _prev_perm = _perm_spec["users"].get(user, []) if "users" in _perm_spec else []
                          _perm_spec["users"][user] = set.union(perms_as_set(_prev_perm), perms_as_set(perm))
      return _perm_spec
function_tokens: def set_owner_permissions ( resource , members = None ) : from . permissions import ( VIEW_PERMISSIONS , DOWNLOAD_PERMISSIONS , ADMIN_PERMISSIONS , SERVICE_PERMISSIONS , DOWNLOADABLE_RESOURCES , DATASET_ADMIN_PERMISSIONS , DATASET_EDIT_STYLE_PERMISSIONS ) _perm_spec = { "users" : { } , "groups" : { } } if resource . polymorphic_ctype : # Owner & Manager Admin Perms admin_perms = VIEW_PERMISSIONS + ADMIN_PERMISSIONS if resource . polymorphic_ctype . name in DOWNLOADABLE_RESOURCES : admin_perms += DOWNLOAD_PERMISSIONS for perm in admin_perms : if not settings . RESOURCE_PUBLISHING and not settings . ADMIN_MODERATE_UPLOADS : assign_perm ( perm , resource . owner , resource . get_self_resource ( ) ) _prev_perm = _perm_spec [ "users" ] . get ( resource . owner , [ ] ) if "users" in _perm_spec else [ ] _perm_spec [ "users" ] [ resource . owner ] = set . union ( perms_as_set ( _prev_perm ) , perms_as_set ( perm ) ) elif perm not in { 'change_resourcebase_permissions' , 'publish_resourcebase' } : assign_perm ( perm , resource . owner , resource . get_self_resource ( ) ) _prev_perm = _perm_spec [ "users" ] . get ( resource . owner , [ ] ) if "users" in _perm_spec else [ ] _perm_spec [ "users" ] [ resource . owner ] = set . union ( perms_as_set ( _prev_perm ) , perms_as_set ( perm ) ) if members : for user in members : assign_perm ( perm , user , resource . get_self_resource ( ) ) _prev_perm = _perm_spec [ "users" ] . get ( user , [ ] ) if "users" in _perm_spec else [ ] _perm_spec [ "users" ] [ user ] = set . union ( perms_as_set ( _prev_perm ) , perms_as_set ( perm ) ) # Set the GeoFence Owner Rule if resource . polymorphic_ctype . name == 'dataset' : DATA_EDIT_PERMISSIONS = [ ] if resource . get_real_instance ( ) . subtype == 'vector' : DATA_EDIT_PERMISSIONS = DATASET_ADMIN_PERMISSIONS elif resource . get_real_instance ( ) . subtype == 'raster' : DATA_EDIT_PERMISSIONS = DATASET_EDIT_STYLE_PERMISSIONS for perm in DATA_EDIT_PERMISSIONS : assign_perm ( perm , resource . owner , resource . dataset ) _prev_perm = _perm_spec [ "users" ] . get ( resource . owner , [ ] ) if "users" in _perm_spec else [ ] _perm_spec [ "users" ] [ resource . owner ] = set . union ( perms_as_set ( _prev_perm ) , perms_as_set ( perm ) ) if members : for user in members : assign_perm ( perm , user , resource . dataset ) _prev_perm = _perm_spec [ "users" ] . get ( user , [ ] ) if "users" in _perm_spec else [ ] _perm_spec [ "users" ] [ user ] = set . union ( perms_as_set ( _prev_perm ) , perms_as_set ( perm ) ) if resource . polymorphic_ctype . name == 'service' : for perm in SERVICE_PERMISSIONS : assign_perm ( perm , resource . owner , resource . service ) _prev_perm = _perm_spec [ "users" ] . get ( resource . owner , [ ] ) if "users" in _perm_spec else [ ] _perm_spec [ "users" ] [ resource . owner ] = set . union ( perms_as_set ( _prev_perm ) , perms_as_set ( perm ) ) if members : for user in members : assign_perm ( perm , user , resource . service ) _prev_perm = _perm_spec [ "users" ] . get ( user , [ ] ) if "users" in _perm_spec else [ ] _perm_spec [ "users" ] [ user ] = set . union ( perms_as_set ( _prev_perm ) , perms_as_set ( perm ) ) return _perm_spec