示例#1
0
            'institusjon':
            ou.institusjon,
            'stedkode':
            "{:02d}{:02d}{:02d}".format(ou.fakultet, ou.institutt,
                                        ou.avdeling),
        })
    except AttributeError:
        pass

    return data


OrganizationalUnit = api.model(
    'OrganizationalUnit', {
        'href':
        fields.href('.ou'),
        'id':
        fields.base.Integer(description='OU entity ID'),
        'contact':
        fields.base.List(fields.base.Nested(models.EntityContactInfo),
                         description='Contact information'),
        'names':
        fields.base.List(fields.base.Nested(models.EntityNameWithLanguage),
                         description='Names'),
        'contexts':
        fields.base.List(fields.Constant(ctype='Spread'),
                         description='Visible in these contexts'),
        'stedkode':
        fields.base.String(),
        'fakultet':
        fields.base.Integer(),
示例#2
0
        attribute='name_language',
        description='Language'),
    'name': fields.base.String(
        description='Name'),
})


EntityConsent = api.model('EntityConsent', {
    'name': fields.base.String(
        description='Consent name'),
    'description': fields.base.String(
        description='Consent description'),
    'type': fields.base.String(
        description='Consent type'),
    'set_at': fields.DateTime(
        dt_format='iso8601',
        description='Consent set at'),
    'expires': fields.DateTime(
        dt_format='iso8601',
        description='Consent expires at'),
})


# Model for referencing OUs by ID
OU = api.model('OU', {
    'href': fields.href(
        '.ou', description='OU resource URL'),
    'id': fields.base.Integer(
        description='OU entity ID'),
})
示例#3
0
    'visibility':
    crb_fields.Constant(ctype='GroupVisibility',
                        transform=GroupVisibility.serialize,
                        description='group visibility'),
    'description':
    base_fields.String(description='group description'),
    'created_at':
    crb_fields.DateTime(dt_format='iso8601', description='creation timestamp'),
    'expire_date':
    crb_fields.DateTime(dt_format='iso8601', description='expire date'),
}

Group = api.model(
    'Group', {
        'href':
        crb_fields.href('.group'),
        'id':
        _group_fields['id'],
        'name':
        _group_fields['name'],
        'visibility':
        _group_fields['visibility'],
        'description':
        _group_fields['description'],
        'created_at':
        _group_fields['created_at'],
        'expire_date':
        _group_fields['expire_date'],
        'contexts':
        base_fields.List(crb_fields.Constant(ctype='Spread'),
                         description='Visible in these contexts'),
示例#4
0
文件: person.py 项目: chrnux/cerebrum
})

PersonName = api.model('PersonName', {
    'source_system': fields.Constant(
        ctype='AuthoritativeSystem',
        description='Source system'),
    'variant': fields.Constant(
        ctype='PersonName',
        attribute='name_variant',
        description='Name variant'),
    'name': fields.base.String(
        description='Name value'),
})

PersonAccount = api.model('PersonAccount', {
    'href': fields.href('.account'),
    'id': fields.base.String(
        description='Account ID'),
    'primary': fields.base.Boolean(
        description='Is this a primary account?'),
})

