示例#1
0
文件: schema.py 项目: zogzog/cubicweb
class Personne(EntityType):
    __permissions__ = {
        'read':   ('managers', 'users'), # 'guests' was removed
        'add':    ('managers', 'users'),
        'update': ('managers', 'owners'),
        'delete': ('managers', 'owners')
    }
    __unique_together__ = [('nom', 'prenom', 'datenaiss')]
    nom    = String(fulltextindexed=True, required=True, maxsize=64)
    prenom = String(fulltextindexed=True, maxsize=64)
    civility   = String(maxsize=1, default='M', fulltextindexed=True)
    promo  = String(vocabulary=('bon','pasbon', 'pasbondutout'))
    titre  = String(fulltextindexed=True, maxsize=128)
    adel   = String(maxsize=128)
    ass    = String(maxsize=128)
    web    = String(maxsize=128)
    tel    = Int()
    fax    = Int()
    datenaiss = Datetime()
    test   = Boolean()

    travaille = SubjectRelation('Societe')
    concerne = SubjectRelation('Affaire')
    concerne2 = SubjectRelation(('Affaire', 'Note'), cardinality='1*')
    connait = SubjectRelation('Personne', symmetric=True)
示例#2
0
文件: schema.py 项目: gurneyalex/yams
class Person(EntityType):
    __unique_together__ = [('nom', 'prenom')]
    nom = String(maxsize=64, fulltextindexed=True, required=True)
    prenom = String(maxsize=64, fulltextindexed=True)
    sexe = String(maxsize=1, default='M')
    promo = String(vocabulary=('bon', 'pasbon'))
    titre = String(maxsize=128, fulltextindexed=True)
    adel = String(maxsize=128)
    ass = String(maxsize=128)
    web = String(maxsize=128)
    tel = Int(__permissions__={
        'read': (),
        'add': ('managers', ),
        'update': ('managers', )
    })
    fax = Int()
    datenaiss = Date()
    test = Boolean()
    salary = Float()
    travaille = SubjectRelation('Societe',
                                __permissions__={
                                    'read': (),
                                    'add': (),
                                    'delete': ('managers', ),
                                })

    evaluee = SubjectRelation('Note')
示例#3
0
class Personne(EntityType):
    __permissions__ = {
        'read': ('managers', 'users', 'guests'),  # 'guests' will be removed
        'add': ('managers', 'users'),
        'update': ('managers', 'owners'),
        'delete': ('managers', 'owners')
    }
    __unique_together__ = [('nom', 'prenom', 'inline2')]
    nom = String(fulltextindexed=True, required=True, maxsize=64)
    prenom = String(fulltextindexed=True, maxsize=64)
    sexe = String(maxsize=1, default='M', fulltextindexed=True)
    promo = String(vocabulary=('bon', 'pasbon'))
    titre = String(fulltextindexed=True, maxsize=128)
    adel = String(maxsize=128)
    ass = String(maxsize=128)
    web = String(maxsize=128)
    tel = Int()
    fax = Int()
    datenaiss = Datetime()
    tzdatenaiss = TZDatetime()
    test = Boolean(
        __permissions__={
            'read': ('managers', 'users', 'guests'),
            'add': ('managers', ),
            'update': ('managers', ),
        })
    description = String()
    firstname = String(fulltextindexed=True, maxsize=64)

    concerne = SubjectRelation('Affaire')
    connait = SubjectRelation('Personne')
    inline2 = SubjectRelation('Affaire', inlined=True, cardinality='?*')
示例#4
0
class Gene(EntityType):
    """ Gene definition """
    name = String(maxsize=256, fulltextindexed=True, indexed=True)
    gene_id = String(maxsize=256, required=True, indexed=True)
    uri = String(maxsize=256, indexed=True)
    start_position = Int(indexed=True)
    stop_position = Int(indexed=True)
