Include employee history data in context for "view profile"

This commit is contained in:
Lance Edgar 2019-07-10 22:58:05 -05:00
parent 839f6affe2
commit fa825da404

View file

@ -247,7 +247,19 @@ class PeopleView(MasterView):
'instance_title': self.get_instance_title(person),
'employee': employee,
'employee_history': employee.get_current_history() if employee else None,
'employee_history_data': [],
}
# employee_history_data
if employee:
data = []
for history in sorted(employee.history, key=lambda h: h.start_date, reverse=True):
data.append({
'start_date': six.text_type(history.start_date),
'end_date': six.text_type(history.end_date or ''),
})
context['employee_history_data'] = data
use_buefy = self.get_use_buefy()
template = 'view_profile_buefy' if use_buefy else 'view_profile'
return self.render_to_response(template, context)