Example #1
0
    def test_update_output_with_related_entities(self):
        self._login_lawyer()
        workspace = self._get_workspace("Area 1")
        document = self._create_fake_document("Title",
                                              workspace_id=workspace._id)
        outputs, _ = get_entities_from_str(document.html)
        output1 = outputs[0]

        output_params = {
            "_id": str(output1._id),
            "title": "Title of Output edited",
            "workspace": str(workspace._id),
            "precondition": str(output1.precondition._id),
            "html": "<p>Io sono il tuo editor</p>",
        }

        response = self.app.put_json("/output/put", params=output_params).json
        ok_(response["redirect_url"])
        self.app.get(response["redirect_url"])
        response = self.app.get(
            "/resolve/original_edit",
            params=dict(workspace=output_params["workspace"]))
        response.follow()
        output_edited = model.Output.query.get(_id=ObjectId(output1._id))
        assert output_edited["title"] == output_params["title"]
Example #2
0
 def content(self):
     from ksweb.lib.utils import get_entities_from_str
     outputs, answers = get_entities_from_str(self.html)
     content = [{
         'content': str(__._id),
         'title': __.title,
         'type': 'output'
     } for __ in outputs if __]
     content.extend([{
         'content': str(__._id),
         'title': __.title,
         'type': 'qa_response'
     } for __ in answers if __])
     return content
Example #3
0
 def children(self):
     from ksweb.lib.utils import get_entities_from_str
     outputs, answers = get_entities_from_str(self.html)
     return outputs + answers
Example #4
0
 def _validate_python(self, value, state=None):
     outputs, __ = get_entities_from_str(value)
     if None in outputs:
         raise ValidationError(l_(u'Output not found.'), self)