示例#5
0
class Personne(EntityType):
    nom = String(fulltextindexed=True, required=True, maxsize=64)
    prenom = String(fulltextindexed=True, maxsize=64)
    sexe = String(maxsize=1,
                  default='M',
                  __permissions__={
                      'read': (
                          'managers',
                          'users',
                          'guests',
                      ),
                      'add': ('managers', 'users'),
                      'update': ('managers', )
                  })
    promo = String(vocabulary=('bon', 'pasbon'))
    titre = String(fulltextindexed=True, maxsize=128)
    ass = String(maxsize=128)
    web = String(maxsize=128)
    tel = Int()
    fax = Int()
    datenaiss = Datetime()
    tzdatenaiss = TZDatetime()
    test = Boolean()
    description = String()
    salary = Float()
    travaille = SubjectRelation('Societe')
示例#6
0
class DMRIData(EntityType):
    voxel_res_x = Float(required=True, indexed=False)
    voxel_res_y = Float(required=True, indexed=False)
    voxel_res_z = Float(required=True, indexed=False)
    fov_x = Float(indexed=False)
    fov_y = Float(indexed=False)
    tr = Float()
    te = Float(required=True, indexed=False)
    shape_x = Int(indexed=False)
    shape_y = Int(indexed=False)
    shape_z = Int(indexed=False)
    field = String(maxsize=10, indexed=False)
示例#7
0
class Societe(EntityType):
    nom = String(maxsize=64, fulltextindexed=True)
    web = String(maxsize=128)
    type = String(maxsize=128)  # attribute in common with Note
    tel = Int()
    fax = Int()
    rncs = String(maxsize=128)
    ad1 = String(maxsize=128)
    ad2 = String(maxsize=128)
    ad3 = String(maxsize=128)
    cp = String(maxsize=12)
    ville = String(maxsize=32)
示例#8
0
class Travail(EntityType):
    artisan = SubjectRelation('Personne', cardinality='1*', composite='object', inlined=True)
    salaire_argent = SubjectRelation('Prix', cardinality='??', inlined=True, composite='subject')
    salaire_nature_qt = Int()
    salaire_nature_obj = String(maxsize=64, fulltextindexed=True)
    nombre_aides = Int()
    designation_aides = String(maxsize=64, fulltextindexed=True)
    salaire_aides = SubjectRelation('Prix', cardinality='??', inlined=True, composite='subject')
    tache = String(maxsize=255, fulltextindexed=True)
    duree = Int()
    date_travail = Date()
    remarques = RichString(fulltextindexed=True, default_format='text/rest')
    facon_et_etoffe = Boolean(default=False, required=True)
示例#9
0
文件: schema.py 项目: gurneyalex/yams
class Societe(EntityType):
    nom = String(maxsize=64, fulltextindexed=True)
    web = String(maxsize=128)
    tel = Int()
    fax = Int()
    rncs = String(maxsize=32)
    ad1 = String(maxsize=128)
    ad2 = String(maxsize=128)
    ad3 = String(maxsize=128)
    cp = String(maxsize=12)
    ville = String(maxsize=32)

    evaluee = SubjectRelation('Note')
示例#10
0
class MRIData(EntityType):
    sequence = String(maxsize=128, indexed=True)
    shape_x = Int(indexed=False)
    shape_y = Int(indexed=False)
    shape_z = Int(indexed=False)
    shape_t = Int(indexed=False)
    voxel_res_x = Float(indexed=False)
    voxel_res_y = Float(indexed=False)
    voxel_res_z = Float(indexed=False)
    fov_x = Float(indexed=False)
    fov_y = Float(indexed=False)
    tr = Float()
    te = Float(indexed=False)
    field = String(maxsize=10, indexed=False)
    affine = Bytes()
示例#11
0
文件: State.py 项目: zogzog/cubicweb
class State(EntityType):
    """used to associate simple states to an entity
    type and/or to define workflows
    """
    __permissions__ = {
        'read': (
            'managers',
            'users',
            'guests',
        ),
        'add': (
            'managers',
            'users',
        ),
        'delete': (
            'managers',
            'owners',
        ),
        'update': (
            'managers',
            'owners',
        ),
    }

    # attributes
    eid = Int(required=True, uid=True)
    name = String(required=True,
                  indexed=True,
                  internationalizable=True,
                  constraints=[SizeConstraint(256)])
    description = String(fulltextindexed=True)
    # relations
    state_of = SubjectRelation('Eetype', cardinality='+*')
    next_state = SubjectRelation('State', cardinality='**')
