def js_input(self):
     multimedia_connect = MultimediaConnect()
     url = multimedia_connect.upload_url()
     upload_error = _(u"Error uploading file, please try again or use a diferent file")
     upload_success = _(u"File uploaded correctly")
     return self.js_template_input % dict(id=self.id, 
         id_uploader=self.uploader_id(), upload_url=url,
         upload_error=upload_error, upload_success=upload_success)
示例#2
0
    def handleAdd(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return
        body = {}
        if 'file_type' in data.keys():
            file_type = data['file_type']
        else:
            raise ActionExecutionError(Invalid(
                _(u"Error creating the report,please try again")))
        if 'IBasic.title' in data.keys():
            body['titulo'] = data['IBasic.title'].encode("utf-8", "ignore")
        if 'file_id' in data.keys():
            body['archivo'] = data['file_id']
        body['tipo'] = 'soy-reportero'
        
        multimedia_connect = MultimediaConnect()
        response, content = multimedia_connect.create_structure(body, file_type)

        if 'status' not in response.keys() or response['status'] != '200':
            raise ActionExecutionError(Invalid(_(u"Error creating the report,\
                please try again")))
        slug = None
        if "slug" in content:
            slug = content['slug']
        else:
            raise ActionExecutionError(Invalid(_(u"Error creating the report,\
                please try again")))

        data['file_slug'] = slug
        obj = self.createAndAdd(data)
        if obj is not None:
            # mark only as finished if we get the new object
            obj.file_slug = slug
            obj.reindexObject()
            self._finishedAdd = True
            IStatusMessage(self.request).addStatusMessage(_(u"Item created"),
                "info")

        return obj
示例#3
0
    def handleSaveAndSend(self, action):
        slug = None
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return
        if 'edited_file_id' in data.keys() and \
            self.context.edited_file_id != data['edited_file_id']:
            body = {}
            if 'file_type' in data.keys():
                file_type = data['file_type']
            else:
                raise ActionExecutionError(Invalid(
                    _(u"Error creating the report, please try again")))
            if 'IBasic.title' in data.keys():
                body['titulo'] = data['IBasic.title']
            if 'IBasic.description' in data.keys():
                body['descripcion'] = data['IBasic.description']
            body['archivo'] = data['edited_file_id']
            body['tipo'] = 'soy-reportero'

            multimedia_connect = MultimediaConnect()
            response, content = multimedia_connect.create_structure(body, file_type)
            slug = None
            if "slug" in content:
                slug = content['slug']
            if 'status' not in response.keys() or response['status'] != '200'\
                or not slug:
                raise ActionExecutionError(Invalid(_(u"Error creating the \
                    report, please try again")))
            data['edited_file_slug'] = slug
            if slug:
                self.context.edited_file_slug = slug
                self.context.reindexObject()
        self.applyChanges(data)
        IStatusMessage(self.request).addStatusMessage(_(u"Changes saved"),
            "info")
        self.request.response.redirect(self.nextURL())
        notify(EditFinishedEvent(self.context))