From: Guillaume Pellerin Date: Thu, 6 Oct 2016 09:59:46 +0000 (+0200) Subject: Fix product first fields when multiple languages X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=1b6be58c9ccb98b38756978038cdf812bd47277b;p=mezzo.git Fix product first fields when multiple languages --- diff --git a/app/organization/core/admin.py b/app/organization/core/admin.py index abdeaffa..631dff66 100644 --- a/app/organization/core/admin.py +++ b/app/organization/core/admin.py @@ -5,6 +5,7 @@ from mezzanine.pages.admin import PageAdmin from organization.core.models import * from mezzanine.blog.models import BlogPost from mezzanine.generic.models import ThreadedComment, Keyword +from mezzanine.conf import settings class KeywordAdmin(BaseTranslationModelAdmin): @@ -16,7 +17,14 @@ class BaseTranslationOrderedModelAdmin(BaseTranslationModelAdmin): def get_fieldsets(self, request, obj = None): res = super(BaseTranslationOrderedModelAdmin, self).get_fieldsets(request, obj) - for field in reversed(self.first_fields): + fields = reversed(self.first_fields) + if settings.USE_MODELTRANSLATION: + lang = settings.LANGUAGE_CODE + lang_fields = [] + for field in fields: + lang_fields.append(field + '_' + lang) + fields = lang_fields + for field in fields: for trans_field in res[0][1]['fields']: if field in trans_field: index = res[0][1]['fields'].index(trans_field) diff --git a/app/settings.py b/app/settings.py index bd1ffe2d..b3402f5b 100644 --- a/app/settings.py +++ b/app/settings.py @@ -257,11 +257,6 @@ MIGRATION_MODULES = { "generic": "migrations.generic", } -MODELTRANSLATION_TRANSLATION_FILES = ( - 'organization.core.translation', - 'organization.festival.translation', - 'organization.magazine.translation' -) TEMPLATES = [{'APP_DIRS': True, 'BACKEND': 'django.template.backends.django.DjangoTemplates', diff --git a/app/templates/agenda/includes/event_date.html b/app/templates/agenda/includes/event_date.html index 6c09e331..f740cbfa 100644 --- a/app/templates/agenda/includes/event_date.html +++ b/app/templates/agenda/includes/event_date.html @@ -17,7 +17,7 @@ {{ event.start|date:"l j F" }} {% if event.start|date:"H:i" != "00:00" %} - {% trans "from" %} + {% trans "at" %} {{ event.start|date:"H\hi" }} {% comment %} {% if event.end|date:"H:i" != "00:00" %} @@ -38,7 +38,7 @@ {% for period in event.periods.all %} {% trans "From" %} {{ period.date_from|date:"j H:i" }} {% trans "to" %} {{ period.date_to|date:"j F H:i" }} {% endfor %} - + {% else %} diff --git a/app/templates/agenda/includes/event_metainfo_line.html b/app/templates/agenda/includes/event_metainfo_line.html index 326e680b..ae27e3e5 100644 --- a/app/templates/agenda/includes/event_metainfo_line.html +++ b/app/templates/agenda/includes/event_metainfo_line.html @@ -1,7 +1,9 @@ {% load i18n mezzanine_tags event_tags %}
- {% include 'agenda/includes/event_date.html' %} + + {% include 'agenda/includes/event_date.html' %} +
diff --git a/app/templates/shop/includes/product_list_circle_style.html b/app/templates/shop/includes/product_list_circle_style.html new file mode 100644 index 00000000..d0e75d6f --- /dev/null +++ b/app/templates/shop/includes/product_list_circle_style.html @@ -0,0 +1,46 @@ +{% load organization_tags mezzanine_tags %} +{% if list %} +
+
+
+
+
+

{{ list.title }}

+ {% if list.description %} +

{{ list.description }}

+ {% endif %} +
+
+
+ +
+
+ {% for product_inline in list.products.all %} + {% with product_inline.product as product %} +
+
+ {% if product.images.all %} +
+ +
+ product +
+
+
+ {% endif %} +
+

{{ product.title }}

+ {% if product.description %} +
{{ product.description|richtext_filters|safe|truncatechars_html:255 }}
+ {% elif product.content %} +
{{ product.content|richtext_filters|safe|truncatechars_html:255 }}
+ {% endif %} +
+
+
+ {% endwith %} + {% endfor %} +
+
+
+{% endif %}