コード例 #1
0
    def execute(self):
        model = self.proposal.load_model()
        jsondata = {'committee_oguid': model.committee.oguid.id,
                    'proposal_oguid': model.oguid.id}

        # XXX use Transporter or API?
        collector = getMultiAdapter((self.proposal,), IDataCollector,
                                    name='field-data')
        jsondata['field-data'] = collector.extract()

        blob = self.proposal.get_proposal_document().file
        jsondata['file'] = {
            'filename': blob.filename,
            'contentType': blob.contentType,
            'data': base64.encodestring(blob.data)}

        record = IHistory(self.proposal).append_record(u'submitted')
        history_data = advancedjson.dumps({'uuid': record.uuid})

        request_data = {
            REQUEST_KEY: json.dumps(decode_for_json(jsondata)),
            'history_data': history_data}
        response = dispatch_json_request(
            self.admin_unit_id, '@@create_submitted_proposal', data=request_data)

        self.submitted_proposal_path = response['path']
コード例 #2
0
    def copy_documents_from_remote_task(self, task, target,
                                        documents=None, comment=None):

        transporter = Transporter()
        data = dispatch_json_request(
            task.admin_unit_id,
            '@@task-documents-extract',
            path=task.physical_path,
            data={'documents': json.dumps(documents)})

        intids_mapping = {}
        intids = getUtility(IIntIds)

        for item in data:
            obj = transporter.create(item, target)

            # Set custom initial version comment
            if comment:
                Versioner(obj).set_custom_initial_version_comment(comment)

            oldintid = IAnnotations(obj)[ORIGINAL_INTID_ANNOTATION_KEY]
            newintid = intids.getId(obj)
            intids_mapping[oldintid] = newintid

        return intids_mapping
コード例 #3
0
    def copy_documents_from_remote_task(self,
                                        task,
                                        target,
                                        documents=None,
                                        comment=None):

        transporter = Transporter()
        data = dispatch_json_request(task.admin_unit_id,
                                     '@@task-documents-extract',
                                     path=task.physical_path,
                                     data={'documents': json.dumps(documents)})

        intids_mapping = {}
        intids = getUtility(IIntIds)

        for item in data:
            obj = transporter.create(item, target)

            # Set custom initial version comment
            if comment:
                Versioner(obj).set_custom_initial_version_comment(comment)

            oldintid = IAnnotations(obj)[ORIGINAL_INTID_ANNOTATION_KEY]
            newintid = intids.getId(obj)
            intids_mapping[oldintid] = newintid

        return intids_mapping
コード例 #4
0
ファイル: refuse.py プロジェクト: 4teamwork/opengever.core
    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)
コード例 #5
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)
コード例 #6
0
    def execute(self):
        model = self.proposal.load_model()
        jsondata = {'committee_oguid': model.committee.oguid.id,
                    'proposal_oguid': model.oguid.id}
        request_data = {REQUEST_KEY: json.dumps(jsondata)}
        response = dispatch_json_request(
            self.admin_unit_id, '@@create_submitted_proposal', data=request_data)

        self.submitted_proposal_path = response['path']
        create_session().add(Submitted(proposal=model))
コード例 #7
0
    def transport_from(self, container, source_cid, path):
        """ Copies the object under *path* from client with *source_cid* into
        the local folder *container*
        *path* is the relative path of the object to its plone site root.
        """

        data = dispatch_json_request(source_cid,
                                     '@@transporter-extract-object-json',
                                     path=path)

        return self.create(data, container)
コード例 #8
0
ファイル: transport.py プロジェクト: 4teamwork/opengever.core
    def transport_from(self, container, source_admin_unit_id, path):
        """ Copies the object under *path* from client with
        *source_admin_unit_id* into the local folder *container*
        *path* is the relative path of the object to its plone site root.
        """

        data = dispatch_json_request(source_admin_unit_id,
                                     '@@transporter-extract-object-json',
                                     path=path)

        return self.create(data, container)
コード例 #9
0
ファイル: transport.py プロジェクト: 4teamwork/opengever.core
    def transport_to(self, obj, target_cid, container_path,
                     view='transporter-receive-object', **data):
        """ Copies an *object* to another client (*target_cid*).
        """

        jsondata = json.dumps(self.extract(obj))

        request_data = {
            REQUEST_KEY: jsondata,
            }
        request_data.update(**data)

        return dispatch_json_request(
            target_cid, '@@{}'.format(view),
            path=container_path, data=request_data)
コード例 #10
0
    def transport_to(self,
                     obj,
                     target_cid,
                     container_path,
                     view='transporter-receive-object',
                     **data):
        """ Copies an *object* to another client (*target_cid*).
        """

        jsondata = json.dumps(self.extract(obj))

        request_data = {
            REQUEST_KEY: jsondata,
        }
        request_data.update(**data)

        return dispatch_json_request(target_cid,
                                     '@@{}'.format(view),
                                     path=container_path,
                                     data=request_data)
コード例 #11
0
ファイル: command.py プロジェクト: braegelno5/opengever.core
    def execute(self):
        model = self.proposal.load_model()
        jsondata = {
            'committee_oguid': model.committee.oguid.id,
            'proposal_oguid': model.oguid.id
        }

        if is_word_meeting_implementation_enabled():
            blob = self.proposal.get_proposal_document().file
            jsondata['file'] = {
                'filename': blob.filename,
                'contentType': blob.contentType,
                'data': base64.encodestring(blob.data)
            }

        request_data = {REQUEST_KEY: json.dumps(jsondata)}
        response = dispatch_json_request(self.admin_unit_id,
                                         '@@create_submitted_proposal',
                                         data=request_data)

        self.submitted_proposal_path = response['path']
        create_session().add(Submitted(proposal=model))