New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CORE Overwrite empty language fields with default value (SH-90) #754
Conversation
Refer to this link for build results (access rights to CI server needed): |
I think the management command should be a datamigration. The reason I think so is that:
|
65aba15
to
ff8dde0
Compare
Refer to this link for build results (access rights to CI server needed): |
Retest this please |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
retest this please |
for obj in objects: | ||
# model being translatable does not guarantee translations exist | ||
if obj.translations.count(): | ||
default_translation = obj.get_translation(default_lang) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fail if the object doesn't have translation in PARLER_DEFAULT_LANGUAGE_CODE. That happens some times since I think only currently active language is required most of the MultiLanguageModelForm
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default_language is a required field in MultiLanguageModelForm isn't it?
self.default_language = kwargs.pop("default_language", getattr(self, 'language', get_language()))
Where is active language set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think not. Can you test it with for few admin modules like products, categories and shops? I think that most of the cases only the currently active language is required. That's probably a bug though. But maybe not for this task. But the migration should work in those "corrupted" databases too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am right here on solution probably would be to check the default translation for one field with safe_translation_getter
Refer to this link for build results (access rights to CI server needed): |
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.apps import apps as django_apps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't from django import apps
suffice? or import django.apps
or something else. Shouldn't be needed to use as
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pikkupomo, the function in which I reference apps, already passes apps as an argument, so there's a conflict. apps passed by the function is different from django.apps.apps
ff8dde0
to
39b88d3
Compare
Refer to this link for build results (access rights to CI server needed): |
retest this please |
Refer to this link for build results (access rights to CI server needed): |
retest this please |
Refer to this link for build results (access rights to CI server needed): |
retest this please |
Refer to this link for build results (access rights to CI server needed): |
retest this please |
Refer to this link for build results (access rights to CI server needed): |
39b88d3
to
decd3c5
Compare
Refer to this link for build results (access rights to CI server needed): |
When a user completes a form that includes translatable fields (e.g. Product) and only fill out the default language portion (e.g. English) the form will fill out the other language fields with that of the english. This fix is meant to address limitations in django-parlers own fallback mechanism. This commit also includes a data migration that will perform the same functionality on existing translation models. Refs SH-90
decd3c5
to
e67d602
Compare
Refer to this link for build results (access rights to CI server needed): |
For this we will be using different approach. We really need to follow parler here and copying the default taranslation is not the right way. The "right" solution is already planned. Let's get back to this issue in a few days. Close for now at least. |
When a user completes a form that includes translatable fields (e.g.
Product) and only fill out the default language portion (e.g. English)
the form will fill out the other language fields with that of the
english. This fix is meant to address limitations in django-parlers own
fallback mechanism.
This commit also includes a new management command
shuup_fallback_language
that will perform the same functionality onexisting models. It's meant to be ran only once as a migration step.