Add translation_of: original content appearing *after* save

15 views
Skip to first unread message

jeroen.pulles

unread,
Jan 13, 2012, 4:47:36 AM1/13/12
to Django FeinCMS
Hi,

When I add a translation to a page in the admin, the new page doesn't
have content by default. I add some content in the new language, press
'Save and continue editing' and without any feedback the original
content appears below the content I just wrote. Is that known,
intentional behavior or a bug?

Since the content is appended at the end of the existing content it is
usually out of sight, which makes it even more confusing behavior to
me.

I noticed the overridden response_add() method on the PageAdmin that
causes this, but I don't see any configuration option to disable this
behavior.

A slightly related question: When I add a new page, I'd like to see an
empty text field by default. Is there a way to configure some default
content on a new page in the admin?

kind regards,
Jeroen

(I'm running FeinCMS 1.4.2 FWIW)

Matthias Kestenholz

unread,
Jan 13, 2012, 4:51:59 AM1/13/12
to django-...@googlegroups.com
On Fri, Jan 13, 2012 at 10:47, jeroen.pulles <jeroen...@gmail.com> wrote:
> Hi,
>
> When I add a translation to a page in the admin, the new page doesn't
> have content by default. I add some content in the new language, press
> 'Save and continue editing' and without any feedback the original
> content appears below the content I just wrote. Is that known,
> intentional behavior or a bug?
>
> Since the content is appended at the end of the existing content it is
> usually out of sight, which makes it even more confusing behavior to
> me.
>
> I noticed the overridden response_add() method on the PageAdmin that
> causes this, but I don't see any configuration option to disable this
> behavior.

The idea is that translations essentially consist of the same content
- it would be tedious having to recreate the same content for 4
languages without this helper.

There's no configuration option at the moment as you have noticed.
Maybe it would be enough to only copy content when nothing has been
added yet?


> A slightly related question: When I add a new page, I'd like to see an
> empty text field by default. Is there a way to configure some default
> content on a new page in the admin?

Unfortunately no. The simplest way to achieve this would be to
customize the page item editor template and add the default content
using javascript (untested):

{% if not original %}
<script>$(function() {
ItemEditor.add_content('richtextcontent', 'main');
});</script>
{% endif %}


Best regards
Matthias

jeroen.pulles

unread,
Jan 13, 2012, 5:25:23 AM1/13/12
to Django FeinCMS
Hi Matthias,

On Jan 13, 10:51 am, Matthias Kestenholz <m...@feinheit.ch> wrote:
> On Fri, Jan 13, 2012 at 10:47, jeroen.pulles <jeroen.pul...@gmail.com> wrote:
> > Hi,
>
> > When I add a translation to a page in the admin, the new page doesn't
> > have content by default. I add some content in the new language, press
> > 'Save and continue editing' and without any feedback the original
> > content appears below the content I just wrote. Is that known,
> > intentional behavior or a bug?
>
> > Since the content is appended at the end of the existing content it is
> > usually out of sight, which makes it even more confusing behavior to
> > me.
>
> > I noticed the overridden response_add() method on the PageAdmin that
> > causes this, but I don't see any configuration option to disable this
> > behavior.
>
> The idea is that translations essentially consist of the same content
> - it would be tedious having to recreate the same content for 4
> languages without this helper.

It's just so completely weird that you don't see this until you press
'Save and continue editing' once. If you press the regular Save
button, you won't even notice this effect. Unless you've been told in
advance about this behavior, you will have started from scratch again
anyhow.

Maybe a message on the top of the page helps here (You could do that
in response_add as well).

Wouldn't it be possible to turn "translate" into a more specialized
action that saves the new translated page to the database before
showing it in the form? Since it's a copy, most required fields
without defaults could be copied in advance as well (maybe with a
suffix like " (new translation)").

> There's no configuration option at the moment as you have noticed.
> Maybe it would be enough to only copy content when nothing has been
> added yet?

That makes sense.

> > A slightly related question: When I add a new page, I'd like to see an
> > empty text field by default. Is there a way to configure some default
> > content on a new page in the admin?
>
> Unfortunately no. The simplest way to achieve this would be to
> customize the page item editor template and add the default content
> using javascript (untested):
>
> {% if not original %}
> <script>$(function() {
>     ItemEditor.add_content('richtextcontent', 'main');});</script>
>
> {% endif %}

Thanks, I'll try that out.

kind regards,
Jeroen

jeroen.pulles

unread,
Jan 13, 2012, 6:35:42 AM1/13/12
to Django FeinCMS
Hi,

> > > A slightly related question: When I add a new page, I'd like to see an
> > > empty text field by default. Is there a way to configure some default
> > > content on a new page in the admin?
>
> > Unfortunately no. The simplest way to achieve this would be to
> > customize the page item editor template and add the default content
> > using javascript (untested):
>
> > {% if not original %}
> > <script>$(function() {
> >     ItemEditor.add_content('richtextcontent', 'main');});</script>
>
> > {% endif %}
>

The 'main' string gave errors; I added this following piece of code to
my admin init script (added with 'feincms_item_editor_includes')

<script>
// ...

// Automatically add a new richtext content on an empty main
// region:
if (!$('#main_body').children('.order-machine').children().length)
{
ItemEditor.add_content('richtextcontent', 0 /* my region
'main' */);
}

// ...
</script>

I had to play around a bit to find the right moment to run this code
since I'm also doing TinyMCE initialization. I moved this snippet
inside an existing contentblock_init_handlers callback.

kind regards,
Jeroen

Wouter van der Graaf

unread,
Jan 17, 2012, 4:23:02 AM1/17/12
to Django FeinCMS
> There's no configuration option at the moment as you have noticed.
> Maybe it would be enough to only copy content when nothing has been
> added yet?

That seems like a good solution to me, but without proper feedback
very confusing. In any case, anything that's done automatically and
users wouldn't expect should be brought to their attention. Use the
Django messages app for that. One line of informative feedback on the
top of the page can't be that annoying, right?

If you want we could collectively create a list of the places/
situations that could be friendlier to the user.

Wouter

Martin J. Laubach

unread,
Jan 17, 2012, 5:10:36 AM1/17/12
to django-...@googlegroups.com
> If you want we could collectively create a list of the places/ 
> situations that could be friendlier to the user. 

  Yes please. Most of the change in the Admin interface is driven by things we notice that "could be better" and annoys enough to be improved, but there's only so much that one can be annoyed by and different people notice different things.

        mjl

Matthias Kestenholz

unread,
Jan 18, 2012, 11:50:25 AM1/18/12
to django-...@googlegroups.com

Yes, definitely!


Thanks,
Matthias

Wouter van der Graaf

unread,
Jan 24, 2012, 3:38:51 AM1/24/12
to Django FeinCMS
OK, I will schedule a FeinCMS annoyance afternoon then ;-)

