def __call__(self):
        jsondata = self.request.get(REQUEST_KEY)
        data = encode_after_json(json.loads(jsondata))
        committee = Oguid.parse(data['committee_oguid']).resolve_object()
        proposal_oguid = Oguid.parse(data['proposal_oguid'])
        proposal = meeting_service().fetch_proposal_by_oguid(proposal_oguid)

        with elevated_privileges():
            submitted_proposal = SubmittedProposal.create(proposal, committee)

            # XXX use Transporter API?
            collector = getMultiAdapter((submitted_proposal, ),
                                        IDataCollector,
                                        name='field-data')
            data['field-data']['ISubmittedProposal'] = data['field-data'].pop(
                'IProposal')
            collector.insert(data['field-data'])
            # XXX fix data types in transporter
            submitted_proposal.date_of_submission = date.today()

            # sync data to proposal after inserting field data
            submitted_proposal.sync_model(proposal_model=proposal)

            submitted_proposal.create_proposal_document(
                filename=data['file']['filename'],
                content_type=data['file']['contentType'].encode('utf-8'),
                data=base64.decodestring(data['file']['data']))

            history_data = advancedjson.loads(self.request.get('history_data'))
            IHistory(submitted_proposal).append_record(
                u'submitted', uuid=history_data['uuid'])

            self.request.response.setHeader("Content-type", "application/json")
            return json.dumps(
                {'path': '/'.join(submitted_proposal.getPhysicalPath())})
    def committees(self):
        committees = []
        filter = self.get_filter_text()
        query = Committee.query.order_by(Committee.title)
        query = query.by_searchable_text(text_filters=filter)
        query = self.extend_query_with_statefilter(query)

        for committee in query.all():
            content_obj = committee.resolve_committee()
            if not content_obj:
                continue
            if not api.user.has_permission('View', obj=content_obj):
                continue

            committees.append(
                {'title': committee.title,
                 'url': committee.get_url(),
                 'state_class': 'active' if committee.is_active() else 'inactive',
                 'number_unscheduled_proposals': len(
                     meeting_service().get_submitted_proposals(committee)),
                 'next_meeting': Meeting.query.get_next_meeting(committee),
                 'last_meeting': Meeting.query.get_last_meeting(committee)}
            )

        return committees
Exemplo n.º 3
0
    def committees(self):
        committees = []
        filter = self.get_filter_text()
        query = Committee.query.order_by(Committee.title)
        query = query.by_searchable_text(text_filters=filter)
        query = self.extend_query_with_statefilter(query)

        for committee in query.all():
            content_obj = committee.resolve_committee()
            if not content_obj:
                continue
            if not api.user.has_permission('View', obj=content_obj):
                continue

            committees.append({
                'title':
                committee.title,
                'url':
                committee.get_url(),
                'state_class':
                'active' if committee.is_active() else 'inactive',
                'number_unscheduled_proposals':
                len(meeting_service().get_submitted_proposals(committee)),
                'next_meeting':
                Meeting.query.get_next_meeting(committee),
                'last_meeting':
                Meeting.query.get_last_meeting(committee)
            })

        return committees
    def __call__(self):
        jsondata = self.request.get(REQUEST_KEY)
        data = encode_after_json(json.loads(jsondata))
        committee = Oguid.parse(data['committee_oguid']).resolve_object()
        proposal_oguid = Oguid.parse(data['proposal_oguid'])
        proposal = meeting_service().fetch_proposal_by_oguid(proposal_oguid)

        with elevated_privileges():
            submitted_proposal = SubmittedProposal.create(proposal, committee)

            # XXX use Transporter API?
            collector = getMultiAdapter((submitted_proposal,), IDataCollector,
                                        name='field-data')
            data['field-data']['ISubmittedProposal'] = data['field-data'].pop(
                'IProposal')
            collector.insert(data['field-data'])
            # XXX fix data types in transporter
            submitted_proposal.date_of_submission = date.today()

            # sync data to proposal after inserting field data
            submitted_proposal.sync_model(proposal_model=proposal)

            submitted_proposal.create_proposal_document(
                filename=data['file']['filename'],
                content_type=data['file']['contentType'].encode('utf-8'),
                data=base64.decodestring(data['file']['data']))

            history_data = advancedjson.loads(self.request.get('history_data'))
            IHistory(submitted_proposal).append_record(
                u'submitted', uuid=history_data['uuid'])

            self.request.response.setHeader("Content-type", "application/json")
            return json.dumps(
                {'path': '/'.join(submitted_proposal.getPhysicalPath())})
