예제 #1
0
class Membership(model.Model):
    user = model.RelatedField(User, related_name='memberships')
    organisation = model.RelatedField(Organisation, related_name='memberships')
    role = model.TextField(null=True)
    active = model.BoolField(default=False)

    class Meta:
        # TODO: How to unique only one active per user? Check?
        uniques = (('user', 'organisation', 'role'), )
        policies = (UserPolicy('auth_membership.user'), )
예제 #2
0
class Actor(model.Model):
    first_name = model.TextField()
    last_name = model.TextField()
    age = model.IntField(null=True)
    address = model.RelatedField(Address, null=True)
    user = model.RelatedField(User,
                              null=True,
                              default=model.session('claims.user_id', 'int'))

    class Meta:
        uniques = (('first_name', 'last_name'), )
        checks = ('first_name is not null or last_name is not null', )
예제 #3
0
class Organisation(model.Model):
    name = model.TextField()
    entity = model.RelatedField(Entity,
                                related_name='organisations',
                                null=True)  # TODO: One-to-one

    class Meta:
        policies = (DirectOrganisationMemberPolicy(), )
예제 #4
0
class User(model.Model):
    name = model.TextField(null=True)
    email = model.EmailField(null=True, unique=True)
    password = model.PasswordField(null=True, omit=omit.ALL)
    logged_out = model.DatetimeField(null=True, omit=omit.ALL)
    created = model.DatetimeField(default=model.Auto)
    anonymous = model.BoolField(default=False)
    entity = model.RelatedField(Entity, related_name='users',
                                null=True)  # TODO: One-to-one

    class Meta:
        policies = (OwnerPolicy('auth_user.entity'), )
예제 #5
0
class Planet(model.Model):
    name = model.TextField(null=False)
    film = model.RelatedField(Film)
예제 #6
0
class Character(model.Model):
    name = model.TextField(null=False)
    film = model.RelatedField(Film)
예제 #7
0
class RelatedDummyModel(model.Model):
    dummy = model.RelatedField(DummyModel, related_name='related_dummies')
    timestamp = model.DatetimeField()
예제 #8
0
class Store(model.Model):
    name = model.TextField()
    parent = model.RelatedField('self')

    class Meta:
        mutation_resolvers = [OverrideNameResolver()]
예제 #9
0
class Movie(model.Model):
    title = model.TextField(unique=True)
    star = model.RelatedField(Actor)
예제 #10
0
class JWTType(model.Type):
    token = model.TextField()
    user = model.RelatedField(User,
                              null=True)  # TODO: Omit reverse relationships
    organisation = model.RelatedField(
        Organisation, null=True)  # TODO: Omit reverse relationships