def get_apikey(self, apikey_id): if self.auth.account.account_type == "senior_admin": return ModelApiKey.get(ModelApiKey.apikey_id == apikey_id, ModelApiKey.deleted == 0) else: return ModelApiKey.get( ModelApiKey.apikey_id == apikey_id, ModelApiKey.account_id == self.auth.account.account_id, ModelApiKey.deleted == 0)
def get_apikey(self, apikey_id): if self.auth.account.account_type == "senior_admin": return ModelApiKey.get( ModelApiKey.apikey_id == apikey_id, ModelApiKey.deleted == 0 ) else: return ModelApiKey.get( ModelApiKey.apikey_id == apikey_id, ModelApiKey.account_id == self.auth.account.account_id, ModelApiKey.deleted == 0 )
def get_apikey(self, key, secret): return ApiKey().select(ApiKey, Account).join( Account, on=ApiKey.account_id == Account.account_id, attr='account_id').where(ApiKey.key == key, ApiKey.secret == secret, ApiKey.deleted == 0, Account.status == 'active').get()
def create_api_key(self, description, account_id): apikey = ModelApiKey() apikey.account_id = account_id apikey.description = description apikey.generate() apikey.save() return apikey
def get_apikey_list(self, account_ids): return ModelApiKey.select().where( ModelApiKey.account_id << account_ids ).where(ModelApiKey.deleted != 1)