示例#12
0
class Affaire(WorkflowableEntityType):
    __permissions__ = {
        'read': ('managers', ERQLExpression('X owned_by U'),
                 ERQLExpression('X concerne S?, S owned_by U')),
        'add': ('managers', ERQLExpression('X concerne S, S owned_by U')),
        'update':
        ('managers', 'owners',
         ERQLExpression('X in_state S, S name in ("pitetre", "en cours")')),
        'delete':
        ('managers', 'owners', ERQLExpression('X concerne S, S owned_by U')),
    }

    ref = String(fulltextindexed=True,
                 indexed=True,
                 constraints=[SizeConstraint(16)])
    sujet = String(fulltextindexed=True, constraints=[SizeConstraint(256)])
    descr = RichString(fulltextindexed=True,
                       description=_('more detailed description'))

    duration = Int()
    invoiced = Float()
    opt_attr = Bytes()

    depends_on = SubjectRelation('Affaire')
    require_permission = SubjectRelation('CWPermission')
    concerne = SubjectRelation(('Societe', 'Note'))
    todo_by = SubjectRelation('Personne', cardinality='?*')
    documented_by = SubjectRelation('Card')
示例#13
0
class Salesterm(EntityType):
    described_by_test = SubjectRelation('File',
                                        cardinality='1*',
                                        composite='subject',
                                        inlined=True)
    amount = Int(constraints=[IntervalBoundConstraint(0, 100)])
    reason = String(maxsize=20, vocabulary=[u'canceled', u'sold'])
示例#14
0
class AchatFabrication(EntityType):
    date_achat = Date()
    quantite = Int()
    quantite_plusieurs = Boolean(default=False, required=True, description='True if quantite is "plusieurs"')
    parure = SubjectRelation('Parure', cardinality='1*', inlined=True)
    avec_mat = SubjectRelation('FabriqueAvecMat', cardinality='*1')
    remarques = RichString(fulltextindexed=True, default_format='text/rest')
示例#15
0
class Bug(EntityType):
    title = String(maxsize=64, required=True, fulltextindexed=True)
    severity = String(vocabulary=('important', 'normal', 'minor'),
                      default='normal')
    cost = Int()
    description = String(maxsize=4096, fulltextindexed=True)
    identical_to = SubjectRelation('Bug', symmetric=True)
示例#16
0
class CWAttribute(EntityType):
    """define a final relation: link a final relation type from a non final
    entity to a final entity type.

    used to build the instance schema
    """
    __permissions__ = PUB_SYSTEM_ENTITY_PERMS
    relation_type = SubjectRelation('CWRType', cardinality='1*',
                                    constraints=[RQLConstraint('O final TRUE')],
                                    composite='object')
    from_entity = SubjectRelation('CWEType', cardinality='1*',
                                  constraints=[RQLConstraint('O final FALSE')],
                                  composite='object')
    to_entity = SubjectRelation('CWEType', cardinality='1*',
                                constraints=[RQLConstraint('O final TRUE')],
                                composite='object')
    constrained_by = SubjectRelation('CWConstraint', cardinality='*1', composite='subject')

    cardinality = String(maxsize=2, internationalizable=True,
                         vocabulary=[_('?1'), _('11')],
                         description=_('subject/object cardinality'))
    ordernum = Int(description=('control subject entity\'s relations order'), default=0)

    formula = String(maxsize=2048)
    indexed = Boolean(description=_('create an index for quick search on this attribute'))
    fulltextindexed = Boolean(description=_('index this attribute\'s value in the plain text index'))
    internationalizable = Boolean(description=_('is this attribute\'s value translatable'))
    defaultval = Bytes(description=_('default value as gziped pickled python object'))
    extra_props = Bytes(description=_('additional type specific properties'))

    description = RichString(internationalizable=True,
                             description=_('semantic description of this attribute'))
