def set_organization(deallocates: list): for deallocate in deallocates: with suppress( UserNotFound, KeyError): # todo ensure organization is not always needed deallocate['fromOrganization'] = AccountDomain.get_one( deallocate['from'])['organization']
def set_organization(receives: list): """ This method needs to execute after add_or_get_inactive_account :param receives: :return: """ for receive in receives: with suppress(UserNotFound): receive['receiverOrganization'] = AccountDomain.get_one(receive['receiver']).get('organization')
def set_organization(receives: list): """ This method needs to execute after add_or_get_inactive_account :param receives: :return: """ for receive in receives: with suppress(UserNotFound): receive['receiverOrganization'] = AccountDomain.get_one( receive['receiver']).get('organization')
def login(): """ Performs a login. We make this out of eve, being totally open. :return: """ try: account = AccountDomain.get_one({'email': request.json['email']}) if not AccountDomain.verify_password(request.json['password'], account['password']): raise WrongCredentials() account['token'] = AccountDomain.hash_token(account['token']) account['_id'] = str(account['_id']) return jsonify(account) except (KeyError, TypeError, UserNotFound): raise WrongCredentials()
def _add_or_get_inactive_account_id(event, field_name): """ We need to execute after insert and insert_resource. """ if field_name in event and type(event[field_name]) is dict: try: # We look for just accounts that share our database _id = AccountDomain.get_one( { "email": event[field_name]["email"] # 'databases': {'$in': AccountDomain.actual['databases']} todo review this } )["_id"] except UserNotFound: event[field_name]["databases"] = [AccountDomain.get_requested_database()] event[field_name]["active"] = False event[field_name]["@type"] = "Account" _id = execute_post_internal("accounts", event[field_name], True)["_id"] event[field_name] = _id
def _add_or_get_inactive_account_id(event, field_name): """ We need to execute after insert and insert_resource. """ if field_name in event and type(event[field_name]) is dict: try: # We look for just accounts that share our database _id = AccountDomain.get_one({ 'email': event[field_name]['email'] # 'databases': {'$in': AccountDomain.actual['databases']} todo review this })['_id'] except UserNotFound: event[field_name]['databases'] = [ AccountDomain.get_requested_database() ] event[field_name]['active'] = False event[field_name]['@type'] = 'Account' _id = execute_post_internal('accounts', event[field_name], True)['_id'] event[field_name] = _id
def set_organization(allocates: list): for allocate in allocates: with suppress(UserNotFound, KeyError): allocate['toOrganization'] = AccountDomain.get_one( allocate['to'])['organization']
def set_organization(deallocates: list): for deallocate in deallocates: with suppress(UserNotFound, KeyError): # todo ensure organization is not always needed deallocate['fromOrganization'] = AccountDomain.get_one(deallocate['from'])['organization']
def set_organization(allocates: list): for allocate in allocates: with suppress(UserNotFound, KeyError): allocate['toOrganization'] = AccountDomain.get_one(allocate['to'])['organization']