Пример #1
0
class RestrictedFile(EntityType):
    """ A downloadable file which may contains binary data
    """
    title = String(required=True, indexed=True, maxsize=256)
    data = Bytes(required=True,
                 fulltextindexed=True,
                 description=_('file to upload'))
    data_format = String(
        required=True,
        maxsize=128,
        description=_('MIME type of the file. Should be dynamically set at '
                      'upload time.'))
    data_encoding = String(
        maxsize=32,
        description=_('encoding of the file when it applies (e.g. text). '
                      'Should be dynamically set at upload time.'))
    data_name = String(
        required=True,
        fulltextindexed=True,
        description=_('name of the file. Should be dynamically set at upload '
                      'time.'))
    data_sha1hex = String(
        maxsize=40,
        description=_('SHA1 sum of the file. May be set at upload time.'))
    description = RichString(fulltextindexed=True,
                             internationalizable=True,
                             default_format='text/rest')
Пример #2
0
class Personne(EntityType):
    __unique_together__ = [('nom', 'prenom', 'inline2')]
    nom = String(fulltextindexed=True, required=True, maxsize=64)
    prenom = String(fulltextindexed=True, maxsize=64)
    inline2 = SubjectRelation('Affaire', inlined=True, cardinality='?*')

    custom_field_of_jungle = BabarTestType(jungle_speed=42)
Пример #3
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)
Пример #4
0
class Personne(EntityType):
    nom = String(required=True)
    prenom = String()
    type = String()
    travaille = SubjectRelation('Societe')
    evaluee = SubjectRelation(('Note', 'Personne'))
    connait = SubjectRelation(
        'Personne',
        symmetric=True,
        constraints=[
            RQLConstraint('NOT S identity O'),
            # conflicting constraints, see cw_unrelated_rql tests in
            # unittest_entity.py
            RQLVocabularyConstraint('NOT (S connait P, P nom "toto")'),
            RQLVocabularyConstraint('S travaille P, P nom "tutu"')
        ])
    actionnaire = SubjectRelation(
        'Societe',
        cardinality='??',
        constraints=[RQLConstraint('NOT EXISTS(O contrat_exclusif S)')])
    dirige = SubjectRelation('Societe',
                             cardinality='??',
                             constraints=[RQLConstraint('S actionnaire O')])
    associe = SubjectRelation(
        'Personne',
        cardinality='?*',
        constraints=[RQLConstraint('S actionnaire SOC, O actionnaire SOC')])
Пример #5
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'))
Пример #6
0
class UploadField(EntityType):
    """ An entity used to upload data but not file.

    Attributes
    ----------
    name: String (mandatory)
        the name field used in the form.
    value: String
        the value defined in the orm.
    type: String (mandatory)
        the value type.
    label: String (mandatory)
        the label used in the form.
    """

    # Set default permissions
    __permissions__ = UPLOAD_PERMISSIONS

    # The name field used in the form
    name = String(maxsize=64,
                  required=True,
                  description=unicode("name field used in form"))
    # The value defined in the form
    value = RichString(default_format="text/rest",
                       description=unicode("the value defined in the form."))
    # The value type
    type = String(maxsize=256,
                  required=True,
                  description=unicode("the value type."))
    # The label used in the form
    label = String(maxsize=64,
                   required=True,
                   description=unicode("the label used in the form."))
Пример #7
0
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='**')
Пример #8
0
class EmailAddress(EntityType):
    """an electronic mail address associated to a short alias"""
    __permissions__ = {
        # application that wishes public email, or use it for something else
        # than users (eg Company, Person), should explicitly change permissions
        'read': ('managers', ERQLExpression('U use_email X')),
        'add': (
            'managers',
            'users',
        ),
        'delete': ('managers', 'owners',
                   ERQLExpression('P use_email X, U has_update_permission P')),
        'update': ('managers', 'owners',
                   ERQLExpression('P use_email X, U has_update_permission P')),
    }

    alias = String(fulltextindexed=True, maxsize=56)
    address = String(required=True,
                     fulltextindexed=True,
                     indexed=True,
                     unique=True,
                     maxsize=128)
    prefered_form = SubjectRelation(
        'EmailAddress',
        cardinality='?*',
        description=_('when multiple addresses are equivalent \
(such as [email protected] and [email protected]), set this \
to indicate which is the preferred form.'))
Пример #9
0
class Note(WorkflowableEntityType):
    date = String(maxsize=10)
    type = String(vocabulary=[u'todo', u'a', u'b', u'T', u'lalala'])
    para = String(maxsize=512,
                  __permissions__={
                      'add': ('managers',
                              ERQLExpression('X in_state S, S name "todo"')),
                      'read': ('managers', 'users', 'guests'),
                      'update':
                      ('managers',
                       ERQLExpression('X in_state S, S name "todo"')),
                  })
    something = String(maxsize=1,
                       __permissions__={
                           'read': ('managers', 'users', 'guests'),
                           'add': (ERQLExpression('NOT X para NULL'), ),
                           'update': ('managers', 'owners')
                       })
    migrated_from = SubjectRelation('Note')
    attachment = SubjectRelation('File')
    inline1 = SubjectRelation('Affaire',
                              inlined=True,
                              cardinality='?*',
                              constraints=[
                                  RQLUniqueConstraint(
                                      'S type T, S inline1 A1, A1 todo_by C, '
                                      'Y type T, Y inline1 A2, A2 todo_by C',
                                      'S,Y')
                              ])
    todo_by = SubjectRelation('CWUser')
