Exemplo n.º 1
0
 def on_created(self, docs):
     push_notification(self.datasource, created=1)
     push_notification('task:new')
     for doc in docs:
         insert_into_versions(doc['_id'])
         if is_assigned_to_a_desk(doc):
             add_activity(ACTIVITY_CREATE, 'added new task {{ subject }} of type {{ type }}',
                          self.datasource, item=doc,
                          subject=get_subject(doc), type=doc[ITEM_TYPE])
Exemplo n.º 2
0
    def on_updated(self, updates, original):
        updated = copy(original)
        updated.update(updates)
        if self._stage_changed(updates, original):
            insert_into_versions(doc=updated)
        new_task = updates.get('task', {})
        old_task = original.get('task', {})
        if new_task.get('stage') != old_task.get('stage'):
            push_notification('task:stage',
                              new_stage=str(new_task.get('stage', '')),
                              old_stage=str(old_task.get('stage', '')),
                              new_desk=str(new_task.get('desk', '')),
                              old_desk=str(old_task.get('desk', ''))
                              )
        else:
            push_notification(self.datasource, updated=1)

        if is_assigned_to_a_desk(updated):
            if self.__is_content_assigned_to_new_desk(original, updates) and \
                    not self._stage_changed(updates, original):
                insert_into_versions(doc=updated)
            add_activity(ACTIVITY_UPDATE, 'updated task {{ subject }} for item {{ type }}',
                         self.datasource, item=updated, subject=get_subject(updated), type=updated['type'])