Skip to content

Commit 8d908b2

Browse files
authored
🐛🗑️ Fixes validation of product vendor ui object and drops unused project_alias ⚠️ (#8266)
1 parent 2ac6d38 commit 8d908b2

File tree

13 files changed

+34
-32
lines changed

13 files changed

+34
-32
lines changed

packages/notifications-library/src/notifications_library/_models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class SharerData:
3030

3131
@dataclass(frozen=True)
3232
class ProductUIData:
33-
project_alias: str
3433
logo_url: str | None = (
3534
None # default_logo = "https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/static-webserver/client/source/resource/osparc/osparc-white.svg" in base.html
3635
)

packages/notifications-library/src/notifications_library/templates/on_share_project.email.content.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
{% block content %}
44
<p>Dear {{ user.first_name or user.user_name }},</p>
55

6-
<p>Great news! {{ sharer.user_name }} has shared a {{ product.ui.project_alias }} with you on {{ product.display_name }}.</p>
6+
<p>Great news! {{ sharer.user_name }} has shared a project with you on {{ product.display_name }}.</p>
77

8-
<p>To view the {{ product.ui.project_alias }} and accept the sharing, follow below:</p>
8+
<p>To view the project and accept the sharing, follow below:</p>
99

1010
<p>
1111
{% if sharer.message %}

packages/notifications-library/src/notifications_library/templates/on_share_project.email.content.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Dear {{ user.first_name or user.user_name }},
22

3-
Great news! {{ sharer.user_name }} has shared a {{ product.ui.project_alias }} with you on {{ product.display_name }}.
3+
Great news! {{ sharer.user_name }} has shared a project with you on {{ product.display_name }}.
44

5-
To view the {{ product.ui.project_alias }} and accept the sharing, follow below:
5+
To view the project and accept the sharing, follow below:
66

77
{{ sharer.message }}
88
{{ accept_link }}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
A {{ product.ui.project_alias }} was shared with you on {{ host }}
1+
A project was shared with you on {{ host }}

packages/notifications-library/tests/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ def product_data(
6666
product_ui = ProductUIData(
6767
logo_url=vendor_ui.get("logo_url"),
6868
strong_color=vendor_ui.get("strong_color"),
69-
project_alias=vendor_ui["project_alias"],
7069
)
7170

7271
return ProductData( # type: ignore

packages/postgres-database/src/simcore_postgres_database/models/products.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
class VendorUI(TypedDict, total=True):
3333
logo_url: str # vendor logo url
3434
strong_color: str # vendor main color
35-
project_alias: str # project alias for the product (e.g. "project" or "study")
3635

3736

3837
class Vendor(TypedDict, total=False):

packages/postgres-database/src/simcore_postgres_database/utils_users.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ async def link_and_update_user_from_pre_registration(
172172
pre_columns = (
173173
users_pre_registration_details.c.pre_first_name,
174174
users_pre_registration_details.c.pre_last_name,
175-
# NOTE: pre_phone is not copied since it has to be validated.
175+
# NOTE: pre_phone is NOT copied since it has to be validated.
176+
# It remains here as informative. In the future it might be given
177+
# as a hint to the front end?
176178
# Otherwise, if phone is wrong, currently user won't be able to login!
177179
)
178180

packages/pytest-simcore/src/pytest_simcore/helpers/faker_factories.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ def random_product(
294294
ui=VendorUI(
295295
logo_url="https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/static-webserver/client/source/resource/osparc/osparc-black.svg",
296296
strong_color=fake.color(),
297-
project_alias=fake.random_element(elements=["project", "study"]),
298297
),
299298
),
300299
"registration_email_template": registration_email_template,

services/web/server/src/simcore_service_webserver/products/_models.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from models_library.basic_types import NonNegativeDecimal
1313
from models_library.emails import LowerCaseEmailStr
1414
from models_library.products import ProductName, StripePriceID, StripeTaxRateID
15-
from models_library.utils.change_case import snake_to_camel
1615
from pydantic import (
1716
BaseModel,
1817
BeforeValidator,
@@ -256,7 +255,6 @@ def _update_json_schema_extra(schema: JsonDict) -> None:
256255
"ui": {
257256
"logo_url": "https://acme.com/logo",
258257
"strong_color": "#123456",
259-
"project_alias": "study",
260258
},
261259
},
262260
"issues": [
@@ -306,13 +304,13 @@ def _update_json_schema_extra(schema: JsonDict) -> None:
306304
)
307305

308306
model_config = ConfigDict(
309-
alias_generator=snake_to_camel,
310-
populate_by_name=True,
311-
str_strip_whitespace=True,
312-
frozen=True,
307+
# NOTE: do not add aliases. Use ProductGet schema for rest API
313308
from_attributes=True,
314-
extra="ignore",
309+
frozen=True,
315310
json_schema_extra=_update_json_schema_extra,
311+
str_strip_whitespace=True,
312+
validate_by_name=True,
313+
extra="ignore",
316314
)
317315

318316
def to_statics(self) -> dict[str, Any]:
@@ -337,13 +335,12 @@ def to_statics(self) -> dict[str, Any]:
337335
},
338336
exclude_none=True,
339337
exclude_unset=True,
340-
by_alias=True,
341338
)
342339

343340
def get_template_name_for(self, filename: str) -> str | None:
344341
"""Checks for field marked with 'x_template_name' that fits the argument"""
345342
template_name = filename.removesuffix(".jinja2")
346-
for name, field in self.model_fields.items():
343+
for name, field in self.__class__.model_fields.items():
347344
if (
348345
field.json_schema_extra
349346
and field.json_schema_extra.get("x_template_name") == template_name # type: ignore[union-attr]

services/web/server/src/simcore_service_webserver/products/_repository.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
)
6464

6565

66-
def _to_domain(products_row: Row, payments: PaymentFields) -> Product:
66+
def _db_to_domain(products_row: Row, payments: PaymentFields) -> Product:
6767
return Product(
6868
**products_row._asdict(),
6969
is_payment_enabled=payments.enabled,
@@ -115,7 +115,7 @@ async def list_products(
115115
async for row in rows:
116116
name = row.name
117117
payments = await _get_product_payment_fields(conn, product_name=name)
118-
app_products.append(_to_domain(row, payments))
118+
app_products.append(_db_to_domain(row, payments))
119119

120120
assert name in FRONTEND_APPS_AVAILABLE # nosec
121121

@@ -142,7 +142,7 @@ async def get_product(
142142
payments = await _get_product_payment_fields(
143143
conn, product_name=row.name
144144
)
145-
return _to_domain(row, payments)
145+
return _db_to_domain(row, payments)
146146
return None
147147

148148
async def get_default_product_name(

0 commit comments

Comments
 (0)