コード例 #1
0
ファイル: test_todo.py プロジェクト: smcmahon/ploneintranet
 def setUp(self):
     self.portal = self.layer["portal"]
     obj = api.content.create(type="todo", title="todo1", container=self.portal)
     todo = ITodo(self.portal.todo1)
     todo.assignee = TEST_USER_ID
     event = ObjectModifiedEvent(obj)
     zope.event.notify(event)
コード例 #2
0
ファイル: test_todo.py プロジェクト: kombinat/ploneintranet
 def setUp(self):
     self.portal = self.layer['portal']
     obj = api.content.create(
         type='todo',
         title='todo1',
         container=self.portal,
     )
     todo = ITodo(self.portal.todo1)
     todo.assignee = TEST_USER_ID
     event = ObjectModifiedEvent(obj)
     zope.event.notify(event)
コード例 #3
0
 def tasks(self):
     items = defaultdict(list) if self.is_case else []
     catalog = api.portal.get_tool('portal_catalog')
     wft = api.portal.get_tool('portal_workflow')
     current_path = '/'.join(self.getPhysicalPath())
     ptype = 'todo'
     brains = catalog(path=current_path, portal_type=ptype, sort_on='due')
     for brain in brains:
         obj = brain.getObject()
         todo = ITodo(obj)
         assignee = api.user.get(obj.assignee) if obj.assignee else None
         initiator = api.user.get(obj.initiator) if obj.initiator else None
         data = {
             'id': brain.UID,
             'title': brain.Title,
             'description': brain.Description,
             'url': brain.getURL(),
             'checked': wft.getInfoFor(todo, 'review_state') == u'done',
             'due': obj.due,
             'assignee': assignee,
             'initiator': initiator,
         }
         if self.is_case:
             milestone = "unassigned"
             if obj.milestone not in ["", None]:
                 milestone = obj.milestone
             items[milestone].append(data)
         else:
             items.append(data)
     if self.is_case:
         for milestone in items.keys():
             # Show the checked tasks before the unchecked tasks
             items[milestone].sort(key=lambda x: x['checked'] is False)
     return items
コード例 #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.my_workspace()
            if self.request.form.get('section', None) == 'task':
                current_tasks = self.request.form.get('current-tasks', [])
                active_tasks = self.request.form.get('active-tasks', [])

                catalog = api.portal.get_tool("portal_catalog")
                brains = catalog(UID={'query': current_tasks,
                                      'operator': 'or'})
                for brain in brains:
                    obj = brain.getObject()
                    todo = ITodo(obj)
                    if brain.UID in active_tasks:
                        todo.status = u'done'
                    else:
                        todo.status = u'tbd'
                api.portal.show_message(_(u'Changes applied'),
                                        self.request,
                                        'success')
            else:
                if form.get('title') and form.get('title') != ws.title:
                    ws.title = form.get('title').strip()
                    api.portal.show_message(_(u'Title changed'),
                                            self.request,
                                            'success')

                if form.get('description') and \
                   form.get('description') != ws.description:
                    ws.description = form.get('description').strip()
                    api.portal.show_message(_(u'Description changed'),
                                            self.request,
                                            'success')

                calendar_visible = not not form.get('calendar_visible')
                if calendar_visible != ws.calendar_visible:
                    ws.calendar_visible = calendar_visible
                    api.portal.show_message(_(u'Calendar visibility changed'),
                                            self.request,
                                            'success')

        return self.render()
コード例 #5
0
def create_tasks(todos):
    portal = api.portal.get()

    if 'todos' not in portal:
        todos_folder = api.content.create(type='Folder',
                                          title='Todos',
                                          container=portal)
    else:
        todos_folder = portal['todos']

    for data in todos:
        obj = create_as(data['creator'],
                        type='simpletodo',
                        title=data['title'],
                        container=todos_folder)
        todo = ITodo(obj)
        todo.assignee = data['assignee']
コード例 #6
0
def create_tasks(todos):
    portal = api.portal.get()

    if 'todos' not in portal:
        todos_folder = api.content.create(
            type='Folder',
            title='Todos',
            container=portal)
    else:
        todos_folder = portal['todos']

    for data in todos:
        obj = create_as(
            data['creator'],
            type='simpletodo',
            title=data['title'],
            container=todos_folder)
        todo = ITodo(obj)
        todo.assignee = data['assignee']
コード例 #7
0
ファイル: workspace.py プロジェクト: johndam/ploneintranet
 def tasks(self):
     ''' Get the context tasks
     '''
     is_case = self.context.is_case
     items = defaultdict(list) if is_case else []
     wft = api.portal.get_tool('portal_workflow')
     ptype = 'todo'
     brains = api.content.find(
         context=self.context,
         portal_type=ptype,
         sort_on=['due', 'getObjPositionInParent'],
     )
     today = date.today()
     for brain in brains:
         obj = brain.getObject()
         todo = ITodo(obj)
         done = wft.getInfoFor(todo, 'review_state') == u'done'
         overdue = False
         if not done and todo.due:
             overdue = todo.due < today
         data = {
             'id':
             brain.UID,
             'title':
             brain.Title,
             'description':
             brain.Description,
             'url':
             brain.getURL(),
             'checked':
             done,
             'due':
             todo.due,
             'overdue':
             overdue,
             'obj':
             obj,
             'can_edit':
             api.user.has_permission('Modify portal content', obj=obj),
         }
         if is_case:
             milestone = "unassigned"
             if obj.milestone not in ["", None]:
                 milestone = obj.milestone
             items[milestone].append(data)
         else:
             items.append(data)
     if is_case:
         for milestone in items.keys():
             # Show the checked tasks before the unchecked tasks
             items[milestone].sort(key=lambda x: x['checked'] is False)
     return items