예제 #1
0
    def copy_document(self, target_path, target_admin_unit_id):
        submitted_version = self.document.get_current_version_id(
            missing_as_zero=True)

        record = IHistory(self.proposal).append_record(
            u'document_submitted',
            document_title=self.document.title,
            submitted_version=submitted_version,
        )

        if self.record_activity:
            ProposalDocumentSubmittedActivity(
                self.proposal, self.proposal.REQUEST, self.document.title).record()

        history_data = advancedjson.dumps({
            'submitted_version': submitted_version,
            'uuid': record.uuid,
            })

        activity = advancedjson.dumps({
            'record_activity': self.record_activity,
            })

        return SubmitDocumentCommand(
            self.document, target_admin_unit_id, target_path,
            history_data=history_data,
            activity=activity).execute()
예제 #2
0
    def copy_document(self, target_path, target_admin_unit_id):
        submitted_version = self.document.get_current_version_id(
            missing_as_zero=True)

        record = IHistory(self.proposal).append_record(
            u'document_submitted',
            document_title=self.document.title,
            submitted_version=submitted_version,
        )

        if self.record_activity:
            ProposalDocumentSubmittedActivity(self.proposal,
                                              self.proposal.REQUEST,
                                              self.document.title).record()

        history_data = advancedjson.dumps({
            'submitted_version': submitted_version,
            'uuid': record.uuid,
        })

        activity = advancedjson.dumps({
            'record_activity': self.record_activity,
        })

        return SubmitDocumentCommand(self.document,
                                     target_admin_unit_id,
                                     target_path,
                                     history_data=history_data,
                                     activity=activity).execute()
예제 #3
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']
예제 #4
0
    def append_record(self, history_type, timestamp=None, **kwargs):
        if timestamp and not isinstance(timestamp, datetime):
            raise TypeError("Invalid type for timestamp: {}".format(
                timestamp.__class__))
        if history_type not in self.record_classes:
            raise ValueError(
                'No record class registered for {}'.format(history_type))

        clazz = self.record_classes[history_type]

        history = self._get_history_for_writing()
        record = clazz(self.context, timestamp=timestamp, **kwargs)
        record.append_to(history)

        if record.needs_syncing:
            # currently we only sync from the submitted side
            # to the dossier
            path = self.context.load_model().physical_path
            request_data = {
                'data':
                advancedjson.dumps({
                    'timestamp': record.timestamp,
                    'data': record.data,
                })
            }
            dispatch_request(
                self.context.get_source_admin_unit_id(),
                '@@receive-proposal-history',
                path=path,
                data=request_data,
            )

        return record
    def append_record(self, history_type, timestamp=None, **kwargs):
        if timestamp and not isinstance(timestamp, datetime):
            raise TypeError("Invalid type for timestamp: {}".format(
                timestamp.__class__))
        if history_type not in self.record_classes:
            raise ValueError(
                'No record class registered for {}'.format(history_type))

        clazz = self.record_classes[history_type]

        history = self._get_history_for_writing()
        record = clazz(self.context, timestamp=timestamp, **kwargs)
        record.append_to(history)

        if record.needs_syncing and self.context.is_submitted():
            path = self.context.get_sync_target_path()
            admin_unit_id = self.context.get_sync_admin_unit_id()

            request_data = {
                'data':
                advancedjson.dumps({
                    'timestamp': record.timestamp,
                    'data': record.data,
                })
            }
            dispatch_request(
                admin_unit_id,
                '@@receive-proposal-history',
                path=path,
                data=request_data,
            )
        return record
예제 #6
0
    def append_record(self, history_type, timestamp=None, **kwargs):
        if timestamp and not isinstance(timestamp, datetime):
            raise TypeError("Invalid type for timestamp: {}".format(
                timestamp.__class__))
        if history_type not in self.record_classes:
            raise ValueError('No record class registered for {}'.format(
                history_type))

        clazz = self.record_classes[history_type]

        history = self._get_history_for_writing()
        record = clazz(self.context, timestamp=timestamp, **kwargs)
        record.append_to(history)

        if record.needs_syncing:
            # currently we only sync from the submitted side
            # to the dossier
            path = self.context.load_model().physical_path
            request_data = {'data': advancedjson.dumps({
                'timestamp': record.timestamp,
                'data': record.data,
            })}
            dispatch_request(
                self.context.get_source_admin_unit_id(),
                '@@receive-proposal-history',
                path=path,
                data=request_data,)

        return record
