Example #1
0
    def store_copy_in_remote_yearfolder(self, refusing_unit_id):
        transporter = Transporter()
        jsondata = json.dumps(transporter.extract(self.context))
        request_data = {REQUEST_KEY: jsondata, }

        response = dispatch_json_request(
            refusing_unit_id, '@@store_refused_forwarding',
            data=request_data)

        if response.get('status') not in [
                STATUS_SUCCESSFULL, STATUS_ALLREADY_DONE]:
            raise Exception(
                'Storing the forwarding on remote yearfolder failed')

        remote_task = response.get('remote_task')
        if response.get('status') != STATUS_ALLREADY_DONE:
            # transport responses
            response_transporter = IResponseTransporter(self.context)
            response_transporter.send_responses(
                refusing_unit_id, remote_task)

            # transport documents
            for document in get_documents_of_task(self.context):
                transporter.transport_to(
                    document, refusing_unit_id, remote_task)

        return self.get_remote_task_url(refusing_unit_id, remote_task)
Example #2
0
    def store_copy_in_remote_yearfolder(self, refusing_client_id):
        transporter = getUtility(ITransporter)
        jsondata = json.dumps(transporter._extract_data(self.context))
        request_data = {
            REQUEST_KEY: jsondata,
        }

        response = remote_json_request(refusing_client_id,
                                       '@@store_refused_forwarding',
                                       data=request_data)

        if response.get('status') not in [
                STATUS_SUCCESSFULL, STATUS_ALLREADY_DONE
        ]:
            raise Exception(
                'Storing the forwarding on remote yearfolder failed')

        remote_task = response.get('remote_task')
        if response.get('status') != STATUS_ALLREADY_DONE:
            # transport responses
            response_transporter = IResponseTransporter(self.context)
            response_transporter.send_responses(refusing_client_id,
                                                remote_task)

            # transport documents
            for document in get_documents_of_task(self.context):
                transporter.transport_to(document, refusing_client_id,
                                         remote_task)

        return self.get_remote_task_url(refusing_client_id, remote_task)
Example #3
0
    def get_documents(self):

        documents = json.loads(self.request.get('documents'))
        documents = documents and [int(iid) for iid in documents]
        intids = getUtility(IIntIds)

        for doc in get_documents_of_task(self.context, include_mails=True):
            if documents is None or intids.getId(doc) in documents:
                yield doc
Example #4
0
    def get_documents(self):

        documents = json.loads(self.request.get('documents'))
        documents = documents and [int(iid) for iid in documents]
        intids = getUtility(IIntIds)

        for doc in get_documents_of_task(self.context, include_mails=True):
            if documents is None or intids.getId(doc) in documents:
                yield doc
Example #5
0
    def uniref_open_to_closed_action(self, transition, c):
        if c.task.is_assigned_to_current_admin_unit:
            return self._addresponse_form_url(transition)

        elif len(get_documents_of_task(self.context, include_mails=True)) == 0:
            return self._addresponse_form_url(transition)

        else:
            return '%s/@@close-task-wizard_select-documents' % (
                self.context.absolute_url())
    def uniref_open_to_closed_action(self, transition, c):
        if c.task.is_assigned_to_current_admin_unit:
            return self._addresponse_form_url(transition)

        elif len(get_documents_of_task(
                self.context, include_mails=True)) == 0:
            return self._addresponse_form_url(transition)

        else:
            return '%s/@@close-task-wizard_select-documents' % (
                self.context.absolute_url())
Example #7
0
def related_documents_vocabulary(task):
    intids = getUtility(IIntIds)

    terms = []
    for doc in get_documents_of_task(task, include_mails=True):
        key = str(intids.getId(doc))
        label = '%s (%s)' % (doc.Title(), IReferenceNumber(doc).get_number())

        terms.append(SimpleVocabulary.createTerm(key, key, label))

    return SimpleVocabulary(terms)
Example #8
0
def related_documents_vocabulary(task):
    intids = getUtility(IIntIds)

    terms = []
    for doc in get_documents_of_task(task, include_mails=True):
        key = str(intids.getId(doc))
        label = "%s (%s)" % (doc.Title(), IReferenceNumber(doc).get_number())

        terms.append(SimpleVocabulary.createTerm(key, key, label))

    return SimpleVocabulary(terms)
Example #9
0
    def uniref_open_to_closed_action(self, transition):
        if not self._is_multiclient_setup():
            return self._addresponse_form_url(transition)

        elif self._is_task_on_responsible_client():
            return self._addresponse_form_url(transition)

        elif len(get_documents_of_task(self.context, include_mails=True)) == 0:
            return self._addresponse_form_url(transition)

        else:
            return '%s/@@close-task-wizard_select-documents' % (
                self.context.absolute_url())
    def uniref_open_to_closed_action(self, transition):
        if not self._is_multiclient_setup():
            return self._addresponse_form_url(transition)

        elif self._is_task_on_responsible_client():
            return self._addresponse_form_url(transition)

        elif len(get_documents_of_task(
                self.context, include_mails=True)) == 0:
            return self._addresponse_form_url(transition)

        else:
            return '%s/@@close-task-wizard_select-documents' % (
                self.context.absolute_url())
Example #11
0
    def test_without_mails_is_default(self):
        task = self.mocker.mock()
        self.expect(task.getPhysicalPath()).result(
            ['', 'path', 'to', 'task'])

        rel1, obj1 = self._stub_related_obj('opengever.document.document')
        rel2, obj2 = self._stub_related_obj('opengever.document.document',
                                            allowed=False)
        rel3, obj3 = self._stub_related_obj('ftw.mail.mail')
        rel4, obj4 = self._stub_related_obj('Folder')
        self.expect(task.relatedItems).result([rel1, rel2, rel3, rel4])

        docbrain1, doc1 = self._stub_catalog_obj()
        expected_query = {'path': '/path/to/task',
                          'portal_type': ['opengever.document.document']}
        self.expect(self.catalog(expected_query)).result([docbrain1])

        self.replay()

        self.assertEqual(get_documents_of_task(task),
                         [doc1, obj1])