Avoid to submit a non-public draft

Review Request #6856 — Created Jan. 31, 2015 and submitted

Information

Review Board
master
f510d18...

Reviewers

Fix not dealing with submit action with review_request.py

Add validation to the ReviewRequest model to prevent state transitions to SUBMITTED if the review request is not public.

Then get rid of the "Submit" button in a review request if it's not currently public on the UI level.

Changes have been made on following tests because they just creat a non-public empty draft to submit. This should not be allowed.

./reviewboard/manage.py test -- reviewboard.reviews.tests:ReviewRequestCounterTests.test_closing_closed_requests

I publish the review request first before discard it.

./reviewboard/manage.py test -- reviewboard.reviews.tests:ReviewRequestCounterTests.test_reopen_submitted_draft_requests

I use test_closing_requests instead of test_closing_draft_requests because test_closing_requests can create a public draft instead.

./reviewboard/manage.py test -- reviewboard.reviews.tests:ReviewRequestTests.test_public_with_discard_reopen_submitted

I publish the review request after reopen a discarded request before submit it.

./reviewboard/manage.py test -- reviewboard.notifications.tests:WebHookSignalDispatchTests.test_review_request_reopened

I create a published request instead.

./reviewboard/manage.py test -- reviewboard.notifications.tests:WebHookSignalDispatchTests.test_review_request_closed_submitted

I create a published request instead.

Description From Last Updated

You should tie this in to the import for PermissioError, like this: from reviewboard.reviews.errors import (PermissionError, PublishError)

mike_conleymike_conley

I think we still want to make it possible to Delete Permanently and Discard a review request that is not …

mike_conleymike_conley

I suspect we're going to want to add a new test too to ensure that we cannot transition from PENDING_REVIEW …

mike_conleymike_conley

TBH, I don't think it's necessary to test the string representation of the exception. See test_publish_changedesc_none, for example.

mike_conleymike_conley

There should be two newlines between root-script level items.

mike_conleymike_conley

local variable 'pe' is assigned to but never used

reviewbotreviewbot
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/models/review_request.py
    
    Ignored Files:
        reviewboard/templates/reviews/review_request_actions_secondary.html
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/models/review_request.py
    
    Ignored Files:
        reviewboard/templates/reviews/review_request_actions_secondary.html
    
    
  2. 
      
mike_conley
  1. Just a few issues, please a reminder to please read this document on writing good change descriptions / testing done documentation.

  2. Show all issues

    You should tie this in to the import for PermissioError, like this:

    from reviewboard.reviews.errors import (PermissionError,
                                            PublishError)
    
  3. Show all issues

    I think we still want to make it possible to Delete Permanently and Discard a review request that is not public, so we should just wrap the Submitted option here.

  4. 
      
CH
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/tests.py
        reviewboard/notifications/tests.py
        reviewboard/reviews/models/review_request.py
    
    Ignored Files:
        reviewboard/templates/reviews/review_request_actions_secondary.html
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/tests.py
        reviewboard/notifications/tests.py
        reviewboard/reviews/models/review_request.py
    
    Ignored Files:
        reviewboard/templates/reviews/review_request_actions_secondary.html
    
    
  2. 
      
mike_conley
  1. This looks really good, Chenxi. I think you're very close - my only suggestion is to add a new test to exercise the restriction you've put in.

  2. reviewboard/reviews/tests.py (Diff revision 2)
     
     
    Show all issues

    I suspect we're going to want to add a new test too to ensure that we cannot transition from PENDING_REVIEW to SUBMITTED if the review request is not public.

  3. 
      
CH
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/tests.py
        reviewboard/notifications/tests.py
        reviewboard/reviews/models/review_request.py
    
    Ignored Files:
        reviewboard/templates/reviews/review_request_actions_secondary.html
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/tests.py
        reviewboard/notifications/tests.py
        reviewboard/reviews/models/review_request.py
    
    Ignored Files:
        reviewboard/templates/reviews/review_request_actions_secondary.html
    
    
  2. 
      
mike_conley
  1. 
      
  2. reviewboard/reviews/tests.py (Diff revision 3)
     
     
     
     
     
    Show all issues

    TBH, I don't think it's necessary to test the string representation of the exception. See test_publish_changedesc_none, for example.

  3. reviewboard/reviews/tests.py (Diff revision 3)
     
     
    Show all issues

    There should be two newlines between root-script level items.

  4. 
      
CH
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/tests.py
        reviewboard/notifications/tests.py
        reviewboard/reviews/models/review_request.py
    
    Ignored Files:
        reviewboard/templates/reviews/review_request_actions_secondary.html
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/tests.py
        reviewboard/notifications/tests.py
        reviewboard/reviews/models/review_request.py
    
    Ignored Files:
        reviewboard/templates/reviews/review_request_actions_secondary.html
    
    
  2. reviewboard/reviews/tests.py (Diff revision 4)
     
     
    Show all issues
     local variable 'pe' is assigned to but never used
    
  3. 
      
CH
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/tests.py
        reviewboard/notifications/tests.py
        reviewboard/reviews/models/review_request.py
    
    Ignored Files:
        reviewboard/templates/reviews/review_request_actions_secondary.html
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/tests.py
        reviewboard/notifications/tests.py
        reviewboard/reviews/models/review_request.py
    
    Ignored Files:
        reviewboard/templates/reviews/review_request_actions_secondary.html
    
    
  2. 
      
mike_conley
  1. This patch looks good to me! Thanks Chenxi!

  2. 
      
david
  1. Ship It!
  2. 
      
CH
Review request changed
Status:
Completed
Change Summary:
Pushed to release-2.0.x (e192efe)