示例#1
0
    def get_customer_details(self, user_id):
        # use the user id to determine the customer's role, whether IND or ORG
        role_id = UserRolePlacement.fetch_role_by_user_id(user_id)
        # get role name using role_id
        role = Role.fetch_role_by_id(role_id)
        if role == 'IND':
            customer_no = IndividualCustomer.get_customer_number(user_id)
            if customer_no:
                user_profile = UserProfile.get_profile_by_user_id(user_id)
                data = {
                    "customer_number": customer_no,
                    "first_name": user_profile.first_name,
                    "last_name": user_profile.last_name,
                    "phone_number": user_profile.phone,
                    "kra_pin": user_profile.kra_pin,
                    "id_passport": user_profile.id_passport,
                }
                return data
            else:
                response_msg = helper.make_rest_fail_response(
                    "Customer does not exist")
                return make_response(response_msg, 404)

        elif role == 'ORG':
            # When the customer is an organization, their details are stored directly in the organization model
            # (not linked with the user profile)
            customer = OrganizationCustomer.get_customer_by_contact(user_id)
            if customer:
                # get customer details
                data = {}
                # TODO: Confirm from Tony whether to fetch organization details or contact person
                pass
示例#2
0
 def get_user_role(user_id):
     """
     get the user role by id, this is needed to throttle permissions on modules to access
     """
     role = UserRolePlacement.fetch_role_by_user_id(user_id)
     role_name = Role.fetch_role_by_id(role)
     return role_name
示例#3
0
 def get_role_name(self, uid):
     u_role = UserRolePlacement.fetch_role_by_user_id(uid)
     return Role.fetch_role_by_id(u_role)