You've already forked hotpocket
BTHLABS-61: Service layer refactoring
A journey to fix `ValidationError` in Pocket imports turned service layer refactoring :D
This commit is contained in:
@@ -7,6 +7,7 @@ from bthlabs_jsonrpc_core import register_method
|
||||
from django import db
|
||||
from django.http import HttpRequest
|
||||
|
||||
from hotpocket_backend.apps.core.rpc import wrap_soa_errors
|
||||
from hotpocket_soa.services import (
|
||||
AccessTokensService,
|
||||
AccountsService,
|
||||
@@ -17,6 +18,7 @@ LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@register_method('accounts.access_tokens.create', namespace='accounts')
|
||||
@wrap_soa_errors
|
||||
def create(request: HttpRequest,
|
||||
auth_key: str,
|
||||
meta: dict,
|
||||
@@ -27,7 +29,7 @@ def create(request: HttpRequest,
|
||||
account_uuid=None,
|
||||
key=auth_key,
|
||||
)
|
||||
except AuthKeysService.AuthKeyNotFound as exception:
|
||||
except AuthKeysService.NotFound as exception:
|
||||
LOGGER.error(
|
||||
'Unable to issue access token: %s',
|
||||
exception,
|
||||
@@ -37,7 +39,7 @@ def create(request: HttpRequest,
|
||||
|
||||
try:
|
||||
account = AccountsService().get(pk=auth_key_object.account_uuid)
|
||||
except AccountsService.AccountNotFound as exception:
|
||||
except AccountsService.NotFound as exception:
|
||||
LOGGER.error(
|
||||
'Unable to issue access token: %s',
|
||||
exception,
|
||||
|
||||
@@ -44,7 +44,7 @@ def check_access_token(request: HttpRequest,
|
||||
access_token=access_token_object,
|
||||
update=meta_update,
|
||||
)
|
||||
except AccessTokensService.AccessTokenNotFound as exception:
|
||||
except AccessTokensService.NotFound as exception:
|
||||
LOGGER.error(
|
||||
'Access Token not found: account_uuid=`%s` key=`%s`',
|
||||
request.user.pk,
|
||||
@@ -52,7 +52,7 @@ def check_access_token(request: HttpRequest,
|
||||
exc_info=exception,
|
||||
)
|
||||
result = False
|
||||
except AccessTokensService.AccessTokenAccessDenied as exception:
|
||||
except AccessTokensService.AccessDenied as exception:
|
||||
LOGGER.error(
|
||||
'Access Token access denied: account_uuid=`%s` key=`%s`',
|
||||
request.user.pk,
|
||||
|
||||
@@ -4,11 +4,13 @@ from __future__ import annotations
|
||||
from bthlabs_jsonrpc_core import register_method
|
||||
from django.http import HttpRequest
|
||||
|
||||
from hotpocket_backend.apps.core.rpc import wrap_soa_errors
|
||||
from hotpocket_backend.apps.ui.services.workflows import CreateSaveWorkflow
|
||||
from hotpocket_soa.dto.associations import AssociationOut
|
||||
|
||||
|
||||
@register_method(method='saves.create')
|
||||
@wrap_soa_errors
|
||||
def create(request: HttpRequest, url: str) -> AssociationOut:
|
||||
association = CreateSaveWorkflow().run_rpc(
|
||||
request=request,
|
||||
|
||||
Reference in New Issue
Block a user