示例#17
0
class CWRelation(EntityType):
    """define a non final relation: link a non final relation type from a non
    final entity to a non final entity type.

    used to build the instance schema
    """
    __permissions__ = PUB_SYSTEM_ENTITY_PERMS
    relation_type = SubjectRelation('CWRType', cardinality='1*',
                                    constraints=[RQLConstraint('O final FALSE')],
                                    composite='object')
    from_entity = SubjectRelation('CWEType', cardinality='1*',
                                  constraints=[RQLConstraint('O final FALSE')],
                                  composite='object')
    to_entity = SubjectRelation('CWEType', cardinality='1*',
                                constraints=[RQLConstraint('O final FALSE')],
                                composite='object')
    constrained_by = SubjectRelation('CWConstraint', cardinality='*1', composite='subject')

    cardinality = String(maxsize=2, internationalizable=True,
                         vocabulary=CARDINALITY_VOCAB,
                         description=_('subject/object cardinality'))
    ordernum = Int(description=_('control subject entity\'s relations order'),
                   default=0)
    composite = String(description=_('is the subject/object entity of the relation '
                                     'composed of the other ? This implies that when '
                                     'the composite is deleted, composants are also '
                                     'deleted.'),
                       vocabulary=('', _('subject'), _('object')),
                       maxsize=8, default=None)

    description = RichString(internationalizable=True,
                             description=_('semantic description of this relation'))
示例#18
0
class Scan(EntityType):
    label = String(maxsize=256,
                   required=True,
                   indexed=True,
                   fulltextindexed=True)
    identifier = String(required=True, maxsize=128, unique=True)
    type = String(maxsize=256, required=True, indexed=True)
    number = Int(indexed=False)
    format = String(maxsize=128, indexed=True)
示例#19
0
class Intervenant(EntityType): # MLIntervenant
    intervenant = SubjectRelation('Personne', cardinality='1*', composite='object', inlined=True)
    indemnite = Int()
    nb_moyen_transport = Int()
    moyen_transport = String(maxsize=255, fulltextindexed=True)
    prix_transport = SubjectRelation('Prix', cardinality='??')
    nombre_valets = Int()
    prix_valet = SubjectRelation('Prix', cardinality='??')
    duree = Int() # XXX
    payeur = Boolean(default=False, required=True)
    pris = Boolean(default=False, required=True)
    commandement = Boolean(default=False, required=True)
    relation_de = Boolean(default=False, required=True)
    donne_par = Boolean()
    par_la_main = Boolean()
    present = Boolean()
    delivre_a = Boolean()
    fait_compte_avec  = Boolean()
示例#20
0
class Occupation(EntityType):
    libelle = String(maxsize=255, fulltextindexed=True)
    valeur = String(maxsize=255, fulltextindexed=True)
    compte = SubjectRelation('Compte', cardinality='?*')
    annee = Int()
    pagination = String(maxsize=64, fulltextindexed=True)
    rattache_a = SubjectRelation('Personne', cardinality='?*')
    occupation = String(maxsize=255, fulltextindexed=True)
    personne = SubjectRelation('Personne', cardinality = '?*', composite='subject', inlined=True)
示例#21
0
class Location(EntityType):
    """
    Entity type for location of Geonames.
    See cities1000.zip, cities5000.zip, cities15000.zip and allCountries.txt
    """
    name = String(maxsize=1024, indexed=True, fulltextindexed=True)
    geonameid = Int(indexed=True)
    asciiname = String(maxsize=200, fulltextindexed=True)
    alternatenames = String(fulltextindexed=True)
    latitude = Float(indexed=True)
    longitude = Float(indexed=True)
    feature_class = String(maxsize=1, indexed=True)
    alternate_country_code = String(maxsize=60)
    admin_code_3 = String(maxsize=20)
    admin_code_4 = String(maxsize=20)
    population = BigInt(indexed=True)
    elevation = Int(indexed=True)
    gtopo30 = Int(indexed=True)
    timezone = SubjectRelation('TimeZone', cardinality='?*', inlined=True)
示例#22
0
class GenomicMeasure(EntityType):
    """ A genomic measure """
    type = String(maxsize=256, required=True, indexed=True)
    format = String(maxsize=128, indexed=True)
    chip_serialnum = Int()
    completed = Boolean(indexed=True)
    chromset = String(maxsize=64)
    valid = Boolean(indexed=True)
    identifier = String(maxsize=128, fulltextindexed=True)
    label = String(maxsize=64)