I will ask my colleagues to join me. Perhaps OP (Jeroen is a friend of
mine) would like to step into our office as well.

W

Matthias Kestenholz

unread,
Feb 15, 2012, 7:12:27 AM2/15/12
to django-...@googlegroups.com
Hi,

On Tue, Jan 24, 2012 at 09:38, Wouter van der Graaf <wou...@dynora.nl> wrote:
> OK, I will schedule a FeinCMS annoyance afternoon then ;-)
>
> I will ask my colleagues to join me. Perhaps OP (Jeroen is a friend of
> mine) would like to step into our office as well.
>

Just wanted to ask if you have found anything interesting to share?


Thanks,
Matthias

Matthias Kestenholz

unread,
Feb 15, 2012, 8:04:01 AM2/15/12
to django-...@googlegroups.com
On Tue, Jan 17, 2012 at 10:23, Wouter van der Graaf <wou...@dynora.nl> wrote:
>> There's no configuration option at the moment as you have noticed.
>> Maybe it would be enough to only copy content when nothing has been
>> added yet?
>
> That seems like a good solution to me, but without proper feedback
> very confusing. In any case, anything that's done automatically and
> users wouldn't expect should be brought to their attention. Use the
> Django messages app for that. One line of informative feedback on the
> top of the page can't be that annoying, right?

Definitely not too annoying. I've implemented these suggestions here:

Only copy content if new object does not have any yet:
https://github.com/feincms/feincms/commit/0a4d0e484317d6c71448ad56c4999e5e8ef238d1

Show notification:
https://github.com/feincms/feincms/commit/971a8b3fe14faf1ba7be7b340ed94145f9525856

Thanks,
Matthias

Reply all
Reply to author
Forward
0 new messages