Skip to content
This repository has been archived by the owner on Jan 18, 2020. It is now read-only.

Changing labels on DataContext language when fields are enumerable #320

Open
sgithens opened this issue Oct 29, 2015 · 0 comments
Open

Changing labels on DataContext language when fields are enumerable #320

sgithens opened this issue Oct 29, 2015 · 0 comments

Comments

@sgithens
Copy link
Contributor

Disclaimer: I realize this should be subclassed and registered as another Translator and not monkey patched, I was having issues yesterday getting it to register and in a hurry and will go back to fix it.

When a field is enumerable, and the model has choice labels, the right hand filter pane on the query view still shows the raw values. After tracking it down, I'm wondering if the default Translator behavior should be to use those values.

This is the patch I'm using at the moment to fix this:

from avocado.query.translators import Translator

Translator.orig_language = Translator.language
def new_language(self, field, operator, value, **kwargs):
    togo = value
    if field.enumerable:
        togo = [field.get_label(i) for i in value]
    return u'{0} {1}'.format(field.name, operator.text(togo))

Translator.language = new_language

If this seems like reasonable default behavior, I can submit a patch to the original translator code and try to add a unit test for this.

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

No branches or pull requests

1 participant