예제 #7
0
    def execute(self):
        submitted_version = self.document.get_current_version_id()

        record = IHistory(self.proposal).append_record(
            u'document_updated',
            document_title=self.document.title,
            submitted_version=submitted_version,
        )
        history_data = advancedjson.dumps({
            'submitted_version': submitted_version,
            'uuid': record.uuid,
        })

        ProposalDocumentUpdatedActivity(self.proposal, self.proposal.REQUEST,
                                        self.document.title,
                                        submitted_version).record()

        Transporter().transport_to(
            self.document,
            self.submitted_document.submitted_admin_unit_id,
            self.submitted_document.submitted_physical_path,
            view='update-submitted-document',
            history_data=history_data)

        submitted_document = SubmittedDocument.query.get_by_source(
            self.proposal, self.document)
        submitted_document.submitted_version = submitted_version
예제 #8
0
    def execute(self):
        submitted_version = self.document.get_current_version_id()

        record = IHistory(self.proposal).append_record(
            u'document_updated',
            document_title=self.document.title,
            submitted_version=submitted_version,
        )
        history_data = advancedjson.dumps({
            'submitted_version': submitted_version,
            'uuid': record.uuid,
            })

        ProposalDocumentUpdatedActivity(
            self.proposal, self.proposal.REQUEST,
            self.document.title, submitted_version).record()

        Transporter().transport_to(
            self.document,
            self.submitted_document.submitted_admin_unit_id,
            self.submitted_document.submitted_physical_path,
            view='update-submitted-document',
            history_data=history_data)

        submitted_document = SubmittedDocument.query.get_by_source(
            self.proposal, self.document)
        submitted_document.submitted_version = submitted_version
예제 #9
0
    def remove_scheduled(self, meeting):
        self.execute_transition('scheduled-submitted')
        IHistory(self.resolve_submitted_proposal()).append_record(
            u'remove_scheduled', meeting_id=meeting.meeting_id)

        request_data = {
            'data': advancedjson.dumps({
                'meeting_id': meeting.meeting_id,
            })
        }
        expect_ok_response(
            dispatch_request(self.admin_unit_id,
                             '@@receive-proposal-unscheduled',
                             path=self.physical_path,
                             data=request_data),
            'Unexpected response {!r} when unscheduling proposal.')
예제 #10
0
    def copy_document(self, target_path, target_admin_unit_id):
        submitted_version = self.document.get_current_version_id(
            missing_as_zero=True)

        record = IHistory(self.proposal).append_record(
            u'document_submitted',
            document_title=self.document.title,
            submitted_version=submitted_version,
        )

        history_data = advancedjson.dumps({
            'submitted_version': submitted_version,
            'uuid': record.uuid,
            })

        return SubmitDocumentCommand(
            self.document, target_admin_unit_id, target_path,
            history_data=history_data).execute()
예제 #11
0
    def reject(self, text):
        assert self.workflow.can_execute_transition(self, 'submitted-pending')

        self.submitted_physical_path = None
        self.submitted_admin_unit_id = None
        self.submitted_int_id = None
        self.date_of_submission = None

        # set workflow state directly for once, the transition is used to
        # redirect to a form.
        self.workflow_state = self.STATE_PENDING.name

        request_data = {
            'data': advancedjson.dumps({
                'text': text,
            })
        }
        expect_ok_response(
            dispatch_request(self.admin_unit_id,
                             '@@receive-proposal-rejected',
                             path=self.physical_path,
                             data=request_data),
            'Unexpected response {!r} when rejecting proposal.')
예제 #12
0
    def schedule(self, meeting):
        assert self.can_be_scheduled()

        self.execute_transition('submitted-scheduled')
        meeting.agenda_items.append(AgendaItem(proposal=self))
        meeting.reorder_agenda_items()

        submitted_proposal = self.resolve_submitted_proposal()
        ProposalScheduledActivity(submitted_proposal, getRequest(),
                                  meeting.meeting_id).record()
        IHistory(self.resolve_submitted_proposal()).append_record(
            u'scheduled', meeting_id=meeting.meeting_id)

        request_data = {
            'data': advancedjson.dumps({
                'meeting_id': meeting.meeting_id,
            })
        }
        expect_ok_response(
            dispatch_request(self.admin_unit_id,
                             '@@receive-proposal-scheduled',
                             path=self.physical_path,
                             data=request_data),
            'Unexpected response {!r} when scheduling proposal.')