Person = api.model('Person', {
    'href': fields.href('.person'),
    'id': fields.base.Integer(
        default=None,
        description='Person entity ID'),
    'birth_date': fields.DateTime(
        dt_format='iso8601',
        description='Birth date'),
    'created_at': fields.DateTime(
示例#5
0
    'priority': fields.base.Integer(
        description='Affiliation priority'),
    'ou': fields.base.Nested(
        models.OU,
        description='Organizational unit'),
})

AccountAffiliationList = api.model('AccountAffiliationList', {
    'affiliations': fields.base.List(
        fields.base.Nested(
            AccountAffiliation),
        description='Account affiliations'),
})

Account = api.model('Account', {
    'href': fields.href('.account'),
    'name': fields.base.String(
        description='Account name'),
    'id': fields.base.Integer(
        default=None,
        description='Entity ID'),
    'owner': fields.base.Nested(
        models.EntityOwner,
        description='Entity owner'),
    'created_at': fields.DateTime(
        dt_format='iso8601',
        description='Account creation timestamp'),
    'expire_date': fields.DateTime(
        dt_format='iso8601',
        description='Expiration date'),
    'contexts': fields.base.List(
示例#6
0
_group_fields = {
    'id': base_fields.Integer(description='group id'),
    'name': base_fields.String(description='group name'),
    'visibility': crb_fields.Constant(ctype='GroupVisibility',
                                      transform=GroupVisibility.serialize,
                                      description='group visibility'),
    'description': base_fields.String(description='group description'),
    'created_at': crb_fields.DateTime(dt_format='iso8601',
                                      description='creation timestamp'),
    'expire_date': crb_fields.DateTime(dt_format='iso8601',
                                       description='expire date'),
}


Group = api.model('Group', {
    'href': crb_fields.href('.group'),
    'id': _group_fields['id'],
    'name': _group_fields['name'],

    'visibility': _group_fields['visibility'],
    'description': _group_fields['description'],
    'created_at': _group_fields['created_at'],
    'expire_date': _group_fields['expire_date'],

    'contexts': base_fields.List(
        crb_fields.Constant(ctype='Spread'),
        description='Visible in these contexts'),
    'moderators': crb_fields.href(
        '.group-moderators',
        description='URL to the resource containing group moderators'),
    'members': crb_fields.href(
示例#7
0
文件: search.py 项目: chrnux/cerebrum
from flask_restplus import Namespace, Resource, abort
from flask_restplus import fields as base_fields

from Cerebrum.Entity import EntityExternalId
from Cerebrum import Errors

from Cerebrum.rest.api import db, auth, utils
from Cerebrum.rest.api import fields as crb_fields
from Cerebrum.rest.api.v1 import models

api = Namespace('search', description='Search operations')


ExternalIdItem = api.model('ExternalIdItem', {
    'href': crb_fields.href(
        endpoint='.person'),
    'person_id': base_fields.Integer(
        description='Person ID',
        attribute='entity_id'),
    'source_system': crb_fields.Constant(
        ctype='AuthoritativeSystem',
        description='Source system'),
    'id_type': crb_fields.Constant(
        ctype='EntityExternalId',
        transform=models.ExternalIdType.serialize,
        description='External ID type'),
    'external_id': base_fields.String(
        description='External ID value')
})

示例#8
0
            'landkode': ou.landkode,
            'fakultet': ou.fakultet,
            'institutt': ou.institutt,
            'avdeling': ou.avdeling,
            'institusjon': ou.institusjon,
            'stedkode': "{:02d}{:02d}{:02d}".format(
                ou.fakultet, ou.institutt, ou.avdeling),
        })
    except AttributeError:
        pass

    return data


OrganizationalUnit = api.model('OrganizationalUnit', {
    'href': fields.href('.ou'),
    'id': fields.base.Integer(
        description='OU entity ID'),
    'contact': fields.base.List(
        fields.base.Nested(models.EntityContactInfo),
        description='Contact information'),
    'names': fields.base.List(
        fields.base.Nested(models.EntityNameWithLanguage),
        description='Names'),
    'contexts': fields.base.List(
        fields.Constant(ctype='Spread'),
        description='Visible in these contexts'),
    'stedkode': fields.base.String(),
    'fakultet': fields.base.Integer(),
    'institutt': fields.base.Integer(),
    'avdeling': fields.base.Integer(),
示例#9
0
                        attribute='name_variant',
                        description='Name variant'),
        'language':
        fields.Constant(ctype='LanguageCode',
                        attribute='name_language',
                        description='Language'),
        'name':
        fields.base.String(description='Name'),
    })

EntityConsent = api.model(
    'EntityConsent', {
        'name':
        fields.base.String(description='Consent name'),
        'description':
        fields.base.String(description='Consent description'),
        'type':
        fields.base.String(description='Consent type'),
        'set_at':
        fields.DateTime(dt_format='iso8601', description='Consent set at'),
        'expires':
        fields.DateTime(dt_format='iso8601', description='Consent expires at'),
    })

# Model for referencing OUs by ID
OU = api.model(
    'OU', {
        'href': fields.href('.ou', description='OU resource URL'),
        'id': fields.base.Integer(description='OU entity ID'),
    })
示例#10
0
})

PersonName = api.model('PersonName', {
    'source_system': fields.Constant(
        ctype='AuthoritativeSystem',
        description='Source system'),
    'variant': fields.Constant(
        ctype='PersonName',
        attribute='name_variant',
        description='Name variant'),
    'name': fields.base.String(
        description='Name value'),
})

PersonAccount = api.model('PersonAccount', {
    'href': fields.href('.account'),
    'id': fields.base.String(
        description='Account ID'),
    'name': fields.base.String(
        description='Account name'),
    'primary': fields.base.Boolean(
        description='Is this a primary account?'),
})

Person = api.model('Person', {
    'href': fields.href('.person'),
    'id': fields.base.Integer(
        default=None,
        description='Person entity ID'),
    'birth_date': fields.DateTime(
        dt_format='iso8601',
示例#11
0
    },
)

PersonName = api.model(
    "PersonName",
    {
        "source_system": fields.Constant(ctype="AuthoritativeSystem", description="Source system"),
        "variant": fields.Constant(ctype="PersonName", attribute="name_variant", description="Name variant"),
        "name": fields.base.String(description="Name value"),
    },
)

PersonAccount = api.model(
    "PersonAccount",
    {
        "href": fields.href(".account"),
        "id": fields.base.String(description="Account ID"),
        "primary": fields.base.Boolean(description="Is this a primary account?"),
    },
)

Person = api.model(
    "Person",
    {
        "href": fields.href(".person"),
        "id": fields.base.Integer(default=None, description="Person entity ID"),
        "birth_date": fields.DateTime(dt_format="iso8601", description="Birth date"),
        "created_at": fields.DateTime(dt_format="iso8601", description="Creation timestamp"),
        "names": fields.base.List(fields.base.Nested(PersonName), description="Names"),
        "contexts": fields.base.List(fields.Constant(ctype="Spread"), description="Visible in these contexts"),
    },