Example #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']
Example #2
0
    def extract(self):
        data = {}
        data[BASEDATA_KEY] = {'id': self.obj.getId(),
                              'title': self.obj.Title(),
                              'portal_type': self.obj.portal_type}

        # collect data
        collectors = getAdapters((self.obj,), IDataCollector)
        for name, collector in collectors:
            data[name] = collector.extract()

        return decode_for_json(data)
Example #3
0
    def _extract_data(self, obj):
        """ Serializes a object
        """
        data = {}
        # base data
        creator = self._get_object_creator(obj.portal_type)
        data[BASEDATA_KEY] = creator.extract(obj)
        # collect data
        collectors = getAdapters((obj,), IDataCollector)
        for name, collector in collectors:
            data[name] = collector.extract()
        data = decode_for_json(data)

        return data