Example #1
0
    def render(self):
        if self.is_already_done():
            # Set correct content type for text response
            self.request.response.setHeader("Content-type", "text/plain")

            return 'OK'

        mtool = getToolByName(self.context, 'portal_membership')
        member = mtool.getAuthenticatedMember()

        if not member.checkPermission('Add portal content', self.context):
            raise Unauthorized()

        successor_oguid = self.request.get('successor_oguid')
        transition = self.request.get('transition')
        response_text = self.request.get('response_text')

        if transition:
            change_task_workflow_state(self.context,
                                       transition,
                                       text=response_text,
                                       successor_oguid=successor_oguid)

        IYearfolderStorer(self.context).store_in_yearfolder()

        # Set correct content type for text response
        self.request.response.setHeader("Content-type", "tex/plain")

        return 'OK'
Example #2
0
def assign_forwarding_to_dossier(context, forwarding_oguid, dossier,
                                 response_text):

    forwarding = Task.query.by_oguid(forwarding_oguid)

    forwarding_obj = context.unrestrictedTraverse(
        forwarding.physical_path.encode('utf-8'))

    # we need all task field values from the forwarding
    fielddata = {}
    for fieldname in ITask.names():
        value = ITask.get(fieldname).get(forwarding_obj)
        fielddata[fieldname] = value

    # Reset issuer to the current inbox
    fielddata['issuer'] = get_current_org_unit().inbox().id()

    # Predefine the task_type to avoid tasks with an invalid task_type
    fielddata['task_type'] = FORWARDING_SUCCESSOR_TYPE

    # lets create a new task - the successor task
    task = createContentInContainer(dossier, 'opengever.task.task',
                                    **fielddata)

    successor_tc_task = ISuccessorTaskController(task)

    # Add issuer and responsible to the watchers of the newly created task
    center = notification_center()
    center.add_task_responsible(task, task.responsible)
    center.add_task_issuer(task, task.issuer)

    # copy documents and map the intids
    intids_mapping = _copy_documents_from_forwarding(forwarding_obj, task)

    # copy the responses
    response_transporter = IResponseTransporter(task)
    response_transporter.get_responses(get_current_admin_unit().id(),
                                       '/'.join(
                                           forwarding_obj.getPhysicalPath()),
                                       intids_mapping=intids_mapping)

    # close and store the forwarding in yearfolder
    change_task_workflow_state(forwarding_obj,
                               'forwarding-transition-assign-to-dossier',
                               text=response_text,
                               successor_oguid=successor_tc_task.get_oguid())

    IYearfolderStorer(forwarding_obj).store_in_yearfolder()

    # successor
    successor_tc_task.set_predecessor(forwarding_oguid)

    return task
Example #3
0
    def handle_close(self, action):

        data, errors = self.extractData()
        if not errors:

            # close and store the forwarding in yearfolder
            change_task_workflow_state(self.context,
                                       'forwarding-transition-close',
                                       text=data.get('text'))

            IYearfolderStorer(self.context).store_in_yearfolder()

            return self.request.RESPONSE.redirect('.')
    def after_transition_hook(self, transition, disable_sync, transition_params):
        successor_task = self.create_successor_task(transition_params['dossier'])

        add_simple_response(
            self.context, transition=transition, text=transition_params.get('text'),
            successor_oguid=Oguid.for_object(successor_task).id)

        # set predecessor on successor task
        successor_tc_task = ISuccessorTaskController(successor_task)
        successor_tc_task.set_predecessor(Oguid.for_object(self.context).id)

        IYearfolderStorer(self.context).store_in_yearfolder()
        return successor_task
Example #5
0
    def test_disable_docproperty_updating(self):
        inbox = create(Builder('inbox'))
        forwarding = create(Builder('forwarding').within(inbox))
        doc = create(Builder('document')
                     .within(forwarding)
                     .titled("Document with file")
                     .with_asset_file('with_gever_user_properties.docx'))

        IYearfolderStorer(forwarding).store_in_yearfolder()

        with TemporaryDocFile(doc.file) as tmpfile:
            properties = dict(read_properties(tmpfile.path))
            self.assertItemsEqual(TEST_USER_ID, properties.get('User.ID'))
Example #6
0
    def __call__(self):
        if self.is_already_done():
            return ok_response()

        mtool = getToolByName(self.context, 'portal_membership')
        member = mtool.getAuthenticatedMember()

        if not member.checkPermission('Add portal content', self.context):
            raise Unauthorized()

        successor_oguid = self.request.get('successor_oguid')
        transition = self.request.get('transition')
        response_text = self.request.get('response_text')

        if transition:
            change_task_workflow_state(self.context,
                                       transition,
                                       text=response_text,
                                       successor_oguid=successor_oguid)

        IYearfolderStorer(self.context).store_in_yearfolder()

        return ok_response()
    def after_transition_hook(self, transition, disable_sync, transition_params):
        add_simple_response(
            self.context, transition=transition, text=transition_params.get('text'))

        IYearfolderStorer(self.context).store_in_yearfolder()