even more beauty: using verbose_name from model for display data
This commit is contained in:
parent
7154707e99
commit
93f31fbaa0
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue