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'), )
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', )
class Organisation(model.Model): name = model.TextField() entity = model.RelatedField(Entity, related_name='organisations', null=True) # TODO: One-to-one class Meta: policies = (DirectOrganisationMemberPolicy(), )
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'), )
class Planet(model.Model): name = model.TextField(null=False) film = model.RelatedField(Film)
class Character(model.Model): name = model.TextField(null=False) film = model.RelatedField(Film)
class RelatedDummyModel(model.Model): dummy = model.RelatedField(DummyModel, related_name='related_dummies') timestamp = model.DatetimeField()
class Store(model.Model): name = model.TextField() parent = model.RelatedField('self') class Meta: mutation_resolvers = [OverrideNameResolver()]
class Movie(model.Model): title = model.TextField(unique=True) star = model.RelatedField(Actor)
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