Пример #1
0
    def render(self):
        form = self.request.form
        task_has_changed = False

        # XXX: I do not get the point on storing the responsible on the
        #      response annotation; that information is not being used
        #      anywhere so this could be way simpler
        current_responsible = self.context.responsible
        response_text = form.get('response', u'')
        responsible = form.get('responsible', u'')
        if responsible != current_responsible:
            self.context.responsible = responsible
            task_has_changed = True
            new_response = Response(response_text, responsible)
        else:
            new_response = Response(response_text)

        result = self._update_workflow()
        if result:
            old, new = result
            new_response.add_change('review_state', _(u'State'), old, new)
            task_has_changed = True

        result = self._update_text_field('priority')
        if result:
            old, new = result
            new_response.add_change('priority', _(u'Priority'), old, new)
            task_has_changed = True

        result = self._update_text_field('responsible')
        if result:
            old, new = result
            new_response.add_change('responsible', _(u'Responsible'), old, new)
            task_has_changed = True

        result = self._update_date()
        if result:
            old, new = result
            new_response.add_change('provided_date', _(u'Expected date'), old, new)
            task_has_changed = True

        if len(response_text) == 0 and not task_has_changed:
            msg = _(u'No response text added and no issue changes made.')
            api.portal.show_message(message=msg, request=self.request)
        else:
            folder = IResponseContainer(self.context)
            folder.add(new_response)
        self.request.response.redirect(self.context.absolute_url())