Esempio n. 1
0
    def __call__(self):
        payload = self.request.get('data', None)
        if not payload:
            raise BadRequest('No data given')

        # TODO validate payload contains blocks and confirmed flag.
        self.link_integrity = ILinkIntegrityInfo(self.request)

        data = json.loads(payload)
        self.block = uuidToObject(data['block'])

        if self.request.get('form.submitted', False):

            if self.link_integrity:
                # Always allow deletion of block, regardless of the integrity
                # check.
                self.request.environ[self.link_integrity.marker] = 'all'

            self.context.manage_delObjects([self.block.id])
            transaction_note('Deleted %s' % self.block.absolute_url())
            return json_response(self.request, proceed=True)
        else:
            return json_response(self.request,
                                 content=self.confirm_template(),
                                 proceed=False)
Esempio n. 2
0
    def render(self):
        if hasattr(self.form_instance, 'obj_uid'):
            obj = uuidToObject(self.form_instance.obj_uid)
            self.request.response.setHeader('Content-Type', 'application/json')

            # Consume all statusmessages
            IStatusMessage(self.request).show()

            return json_response(self.request,
                                 uid=self.form_instance.obj_uid,
                                 url=obj.absolute_url(),
                                 content=self.form_instance.obj_html,
                                 proceed=True)

        return json_response(self.request,
                             content=super(AddView, self).render(),
                             proceed=False)
Esempio n. 3
0
    def render(self):
        response = {'content': self.template(),
                    'proceed': False}

        if self._finished_edit:
            response['proceed'] = True
            response['content'] = self.context()
        return json_response(self.request, response)
Esempio n. 4
0
    def render(self):

        response = {'content': self.template(),
                    'proceed': False}

        if self._finished_edit:
            response['proceed'] = True
            response['content'] = self.get_block_content()

        self.request.response.setHeader("Cache-Control",
                                        "no-cache, no-store, must-revalidate")
        self.request.response.setHeader("Expires", "Sat, 1 Jan 2000 00:00:00 GMT")

        return json_response(self.request, response)
Esempio n. 5
0
    def __call__(self):
        response = {'content': self.template(),
                    'proceed': False}

        if 'form.buttons.save' in self.request.form:
            self.handleSave()
            response['proceed'] = True
            response['content'] = self.get_block_content()

        self.request.response.setHeader("Cache-Control",
                                        "no-cache, no-store, must-revalidate")
        self.request.response.setHeader("Expires", "Sat, 1 Jan 2000 00:00:00 GMT")

        return json_response(self.request, response)
Esempio n. 6
0
 def render(self):
     if self._finishedAdd:
         return json_response(self.request, proceed=True)
     return super(AddForm, self).render()
Esempio n. 7
0
 def created_response(self, obj):
     self.request.response.setStatus(201)
     return json_response(self.request,
                          content='Created',
                          proceed=True,
                          url=obj.absolute_url())