Esempio n. 1
0
    def _sqlalchemy_task_link(self, item):
        """Renders a indexed task item (globalindex sqlalchemy object) either
        with a link to the effective task (if the user has access) or just with
        the title.
        We have two different types of a task. task-object providing the
        ITask-interface is handled in the _object_task_link.
        """

        css_class = self.get_css_class(item)

        # get the client which the task cames from
        info = queryUtility(IContactInformation)
        if info:
            client = info.get_client_by_id(item.client_id)
        if not info or not client:
            return '<span class="%s">%s</span>' % (css_class, item.title)

        # has the user access to the target task?
        has_access = False
        mtool = getToolByName(self.context, 'portal_membership')
        member = mtool.getAuthenticatedMember()

        if member:
            principals = set(member.getGroups() + [member.getId()])
            allowed_principals = set(item.principals)
            has_access = len(principals & allowed_principals) > 0

        # If the target is on a different client we need to make a popup
        if item.client_id != get_client_id():
            link_target = ' target="_blank"'
            url = '%s/%s' % (client.public_url, item.physical_path)
        else:
            link_target = ''
            url = client.public_url + '/' + item.physical_path

        # create breadcrumbs including the (possibly remote) client title
        breadcrumb_titles = "[%s] > %s" % (client.title, item.breadcrumb_title)

        # Client and user info
        info_html = ' <span class="discreet">(%s / %s)</span>' % (
            client_title_helper(item, item.assigned_client),
            info.render_link(item.responsible),
        )

        # Link to the task object
        task_html = '<span class="%s">%s</span>' % \
                        (css_class, item.title)

        # Render the full link if we have acccess
        if has_access:
            inner_html = '<a href="%s"%s title="%s">%s</a> %s' % (
                url, link_target, breadcrumb_titles, task_html, info_html)
        else:
            inner_html = '%s %s' % (task_html, info_html)

        # Add the task-state css and return it
        return self._task_state_wrapper(item, inner_html)
Esempio n. 2
0
        def _get_issuer():
            info = getUtility(IContactInformation)
            task = ITask(self.context)

            client_id = get_client_id()
            predecessors = self.get_predecessor_task()

            if predecessors and predecessors[0].task_type != "forwarding_task_type":
                client_id = predecessors[0].client_id
            else:
                client_id = get_client_id()

            client = client_title_helper(task, client_id)

            return client + " / " + info.render_link(task.issuer)
Esempio n. 3
0
        def _get_issuer():
            info = getUtility(IContactInformation)
            task = ITask(self.context)

            if info.is_one_client_setup():
                return info.render_link(task.issuer)

            client_id = get_client_id()
            predecessors = self.get_predecessor_task()

            if predecessors and \
                predecessors[0].task_type != 'forwarding_task_type':
                client_id = predecessors[0].client_id

            client = client_title_helper(task, client_id)

            return client + ' / ' + info.render_link(task.issuer)
Esempio n. 4
0
        def _get_issuer():
            info = getUtility(IContactInformation)
            task = ITask(self.context)

            if info.is_one_client_setup():
                return info.render_link(task.issuer)

            client_id = get_client_id()
            predecessors = self.get_predecessor_task()

            if predecessors and \
                predecessors[0].task_type != 'forwarding_task_type':
                client_id = predecessors[0].client_id

            client = client_title_helper(task, client_id)

            return client + ' / ' + info.render_link(task.issuer)
Esempio n. 5
0
    def _object_task_link(self, item):
        """ Renders a task object with a link to the effective task
        We have two different types of a task. task-object from the sql-db is
        handled in the _sqlalchemy_task_link-method.
        """
        breadcrumb_titles = "[%s] > %s" % (
            client_title_helper(item, item.responsible_client).encode("utf-8"),
            " > ".join(_breadcrumbs_from_item(item)),
        )

        info_html = self.get_task_info(item)
        task_html = '<a href="%s" title="%s"><span class="%s">%s</span></a>' % (
            item.absolute_url(),
            breadcrumb_titles,
            self.get_css_class(item),
            item.Title(),
        )
        inner_html = '%s <span class="discreet">(%s)</span>' % (task_html, info_html)

        return self._task_state_wrapper(item, inner_html)
