Add convenience method for gathering employee history context data
so we can reuse that for returning JSON from various views
This commit is contained in:
parent
8c2287a1e8
commit
aeaef04fac
|
@ -247,22 +247,22 @@ class PeopleView(MasterView):
|
||||||
'instance_title': self.get_instance_title(person),
|
'instance_title': self.get_instance_title(person),
|
||||||
'employee': employee,
|
'employee': employee,
|
||||||
'employee_history': employee.get_current_history() if employee else None,
|
'employee_history': employee.get_current_history() if employee else None,
|
||||||
'employee_history_data': [],
|
'employee_history_data': self.get_context_employee_history(employee),
|
||||||
}
|
}
|
||||||
|
|
||||||
# employee_history_data
|
use_buefy = self.get_use_buefy()
|
||||||
|
template = 'view_profile_buefy' if use_buefy else 'view_profile'
|
||||||
|
return self.render_to_response(template, context)
|
||||||
|
|
||||||
|
def get_context_employee_history(self, employee):
|
||||||
|
data = []
|
||||||
if employee:
|
if employee:
|
||||||
data = []
|
|
||||||
for history in sorted(employee.history, key=lambda h: h.start_date, reverse=True):
|
for history in sorted(employee.history, key=lambda h: h.start_date, reverse=True):
|
||||||
data.append({
|
data.append({
|
||||||
'start_date': six.text_type(history.start_date),
|
'start_date': six.text_type(history.start_date),
|
||||||
'end_date': six.text_type(history.end_date or ''),
|
'end_date': six.text_type(history.end_date or ''),
|
||||||
})
|
})
|
||||||
context['employee_history_data'] = data
|
return data
|
||||||
|
|
||||||
use_buefy = self.get_use_buefy()
|
|
||||||
template = 'view_profile_buefy' if use_buefy else 'view_profile'
|
|
||||||
return self.render_to_response(template, context)
|
|
||||||
|
|
||||||
def make_note_form(self, mode, person):
|
def make_note_form(self, mode, person):
|
||||||
schema = NoteSchema().bind(session=self.Session(),
|
schema = NoteSchema().bind(session=self.Session(),
|
||||||
|
|
Loading…
Reference in a new issue