Exemplo n.º 1
0
    class GroupUser(orb.Table):
        id = orb.IdColumn()
        user = orb.ReferenceColumn(reference='User')
        group = orb.ReferenceColumn(reference='Group')

        byUserAndGroup = orb.Index(('user', 'group'), flags={'Unique'})
        byUser = orb.Index(('user', ))
Exemplo n.º 2
0
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')
Exemplo n.º 3
0
def test_pg_statement_create_index(orb, GroupUser, pg_sql):
    index = orb.Index(name='byGroupAndUser',
                      columns=[
                          orb.ReferenceColumn(name='group'),
                          orb.ReferenceColumn('user')
                      ])
    index.setSchema(GroupUser.schema())
    st = pg_sql.statement('CREATE INDEX')
    assert st is not None

    statement, data = st(index)
    assert 'CREATE INDEX' in statement

    statement, data = st(index, checkFirst=True)
    assert 'DO $$' in statement
Exemplo n.º 4
0
class Address(orb.Table):
    id = orb.IdColumn()
    user = orb.ReferenceColumn(reference='User')
    name = orb.StringColumn()
    street = orb.StringColumn()
    city = orb.StringColumn()
    state = orb.StringColumn()
    zipcode = orb.IntegerColumn()
Exemplo n.º 5
0
    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'})
Exemplo n.º 6
0
    class Address(orb.Table):
        __resource__ = True

        id = orb.IdColumn()
        user = orb.ReferenceColumn(reference='User')
        street = orb.StringColumn(flags={'Required'})
        city = orb.StringColumn(flags={'Required'})
        state = orb.StringColumn(flags={'Required'})
        zipcode = orb.IntegerColumn()

        def onInit(self, event):
            context = self.context()
            self.set('user', context.scope.get('user'))
Exemplo n.º 7
0
    class TestAllColumns(orb.Table):
        Test = enum('Ok')

        # boolean
        bool = orb.BooleanColumn()

        # data
        binary = orb.BinaryColumn()
        json = orb.JSONColumn()
        query = orb.QueryColumn()
        yaml = orb.YAMLColumn()

        # datetime
        date = orb.DateColumn()
        datetime = orb.DatetimeColumn()
        datetime_tz = orb.DatetimeWithTimezoneColumn()
        interval = orb.IntervalColumn()
        time = orb.TimeColumn()
        timestamp = orb.TimestampColumn()
        utc_datetime = orb.UTC_DatetimeColumn()
        utc_timestamp = orb.UTC_TimestampColumn()

        # numeric
        id = orb.IdColumn()
        decimal = orb.DecimalColumn(scale=2)
        float = orb.FloatColumn()
        integer = orb.IntegerColumn()
        long = orb.LongColumn()
        enum = orb.EnumColumn()

        # reference
        reference = orb.ReferenceColumn(reference='TestReference')

        # string
        string = orb.StringColumn()
        text = orb.TextColumn()
        color = orb.ColorColumn()
        directory = orb.DirectoryColumn()
        email = orb.EmailColumn()
        filepath = orb.FilepathColumn()
        html = orb.HtmlColumn()
        password = orb.PasswordColumn(default='T3st1ng!')
        token = orb.TokenColumn()
        url = orb.UrlColumn()
        xml = orb.XmlColumn()
Exemplo n.º 8
0
class ProjectSupervisor(orb.Table):
    id = orb.IdColumn()
    project = orb.ReferenceColumn(reference='Project')
    user = orb.ReferenceColumn(reference='User')
Exemplo n.º 9
0
class Dependency(orb.Table):
    id = orb.IdColumn()
    source = orb.ReferenceColumn(reference='Asset')
    target = orb.ReferenceColumn(reference='Asset')
Exemplo n.º 10
0
class GroupUser(orb.Table):
    id = orb.IdColumn()
    user = orb.ReferenceColumn(reference='User')
    group = orb.ReferenceColumn(reference='Group')
Exemplo n.º 11
0
class Preference(orb.Table):
    id = orb.IdColumn()
    user = orb.ReferenceColumn(reference='User', flags={'Unique'})
    notifications_enabled = orb.BooleanColumn()
Exemplo n.º 12
0
 class Attachment(orb.Table):
     id = orb.IdColumn(type='hash')
     filename = orb.StringColumn()
     comment = orb.ReferenceColumn(reference='Comment', flags={'Required'})
Exemplo n.º 13
0
 class Employee(User):
     role = orb.ReferenceColumn(reference='Role', flags={'AutoExpand'})