From 6ae703dfd9be8802a798e85f6926274103db3837 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 10 Apr 2019 16:46:16 -0500 Subject: [PATCH] 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 --- tailbone/templates/people/view_profile.mako | 155 ++++++++++++++++++++ tailbone/views/people.py | 25 ++++ 2 files changed, 180 insertions(+) create mode 100644 tailbone/templates/people/view_profile.mako diff --git a/tailbone/templates/people/view_profile.mako b/tailbone/templates/people/view_profile.mako new file mode 100644 index 00000000..35a4e700 --- /dev/null +++ b/tailbone/templates/people/view_profile.mako @@ -0,0 +1,155 @@ +## -*- coding: utf-8; -*- +<%inherit file="/master/view.mako" /> + +<%def name="extra_javascript()"> + ${parent.extra_javascript()} + + + +
+ + +
+ +
+
+ +
+ ${person.first_name} +
+
+
+ +
+
+ +
+ ${person.middle_name} +
+
+
+ +
+
+ +
+ ${person.last_name} +
+
+
+ +
+
+ +
+ ${person.address.street if person.address else ''} +
+
+
+ +
+
+ +
+ ${person.address.street2 if person.address else ''} +
+
+
+ +
+
+ +
+ ${person.address.city if person.address else ''} +
+
+
+ +
+
+ +
+ ${person.address.state if person.address else ''} +
+
+
+ +
+
+ +
+ ${person.address.zipcode if person.address else ''} +
+
+
+ +
+ +
+ % for customer in person.customers: + +
+
+ +
+ ${customer.id or ''} +
+
+
+ +
+
+ +
+ ${customer.name} +
+
+
+ + % endfor +
+ +
+ % if person.employee: + +
+
+ +
+ ${person.employee.id or ''} +
+
+
+ +
+
+ +
+ ${person.employee.display_name or ''} +
+
+
+ +
+
+ +
+ ${enum.EMPLOYEE_STATUS[person.employee.status]} +
+
+
+ + % else: +

${person} has never been an employee.

+ % endif +
+ +
diff --git a/tailbone/views/people.py b/tailbone/views/people.py index cdf40766..ec201ac3 100644 --- a/tailbone/views/people.py +++ b/tailbone/views/people.py @@ -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),