Ejemplo n.º 1
0
    def __call__(self):
        """Display a list of Todo items in the Open workflow state, grouped by
        Workspace and ordered by Due date.
        {'workspace1': {'title': 'WS1', 'url': '...', 'tasks':[<brain>, ...]}}
        """
        pc = api.portal.get_tool("portal_catalog")
        me = api.user.get_current().getId()
        form = self.request.form

        if self.request.method == "POST" and form:
            return update_task_status(self, return_status_message=True)

        tasks = pc(portal_type="todo", review_state=["open", "planned"], assignee=me, sort_on="due")
        self.grouped_tasks = {}
        for task in tasks:
            obj = task.getObject()
            workspace = parent_workspace(obj)
            if workspace.id not in self.grouped_tasks:
                self.grouped_tasks[workspace.id] = {
                    "title": workspace.title,
                    "url": workspace.absolute_url(),
                    "tasks": [task],
                }
            else:
                self.grouped_tasks[workspace.id]["tasks"].append(task)
        return self.render()
Ejemplo n.º 2
0
    def __call__(self):
        """Display a list of Todo items in the Open workflow state, grouped by
        Workspace and ordered by Due date.
        {'workspace1': {'title': 'WS1', 'url': '...', 'tasks':[<brain>, ...]}}
        """
        pc = api.portal.get_tool('portal_catalog')
        me = api.user.get_current().getId()
        form = self.request.form

        if self.request.method == 'POST' and form:
            return update_task_status(self, return_status_message=True)

        tasks = pc(portal_type='todo',
                   review_state='open',
                   assignee=me,
                   sort_on='due')
        self.grouped_tasks = {}
        for task in tasks:
            obj = task.getObject()
            workspace = parent_workspace(obj)
            if workspace.id not in self.grouped_tasks:
                self.grouped_tasks[workspace.id] = {
                    'title': workspace.title,
                    'url': workspace.absolute_url(),
                    'tasks': [task],
                }
            else:
                self.grouped_tasks[workspace.id]['tasks'].append(task)
        return self.render()
    def __call__(self):
        """
        Write attributes, if any, set state, render
        """
        form = self.request.form
        if self.request.method == 'POST' and form:
            ws = self.workspace()
            self.set_grouping_cookie()
            # wft = api.portal.get_tool("portal_workflow")
            section = self.request.form.get('section', None)
            do_reindex = False

            # Do the workflow transitions based on what tasks the user checked
            # or unchecked
            if section == 'task':
                update_task_status(self)

            # Do the property editing. Edits only if there is something to edit
            # in form
            if self.can_manage_workspace() and form:
                modified, errors = dexterity_update(self.context)

                if modified and not errors:
                    api.portal.show_message(
                        _("Attributes changed."),
                        request=self.request,
                        type="success")
                    do_reindex = True
                    notify(ObjectModifiedEvent(self.context))

                if errors:
                    api.portal.show_message(
                        _("There was a problem updating the content: %s."
                            % errors),
                        request=self.request,
                        type="error",
                    )

            if do_reindex:
                ws.reindexObject()
        return self.render()
Ejemplo n.º 4
0
    def __call__(self):
        """
        Write attributes, if any, set state, render
        """
        form = self.request.form
        if self.request.method == 'POST' and form:
            ws = self.workspace()
            self.set_grouping_cookie()
            # wft = api.portal.get_tool("portal_workflow")
            section = self.request.form.get('section', self.section)
            set_show_extra_cookie(self.request, section)
            do_reindex = False

            # Do the workflow transitions based on what tasks the user checked
            # or unchecked
            if section == 'task':
                update_task_status(self)

            # Do the property editing. Edits only if there is something to edit
            # in form
            if self.can_manage_workspace() and form:
                modified, errors = dexterity_update(self.context)

                if modified and not errors:
                    api.portal.show_message(_("Attributes changed."),
                                            request=self.request,
                                            type="success")
                    do_reindex = True
                    notify(ObjectModifiedEvent(self.context))

                if errors:
                    api.portal.show_message(
                        _("There was a problem updating the content: %s." %
                          errors),
                        request=self.request,
                        type="error",
                    )

            if do_reindex:
                ws.reindexObject()
        return self.render()