You've already forked hotpocket
BTHLABS-66: Prepping for public release: Take five
AKA "Using Apple reviewers as QA for your project". Thanks, y'all! :)
This commit is contained in:
@@ -38,3 +38,5 @@ class PSettings(typing.Protocol):
|
||||
|
||||
UI_PAGE_HEAD_INCLUDES: list
|
||||
UI_PAGE_SCRIPT_INCLUDES: list
|
||||
|
||||
OPERATOR_EMAIL: str | None
|
||||
|
||||
@@ -100,3 +100,9 @@ def page_includes(request: HttpRequest) -> dict:
|
||||
'script': settings.UI_PAGE_SCRIPT_INCLUDES,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def operator_email(request: HttpRequest) -> dict:
|
||||
return {
|
||||
'OPERATOR_EMAIL': settings.OPERATOR_EMAIL,
|
||||
}
|
||||
|
||||
19
services/backend/hotpocket_backend/apps/ui/dto/rpc.py
Normal file
19
services/backend/hotpocket_backend/apps/ui/dto/rpc.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import annotations
|
||||
|
||||
import uuid
|
||||
|
||||
import pydantic
|
||||
|
||||
|
||||
class SavesCreateOut(pydantic.BaseModel):
|
||||
id: uuid.UUID
|
||||
target_uuid: uuid.UUID
|
||||
url: pydantic.AnyHttpUrl
|
||||
|
||||
def to_rpc(self) -> dict:
|
||||
return {
|
||||
'id': self.id,
|
||||
'target_uuid': self.target_uuid,
|
||||
'url': str(self.url),
|
||||
}
|
||||
@@ -3,19 +3,28 @@ from __future__ import annotations
|
||||
|
||||
from bthlabs_jsonrpc_core import register_method
|
||||
from django.http import HttpRequest
|
||||
from django.urls import reverse
|
||||
|
||||
from hotpocket_backend.apps.core.rpc import wrap_soa_errors
|
||||
from hotpocket_backend.apps.ui.dto.rpc import SavesCreateOut
|
||||
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:
|
||||
def create(request: HttpRequest, url: str) -> SavesCreateOut:
|
||||
association = CreateSaveWorkflow().run_rpc(
|
||||
request=request,
|
||||
account=request.user,
|
||||
url=url,
|
||||
)
|
||||
|
||||
return association
|
||||
result = SavesCreateOut.model_validate({
|
||||
'id': association.pk,
|
||||
'target_uuid': association.target_uuid,
|
||||
'url': request.build_absolute_uri(reverse(
|
||||
'ui.associations.view', args=(association.pk,),
|
||||
)),
|
||||
})
|
||||
|
||||
return result
|
||||
|
||||
@@ -36,6 +36,12 @@
|
||||
{% blocktranslate %}Log in with {{ HOTPOCKET_OIDC_DISPLAY_NAME }}{% endblocktranslate %}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
{% if OPERATOR_EMAIL %}
|
||||
<p class="my-0 mt-2 text-center">
|
||||
<small>{% blocktranslate %}For support with your account, contact the <a href="mailto:{{ OPERATOR_EMAIL }}">instance operator</a>.{% endblocktranslate %}</small>
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% include "ui/ui/partials/uname.html" %}
|
||||
|
||||
@@ -72,6 +72,7 @@ TEMPLATES = [
|
||||
'hotpocket_backend.apps.ui.context_processors.debug',
|
||||
'hotpocket_backend.apps.ui.context_processors.version',
|
||||
'hotpocket_backend.apps.ui.context_processors.appearance_settings',
|
||||
'hotpocket_backend.apps.ui.context_processors.operator_email',
|
||||
],
|
||||
},
|
||||
},
|
||||
@@ -295,3 +296,5 @@ SAVES_ASSOCIATION_ADAPTER = os.environ.get(
|
||||
UPLOADS_PATH = None
|
||||
|
||||
SITE_SHORT_TITLE = 'HotPocket'
|
||||
|
||||
OPERATOR_EMAIL = os.environ.get('HOTPOCKET_BACKEND_OPERATOR_EMAIL', None)
|
||||
|
||||
@@ -54,8 +54,12 @@ def test_ok(authenticated_client: Client,
|
||||
call_result = result.json()
|
||||
assert 'error' not in call_result
|
||||
|
||||
save_pk = uuid.UUID(call_result['result']['target_uuid'])
|
||||
association_pk = uuid.UUID(call_result['result']['id'])
|
||||
save_pk = uuid.UUID(call_result['result']['target_uuid'])
|
||||
|
||||
assert call_result['result']['url'].endswith(reverse(
|
||||
'ui.associations.view', args=(association_pk,),
|
||||
))
|
||||
|
||||
AssociationsTestingService().assert_created(
|
||||
pk=association_pk,
|
||||
|
||||
Reference in New Issue
Block a user