示例#23
0
文件: schema.py 项目: zogzog/cubicweb
class Societe(EntityType):
    __unique_together__ = [('nom', 'type', 'cp')]
    __permissions__ = {
        'read': ('managers', 'users', 'guests'),
        'update': ('managers', 'owners', ERQLExpression('U login L, X nom L')),
        'delete': ('managers', 'owners', ERQLExpression('U login L, X nom L')),
        'add': ('managers', 'users',)
    }

    nom  = String(maxsize=64, fulltextindexed=True)
    web  = String(maxsize=128)
    type  = String(maxsize=128) # attribute in common with Note
    tel  = Int()
    fax  = Int()
    rncs = String(maxsize=128)
    ad1  = String(maxsize=128)
    ad2  = String(maxsize=128)
    ad3  = String(maxsize=128)
    cp   = String(maxsize=12)
    ville= String(maxsize=32)
示例#24
0
class Prix(EntityType):
    monnaie = SubjectRelation('Monnaie', cardinality='1*', inlined=True)
    livres = Int()
    sous = Int()
    deniers = Float()
    florins = Float()
    florin_ad = Float(description="nombre de deniers(?) dans un 'florin'")
    gros = Float()
    sous_florins = Int()
    denier_florins = Float()
    monnaie_or = Float()
    conversion = Float()
    source = String(vocabulary=[_('direct'),
                                _('conv_transaction'),
                                _('conv_compte'),
                                _('conv_voisin'),
                                _('conv_voisin 2'),
                                _('conv_externe'),
                                _('no_transaction'),])

    changes = SubjectRelation('Change', cardinality='**')
示例#25
0
文件: schema.py 项目: zogzog/cubicweb
class Societe(WorkflowableEntityType):
    __permissions__ = {
        'read': ('managers', 'users', 'guests'),
        'update': ('managers', 'owners'),
        'delete': ('managers', 'owners'),
        'add': ('managers', 'users',)
        }
    nom  = String(maxsize=64, fulltextindexed=True)
    web  = String(maxsize=128)
    tel  = Float()
    fax  = Int()
    rncs = String(maxsize=128)
    ad1  = String(maxsize=128)
    ad2  = String(maxsize=128)
    ad3  = String(maxsize=128)
    cp   = String(maxsize=12)
    ville= String(maxsize=32)
示例#26
0
class Subject(EntityType):
    """ The subject """
    code_in_study = String(required=True,
                           unique=True,
                           fulltextindexed=True,
                           indexed=True,
                           maxsize=64)
    identifier = String(required=True, maxsize=128, unique=True)
    surname = String(fulltextindexed=True, maxsize=256)
    gender = String(required=True,
                    indexed=True,
                    vocabulary=('male', 'female', 'unknown'))
    handedness = String(required=True,
                        indexed=True,
                        vocabulary=('right', 'left', 'ambidextrous', 'mixed',
                                    'unknown'))
    position_in_family = String(maxsize=64)
    siblings_status = Int(required=False)
    dataset_status = String(maxsize=64, required=False, default='Valid')
示例#27
0
文件: schema.py 项目: zogzog/cubicweb
class Note(Para):
    __specializes_schema__ = True

    __permissions__ = {'read':   ('managers', 'users', 'guests',),
                   'update': ('managers', 'owners',),
                   'delete': ('managers', ),
                   'add':    ('managers',
                              ERQLExpression('X ecrit_part PE, U in_group G, '
                                             'PE require_permission P, P name "add_note", '
                                             'P require_group G'),)}

    whatever = Int(default=0)  # keep it before `date` for unittest_migraction.test_add_attribute_int
    yesno = Boolean(default=False)
    date = Datetime()
    type = String(maxsize=1)
    unique_id = String(maxsize=1, required=True, unique=True)
    mydate = Date(default='TODAY')
    oldstyledefaultdate = Date(default='2013/01/01')
    newstyledefaultdate = Date(default=dt.date(2013, 1, 1))
    shortpara = String(maxsize=11, default='hop', vocabulary=['hop', 'hop hop', 'hop hop hop'])
    ecrit_par = SubjectRelation('Personne', constraints=[RQLConstraint('S concerne A, O concerne A')])
    attachment = SubjectRelation('File')
