Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b56238dfc4 | |||
| a6a9ed2973 | |||
| 90a71adb4f |
56
mandelstudio/migrations/0005_checkout_i18n_columns.py
Normal file
56
mandelstudio/migrations/0005_checkout_i18n_columns.py
Normal file
@@ -0,0 +1,56 @@
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
LANGUAGES = ("en", "de", "fr", "es", "it", "pt", "ru")
|
||||
|
||||
|
||||
def _add_column_if_missing(schema_editor, table_name, column_name, column_sql):
|
||||
connection = schema_editor.connection
|
||||
with connection.cursor() as cursor:
|
||||
existing = {
|
||||
row.name
|
||||
for row in connection.introspection.get_table_description(cursor, table_name)
|
||||
}
|
||||
if column_name in existing:
|
||||
return
|
||||
quoted_table = schema_editor.quote_name(table_name)
|
||||
quoted_column = schema_editor.quote_name(column_name)
|
||||
cursor.execute(
|
||||
f"ALTER TABLE {quoted_table} ADD COLUMN {quoted_column} {column_sql}"
|
||||
)
|
||||
|
||||
|
||||
def add_checkout_i18n_columns(apps, schema_editor):
|
||||
for lang in LANGUAGES:
|
||||
_add_column_if_missing(
|
||||
schema_editor,
|
||||
"checkout_fixedsurcharge",
|
||||
f"name_{lang}",
|
||||
"varchar(32) NULL",
|
||||
)
|
||||
_add_column_if_missing(
|
||||
schema_editor,
|
||||
"checkout_percentagesurcharge",
|
||||
f"name_{lang}",
|
||||
"varchar(32) NULL",
|
||||
)
|
||||
_add_column_if_missing(
|
||||
schema_editor,
|
||||
"checkout_paymentmethod",
|
||||
f"label_{lang}",
|
||||
"varchar(32) NULL",
|
||||
)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("mandelstudio", "0004_contact_messages"),
|
||||
("checkout", "0017_remove_unused_price_fields"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
add_checkout_i18n_columns,
|
||||
migrations.RunPython.noop,
|
||||
)
|
||||
]
|
||||
43
mandelstudio/migrations/0006_address_country_i18n_columns.py
Normal file
43
mandelstudio/migrations/0006_address_country_i18n_columns.py
Normal file
@@ -0,0 +1,43 @@
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
LANGUAGES = ("en", "de", "fr", "es", "it", "pt", "ru")
|
||||
|
||||
|
||||
def _add_column_if_missing(schema_editor, table_name, column_name, column_sql):
|
||||
connection = schema_editor.connection
|
||||
with connection.cursor() as cursor:
|
||||
existing = {
|
||||
row.name
|
||||
for row in connection.introspection.get_table_description(cursor, table_name)
|
||||
}
|
||||
if column_name in existing:
|
||||
return
|
||||
quoted_table = schema_editor.quote_name(table_name)
|
||||
quoted_column = schema_editor.quote_name(column_name)
|
||||
cursor.execute(
|
||||
f"ALTER TABLE {quoted_table} ADD COLUMN {quoted_column} {column_sql}"
|
||||
)
|
||||
|
||||
|
||||
def add_address_i18n_columns(apps, schema_editor):
|
||||
for lang in LANGUAGES:
|
||||
_add_column_if_missing(
|
||||
schema_editor,
|
||||
"address_country",
|
||||
f"printable_name_{lang}",
|
||||
"varchar(128) NULL",
|
||||
)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("mandelstudio", "0005_checkout_i18n_columns"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
add_address_i18n_columns,
|
||||
migrations.RunPython.noop,
|
||||
)
|
||||
]
|
||||
@@ -1,5 +1,5 @@
|
||||
from django.conf.urls.i18n import i18n_patterns
|
||||
from django.urls import path
|
||||
from django.urls import include, path
|
||||
from django.views.decorators.cache import cache_page
|
||||
|
||||
from ocyan.core.fender import config
|
||||
@@ -7,6 +7,9 @@ from ocyan.main.urls import urlpatterns as ocyan_urlpatterns
|
||||
from ocyan.plugin.contact_form.entrypoint import SHOP_BASE_URL
|
||||
from ocyan.plugin.wagtail_oscar_integration.constants import CACHE_DURATION
|
||||
from ocyan.plugin.wordspinner.views.ai_search import ai_search_view
|
||||
from ocyan.plugin.wordspinner.views.bulk import BulkAIOperationsView
|
||||
from ocyan.plugin.wordspinner.views.bulk import ProcessNextBulkAIJobView
|
||||
from ocyan.plugin.wordspinner.views.results import GeneratedResultsListView
|
||||
|
||||
from ocyan.plugin.contact_form.views import post_contact_form
|
||||
|
||||
@@ -36,6 +39,13 @@ contact_form_urlpatterns = [
|
||||
),
|
||||
]
|
||||
|
||||
wordspinner_urlpatterns = [
|
||||
path(
|
||||
"wordspinner/",
|
||||
include(("ocyan.plugin.wordspinner.urls", "wordspinner"), namespace="wordspinner"),
|
||||
),
|
||||
]
|
||||
|
||||
# Ensure public AI search routes are resolved before Wagtail catch-all URLs.
|
||||
ai_search_urlpatterns = [
|
||||
path("ai-search/", ai_search_view, name="wordspinner_ai_search_public"),
|
||||
@@ -56,13 +66,38 @@ ai_search_urlpatterns = [
|
||||
),
|
||||
]
|
||||
|
||||
wordspinner_i18n_aliases = [
|
||||
path(
|
||||
"<str:lang_code>/wordspinner/ai/bulk/",
|
||||
BulkAIOperationsView.as_view(),
|
||||
name="wordspinner_bulk_ai_operations_i18n",
|
||||
),
|
||||
path(
|
||||
"<str:lang_code>/wordspinner/ai/bulk/process-next/",
|
||||
ProcessNextBulkAIJobView.as_view(),
|
||||
name="wordspinner_bulk_ai_process_next_i18n",
|
||||
),
|
||||
path(
|
||||
"<str:lang_code>/wordspinner/results/",
|
||||
GeneratedResultsListView.as_view(),
|
||||
name="wordspinner_generated_results_i18n",
|
||||
),
|
||||
]
|
||||
|
||||
if config.i18n_enabled:
|
||||
urlpatterns += i18n_patterns(
|
||||
*wordspinner_urlpatterns,
|
||||
*contact_form_urlpatterns,
|
||||
*ai_search_urlpatterns,
|
||||
*wordspinner_i18n_aliases,
|
||||
prefix_default_language=False,
|
||||
)
|
||||
else:
|
||||
urlpatterns += contact_form_urlpatterns + ai_search_urlpatterns
|
||||
urlpatterns += (
|
||||
wordspinner_urlpatterns
|
||||
+ contact_form_urlpatterns
|
||||
+ ai_search_urlpatterns
|
||||
+ wordspinner_i18n_aliases
|
||||
)
|
||||
|
||||
urlpatterns += ocyan_urlpatterns
|
||||
|
||||
Reference in New Issue
Block a user