Пример #10
0
class File(EntityType):
    """a downloadable file which may contains binary data"""
    title = String(fulltextindexed=True, maxsize=256)
    data = Bytes(required=True, description='file to upload')
    data_format = String(
        required=True,
        maxsize=128,
        description=('MIME type of the file. Should be dynamically set '
                     'at upload time.'))
    data_encoding = String(
        maxsize=32,
        description=('encoding of the file when it applies (e.g. text). '
                     'Should be dynamically set at upload time.'))
    data_name = String(
        required=True,
        fulltextindexed=True,
        description=('name of the file. Should be dynamically set '
                     'at upload time.'))
    data_hash = String(
        maxsize=256,  # max len of currently available hash alg + prefix is 140
        description=('hash of the file. May be set at upload time.'),
        __permissions__={
            'read': ('managers', 'users', 'guests'),
            'add': (),
            'update': ()
        })
    description = RichString(fulltextindexed=True,
                             internationalizable=True,
                             default_format='text/rest')
Пример #11
0
class Center(EntityType):
    """ A center used for study """
    identifier = String(required=True, unique=True, maxsize=64)
    name = String(maxsize=256, required=True, indexed=True)
    department = String(maxsize=256)
    city = String(maxsize=64)
    country = String(maxsize=64)
Пример #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 SubjectGroup(EntityType):
    """ Group of subject """
    identifier = String(required=True, unique=True, maxsize=64)
    name = String(maxsize=64, required=True, indexed=False)
    type = String(maxsize=64,
                  required=True,
                  vocabulary=[u"family", u"schedule"])
Пример #14
0
class Bookmark(EntityType):
    """bookmarks are used to have user's specific internal links"""
    __permissions__ = {
        'read': (
            'managers',
            'users',
            'guests',
        ),
        'add': (
            'managers',
            'users',
        ),
        'delete': (
            'managers',
            'owners',
        ),
        'update': (
            'managers',
            'owners',
        ),
    }

    title = String(required=True, maxsize=128, internationalizable=True)
    path = String(maxsize=2048,
                  required=True,
                  description=_("relative url of the bookmarked page"))

    bookmarked_by = SubjectRelation('CWUser',
                                    description=_("users using this bookmark"))
Пример #15
0
class ExternalResource(EntityType):
    """ An entity used to to store a file path.

    Attributes
    ----------
    name: String (mandatory)
        the parameter name.
    filepath: String (mandatory)
        the file path.
    uploaded_by: SubjectRelation (mandatory)
        who has created the item.
    """
    # Set default permissions
    __permissions__ = {
        "read": (
            "managers",
            ERQLExpression("X uploaded_by U"),
        ),
        "add": ("managers", "users"),
        "delete": ("managers", ),
        "update": ("managers", ),
    }

    # Entity parameters
    name = String(required=True, indexed=False)
    filepath = String(required=True, indexed=False)

    # The link to the owner of the data
    uploaded_by = SubjectRelation("CWUser",
                                  cardinality="1*",
                                  composite="subject")
Пример #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 CWUser(WorkflowableEntityType):
    """define a CubicWeb user"""
    __permissions__ = {
        'read': ('managers', 'users', ERQLExpression('X identity U')),
        'add': ('managers', ),
        'delete': ('managers', ),
        'update': (
            'managers',
            ERQLExpression('X identity U, NOT U in_group G, G name "guests"'),
        ),
    }

    login = String(
        required=True,
        unique=True,
        maxsize=64,
        description=_('unique identifier used to connect to the application'))
    upassword = Password(
        required=True)  # password is a reserved word for mysql
    firstname = String(maxsize=64)
    surname = String(maxsize=64)
    last_login_time = TZDatetime(description=_('last connection date'))
    in_group = SubjectRelation(
        'CWGroup',
        cardinality='+*',
        constraints=[RQLConstraint('NOT O name "owners"')],
        description=_('groups grant permissions to the user'))
