-
Notifications
You must be signed in to change notification settings - Fork 26
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
Cosign improvements (batch 2) #4838
Merged
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
8bd1ac3
:technologist: [#4320] Add debug view links to submission admin in de…
sergei-maertens 4621aa5
:test_tube: [#4320] Add regression test for unexpected summary heading
sergei-maertens 68ed6df
:bug: [#4320] Ensure that the summary tag is not emitted if there's n…
sergei-maertens d56ee8a
:white_check_mark: [#4320] Add test for cosign-specific confirmation …
sergei-maertens f7a0717
:card_file_box: [#4320] Define model fields for cosign confirmation t…
sergei-maertens 28dc3a3
:sparkles: [#4320] Select the correct templates for confirm email
sergei-maertens 02600c9
:recycle: [#4320] Put default translation fix in re-usable helper
sergei-maertens f3748de
:adhesive_bandage: [#4320] Ensure new translatable fields have proper…
sergei-maertens 100e720
:globe_with_meridians: [#4320] Initial pass at translating the new fi…
sergei-maertens d68e08c
:sparkles: [#4320] Add new template fields to the frontend
sergei-maertens 5eac22f
:speech_balloon: [#4320] Tweak the (default) templates for cosign con…
sergei-maertens 3b4daae
:boom: [#4320] Remove header from cosign_information tag
sergei-maertens ea34ad7
:bento: [#4320] Re-generate API spec
sergei-maertens bb9c1fb
:sparkles: [#4320] Treat PDF confirmation page content different depe…
sergei-maertens 8cf1dca
:globe_with_meridians: [#4320] Extract new translations
sergei-maertens d9c6e9d
:children_crossing: [#4320] Use more accessible language
sergei-maertens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/openforms/utils/migrations_utils/fix_default_translation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import functools | ||
from collections.abc import Sequence | ||
|
||
from django.conf import settings | ||
from django.db.backends.base.schema import BaseDatabaseSchemaEditor | ||
from django.db.migrations.state import StateApps | ||
from django.utils import translation | ||
from django.utils.translation import gettext | ||
|
||
import openforms.utils.translations | ||
|
||
|
||
class FixDefaultTranslations: | ||
""" | ||
Set the properly translated default translatable field values. | ||
|
||
Workaround for https://github.com/open-formulieren/open-forms/issues/4826 | ||
""" | ||
|
||
def __init__(self, app_label: str, model: str, fields: Sequence[str]): | ||
self.app_label = app_label | ||
self.model = model | ||
self.fields = fields | ||
|
||
def __call__(self, apps: StateApps, schema_editor: BaseDatabaseSchemaEditor): | ||
Model = apps.get_model(self.app_label, self.model) | ||
for obj in Model.objects.all(): | ||
for field in self.fields: | ||
for lang, _ in settings.LANGUAGES: | ||
with translation.override(lang): | ||
default_callback = Model._meta.get_field(field).default | ||
assert isinstance(default_callback, functools.partial) | ||
if ( | ||
default_callback.func | ||
is openforms.utils.translations.get_default | ||
): | ||
default_callback = functools.partial( | ||
gettext, | ||
*default_callback.args, | ||
) | ||
setattr(obj, f"{field}_{lang}", default_callback()) | ||
obj.save() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Are we going to keep this solution?I thought it was not the what we wanted.(asking since this is now a reusable thing..)
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.
it's not what we want, but it is what we need for the time being 😬