Example #1
0
    class Contacts(Model):
        class Address(Model):
            type = fields.String()
            street = fields.String()
            city = fields.String()
            state = fields.String()
            zip = fields.String()
            country = fields.String()

        class Email(Model):
            type = fields.String()
            email_address = fields.String(name='emailAddress')

        class Phone(Model):
            type = fields.String()
            phone_number = fields.String(name='phoneNumber')

        class Website(Model):
            type = fields.String()
            web_service = fields.String(
                name='webService',
                choices=
                'URL SKYPE TWITTER FACEBOOK LINKED_IN XING FEED GOOGLE_PLUS FLICKR GITHUB YOUTUBE'
                .split())
            web_address = fields.String(name='webAddress')

        address = fields.Embedded(Address)
        email = fields.Embedded(Email)
        phone = fields.Embedded(Phone)
        website = fields.Embedded(Website)
Example #2
0
class ArticleL1(Model):

    id = fields.Integer(required=True)
    title = fields.String(required=True)
    doi = fields.String(required=True)
    url = fields.String(required=True)
    published_date = Date(required=True)

    citation = fields.String()
    confidential_reason = fields.String()
    embargo_type = fields.String()
    is_confidential = fields.Boolean()
    size = fields.Integer()
    funding = fields.String()
    tags = fields.Collection(fields.String)
    version = fields.Integer()
    is_active = fields.Integer()
    is_metadata_record = fields.Boolean()
    metadata_reason = fields.String()
    status = fields.String()
    description = fields.String()
    is_embargoed = fields.Boolean()
    embargo_date = Date()
    is_public = fields.Boolean()
    modified_date = Date()
    created_date = Date()
    has_linked_file = fields.Boolean()
    categories = fields.Collection(Category)
    license = fields.Embedded(License)
    defined_type = fields.Integer()
    published_date = Date()
    embargo_reason = fields.String()
    references = fields.Collection(fields.String)
Example #3
0
class User(Model):
    login = fields.String(required=True)
    email = fields.Email()
    name = fields.String()
    karma = fields.Integer()
    token = fields.Embedded(Token)
Example #4
0
class User(models.Model):
    login = fields.String(required=True)
    email = fields.Email()
    karma = fields.Integer()
    token = fields.Embedded(Token)
    friends = fields.Collection(Friend)
Example #5
0
 def setup(self):
     self.field = fields.Embedded(User)
Example #6
0
class Group(models.Model):
    name = fields.String()
    admin = fields.Embedded(User)
Example #7
0
class Person(Model):
    class Contacts(Model):
        class Address(Model):
            type = fields.String()
            street = fields.String()
            city = fields.String()
            state = fields.String()
            zip = fields.String()
            country = fields.String()

        class Email(Model):
            type = fields.String()
            email_address = fields.String(name='emailAddress')

        class Phone(Model):
            type = fields.String()
            phone_number = fields.String(name='phoneNumber')

        class Website(Model):
            type = fields.String()
            web_service = fields.String(
                name='webService',
                choices=
                'URL SKYPE TWITTER FACEBOOK LINKED_IN XING FEED GOOGLE_PLUS FLICKR GITHUB YOUTUBE'
                .split())
            web_address = fields.String(name='webAddress')

        address = fields.Embedded(Address)
        email = fields.Embedded(Email)
        phone = fields.Embedded(Phone)
        website = fields.Embedded(Website)

    id = fields.Integer(primary=True)
    title = fields.String()
    first_name = fields.String(name='firstName')
    last_name = fields.String(name='lastName')
    job_title = fields.String(name='jobTitle')
    organisation_name = fields.String(name='organisationName')
    contacts = fields.Embedded(Contacts)
    about = fields.String()

    created_on = fields.String(name='createdOn', read_only=True)
    updated_on = fields.String(name='updatedOn', read_only=True)

    def set_email_address(self, email_address):
        '''
        Convenience method sets email address.

        This just modifies the instance. It's the caller's
        responsibility to persist the change by re-adding
        the object.

        '''
        if self.contacts is None:
            self.contacts = self.Contacts()
        if self.contacts.email is None:
            self.contacts.email = self.Contacts.Email()
        self.contacts.email.email_address = email_address

    def __repr__(self):
        name_parts = [
            s for s in self.first_name, self.last_name if s is not None
        ]
        return 'Person({})'.format(' '.join(name_parts))