def get_formatted_comments(self, threshold=400): """Returns the dossier's comment truncated to characters defined in `threshold` and transformed as web intelligent text. """ comments = IDossier(self).comments if comments: if threshold: comments = truncate_ellipsis(comments, threshold) return api.portal.get_tool(name='portal_transforms').convertTo( 'text/html', comments, mimetype='text/x-web-intelligent').getData()
def __call__(self): self.request.response.setHeader('Content-Type', 'application/json') self.request.response.setHeader('X-Theme-Disabled', 'True') data = json.loads(self.request.get('data', '{}')) dossier = IDossier(self.context) dossier.comments = data['comments'] self.context.reindexObject(idxs=['SearchableText']) return json.dumps( {'comment': truncate_ellipsis(dossier.comments, 400)})
def get_comments(self): return truncate_ellipsis( IDossier(self.context).comments, self.comments_max_length)