cubicweb/server/test/data/cubicweb_localperms/schema.py
author Philippe Pepiot <philippe.pepiot@logilab.fr>
Tue, 19 Mar 2019 14:26:51 +0100
changeset 12515 2d43c8b30ef0
permissions -rw-r--r--
[server/test] do not depend on third party cubes Drop requirement of basket, card, comment, file, localperms and tag cubes for cubicweb.server tests. Copy needed part of schema, entities, views, hooks into the cubicweb/server/test/data directory (which is included in PYTHONPATH for CubicWebTC tests). For migration tests which use different "datapath", use symlinks to have dependent cubes importables.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12515
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
     1
from yams.buildobjs import EntityType, RelationType, RelationDefinition, String
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
     2
from cubicweb.schema import PUB_SYSTEM_ENTITY_PERMS, PUB_SYSTEM_REL_PERMS
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
     3
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
     4
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
     5
class CWPermission(EntityType):
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
     6
    """entity type that may be used to construct some advanced security
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
     7
    configuration
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
     8
    """
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
     9
    __permissions__ = PUB_SYSTEM_ENTITY_PERMS
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    10
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    11
    name = String(required=True, indexed=True, internationalizable=True,
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    12
                  maxsize=100, description=(
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    13
                      'name or identifier of the permission'))
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    14
    label = String(required=True, internationalizable=True, maxsize=100,
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    15
                   description=('distinct label to distinguate between other '
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    16
                                'permission entity of the same name'))
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    17
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    18
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    19
class granted_permission(RelationType):
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    20
    """explicitly granted permission on an entity"""
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    21
    __permissions__ = PUB_SYSTEM_REL_PERMS
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    22
    # XXX cardinality = '*1'
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    23
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    24
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    25
class require_permission(RelationType):
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    26
    __permissions__ = PUB_SYSTEM_REL_PERMS
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    27
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    28
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    29
class require_group(RelationDefinition):
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    30
    """groups to which the permission is granted"""
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    31
    __permissions__ = PUB_SYSTEM_REL_PERMS
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    32
    subject = 'CWPermission'
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    33
    object = 'CWGroup'
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    34
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    35
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    36
class has_group_permission(RelationDefinition):
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    37
    """short cut relation for 'U in_group G, P require_group G' for efficiency
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    38
    reason. This relation is set automatically, you should not set this.
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    39
    """
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    40
    __permissions__ = PUB_SYSTEM_REL_PERMS
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    41
    subject = 'CWUser'
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    42
    object = 'CWPermission'