emencia / django-blog-lotus

A weblog application with Django.
https://django-blog-lotus.readthedocs.io/
MIT License
6 stars 1 forks source link

Translated object should inherit from some of original content #40

Open sveetch opened 1 year ago

sveetch commented 1 year ago

Is your feature request related to a problem? Please describe. When creating a translation object from an original one, the create form is almost blank except the "orginal" relation.

Describe the solution you'd like Category has nothing valuable to share with translation.

Article translation should inherit from states and publication dates because we can assume it should be identical on its visibility behaviors and the user should be aware enough to change these value for specific case.

Describe alternatives you've considered Let this as it work currently, this is not a breaking issue but this is not really useful for users to apply again all the original value.

sveetch commented 1 year ago

I would say that a new setting could define what model field have to be copied during translation, so each project could choose to copy or not some fields.

Something like this:

{
    "Article": [
        "cover",
        "publish_date",
        "publish_time",
    ],
}
sveetch commented 1 year ago

By the way, actually from translation form we give the original id as an URL argument automatically set on input from Django admin form view.

But this won't work to copy original field values, date won't be formatted well and images cannot be given like this.

So we will need to customize the admin form to get values and set them on new non created (yet) form for the translation.

sveetch commented 1 year ago

We may have a proper way using a form in AdminTranslateView which sends POST request to pass data to copy into new translation object admin creation view which could fill initial form values with getting data into ModelAdmin.get_changeform_initial_data. The form from AdminTranslateView should have the "language target" field and then a list of checkbox for available fields to copy from original.

sveetch commented 1 year ago

Also there is a bug with "Translate" button from detail page, it shows even if there is not any available language for the object to translate.

sveetch commented 1 year ago

The POST technique won't work since it is catched as submitting create form, not as "go to creation form and fill this". The GET could work but not for images since they need to be duplicated (each article needs its own file since it can be removed).

We may change of the way to perform a translation. Instead of sending to creation form, it could be some sort of resumed form with choosing data to copy and then directly create object ? (It seems impossible since there is many required fields)