Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
felipao-mx committed Dec 24, 2020
1 parent ed5b88e commit 48a5c6f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions agave/blueprints/rest_api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, Type
from typing import Type
from urllib.parse import urlencode

from chalice import Blueprint, NotFoundError, Response
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions agave/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 48a5c6f

Please sign in to comment.