Skip to content
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

modeltranslation 0.19.3+ with Django CMS 4.1.x - CMS Plugin functionalities broken #748

Open
aacimov opened this issue Jul 17, 2024 · 13 comments

Comments

@aacimov
Copy link

aacimov commented Jul 17, 2024

As stated in Django CMS issue tracker: django-cms/django-cms#7948

Django CMS 4.1.x with modeltranslation active - custom CMS plugin attributes allow_children, and child_classes do not work correctly.

Each plugin that has allow_children has the ability to add child plugins but they are locked (one is not able to add plugins to children even though the allow_children with child_classes is set on Column in this example).

On the other hand, plugins that do not have explicitly set the allow_children attribute still have the ability to add children which is wrong.

Image 1 - working example with modeltranslation 0.19.2 - Text plugin has the + sign disabled which is expected, and the Column plugins have the + sign enabled which is expected:

working 0 9 12

Image 2 - not working example with modeltranslation 0.19.3 and above - Text plugin has the + sign enabled which is not expected, and the Column plugins have the lock sign which is not expected since no other plugins can be added into it:

not_working 0 9 13

Project environment variables

  • Django 4.2.13
  • django_modeltranslation 0.19.2 (tried 0.19.3 and above which are not working, lower versions do work correctly)
  • django-cms 4.1.1
  • Python 3.10
@aacimov
Copy link
Author

aacimov commented Jul 17, 2024

Just tested with django-cms 3.11.x - affected as well.

@last-partizan
Copy link
Collaborator

last-partizan commented Jul 18, 2024

Hello.

Are you sure version 0.19.0 is working? because i there isn't much changes. But jump from 0.18 to 0.19 included some relatively big changes.

If you have time, please do additional testing using git version and git bisect to identify exact bad commit.

@aacimov
Copy link
Author

aacimov commented Jul 19, 2024

@last-partizan yes, everything below 0.19.3 is working as expected. I will look into it over weekend probably and let you know.

@benzkji
Copy link

benzkji commented Jul 22, 2024

for me as well, it is django-modeltranslation<0.19.3 that works.

@benzkji
Copy link

benzkji commented Jul 22, 2024

0.9.13 introduces changes on the admin clasess, that is what the cms uses, it makes sense to me.

@last-partizan
Copy link
Collaborator

Yeah, there's some changes in admin, but they're mostly related to typing support.

If someone can provide repo with minimal reproduction, i can look into this.

@MacLake
Copy link

MacLake commented Aug 3, 2024

I can confirm it, 0.19.2 works, and 0.19.3 introduces the bug in both django-cms 3.11.6 and 4.1.2.

@MacLake
Copy link

MacLake commented Aug 6, 2024

So here is a minimal repo for reproducing the issue: I have added modeltranslation to django-cms-quickstart and published a fork here:

https://github.com/MacLake/django-cms-quickstart/tree/modeltranslation. Follow the instructions to get the project running.

First add a plugin that can contain other plugins, e. g. a Jumbotron, at top level. You can add a text plugin. to the Jumotron.

Then add a container, add a Jumbotron to the container. Now you can’t add a text or any other plugin to this Jumbotron, as it is locked. This is caused by modeltranslation>=0.19.3.

Then stop the containers, switch to the main branch (i.e. without modeltranslation) and run

docker compose build
docker compose up

The database content persists. Open the structure board Now the nested Jumbotron doesn’t have a lock icon, and you can add plugins to it.

MacLake pushed a commit to MacLake/django-cms-quickstart that referenced this issue Aug 6, 2024
@benzkji
Copy link

benzkji commented Aug 7, 2024

there is some background info in #745. The problem seems hidden and complicated.

@benzkji
Copy link

benzkji commented Aug 13, 2024

I think I found the problem. Dict access of a admin class that inherits from a TranslationAdmin is possible, and doesn't throw any error. As far as I know, that kind of access is/should never be possible, or only in special cases (fabric 1 did have some kind of "DictObject", for it's env...)? As Django itself relies on it, in it's template engine.

class MyTranslationAdmin(TranslationAdmin):
    my_prop = "123"

MyTranslationAdmin["my_prop"]  # returns that class itself!

Also, a PR that shows that: #749 (test fails with 0.19.3+, runs ok below)

@benzkji
Copy link

benzkji commented Sep 3, 2024

#755 resolves this problem for me.

@last-partizan
Copy link
Collaborator

Thanks for testing, merged and released.

@benzkji
Copy link

benzkji commented Sep 5, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants