def deserialize(self, inp: Dict): """ reverse operation as serialize """ event_data = inp["event_data"] del event_data["trigger"] event_data["status"] = WhitelistStatus(event_data["status"]) inp["event_data"] = InstallationEvent(**event_data) inp["identifier"] = event_data["installation_id"] super().deserialize(inp)
def accounts_waiting(self) -> list: """ Get accounts waiting for approval :return: list of accounts waiting for approval """ return [ key for (key, item) in self.db.items() if WhitelistStatus(item["status"]) == WhitelistStatus.waiting ]
def is_approved(self, account_name: str) -> bool: """ Check if user is approved in the whitelist :param account_name: :return: """ if account_name in self.db: account = self.get_account(account_name) db_status = account["status"] s = WhitelistStatus(db_status) return (s == WhitelistStatus.approved_automatically or s == WhitelistStatus.approved_manually) return False
def accounts_waiting(self) -> list: """ Get accounts waiting for approval :return: list of accounts waiting for approval """ # TODO: Once add_automatically/waiting works for postgres, # merge redis and postgres results # Fetch postgres results by DBWhitelist.get_account_by_status(WhitelistStatus.waiting) return [ key for (key, item) in self.db.items() if WhitelistStatus(item["status"]) == WhitelistStatus.waiting ]
def is_approved(account_name: str) -> bool: """ Check if user is approved in the whitelist :param account_name: account name to check :return: """ account = WhitelistModel.get_account(account_name) if account: db_status = account.status s = WhitelistStatus(db_status) return (s == WhitelistStatus.approved_automatically or s == WhitelistStatus.approved_manually) return False