Esempio n. 6
0
    def get_task_info(self, item):
        """ return some task attributes for objects:
            Responsible client ID /  responsible
        """
        if not ITask.providedBy(item):
            return ""

        info = getUtility(IContactInformation)

        if not item.responsible_client or len(info.get_clients()) <= 1:
            # No responsible client is set yet or we have a single client
            # setup.
            return info.describe(item.responsible)

        # Client
        client = client_title_helper(item, item.responsible_client)

        taskinfo = "%s / %s" % (client, info.render_link(item.responsible))

        return taskinfo.encode("utf-8")
Esempio n. 7
0
    def _object_task_link(self, item):
        """ Renders a task object with a link to the effective task
        We have two different types of a task. task-object from the sql-db is
        handled in the _sqlalchemy_task_link-method.
        """
        breadcrumb_titles = "[%s] > %s" % (client_title_helper(
            item, item.responsible_client).encode('utf-8'), ' > '.join(
                _breadcrumbs_from_item(item)))

        info_html = self.get_task_info(item)
        task_html = \
            '<a href="%s" title="%s"><span class="%s">%s</span></a>' % (
                item.absolute_url(),
                breadcrumb_titles,
                self.get_css_class(item),
                item.Title(),
            )
        inner_html = '%s <span class="discreet">(%s)</span>' % (task_html,
                                                                info_html)

        return self._task_state_wrapper(item, inner_html)
Esempio n. 8
0
    def get_task_info(self, item):
        """ return some task attributes for objects:
            Responsible client ID /  responsible
        """
        if not ITask.providedBy(item):
            return ''

        info = getUtility(IContactInformation)

        if not item.responsible_client or len(info.get_clients()) <= 1:
            # No responsible client is set yet or we have a single client
            # setup.
            return info.describe(item.responsible)

        # Client
        client = client_title_helper(item, item.responsible_client)

        taskinfo = "%s / %s" % (
            client,
            info.render_link(item.responsible),
        )

        return taskinfo.encode('utf-8')
Esempio n. 9
0
    def _sqlalchemy_task_link(self, item):
        """Renders a indexed task item (globalindex sqlalchemy object) either
        with a link to the effective task (if the user has access) or just with
        the title.
        We have two different types of a task. task-object providing the
        ITask-interface is handled in the _object_task_link.
        """

        css_class = self.get_css_class(item)

        # get the client which the task cames from
        info = queryUtility(IContactInformation)
        if info:
            client = info.get_client_by_id(item.client_id)
        if not info or not client:
            return '<span class="%s">%s</span>' % (css_class, item.title)

        # has the user access to the target task?
        has_access = False
        mtool = getToolByName(self.context, "portal_membership")
        member = mtool.getAuthenticatedMember()

        if member:
            principals = set(member.getGroups() + [member.getId()])
            allowed_principals = set(item.principals)
            has_access = len(principals & allowed_principals) > 0

        # If the target is on a different client we need to make a popup
        if item.client_id != get_client_id():
            link_target = ' target="_blank"'
            url = "%s/%s" % (client.public_url, item.physical_path)
        else:
            link_target = ""
            url = client.public_url + "/" + item.physical_path

        # create breadcrumbs including the (possibly remote) client title
        breadcrumb_titles = "[%s] > %s" % (client.title, item.breadcrumb_title)

        # Client and user info
        info_html = ' <span class="discreet">(%s / %s)</span>' % (
            client_title_helper(item, item.assigned_client),
            info.render_link(item.responsible),
        )

        # Link to the task object
        task_html = '<span class="%s">%s</span>' % (css_class, item.title)

        # Render the full link if we have acccess
        if has_access:
            inner_html = '<a href="%s"%s title="%s">%s</a> %s' % (
                url,
                link_target,
                breadcrumb_titles,
                task_html,
                info_html,
            )
        else:
            inner_html = "%s %s" % (task_html, info_html)

        # Add the task-state css and return it
        return self._task_state_wrapper(item, inner_html)