class User(Model, UserMixin): __metadata__ = { "_name": "users", 'throughput': { 'read': 1, 'write': 1, }, 'global_indexes': [ GlobalIndex.all('email-username', 'username').throughput(read=1, write=1), GlobalIndex.all('email-index', 'email').throughput(read=1, write=1) ], } id = Field(hash_key=True) active = Field(data_type=bool) # User authentication information username = Field() password = Field() # User email information email = Field() email_confirmed_at = Field(data_type=datetime) # User information first_name = Field() last_name = Field() def get_id(self): if self.id is None: self.id = str(uuid.uuid1()) return self.id
class PublicHoliday(DyBase): __tablename__ = 'public_holiday' __metadata__ = { 'throughput': { 'read': 1, 'write': 1, }, 'global_indexes': [ GlobalIndex.all('ts-index', 'group_id').throughput(read=1, write=1), ], } created_by_id = Field(data_type=STRING, nullable=False) group_id = Field(data_type=STRING, nullable=False) holiday_date = Field(data_type=NUMBER, nullable=False) # full day or half day is_halfday = Field(data_type=NUMBER, nullable=False) # New instance instantiation procedure def __init__(self, created_by_id, group_id, date, is_halfday): super(PublicHoliday, self).__init__() self.created_by_id = created_by_id self.group_id = group_id self.holiday_date = date self.is_halfday = is_halfday def __repr__(self): return '<Date %r>' % (str(self.holiday_date)) def __getitem__(self, key): return self.holiday_date
class Invite(DyBase): __tablename__ = 'invite' __metadata__ = { 'throughput': { 'read': 1, 'write': 1, }, 'global_indexes': [ GlobalIndex.all('ts-index', 'group_id').throughput(read=1, write=1), ], } email = Field(data_type=STRING, nullable=False) group_id = Field(data_type=STRING, nullable=False) invite_token = Field(data_type=STRING, nullable=True) # New instance instantiation procedure def __init__(self, email, group_id, invite_token): super(Invite, self).__init__() self.email = email self.group_id = group_id self.invite_token = invite_token def __repr__(self): return '<Email %r>' % (self.email)
class Member(DyBase): __tablename__ = 'group_member' __metadata__ = { 'throughput': { 'read': 1, 'write': 1, }, 'global_indexes': [ GlobalIndex.all('ts-index', 'group_id').throughput(read=1, write=1), ], } group_id = Field(data_type=STRING, nullable=False) user_id = Field(data_type=NUMBER, nullable=False) # New instance instantiation procedure def __init__(self, group_id, user_id): super(Member, self).__init__() self.group_id = group_id self.user_id = user_id def __repr__(self): return '<User_id %r>' % (self.user_id)
class Rule(DyBase): __tablename__ = 'rule' __metadata__ = { 'throughput': { 'read': 1, 'write': 1, }, 'global_indexes': [ GlobalIndex.all('ts-index', 'group_id', 'term_id').throughput(read=1, write=1), ], } # Identification Data: email & password group_id = Field(data_type=STRING, nullable=False) term_id = Field(data_type=STRING, nullable=False) definition = Field(data_type=STRING, nullable=False) # New instance instantiation procedure def __init__(self, group_id, term_id, definition): super(Rule, self).__init__() self.group_id = group_id self.term_id = term_id self.definition = definition def __repr__(self): return '<group %r>' % (self.group_id)
class EmailNotify(DyBase): __tablename__ = 'email_notify' __metadata__ = { 'throughput': { 'read': 1, 'write': 1, }, 'global_indexes': [ GlobalIndex.all('ts-index', 'email', 'date_created').throughput(read=1, write=1), ], } # Identification Data: email & password email = Field(data_type=STRING, nullable=False) type = Field(data_type=STRING, nullable=False) # New instance instantiation procedure def __init__(self, email, type): super(EmailNotify, self).__init__() self.email = email self.type = type def __repr__(self): return '<email %r>' % (self.email)
class Group(DyBase): __tablename__ = 'group' __metadata__ = { 'throughput': { 'read': 1, 'write': 1, }, 'global_indexes': [ GlobalIndex.all('ts-index', 'domain').throughput(read=1, write=1), ], } # Identification Data: email & password name = Field(data_type=STRING) type_id = Field(data_type=NUMBER) domain = Field(data_type=STRING) default_term_id = Field(data_type=STRING, nullable=True) # New instance instantiation procedure def __init__(self, name, type_id, domain): super(Group, self).__init__() self.name = name self.type_id = type_id self.domain = domain def __repr__(self): return '<Group %r>' % (self.name) def __getitem__(self, key): return self.id
class Term(DyBase): __tablename__ = 'term' __metadata__ = { 'throughput': { 'read': 1, 'write': 1, }, 'global_indexes': [ GlobalIndex.all('ts-index', 'group_id').throughput(read=1, write=1), ], } group_id = Field(data_type=STRING, nullable=False) name = Field(data_type=STRING, nullable=False) start_date = Field(data_type=NUMBER, nullable=False) end_date = Field(data_type=NUMBER, nullable=False) family_spread = Field(data_type=STRING, nullable=False) # New instance instantiation procedure def __init__(self, group_id, name, start_dt, end_dt, family_spread): super(Term, self).__init__() self.group_id = group_id self.name = name self.start_date =start_dt self.end_date = end_dt self.family_spread = family_spread def __repr__(self): return '<term name %r>' % (self.name)
class Children(DyBase): __tablename__ = 'term_children' __metadata__ = { 'throughput': { 'read': 1, 'write': 1, }, 'global_indexes': [ GlobalIndex.all('ts-index', 'term_id').throughput(read=1, write=1), ], } term_id = Field(data_type=STRING, nullable=False) child_count = Field(data_type=NUMBER, nullable=False) # New instance instantiation procedure def __init__(self, term_id, child_count): super(Children, self).__init__() self.term_id = term_id self.child_count = child_count def __repr__(self): return '<term id %r>' % (self.term_id)
class User(DyBase): __tablename__ = 'user' __metadata__ = { 'throughput': { 'read': 1, 'write': 1, }, 'global_indexes': [ GlobalIndex.all('ts-index1', 'email').throughput(read=1, write=1), GlobalIndex.all('ts-index', 'role').throughput(read=1, write=1), ], } # Identification Data: email & password name = Field(data_type=STRING, nullable=False) given_name = Field(data_type=STRING, nullable=False) family_name = Field(data_type=STRING, nullable=False) email = Field(data_type=STRING, nullable=False) password = Field(data_type=STRING, nullable=True) auth_token = Field(data_type=STRING, nullable=True) image_url = Field(data_type=STRING, nullable=True) # Authorisation Data: role & status role = Field(data_type=NUMBER, nullable=False, default=1) is_active = Field(data_type=NUMBER, nullable=False, default=True) # New instance instantiation procedure def __init__(self, name, givenName, familyName, email, password, token, imageUrl): super(User, self).__init__() self.name = name self.given_name = givenName self.family_name = familyName self.email = email self.password = password self.auth_token = token self.image_url = imageUrl def __repr__(self): return '<User %r>' % (self.email) def __getitem__(self, key): return self.email
class Store(Model): """ Test model for indexes """ __metadata__ = { 'global_indexes': [ GlobalIndex.all('name-index', 'name', 'city'), GlobalIndex.keys('name-emp-index', 'name', 'num_employees'), GlobalIndex.include('name-profit-index', 'name', 'monthly_profit', includes=['name', 'num_employees']), ], } city = Field(hash_key=True) name = Field(range_key=True) sq_feet = Field(data_type=int).all_index('size-index') num_employees = Field(data_type=int).keys_index('emp-index') monthly_profit = Field(data_type=float)\ .include_index('profit-index', ['name', 'num_employees'])
class Switchday(DyBase): __tablename__ = 'switchday' __metadata__ = { 'throughput': { 'read': 1, 'write': 1, }, 'global_indexes': [ GlobalIndex.all('ts-index', 'group_id').throughput(read=1, write=1), ], } group_id = Field(data_type=STRING, nullable=False) switch_date = Field(data_type=NUMBER, nullable=False) from_time_in_24hours = Field(data_type=STRING, default = '0900') to_time_in_24hours = Field(data_type=STRING, default = '1630') standin_user_id = Field(data_type=STRING, nullable=True) is_half_day = Field(data_type=NUMBER, nullable=False, default=False) is_work_day = Field(data_type=NUMBER, nullable=False, default=False) # New instance instantiation procedure def __init__(self, group_id, switch_date, from_time, to_time, standin_user_id, is_half_day, is_work_day): super(Switchday, self).__init__() self.group_id = group_id self.switch_date = switch_date self.from_time_in_24hours = from_time self.to_time_in_24hours = to_time self.standin_user_id = standin_user_id self.is_half_day = is_half_day self.is_work_day = is_work_day def __repr__(self): return '<Switch_date %r>' % (self.switch_date) def __getitem__(self, key): return self.switch_date