chol
/
eva
forked from tohe/eva
1
0
Fork 0

even more beauty: using verbose_name from model for display data

This commit is contained in:
Benni Bärmann 2021-01-19 09:08:59 +01:00
parent 7154707e99
commit 93f31fbaa0
1 changed files with 5 additions and 2 deletions

View File

@ -82,11 +82,14 @@ class EvaFormView(CookieWizardView):
#
def beautify_data(self, data):
# update data with keys from *_CHOICES if present there
# update values in data dictionary with keys from *_CHOICES if present there
choices = {**DEPARTMENT_CHOICES, **LAPTOP_CHOICES, **TRANSPONDER_CHOICES,
**OS_CHOICES, **MOBILE_CHOICES, **LANG_CHOICES,}
data.update({k:choices[v] for k,v in data.items() \
if isinstance(v,collections.abc.Hashable) \
and v in choices})
return data
# replace keys in data dictionary with verbose_name
newdata = {self.instance._meta.get_field(k).verbose_name.title() : v for k,v in data.items()}
return newdata