Exemplo n.º 5
0
    def render(self):
        jsondata = self.request.get(REQUEST_KEY)
        data = json.loads(jsondata)
        committee = Oguid.parse(data['committee_oguid']).resolve_object()
        proposal_oguid = Oguid.parse(data['proposal_oguid'])
        proposal = meeting_service().fetch_proposal_by_oguid(proposal_oguid)

        with elevated_privileges():
            submitted_proposal = SubmittedProposal.create(proposal, committee)

            self.request.response.setHeader("Content-type", "application/json")
            return json.dumps(
                {'path': '/'.join(submitted_proposal.getPhysicalPath())})
Exemplo n.º 6
0
    def render(self):
        jsondata = self.request.get(REQUEST_KEY)
        data = json.loads(jsondata)
        committee = Oguid.parse(data['committee_oguid']).resolve_object()
        proposal_oguid = Oguid.parse(data['proposal_oguid'])
        proposal = meeting_service().fetch_proposal_by_oguid(proposal_oguid)

        with elevated_privileges():
            submitted_proposal = SubmittedProposal.create(proposal, committee)

            if is_word_meeting_implementation_enabled():
                submitted_proposal.create_proposal_document(
                    filename=data['file']['filename'],
                    content_type=data['file']['contentType'].encode('utf-8'),
                    data=base64.decodestring(data['file']['data']))

            self.request.response.setHeader("Content-type", "application/json")
            return json.dumps(
                {'path': '/'.join(submitted_proposal.getPhysicalPath())})
Exemplo n.º 7
0
    def publishTraverse(self, request, name):
        if name in IAgendaItemActions.names():
            return getattr(self, name)

        # we only support exactly one id
        if self.agenda_item_id:
            raise NotFound

        try:
            self.agenda_item_id = int(name)
        except ValueError:
            raise NotFound

        self.agenda_item = meeting_service().fetch_agenda_item(
            self.agenda_item_id)

        if not self.agenda_item:
            raise NotFound

        if self.agenda_item.meeting is not self.meeting:
            # Prevent from cross injections
            raise NotFound

        return self
Exemplo n.º 8
0
    def publishTraverse(self, request, name):
        if name in IAgendaItemActions.names():
            return getattr(self, name)

        # we only support exactly one id
        if self.agenda_item_id:
            raise NotFound

        try:
            self.agenda_item_id = int(name)
        except ValueError:
            raise NotFound

        self.agenda_item = meeting_service().fetch_agenda_item(
            self.agenda_item_id)

        if not self.agenda_item:
            raise NotFound

        if self.agenda_item.meeting is not self.meeting:
            # Prevent from cross injections
            raise NotFound

        return self
Exemplo n.º 9
0
 def get_unscheduled_proposals(self):
     committee_model = self.load_model()
     return meeting_service().get_submitted_proposals(committee_model)
Exemplo n.º 10
0
 def setUp(self):
     super(TestService, self).setUp()
     self.session = self.layer.session
     self.service = meeting_service()
Exemplo n.º 11
0
 def get_unscheduled_proposals(self):
     committee_model = self.load_model()
     return meeting_service().get_submitted_proposals(committee_model)
Exemplo n.º 12
0
 def setUp(self):
     super(TestService, self).setUp()
     self.session = self.layer.session
     self.service = meeting_service()