class Token(orm.Document): _db = 'lablog' _collection = 'tokens' _indexes = [ orm.Index('access_token', key=('access_token', 1), unique=True), orm.Index('refresh_token', key=('refresh_token', 1), unique=True), orm.Index('client', key=('client', 1)), orm.Index('user', key=('user', 1)), orm.Index('user_agent', key=('user_agent', 1)), ] access_token = field.Char() refresh_token = field.Char() client = field.DocumentId(type=Client) scopes = orm.List(type=unicode) expires = field.Date() user = field.DocumentId(type=Admin) user_agent = field.Char() _type = field.Char() @property def token_type(self): return self._type def delete(self): self.remove()
class Grant(orm.Document): _db = 'lablog' _collection = 'grants' client = field.DocumentId(type=Client) code = field.Char() user = field.DocumentId(type=Admin) scopes = orm.List(type=unicode) expires = field.Date() redirect_url = field.Char() def delete(self): self.remove()
class Car(orm.Document): _db = "test" _collection = "cars" owner = field.DocumentId(type=Human) make = field.Char() model = field.Char() year = field.Date()
class Car(orm.Document): _db = "test" _collection = "cars" owner = field.DocumentId(type=Human) make = field.Char() model = field.Char() year = field.Date() features = orm.List(type=unicode) properties = orm.List(type=Property)
class Beacon(orm.Document): _db = 'lablog' _collection = 'floorplan_beacons' id = field.Char() x = field.Integer() y = field.Integer() level = field.Integer() location = field.DocumentId(type=Location)
class Admin(orm.Document): _db = "entropealabs" _collection = "client_admins" _indexes = [ orm.Index('email', key=('email', 1), unique=True), ] name = field.Char() email = field.Char() password = field.Char() last_login = field.Date() client = field.DocumentId(type=Client) social = SocialAccounts(type=SocialAccount) facebook_pages = orm.List(type=FacebookPage) def social_account(self, account_type=None): for sa in self.social_accounts: if sa.type == account_type: return sa sa = SocialAccount() sa.type = account_type return sa @staticmethod def passwords_match(pwd, cpwd): if pwd == cpwd: return True return False def save(self): if not password.identify(self.password): self.password = password.encrypt_password(self.password) return super(Admin, self).save() def verify_pwd(self, pwd): self.logger.info(password.encrypt_password(pwd)) self.logger.info(self.password) return password.check_password(pwd, self.password) def is_authenticated(self): if self._id: return True return False def is_active(self): return True def is_anonymous(self): return False def get_id(self): self.logger.info(unicode(self._id)) return unicode(self._id)
class ClientRef(orm.EmbeddedDocument): ref = field.DocumentId(type=Client)