示例#28
0
class TrInfo(EntityType):
    """workflow history item"""
    # 'add' security actually done by hooks
    __permissions__ = {
        'read': (
            'managers',
            'users',
            'guests',
        ),  # XXX U has_read_permission O ?
        'add': (
            'managers',
            'users',
            'guests',
        ),
        'delete': (),  # XXX should we allow managers to delete TrInfo?
        'update': (
            'managers',
            'owners',
        ),
    }
    # The unique_together constraint ensures that 2 repositories
    # sharing the db won't be able to fire a transition simultaneously
    # on the same entity tr_count is filled in the FireTransitionHook
    # to the number of TrInfo attached to the entity on which we
    # attempt to fire a transition. In other word, it contains the
    # rank of the TrInfo for that entity, and the constraint says we
    # cannot have 2 TrInfo with the same rank.
    __unique_together__ = [('tr_count', 'wf_info_for')]
    from_state = SubjectRelation('State', cardinality='1*', inlined=True)
    to_state = SubjectRelation('State', cardinality='1*', inlined=True)
    # make by_transition optional because we want to allow managers to set
    # entity into an arbitrary state without having to respect wf transition
    by_transition = SubjectRelation('BaseTransition', cardinality='?*')
    comment = RichString(fulltextindexed=True, default_format='text/plain')
    tr_count = Int(
        description='autocomputed attribute used to ensure transition coherency'
    )
示例#29
0
    def test_unfinalized_manipulation(self):
        class MyEntity(EntityType):
            base_arg_b = String()
            base_arg_a = Boolean()
            base_sub = SubjectRelation('MyOtherEntity')
        class base_obj(RelationDefinition):
            subject = 'MyOtherEntity'
            object = 'MyEntity'
        class MyOtherEntity(EntityType):
            base_o_obj = SubjectRelation('MyEntity')
        class base_o_sub(RelationDefinition):
            subject = 'MyEntity'
            object = 'MyOtherEntity'
        MyEntity.add_relation(Date(), name='new_arg_a')
        MyEntity.add_relation(Int(), name='new_arg_b')
        MyEntity.add_relation(SubjectRelation('MyOtherEntity'), name="new_sub")
        MyOtherEntity.add_relation(SubjectRelation('MyEntity'), name="new_o_obj")
        class new_obj(RelationDefinition):
            subject = 'MyOtherEntity'
            object = 'MyEntity'
        class new_o_sub(RelationDefinition):
            subject = 'MyEntity'
            object = 'MyOtherEntity'

        schema = build_schema_from_namespace(locals().items())
        self.assertIn('MyEntity', schema.entities())
        my_entity = schema['MyEntity']
        attributes_def = my_entity.attribute_definitions()
        attributes = sorted(attr[0].type for attr in attributes_def)
        self.assertEqual(['base_arg_a', 'base_arg_b', 'new_arg_a', 'new_arg_b'],
                         attributes)
        relations_def = my_entity.relation_definitions()
        relations = sorted( rel[0].type for rel in relations_def)
        self.assertEqual(['base_o_obj', 'base_o_sub', 'base_obj',
                          'base_sub', 'new_o_obj', 'new_o_sub', 'new_obj',
                          'new_sub'],
                         relations)
示例#30
0
文件: schema.py 项目: zogzog/cubicweb
class EmailPart(EntityType):
    """an email attachment"""
    __permissions__ = {
        'read': (
            'managers',
            'users',
            'guests',
        ),  # XXX if E parts X, U has_read_permission E
        'add': (
            'managers',
            ERQLExpression('E parts X, U has_update_permission E'),
        ),
        'delete':
        ('managers', ERQLExpression('E parts X, U has_update_permission E')),
        'update': (
            'managers',
            'owners',
        ),
    }

    content = String(fulltextindexed=True)
    content_format = String(required=True, maxsize=50)
    ordernum = Int(required=True)
    alternative = SubjectRelation('EmailPart', symmetric=True)