3205: Closing review request does not add the optional submission text to the ChangeDescription python instance.

dtsc****@vizr***** (Google Code) (Is this you? Claim this profile.)
Feb. 28, 2014
What version are you running?
RB 1.7.18

What's the URL of the page containing the problem?
/r/X/

What steps will reproduce the problem?
1.Create new review request.
2.Click on Close->Submitted
3.Enter some text in the edit field below "Describe the submission (optional):"
4.Click on "OK"

What is the expected output? What do you see instead?
I expect that the text entered in the edit field is added as a description to the ChangeDescription instance so that it can be retrieved on callbacks.

When I added some simple debugging logs, I see that no text is attached:

- reviewboard/reviews/models.py:

class ReviewRequest(BaseReviewRequestDetails):
...
    def close(self, type, user=None, description=None):
...
about line 830:
        if type not in [self.SUBMITTED, self.DISCARDED]:
            raise AttributeError("%s is not a valid close type" % type)

        if self.status != type:
            changedesc = ChangeDescription(public=True, text=description or "")
            changedesc.record_field_change('status', self.status, type)
            changedesc.save()

            self.changedescs.add(changedesc)

            if type == self.SUBMITTED:
                self.public = True

            self.status = type
            self.save(update_counts=True)

            if description:
                logging.warn('SAVE DESCRIPTION SET RR:' + description)

            logging.warn('SAVE RR:' + changedesc.text)
            logging.warn('SAVE STACK:' + traceback.format_exc())

            review_request_closed.send(sender=self.__class__, user=user,
                                       review_request=self,
                                       type=type)


stacktrace in log:
WARNING:root:SAVE RR:
WARNING:root:SAVE STACK:Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/Djblets-0.7.23-py2.7.egg/djblets/webapi/resources.py", line 441, in __call__
    request.method = 'POST'
AttributeError: can't set attribute


What operating system are you using? What browser?
Linux Ubunty-12.04-32bit
Mozilla Firefox 26.0

Please provide any additional information below.
This information is required by a own written extension that connects on review_request_closed.
chipx86
#1 chipx86
What version of Django are you using? I wouldn't expect the AttributeError.

There should be an else clause that updates the existing ChangeDescription.
  • +NeedInfo
#2 dtsc****@vizr***** (Google Code) (Is this you? Claim this profile.)
I believe that it is the version that got installed together with RB:

pip freeze|grep -i django
Django==1.4.10
django-evolution==0.6.9
django-pipeline==1.2.24
david
#3 david
So the thing going on here is that the review_request_closed signal fires as soon as the user clicks "Close -> Submitted", and then editing the text just changes the ChangeDescription object.

You may be able to have your extension listed to review_request_closed and also the ChangeDescription post_save signal (from django.db.models.signals). If you see one after the other, then you get the text.
david
#4 david
  • -NeedInfo
    +New
#5 dtsc****@vizr***** (Google Code) (Is this you? Claim this profile.)
I could solved with the following:

...
        post_save.connect(self._review_request_closed_cb,
            sender=ChangeDescription)

    def _review_request_closed_cb(self, sender, **kwargs):
        latest = kwargs.get('instance')
        review_request = None

        result = ReviewRequest.objects.filter(status='S', changedescs=latest)

        if result is None or len(result) != 1:
            return

        review_request = result[0]
...

Thanks a lot for the help!
david
#6 david
  • -New
    +NotABug