Giter Club home page Giter Club logo

Comments (14)

linuxsoftware avatar linuxsoftware commented on May 24, 2024 1

The full source code for my test case is at https://github.com/linuxsoftware/joyous-issue33-mysite

from ls.joyous.

linuxsoftware avatar linuxsoftware commented on May 24, 2024 1

For a proper fix install ls.joyous 1.3.0 and add the setting JOYOUS_DEFEND_FORMS=True

When this setting is set to True then the Joyous page models will not allow their base_form_class to be replaced. Instead they will assimilate the newly assigned form class. The purpose of this setting is to make Joyous compatible with the wagtail-modeltranslations app. (Users who do not use wagtail-modeltranslations probably do not need to enable this option.)

I have also raised the issue with the maintainers of wagtail-modeltranslations, for better documentation if nothing else.

from ls.joyous.

linuxsoftware avatar linuxsoftware commented on May 24, 2024

As a temporary work-around I suggest adding the following code to your translation.py before you register CalendarPage for translation.

from ls.joyous.models.calendar import CalendarPageForm
CalendarPageForm.registerImportHandler = lambda *args: None

This will disable the iCal import functionality. I will continue to investigate a better solution, but this will probably require a new release of Joyous.

My most minimal translation.py file looks like this (below). I do not know why those 5 Joyous pages require registering, but others like CancellationPage, ExtraInfoPage, PostponementPage etc do not?!

from wagtail_modeltranslation.translation import TranslationOptions
from modeltranslation.decorators import register
from .models import HomePage
from ls.joyous.models import GroupPage, CalendarPage, SimpleEventPage, MultidayEventPage, RecurringEventPage

@register(HomePage)
class HomeTR(TranslationOptions):
    fields = (
    )

from ls.joyous.models.calendar import CalendarPageForm
CalendarPageForm.registerImportHandler = lambda *args: None

@register(CalendarPage)
class CalendarTR(TranslationOptions):
    fields = (
    )

@register(GroupPage)
class GroupTR(TranslationOptions):
    fields = (
    )

@register(SimpleEventPage)
class SimpleEventTR(TranslationOptions):
    fields = (
    )

@register(MultidayEventPage)
class MultidayTR(TranslationOptions):
    fields = (
    )

@register(RecurringEventPage)
class RecurringEventTR(TranslationOptions):
    fields = (
    )

from ls.joyous.

vbroskas avatar vbroskas commented on May 24, 2024

Works great, thanks for all the help @linuxsoftware !

from ls.joyous.

linuxsoftware avatar linuxsoftware commented on May 24, 2024

Another problem with this work-around is that the validation that the start-time of the event is before its end-time is now broken.

This is because wagtail-modeltranslation replaces the page's base_form_class attribute with no regard to its previous value. I intend to raise an issue for this once I have a nice simple test case for it.

from ls.joyous.

linuxsoftware avatar linuxsoftware commented on May 24, 2024

Ooops. Sorry. Looks like there is still a problem. :-( I need to test further.

from ls.joyous.

linuxsoftware avatar linuxsoftware commented on May 24, 2024

There is a new version of wagtail-modeltranslations v0.10.14, which fixes the form overwriting bug. And a new version of ls.joyous v1.3.1 which works around a problem with modeltranslation patch_constructor breaking initialization of pages which have multiple inheritance. I recommend upgrading both apps to these versions.

NB: The JOYOUS_DEFEND_FORMS setting mentioned above is still there in ls.joyous v1.3.1, but is not needed with wagtail-modeltranslations v0.10.14.

from ls.joyous.

linuxsoftware avatar linuxsoftware commented on May 24, 2024

Also note that all pages (CancellationPage, ExtraInfoPage, PostponementPage etc) do need to be registered with modeltranslations. It may not give an error on startup, but it will error during runtime if these page types are accessed. See https://github.com/linuxsoftware/joyous-issue33-mysite/blob/master/home/translation.py for my translations file.

from ls.joyous.

joaquinstirling avatar joaquinstirling commented on May 24, 2024

Hello, Thanks for making an example site.
Although I cannot get your solution working. I keep getting this, I've the same as you on a fresh install.

Do you have a hint on what It might be?
image

from ls.joyous.

linuxsoftware avatar linuxsoftware commented on May 24, 2024

Can you confirm you have wagtail-modeltranslations v0.10.14 and ls.joyous v1.3.1 installed?
And, which version of Django and Wagtail are you using?

from ls.joyous.

joaquinstirling avatar joaquinstirling commented on May 24, 2024

Can you confirm you have wagtail-modeltranslations v0.10.14 and ls.joyous v1.3.1 installed?
And, which version of Django and Wagtail are you using?

I can confirm I'm using those versions.
Django: 2.2.X STABLE (LTS)
Wagtail: 2.10.1

PD: I'm using Divio and using their packages for both apps.
https://github.com/divio/aldryn-wagtail
https://github.com/divio/aldryn-django

from ls.joyous.

linuxsoftware avatar linuxsoftware commented on May 24, 2024

I suspect the problem is with trying to add an extra migration to an installed package like Joyous in this environment. Try copying the migrations from Joyous to you own app and then add a MIGRATION_MODULES entry for it to your settings.
e.g.

MIGRATION_MODULES = {
    'joyous': 'home.migratejoyous'
}

Then, when you run makemigrations, the new migration should be created in this directory under your app.

I have updated https://github.com/linuxsoftware/joyous-issue33-mysite with this change.

from ls.joyous.

joaquinstirling avatar joaquinstirling commented on May 24, 2024

I suspect the problem is with trying to add an extra migration to an installed package like Joyous in this environment. Try copying the migrations from Joyous to you own app and then add a MIGRATION_MODULES entry for it to your settings.
e.g.

MIGRATION_MODULES = {
    'joyous': 'home.migratejoyous'
}

Then, when you run makemigrations, the new migration should be created in this directory under your app.

I have updated https://github.com/linuxsoftware/joyous-issue33-mysite with this change.

Hi, I've replicated what you did on issue-33 site but I cannot even run the migrations because the same exception appears... It's quite strange. I think it has to do with Page TranslationOption, The fields that raise the error come because the page hierarchy

from ls.joyous.

linuxsoftware avatar linuxsoftware commented on May 24, 2024

I have no further suggestions. This is working for me on Divio with Aldryn-Wagtail and Aldryn-Django.

from ls.joyous.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.