class Asset(orb.Table): id = orb.IdColumn() code = orb.StringColumn(flags={'Unique'}) display_name = orb.StringColumn() parent = orb.ReferenceColumn(reference='Asset') project = orb.ReferenceColumn(reference='Project') type = orb.StringColumn(flags={'Polymorphic'}) children = orb.ReverseLookup(from_column='Asset.parent') dependsOn = orb.Pipe(through_path='Dependency.target.source') dependencies = orb.Pipe(through_path='Dependency.source.target')
class Group(orb.Table): id = orb.IdColumn() name = orb.StringColumn() users = orb.Pipe(through_path='GroupUser.group.user') byName = orb.Index(columns=['name'], flags={'Unique'})
class Group(orb.Table): __resource__ = True id = orb.IdColumn() name = orb.StringColumn(flags={'Required'}) users = orb.Pipe(through_path='GroupUser.group.user') byName = orb.Index(columns=['name'], flags={'Unique'})
class Group(orb.Table): __resource__ = True id = orb.IdColumn() name = orb.StringColumn(flags={'Unique'}) owner = orb.ReferenceColumn(reference='User') users = orb.Pipe(through_path='GroupUser.group.user') groupUsers = orb.ReverseLookup(from_column='GroupUser.group') byName = orb.Index(columns=['name'], flags={'Unique'})
class UserSchema(orb.ModelMixin): id = orb.IdColumn() username = orb.StringColumn(flags={'Required'}) password = orb.StringColumn(flags={'Required'}) first_name = orb.StringColumn() last_name = orb.StringColumn() addresses = orb.ReverseLookup(from_column='Address.user') preferences = orb.ReverseLookup(from_column='Preference.user', flags={'Unique'}) groups = orb.Pipe(through_path='GroupUser.user.group') byUsername = orb.Index(columns=['username'], flags={'Unique'}) byName = orb.Index(columns=['first_name', 'last_name'])
class User(orb.Table): __resource__ = True id = orb.IdColumn() username = orb.StringColumn(flags={'Required'}) password = orb.StringColumn(flags={'Required', 'Private'}) groups = orb.Pipe(through_path='GroupUser.user.group') addresses = orb.ReverseLookup(from_column='Address.user') byUsername = orb.Index(columns=['username'], flags={'Unique'}) @classmethod @action(method='get') def run(cls, request): return 'user run model' @action(method='get', name='run') def run_record(self, request): return 'user run record' @classmethod @action(method='post', name='exec') def run_post_model(self, request): return 'user exec post model' @action(method='delete', name='run') def run_delete(self, request): return 'user run delete record' @action(method='patch', name='run') def run_patch(self, request): return 'user run patch record' @action(method='put', name='run') def run_put(self, request): return 'user run put record'
class User(orb.Table): __resouce__ = True id = orb.IdColumn() username = orb.StringColumn(flags={'Unique'}) password = orb.PasswordColumn() token = orb.TokenColumn() groups = orb.Pipe(through='GroupUser', from_='user', to='group') userGroups = orb.ReverseLookup(from_column='GroupUser.user') @orb.virtual(orb.BooleanColumn) def hasGroups(self, **context): return len(self.get('groups')) != 0 @orb.virtual(orb.Collector, model='Group') def myGroups(self, **context): group_ids = GroupUser.select( where=orb.Query('user') == self).values('group') context['where'] = orb.Query('id').in_(group_ids) & context.get( 'where') return Group.select(**context) byUsername = orb.Index(columns=['username'], flags={'Unique'})
class Project(Asset): budget = orb.LongColumn() supervisors = orb.Pipe(through_path='ProjectSupervisor.project.user') def onInit(self, event): self.set('project', self)