Beispiel #1
0
    def _apply_filter_by_client(self):
        # If the current context is a Client, filter Patients by Client UID
        if IClient.providedBy(self.context):
            client_uid = api.get_uid(self.context)
            self.contentFilter['getPrimaryReferrerUID'] = client_uid
            return

        # If the current user is a Client contact, filter the Patients in
        # accordance. For the rest of users (LabContacts), the visibility of
        # the patients depend on their permissions
        user = api.get_current_user()
        roles = user.getRoles()
        if 'Client' not in roles:
            return

        # Are we sure this a ClientContact?
        # May happen that this is a Plone member, w/o having a ClientContact
        # assigned or having a LabContact assigned... weird
        contact = api.get_user_contact(user)
        if not contact or ILabContact.providedBy(contact):
            return

        # Is the parent from the Contact a Client?
        client = api.get_parent(contact)
        if not client or not IClient.providedBy(client):
            return
        client_uid = api.get_uid(client)
        self.contentFilter['getPrimaryReferrerUID'] = client_uid
Beispiel #2
0
    def _apply_filter_by_client(self):
        """
        If the user has the role Client, the user can not see batches
        from client objects he/she does not belong to.
        """
        # If the current context is a Client, filter Batches by Client UID
        if IClient.providedBy(self.context):
            client_uid = api.get_uid(self.context)
            self.contentFilter['getClientUID'] = client_uid
            return

        # If the current user is a Client contact, filter the Batches in
        # accordance. For the rest of users (LabContacts), the visibility of
        # the Batches depend on their permissions
        user = api.get_current_user()
        roles = user.getRoles()
        if 'Client' not in roles:
            return

        # Are we sure this a ClientContact?
        # May happen that this is a Plone member, w/o having a ClientContact
        # assigned or having a LabContact assigned... weird
        contact = api.get_user_contact(user)
        if not contact or ILabContact.providedBy(contact):
            return

        # Is the parent from the Contact a Client?
        client = api.get_parent(contact)
        if not client or not IClient.providedBy(client):
            return
        client_uid = api.get_uid(client)
        self.contentFilter['getClientUID'] = client_uid
Beispiel #3
0
    def __call__(self):
        url = api.get_url(api.get_portal())
        current_user = api.get_current_user()
        contact = api.get_user_contact(current_user)
        if contact:
            parent = api.get_parent(contact)
            url = api.get_url(parent)

        return self.request.response.redirect(url)
Beispiel #4
0
 def _get_fullname_from_user_id(self, userid, default=""):
     """Try the fullname of the user
     """
     fullname = default
     user = api.get_user(userid)
     if user:
         props = api.get_user_properties(user)
         fullname = props.get("fullname", fullname)
         contact = api.get_user_contact(user)
         fullname = contact and contact.getFullname() or fullname
     return fullname
Beispiel #5
0
 def __call__(self):
     plone.protect.CheckAuthenticator(self.request)
     curr_user = api.get_current_user()
     contact = api.get_user_contact(curr_user, contact_types=['Contact'])
     parent = contact and contact.getParent() or None
     if parent and not IClient.providedBy(parent):
         parent = None
     ret = {'ClientTitle': parent and parent.Title() or '',
            'ClientID': parent and parent.getClientID() or '',
            'ClientSysID': parent and parent.id or '',
            'ClientUID': parent and parent.UID() or '',}
     return json.dumps(ret)
Beispiel #6
0
 def __call__(self):
     plone.protect.CheckAuthenticator(self.request)
     curr_user = api.get_current_user()
     contact = api.get_user_contact(curr_user, contact_types=['Contact'])
     parent = contact and contact.getParent() or None
     if parent and not IClient.providedBy(parent):
         parent = None
     ret = {'ClientTitle': parent and parent.Title() or '',
            'ClientID': parent and parent.getClientID() or '',
            'ClientSysID': parent and parent.id or '',
            'ClientUID': parent and parent.UID() or '',}
     return json.dumps(ret)
Beispiel #7
0
 def to_history_record(self, value):
     """Transforms the value to an history record
     """
     user = api.get_current_user()
     contact = api.get_user_contact(user)
     fullname = contact and contact.getFullname() or ""
     if not contact:
         # get the fullname from the user properties
         props = api.get_user_properties(user)
         fullname = props.get("fullname", "")
     return RemarksHistoryRecord(user_id=user.id,
                                 user_name=fullname,
                                 content=value.strip())
Beispiel #8
0
    def get_other_contacts(self, sample):
        """Returns a list with additional contacts the alert has to be sent to
        """
        contacts = set()
        contacts.add(api.get_user_contact(api_user.get_user()))

        # Get the responsibles of departments
        in_panic = self.get_analyses_in_panic(sample)
        departments = map(lambda an: an.getDepartment(), in_panic)
        managers = map(lambda dept: dept.getManager(), departments)
        for manager in managers:
            if manager:
                contacts.add(manager)
        return list(contacts)
Beispiel #9
0
    def get_current_client(self, default=None):
        """Returns the client the current user belongs to
        """
        user = api.get_current_user()
        roles = user.getRoles()
        if 'Client' not in roles:
            return default

        contact = api.get_user_contact(user)
        if not contact or ILabContact.providedBy(contact):
            return default

        client = api.get_parent(contact)
        if not client or not IClient.providedBy(client):
            return default

        return client
Beispiel #10
0
    def get_current_client(self, default=None):
        """Returns the client the current user belongs to
        """
        user = api.get_current_user()
        roles = user.getRoles()
        if 'Client' not in roles:
            return default

        contact = api.get_user_contact(user)
        if not contact or ILabContact.providedBy(contact):
            return default

        client = api.get_parent(contact)
        if not client or not IClient.providedBy(client):
            return default

        return client
Beispiel #11
0
 def get_contact_name(self):
     user = api.get_current_user()
     contact = api.get_user_contact(user)
     return contact.getFullname()
Beispiel #12
0
 def get_contact_title(self):
     user = api.get_current_user()
     contact = api.get_user_contact(user)
     return contact.getJobTitle()
Beispiel #13
0
 def __call__(self):
     self.client_contact = api.get_user_contact(api.get_current_user(),
                                                contact_types=['Contact'])
     return ClientView.__call__(self)