Add "view profile" for viewing *all* details of a given person at once

feature preview (easter egg) only for now though, lots of refinement to do yet
This commit is contained in:
Lance Edgar 2019-04-10 16:46:16 -05:00
parent ec70d85638
commit 6ae703dfd9
2 changed files with 180 additions and 0 deletions

View file

@ -0,0 +1,155 @@
## -*- coding: utf-8; -*-
<%inherit file="/master/view.mako" />
<%def name="extra_javascript()">
${parent.extra_javascript()}
<script type="text/javascript">
$(function() {
$('#profile-tabs').tabs();
});
</script>
</%def>
<div id="profile-tabs">
<ul>
<li><a href="#personal-tab">Personal</a></li>
<li><a href="#customer-tab">Customer</a></li>
<li><a href="#employee-tab">Employee</a></li>
</ul>
<div id="personal-tab">
<div class="field-wrapper first_name">
<div class="field-row">
<label>First Name</label>
<div class="field">
${person.first_name}
</div>
</div>
</div>
<div class="field-wrapper middle_name">
<div class="field-row">
<label>Middle Name</label>
<div class="field">
${person.middle_name}
</div>
</div>
</div>
<div class="field-wrapper last_name">
<div class="field-row">
<label>Last Name</label>
<div class="field">
${person.last_name}
</div>
</div>
</div>
<div class="field-wrapper street">
<div class="field-row">
<label>Street 1</label>
<div class="field">
${person.address.street if person.address else ''}
</div>
</div>
</div>
<div class="field-wrapper street2">
<div class="field-row">
<label>Street 2</label>
<div class="field">
${person.address.street2 if person.address else ''}
</div>
</div>
</div>
<div class="field-wrapper city">
<div class="field-row">
<label>City</label>
<div class="field">
${person.address.city if person.address else ''}
</div>
</div>
</div>
<div class="field-wrapper state">
<div class="field-row">
<label>State</label>
<div class="field">
${person.address.state if person.address else ''}
</div>
</div>
</div>
<div class="field-wrapper zipcode">
<div class="field-row">
<label>Zipcode</label>
<div class="field">
${person.address.zipcode if person.address else ''}
</div>
</div>
</div>
</div><!-- personal-tab -->
<div id="customer-tab">
% for customer in person.customers:
<div class="field-wrapper id">
<div class="field-row">
<label>ID</label>
<div class="field">
${customer.id or ''}
</div>
</div>
</div>
<div class="field-wrapper name">
<div class="field-row">
<label>Name</label>
<div class="field">
${customer.name}
</div>
</div>
</div>
% endfor
</div><!-- customer-tab -->
<div id="employee-tab">
% if person.employee:
<div class="field-wrapper id">
<div class="field-row">
<label>ID</label>
<div class="field">
${person.employee.id or ''}
</div>
</div>
</div>
<div class="field-wrapper display_name">
<div class="field-row">
<label>Display Name</label>
<div class="field">
${person.employee.display_name or ''}
</div>
</div>
</div>
<div class="field-wrapper status">
<div class="field-row">
<label>Status</label>
<div class="field">
${enum.EMPLOYEE_STATUS[person.employee.status]}
</div>
</div>
</div>
% else:
<p>${person} has never been an employee.</p>
% endif
</div><!-- employee-tab -->
</div><!-- profile-tabs -->

View file

@ -225,6 +225,20 @@ class PeopleView(MasterView):
(model.VendorContact, 'person_uuid'),
]
def view_profile(self):
"""
View which exposes the "full profile" for a given person, i.e. all
related customer, employee, user info etc.
"""
self.viewing = True
person = self.get_instance()
context = {
'person': person,
'instance': person,
'instance_title': self.get_instance_title(person),
}
return self.render_to_response('view_profile', context)
def make_user(self):
uuid = self.request.POST['person_uuid']
person = self.Session.query(model.Person).get(uuid)
@ -249,8 +263,19 @@ class PeopleView(MasterView):
@classmethod
def _people_defaults(cls, config):
permission_prefix = cls.get_permission_prefix()
route_prefix = cls.get_route_prefix()
url_prefix = cls.get_url_prefix()
model_key = cls.get_model_key()
model_title = cls.get_model_title()
# view profile
config.add_tailbone_permission(permission_prefix, '{}.view_profile'.format(permission_prefix),
"View full \"profile\" for {}".format(model_title))
config.add_route('{}.view_profile'.format(route_prefix), '{}/{{{}}}/profile'.format(url_prefix, model_key),
request_method='GET')
config.add_view(cls, attr='view_profile', route_name='{}.view_profile'.format(route_prefix),
permission='{}.view_profile'.format(permission_prefix))
# make user for person
config.add_route('{}.make_user'.format(route_prefix), '{}/make-user'.format(url_prefix),