• 
      

    [1.7] Allow Review UIs to decide whether they're usable on a case-by-case basis.

    Review Request #6007 — Created June 17, 2014 and submitted

    Information

    Review Board
    release-1.7.x
    ade64f4...

    Reviewers

    ReviewUI subclaseses can now define a is_enabled_for() function, which
    returns whether it can be enabled for the given user, review request,
    and/or file attachment. This allows, for instance, limiting a review UI
    based on extra_data on an object, or based on the given user or
    Local Site, or anything else.

    Tested this with a file attachment returning True, and then returning False.

    Implemented a custom version and tested by file attachment name.

    Description From Last Updated

    Same question here about kwargs vs args.

    daviddavid

    Does it require using kwargs for these? The variable names seem pretty self explanatory (is_enabled_for(request.user, review_request. file_attachment))

    daviddavid
    reviewbot
    1. Tool: Pyflakes
      Processed Files:
          reviewboard/reviews/views.py
          reviewboard/reviews/ui/base.py
          reviewboard/reviews/templatetags/reviewtags.py
      
      Ignored Files:
          reviewboard/templates/reviews/review_request_box.html
      
      
      
      Tool: PEP8 Style Checker
      Processed Files:
          reviewboard/reviews/views.py
          reviewboard/reviews/ui/base.py
          reviewboard/reviews/templatetags/reviewtags.py
      
      Ignored Files:
          reviewboard/templates/reviews/review_request_box.html
      
      
    2. 
        
    david
    1. 
        
    2. reviewboard/reviews/templatetags/reviewtags.py (Diff revision 1)
       
       
       
       
      Show all issues

      Same question here about kwargs vs args.

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

      Does it require using kwargs for these? The variable names seem pretty self explanatory (is_enabled_for(request.user, review_request. file_attachment))

      1. I wanted to basically allow this to be somewhat expansive for the future, and to allow implementations to just define:

        def is_enabled_for(self, file_attachment, **kwargs):
            ...
        

        Most won't need all the objects, so it didn't seem worth them all listing all of them in the right order.

      2. In that case, I think that ReviewUI.is_enabled_for() should list them as kwargs (using =None) and probably mention your subclass intent.

    4. 
        
    chipx86
    reviewbot
    1. Tool: Pyflakes
      Processed Files:
          reviewboard/reviews/views.py
          reviewboard/reviews/ui/base.py
          reviewboard/reviews/templatetags/reviewtags.py
      
      Ignored Files:
          reviewboard/templates/reviews/review_request_box.html
      
      
      
      Tool: PEP8 Style Checker
      Processed Files:
          reviewboard/reviews/views.py
          reviewboard/reviews/ui/base.py
          reviewboard/reviews/templatetags/reviewtags.py
      
      Ignored Files:
          reviewboard/templates/reviews/review_request_box.html
      
      
    2. 
        
    david
    1. Ship It!

    2. 
        
    chipx86
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-2.0.x (ba025c7)
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to master (ba025c7)