BTHLABS-94: Pass is_netloc_banned from save to share extension

This commit is contained in:
2026-07-21 08:20:43 +02:00
parent 9565a71bc8
commit d90504eed9
15 changed files with 124 additions and 34 deletions

View File

@@ -10,10 +10,12 @@ class SavesCreateOut(pydantic.BaseModel):
id: uuid.UUID
target_uuid: uuid.UUID
url: pydantic.AnyHttpUrl
is_netloc_banned: bool
def to_rpc(self) -> dict:
return {
'id': self.id,
'target_uuid': self.target_uuid,
'url': str(self.url),
'is_netloc_banned': self.is_netloc_banned,
}

View File

@@ -25,6 +25,7 @@ def create(request: HttpRequest, url: str) -> SavesCreateOut:
'url': request.build_absolute_uri(reverse(
'ui.associations.view', args=(association.pk,),
)),
'is_netloc_banned': association.target.is_netloc_banned,
})
return result

View File

@@ -9,7 +9,10 @@ from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from hotpocket_backend.apps.accounts.types import PAccount
from hotpocket_soa.dto.associations import AssociationOut
from hotpocket_soa.dto.associations import (
AssociationOut,
AssociationWithTargetOut,
)
from hotpocket_soa.dto.celery import AsyncResultOut
from hotpocket_soa.dto.saves import SaveIn, SaveOut
@@ -69,9 +72,14 @@ class CreateSaveWorkflow(SaveWorkflow):
request: HttpRequest,
account: PAccount,
url: str,
) -> AssociationOut:
) -> AssociationWithTargetOut:
save, association, processing_result = self.create_associate_and_process(
account, url,
)
return association
result = AssociationWithTargetOut.from_association_save(
association=association,
save=save,
)
return result

View File

@@ -22,10 +22,10 @@ line_length=80
use_parentheses=true
combine_as_imports=true
star_first=true
extend_skip_glob=hotpocket_backend/apps/*/migrations/*.py
extend_skip_glob=hotpocket_backend/apps/*/migrations/*.py,hotpocket_backend/playground.py
[mypy]
exclude = (apps/.+?/migrations/.+)|(ops/docker/.+)|(ops/metal/.+)|(testing/.+)
exclude = (apps/.+?/migrations/.+)|(ops/docker/.+)|(ops/metal/.+)|(testing/.+)|(playground.py)
[mypy-celery.*]
ignore_missing_imports = true

View File

@@ -60,6 +60,7 @@ def test_ok(authenticated_client: Client,
assert call_result['result']['url'].endswith(reverse(
'ui.associations.view', args=(association_pk,),
))
assert call_result['result']['is_netloc_banned'] is False
AssociationsTestingService().assert_created(
pk=association_pk,
@@ -105,6 +106,8 @@ def test_ok_netloc_banned(authenticated_client: Client,
save_pk = uuid.UUID(call_result['result']['target_uuid'])
assert call_result['result']['is_netloc_banned'] is True
SavesTestingService().assert_created(
pk=save_pk,
account_uuid=account.pk,