Changeset aeaef04 in tailbone


Ignore:
Timestamp:
07/11/19 14:01:22 (13 months ago)
Author:
Lance Edgar <ledgar@…>
Branches:
master
Children:
61df774
Parents:
8c2287a
Message:

Add convenience method for gathering employee history context data

so we can reuse that for returning JSON from various views

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tailbone/views/people.py

    r8c2287a raeaef04  
    248248            'employee': employee,
    249249            'employee_history': employee.get_current_history() if employee else None,
    250             'employee_history_data': [],
     250            'employee_history_data': self.get_context_employee_history(employee),
    251251        }
    252252
    253         # employee_history_data
     253        use_buefy = self.get_use_buefy()
     254        template = 'view_profile_buefy' if use_buefy else 'view_profile'
     255        return self.render_to_response(template, context)
     256
     257    def get_context_employee_history(self, employee):
     258        data = []
    254259        if employee:
    255             data = []
    256260            for history in sorted(employee.history, key=lambda h: h.start_date, reverse=True):
    257261                data.append({
     
    259263                    'end_date': six.text_type(history.end_date or ''),
    260264                })
    261             context['employee_history_data'] = data
    262 
    263         use_buefy = self.get_use_buefy()
    264         template = 'view_profile_buefy' if use_buefy else 'view_profile'
    265         return self.render_to_response(template, context)
     265        return data
    266266
    267267    def make_note_form(self, mode, person):
Note: See TracChangeset for help on using the changeset viewer.