Пример #18
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='?*')
Пример #19
0
class Gene(EntityType):
    """Gene entity defintion.

    A gene is characterized by the following attributes:

    - label, defined through a Yams String.
    - bio2rdf_symbol, also defined as a Yams String, since it is 
      just an identifier.
    - gene_id is a URI identifying a gene, hence it is defined
      as a relation with an ``ExternalUri`` object.
    - a pair of unique identifiers in the HUGO Gene Nomenclature
      Committee (http://http://www.genenames.org/). They are defined
      as ``ExternalUri`` entities as well.
    - same_as is also defined through a URI, and hence through a
      relation having ``ExternalUri`` entities as objects.
    """
    # Corresponds to http://www.w3.org/2000/01/rdf-schema#label
    label = String(maxsize=512, fulltextindexed=True)
    # Corresponds to http://www4.wiwiss.fu-berlin.de/diseasome/resource/
    # diseasome/geneId
    gene_id = SubjectRelation('ExternalUri', cardinality='**')
    # Corresponds to http://www4.wiwiss.fu-berlin.de/diseasome/resource/
    # diseasome/hgncId
    hgnc_id = SubjectRelation('ExternalUri', cardinality='**')
    # Corresponds to http://www4.wiwiss.fu-berlin.de/diseasome/resource/
    # diseasome/hgncIdPage
    hgnc_page = SubjectRelation('ExternalUri', cardinality='**')
    # Corresponds to http://www4.wiwiss.fu-berlin.de/diseasome/resource/
    # diseasome/bio2rdfSymbol
    bio2rdf_symbol = String(maxsize=64, fulltextindexed=True)
    #Corresponds to http://www.w3.org/2002/07/owl#sameAs
    same_as = SubjectRelation('ExternalUri', cardinality='**')
Пример #20
0
class CWUpload(EntityType):
    """ An entity used to upload data.

    Attributes
    ----------
    form_name: String (mandatory)
        the name of the form used to upload data.
    status: String (mandatory)
        the status od the upload.
        the value must be 'Quarantine', 'Rejected' or 'Validated'.
    error: String
        the message error if the stutis is 'Rejected'
    """

    # Set default permissions
    __permissions__ = UPLOAD_PERMISSIONS

    # The name of the form used to upload data
    form_name = String(
        maxsize=256,
        required=True,
        description=unicode("form name label used to upload data."))
    # The status of the upload
    status = String(required=True,
                    vocabulary=("Quarantine", "Rejected", "Validated"),
                    description=unicode("upload status."))
    # The error message of the upload
    error = RichString(default_format="text/rest",
                       description=unicode("eror message."))
Пример #21
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)
Пример #22
0
class Personne(EntityType):
    nom = String(required=True)
    prenom = String()
    enfant = SubjectRelation('Personne', inlined=True, cardinality='?*')
    connait = SubjectRelation('Personne',
                              symmetric=True,
                              constraints=[RQLConstraint('NOT S identity O')])
    photo = Bytes()
Пример #23
0
class CWComputedRType(EntityType):
    """define a virtual relation type, used to build the instance schema"""
    __permissions__ = PUB_SYSTEM_ENTITY_PERMS
    name = String(required=True, indexed=True, internationalizable=True,
                  unique=True, maxsize=64)
    description = RichString(internationalizable=True,
                             description=_('semantic description of this relation type'))
    rule = String(required=True)
Пример #24
0
class School(EntityType):
    """an (high) school"""
    name        = String(required=True, fulltextindexed=True, maxsize=128)
    address     = String(maxsize=512)
    description = String(fulltextindexed=True)

    phone     = SubjectRelation('PhoneNumber', composite='subject')
    use_email = SubjectRelation('EmailAddress', composite='subject')
Пример #25
0
class Affaire(EntityType):
    sujet = String(maxsize=128)
    ref = String(maxsize=12)

    concerne = SubjectRelation('Societe')
    obj_wildcard = SubjectRelation('*')
    sym_rel = SubjectRelation('Person', symmetric=True)
    inline_rel = SubjectRelation('Person', inlined=True, cardinality='?*')
Пример #26
0
class Blog(EntityType):
    title = String(maxsize=50, required=True)
    description = RichString()
    rss_url = String(
        maxsize=128,
        description=
        ('blog\'s rss url (useful for when using external site such as feedburner)'
         ))
Пример #27
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)
Пример #28
0
class ExternalFile(EntityType):
    """ An external resource file (e.g. an absolute/relative filepath).

    If not absolute_path, use the data_filepath of the study
    """
    identifier = String(required=True, maxsize=256, unique=True)
    name = String(maxsize=256)
    absolute_path = Boolean(default=True)
    filepath = String(required=True, indexed=True, maxsize=256)
Пример #29
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)
Пример #30
0
class ScoreDefinition(EntityType):
    name = String(maxsize=256, required=True, fulltextindexed=True)
    category = String(maxsize=64, fulltextindexed=True)
    type = String(
        required=True,
        indexed=True,
        vocabulary=('string', 'numerical', 'logical'),
    )
    unit = String(maxsize=16, indexed=True)
    possible_values = String(maxsize=256, fulltextindexed=True)