Closed timhallmann closed 1 month ago
Yep, this commit is a mess right now, sorry about that.
Anyway, languages
in the template doesn't actually equal object_languages
in view.py
, nor does it equal template_kwargs['languages']
right before that is passed to render_template()
.
For example, try the following:
view.py
, output template_kwargs['languages']
view/base.html
, add <pre>{{ languages | tojson(indent=4) }}</pre>
Result (on my system using the develop
branch):
view.py
will output just the english languageview/base.html
will output the english and the german languageIf I use object_languages
in the template (and also pass it into the template...), everything works fine.
I have no idea where this goes wrong, I have not found a pesky jinja global or something like that.
Ah, I've found the issue: The languages
value is overridden by the result of get_object_form_template_kwargs(object_id)
when using the inline_edit mode: https://github.com/sciapp/sampledb/blob/06a0a424f0fee1f3cdd0410e957f011f06a47174/sampledb/frontend/objects/view.py#L468 So renaming the object languages to object_languages
would be the way to go, yes.
The update on line 461 was safe, so I thought it would be fine to place the log statement before the if condition... Well...
Have you already addressed this, or should I finish this later?
I haven't fixed it, I figured since you were halfway there with the object_languages, you'd probably want to provide the other half. I can fix it, though, if you prefer that.
Done. I've unified the language code in view.py
and versions.py
.
I've also changed the "Change language" links to not remove the query arg for the diff view.
Thanks again for the PR!
Hey @timhallmann, thanks for the PR, but I am slightly confused about it. The variable
object_languages
in the Python code is passed aslanguages
to the templates in https://github.com/sciapp/sampledb/blob/06a0a424f0fee1f3cdd0410e957f011f06a47174/sampledb/frontend/objects/view.py#L144 and similarly the variable is calledlanguages
in https://github.com/sciapp/sampledb/blob/06a0a424f0fee1f3cdd0410e957f011f06a47174/sampledb/frontend/objects/versions.py#L69I just tried the branch for this PR, and
object_languages
is simply undefined in the template.