server/test/data-schema2sql/schema/Company.py
changeset 11057 0b59724cb3f2
parent 11052 058bb3dc685f
child 11058 23eb30449fe5
equal deleted inserted replaced
11052:058bb3dc685f 11057:0b59724cb3f2
     1 # copyright 2004-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
       
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
       
     3 #
       
     4 # This file is part of yams.
       
     5 #
       
     6 # yams is free software: you can redistribute it and/or modify it under the
       
     7 # terms of the GNU Lesser General Public License as published by the Free
       
     8 # Software Foundation, either version 2.1 of the License, or (at your option)
       
     9 # any later version.
       
    10 #
       
    11 # yams is distributed in the hope that it will be useful, but WITHOUT ANY
       
    12 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
       
    13 # A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
       
    14 # details.
       
    15 #
       
    16 # You should have received a copy of the GNU Lesser General Public License along
       
    17 # with yams. If not, see <http://www.gnu.org/licenses/>.
       
    18 from yams.buildobjs import EntityType, RelationType, RelationDefinition, \
       
    19      SubjectRelation, String
       
    20 
       
    21 class Company(EntityType):
       
    22     name = String()
       
    23 
       
    24 class Subcompany(Company):
       
    25     __specializes_schema__ = True
       
    26     subcompany_of = SubjectRelation('Company')
       
    27 
       
    28 class Division(Company):
       
    29     __specializes_schema__ = True
       
    30     division_of = SubjectRelation('Company')
       
    31 
       
    32 class Subdivision(Division):
       
    33     __specializes_schema__ = True
       
    34     subdivision_of = SubjectRelation('Company')
       
    35 
       
    36 class Employee(EntityType):
       
    37     works_for = SubjectRelation('Company')
       
    38 
       
    39 class require_permission(RelationType):
       
    40     """link a permission to the entity. This permission should be used in the
       
    41     security definition of the entity's type to be useful.
       
    42     """
       
    43     fulltext_container = 'subject'
       
    44     __permissions__ = {
       
    45         'read':   ('managers', 'users', 'guests'),
       
    46         'add':    ('managers',),
       
    47         'delete': ('managers',),
       
    48         }
       
    49 
       
    50 
       
    51 class missing_require_permission(RelationDefinition):
       
    52     name = 'require_permission'
       
    53     subject = 'Company'
       
    54     object = 'EPermission'
       
    55 
       
    56 class EPermission(EntityType):
       
    57     """entity type that may be used to construct some advanced security configuration
       
    58     """
       
    59     __permissions__ = {
       
    60         'read':   ('managers', 'users', 'guests',),
       
    61         'add':    ('managers',),
       
    62         'delete': ('managers',),
       
    63         'update': ('managers', 'owners',),
       
    64         }
       
    65     name = String(required=True, indexed=True, internationalizable=True,
       
    66                   fulltextindexed=True, maxsize=100,
       
    67                   description=_('name or identifier of the permission'))