Geonode: Admin Panel add Menu Item does not work for UTF-8 Characters

Created on 5 Nov 2019  路  6Comments  路  Source: GeoNode/geonode

Expected Behavior

You could go to http://your.geonode.com/en/admin/base/menu/add/ and write UTF-8 characters into the title ofr menus and menu items.

Actual Behavior

You can not use UTF-8 characters due to encoding issues:

UnicodeEncodeError at /de/admin/base/menuitem/2/change/
'ascii' codec can't encode character u'\xdc' in position 0: ordinal not in range(128)

Steps to Reproduce the Problem

  1. http://your.geonode.com/en/admin/base/menu/add/
  2. add item with UTF-8 characters
  3. try to save it

Specifications

  • GeoNode version: 2.10.x
  • Installation method (manual, GeoNode Docker, SPCGeoNode Docker): SPC
  • Platform: Ubuntu 18.04

Additional Information

adding def __unicode__(self): functions to the menu customization models (base/models.py) will fix this issue.

minor

Most helpful comment

There's always the need for tests!!

All 6 comments

Create @gannebamm ! Thanks. How about adding a test for this. From a quick look it might be here: https://github.com/GeoNode/geonode/blob/master/geonode/base/tests.py

馃槄 never written a test before ... but will do ;)

Maybe it's not needed but thinking out loud the more we test the better we sleep at night ;))

From what I see you would run the test locally with python manage.py test geonode.base.tests.RenderMenuTagTest you might adapt this to SPC, based on what Travis has written at the google docs.

Now let's try to include some " german umlaute " for example here when creating a menu item
https://github.com/GeoNode/geonode/blob/master/geonode/base/tests.py#L60

        self.menu_0_1 = Menu.objects.create(
            title='test_menu_0_1_盲枚脺',
            order=1,
            placeholder=self.placeholder_0
        )

It should fail with the error message from above ?! And succeed with your commit?

@afabiani please don't hesitate to say if you do not see the need of testing special chars ;)

There's always the need for tests!!

just a hint for myself and others. The gdoc t-book referred to is this one: https://docs.google.com/document/d/1h4xhXTejSkfqmEQmzl6CkcySc9_COZldm_5qvFI3fB8/edit

@t-book it isn麓t that simple. I made a local test and

https://github.com/GeoNode/geonode/blob/master/geonode/base/tests.py#L132

fails with a UnicodeDecodeError

I am just to stupid for unicode in python 馃槗

Was this page helpful?
0 / 5 - 0 ratings