Implement something like this for RawHtml content blocks via modeltranslation, dashboard will be display all fieldname_<lang> fields automatically
Maybe only what u what - removing multiltranslate fields dublication (it for example field name and name_en), but this is not hard:
Example:
translation:from modeltranslation.translator import translator, TranslationOptions
from oscar.apps.promotions.models import RawHTML
class RawHTMLTranslationOptions(TranslationOptions):
fields = ('name', 'body',)
translator.register(RawHTML, RawHTMLTranslationOptions)
dashboard.promotion.app:from oscar.apps.dashboard.promotions import app
from .views import CreateRawHTMLView, UpdateRawHTMLView
class PromotionsDashboardApplication(app.PromotionsDashboardApplication):
create_rawhtml_view = CreateRawHTMLView
update_rawhtml_view = UpdateRawHTMLView
dashboard.promotion.forms:from django.conf import settings
from oscar.apps.dashboard.promotions.forms import RawHTMLForm as RawHTMLFormOrig
from mapstore.apps.core.translation import RawHTMLTranslationOptions
# Dynamically generate something like ['name_en', 'titile_en']
rawhtml_exclude_fields = map(lambda f: '_'.join([f, settings.MODELTRANSLATION_DEFAULT_LANGUAGE]),
RawHTMLTranslationOptions.fields)
class RawHTMLForm(RawHTMLFormOrig):
class Meta(RawHTMLFormOrig.Meta):
exclude = rawhtml_exclude_fields + list(RawHTMLFormOrig.Meta.exclude)
dashboard.promotion.views:from oscar.apps.dashboard.promotions.views import (CreateRawHTMLView as CreateRawHTMLViewOrig,
UpdateRawHTMLView as UpdateRawHTMLViewOrig)
from .forms import RawHTMLForm
class CreateRawHTMLView(CreateRawHTMLViewOrig):
form_class = RawHTMLForm
class UpdateRawHTMLView(UpdateRawHTMLViewOrig):
form_class = RawHTMLForm
dashboard.app:from oscar.apps.dashboard import app
from .
promotions.app import PromotionsDashboardApplication
class DashboardApplication(app.DashboardApplication):
promotions_app = PromotionsDashboardApplication()
application = DashboardApplication()
app.py:
from
oscar.app import Shop
from .
dashboard.app import application as dashboard_app
class Application(Shop):
dashboard_app = dashboard_app
application = Application()