diff --git a/agave/blueprints/rest_api.py b/agave/blueprints/rest_api.py index 1275888e..0c1838ed 100644 --- a/agave/blueprints/rest_api.py +++ b/agave/blueprints/rest_api.py @@ -1,4 +1,4 @@ -from typing import Optional, Type +from typing import Type from urllib.parse import urlencode from chalice import Blueprint, NotFoundError, Response @@ -137,13 +137,14 @@ def retrieve(id: str): The most of times this implementation is enough and is not necessary define a custom "retrieve" method """ - user_id: Optional[bool] = None - if self.user_id_filter_required(): - user_id = self.current_user_id if hasattr(cls, 'retrieve'): # at the moment, there are no resources with a custom # retrieve method return cls.retrieve(id) # pragma: no cover + + user_id = None + if self.user_id_filter_required(): + user_id = self.current_user_id try: data = cls.model.retrieve(id, user_id=user_id) except DoesNotExist: diff --git a/agave/models/base.py b/agave/models/base.py index 1a1f645d..98d58801 100644 --- a/agave/models/base.py +++ b/agave/models/base.py @@ -13,11 +13,11 @@ def __init__(self, *args, **values): def _dict(self, dict_func: Callable) -> DictStrAny: private_fields = [f for f in dir(self) if f.startswith('_')] excluded = self._excluded + private_fields - response = dict_func(self, excluded) + model_dict = dict_func(self, excluded) for field in self._hidden: - response[field] = '********' - return response + model_dict[field] = '********' + return model_dict def __repr__(self) -> str: return str(self.dict()) # type: ignore # pragma: no cover