Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 3445 by marc2...@gmail.com: ReviewRequest.get_last_activity() always returns the ReviewRequest itself
http://code.google.com/p/reviewboard/issues/detail?id=3445

*** READ THIS BEFORE POSTING!
***
*** You must complete this form in its entirety, or your bug report will be
*** rejected.
***
*** If you have a security issue to report, please send it confidentially
to
*** secur...@reviewboard.org. Posting security-related issues to this bug
*** tracker causes us to have to do an emergency release.
***
*** For customer support, please post to reviewbo...@googlegroups.com
***
*** If you have a patch, please submit it to
http://reviews.reviewboard.org/
***
*** This bug tracker is public. Please check that any logs or other
information
*** that you include has been stripped of confidential information.


What version are you running?

Review Board 2.1 alpha 0 (dev)


What's the URL of the page containing the problem?

My local page.


What steps will reproduce the problem?
1. Add a review to a review request
2. Compare timestamps between the latest review and the last_updated field on the review request


What is the expected output? What do you see instead?

ReviewRequest.get_last_activity() always returns the ReviewRequest itself instead of any of the reviews. This is because the last_updated field on a ReviewRequest gets set to a time after the latest review, so there is never a review that is newer than the ReviewRequest itself.


What operating system are you using? What browser?

Ubuntu and Chrome


Please provide any additional information below.

I'm trying to write an extension that will display the last user to update a review request. However, ReviewRequest.get_last_activity() keeps returning the ReviewRequest itself, so it always displays the submitter's name.

I made an update as a different user than the one I submitted with and got this:

$ python reviewboard/manage.py shell
...
from reviewboard.reviews.models.review_request import ReviewRequest as RR
RR.objects.all()
[<ReviewRequest: Test1>]
rr = RR.objects.all()[0]
r = rr.reviews.filter(public=True).latest()
r
<Review: Review of 'Test1'>
r.timestamp
datetime.datetime(2014, 6, 26, 19, 46, 45, 65830, tzinfo=<UTC>)
rr.last_updated
datetime.datetime(2014, 6, 26, 19, 46, 45, 153334, tzinfo=<UTC>)


Here is the code I was playing with:

extension.py:

class LastUpdatedByColumn(Column):
    def render_data(self, stateful_column, review_request):
        timestamp, updated_object = review_request.get_last_activity()
        if hasattr(updated_object, 'user'):
           return updated_object.user.username
        elif hasattr(updated_object, 'submitter'):
           return updated_object.submitter.username
        return '??? %s' % updated_object.__class__.__name__

class LastUpdatedBy(Extension):
    metadata = {
        'Name': 'LastUpdatedBy',
'Summary': 'A column that displays who the last user was to update a review request.',
    }

    def initialize(self):
        DashboardColumnsHook(self, [
            LastUpdatedByColumn(id='lastUpdatedBy',
                                label='Last Updated',
                                detailed_label='Last Updated By'),
                                shrink=True),
        ])


--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups 
"reviewboard-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to reviewboard-issues+unsubscr...@googlegroups.com.
To post to this group, send email to reviewboard-issues@googlegroups.com.
Visit this group at http://groups.google.com/group/reviewboard-issues.
For more options, visit https://groups.google.com/d/optout.

Reply via email to