[WIP] Figuring out how to affect front-end to enable read-only mode

Review Request #8677 - Created Jan. 29, 2017 and discarded

Kanghee Park
Review Board
master
8657, 8648
reviewboard, students

This is exploration for read-only mode, which is a feature to allow admins to disable functionality which would disrupt RB upgrades and maintenance while allowing users to consume site content.

Blocking API and introducing feature into admin panel are in previous commits.

Changes to Navbar (New Review Request link), Actions in ReviewRequestEditorView, ReviewRequestEditorView description, testing, information, comments, diff/comment box all changed.

Sidebar in Dashboard disabled (possibly not the best way to disable those features).

ETag updated to reflect changes in read-only mode for ReviewRequestEditorView.



  • 0
  • 0
  • 45
  • 4
  • 49
Description From Last Updated
Review Bot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/models/base_comment.py
        reviewboard/reviews/context.py
    
    Ignored Files:
        reviewboard/static/rb/js/models/reviewRequestEditorModel.js
        reviewboard/static/rb/js/models/userSessionModel.js
        reviewboard/static/rb/js/utils/apiUtils.es6.js
        reviewboard/templates/base.html
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/models/base_comment.py
        reviewboard/reviews/context.py
    
    Ignored Files:
        reviewboard/static/rb/js/models/reviewRequestEditorModel.js
        reviewboard/static/rb/js/models/userSessionModel.js
        reviewboard/static/rb/js/utils/apiUtils.es6.js
        reviewboard/templates/base.html
    
    
  2. reviewboard/reviews/context.py (Diff revision 1)
     
     
    Col: 13
     W291 trailing whitespace
    
  3. reviewboard/reviews/context.py (Diff revision 1)
     
     
    Col: 80
     E501 line too long (87 > 79 characters)
    
  4. reviewboard/reviews/context.py (Diff revision 1)
     
     
    Col: 13
     E131 continuation line unaligned for hanging indent
    
  5. Col: 80
     E501 line too long (83 > 79 characters)
    
  6. Col: 1
     W293 blank line contains whitespace
    
  7. 
      
Kanghee Park
Review Bot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/templatetags/reviewtags.py
        reviewboard/reviews/models/base_comment.py
        reviewboard/reviews/default_actions.py
        reviewboard/reviews/context.py
    
    Ignored Files:
        reviewboard/templates/reviews/review_reply_section.html
        reviewboard/templates/base.html
        reviewboard/static/rb/js/models/userSessionModel.js
        reviewboard/static/rb/js/models/reviewRequestEditorModel.js
        reviewboard/static/rb/js/views/commentDialogView.js
        reviewboard/static/rb/js/models/commentEditorModel.js
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/templatetags/reviewtags.py
        reviewboard/reviews/models/base_comment.py
        reviewboard/reviews/default_actions.py
        reviewboard/reviews/context.py
    
    Ignored Files:
        reviewboard/templates/reviews/review_reply_section.html
        reviewboard/templates/base.html
        reviewboard/static/rb/js/models/userSessionModel.js
        reviewboard/static/rb/js/models/reviewRequestEditorModel.js
        reviewboard/static/rb/js/views/commentDialogView.js
        reviewboard/static/rb/js/models/commentEditorModel.js
    
    
  2. reviewboard/reviews/context.py (Diff revision 2)
     
     
    Col: 80
     E501 line too long (87 > 79 characters)
    
  3. reviewboard/reviews/context.py (Diff revision 2)
     
     
    Col: 13
     E131 continuation line unaligned for hanging indent
    
  4. reviewboard/reviews/default_actions.py (Diff revision 2)
     
     
    Col: 19
     E127 continuation line over-indented for visual indent
    
  5. reviewboard/reviews/default_actions.py (Diff revision 2)
     
     
    Col: 80
     E501 line too long (93 > 79 characters)
    
  6. reviewboard/reviews/default_actions.py (Diff revision 2)
     
     
    Col: 80
     E501 line too long (112 > 79 characters)
    
  7. reviewboard/reviews/default_actions.py (Diff revision 2)
     
     
    Col: 18
     E127 continuation line over-indented for visual indent
    
  8. reviewboard/reviews/default_actions.py (Diff revision 2)
     
     
    Col: 80
     E501 line too long (112 > 79 characters)
    
  9. reviewboard/reviews/default_actions.py (Diff revision 2)
     
     
    Col: 80
     E501 line too long (103 > 79 characters)
    
  10. reviewboard/reviews/default_actions.py (Diff revision 2)
     
     
    Col: 80
     E501 line too long (86 > 79 characters)
    
  11. reviewboard/reviews/default_actions.py (Diff revision 2)
     
     
    Col: 80
     E501 line too long (103 > 79 characters)
    
  12. Col: 80
     E501 line too long (83 > 79 characters)
    
  13. 
      
Kanghee Park
Review Bot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/views.py
        reviewboard/admin/read_only.py
        reviewboard/reviews/models/base_comment.py
        reviewboard/reviews/templatetags/reviewtags.py
        reviewboard/reviews/default_actions.py
        reviewboard/reviews/models/review_request.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/starManagerView.js
        reviewboard/templates/reviews/review_reply_section.html
        reviewboard/templates/base/navbar.html
        reviewboard/templates/base.html
        reviewboard/static/rb/js/models/userSessionModel.js
        reviewboard/static/rb/js/views/commentDialogView.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/static/rb/js/pages/views/datagridPageView.js
        reviewboard/static/rb/js/models/commentEditorModel.js
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/views.py
        reviewboard/admin/read_only.py
        reviewboard/reviews/models/base_comment.py
        reviewboard/reviews/templatetags/reviewtags.py
        reviewboard/reviews/default_actions.py
        reviewboard/reviews/models/review_request.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/starManagerView.js
        reviewboard/templates/reviews/review_reply_section.html
        reviewboard/templates/base/navbar.html
        reviewboard/templates/base.html
        reviewboard/static/rb/js/models/userSessionModel.js
        reviewboard/static/rb/js/views/commentDialogView.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/static/rb/js/pages/views/datagridPageView.js
        reviewboard/static/rb/js/models/commentEditorModel.js
    
    
  2. reviewboard/reviews/default_actions.py (Diff revision 3)
     
     
     'SiteConfiguration' imported but unused
    
  3. reviewboard/reviews/default_actions.py (Diff revision 3)
     
     
    Col: 19
     E127 continuation line over-indented for visual indent
    
  4. reviewboard/reviews/default_actions.py (Diff revision 3)
     
     
    Col: 18
     E127 continuation line over-indented for visual indent
    
  5. 
      
Kanghee Park
Kanghee Park
Review Bot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/views.py
        reviewboard/admin/read_only.py
        reviewboard/reviews/models/base_comment.py
        reviewboard/accounts/views.py
        reviewboard/reviews/templatetags/reviewtags.py
        reviewboard/reviews/default_actions.py
        reviewboard/reviews/models/review_request.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/starManagerView.js
        reviewboard/templates/reviews/review_reply_section.html
        reviewboard/templates/base/navbar.html
        reviewboard/templates/base.html
        reviewboard/templates/base/_nav_support_menu.html
        reviewboard/static/rb/js/models/userSessionModel.js
        reviewboard/static/rb/js/views/commentDialogView.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/static/rb/js/pages/views/datagridPageView.js
        reviewboard/static/rb/js/models/commentEditorModel.js
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/views.py
        reviewboard/admin/read_only.py
        reviewboard/reviews/models/base_comment.py
        reviewboard/accounts/views.py
        reviewboard/reviews/templatetags/reviewtags.py
        reviewboard/reviews/default_actions.py
        reviewboard/reviews/models/review_request.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/starManagerView.js
        reviewboard/templates/reviews/review_reply_section.html
        reviewboard/templates/base/navbar.html
        reviewboard/templates/base.html
        reviewboard/templates/base/_nav_support_menu.html
        reviewboard/static/rb/js/models/userSessionModel.js
        reviewboard/static/rb/js/views/commentDialogView.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/static/rb/js/pages/views/datagridPageView.js
        reviewboard/static/rb/js/models/commentEditorModel.js
    
    
  2. reviewboard/accounts/views.py (Diff revision 4)
     
     
     local variable 'siteconfig' is assigned to but never used
    
  3. reviewboard/accounts/views.py (Diff revision 4)
     
     
     local variable 'siteconfig' is assigned to but never used
    
  4. reviewboard/accounts/views.py (Diff revision 4)
     
     
    Col: 73
     W292 no newline at end of file
    
  5. reviewboard/reviews/default_actions.py (Diff revision 4)
     
     
     'SiteConfiguration' imported but unused
    
  6. reviewboard/reviews/default_actions.py (Diff revision 4)
     
     
    Col: 19
     E127 continuation line over-indented for visual indent
    
  7. reviewboard/reviews/default_actions.py (Diff revision 4)
     
     
    Col: 18
     E127 continuation line over-indented for visual indent
    
  8. 
      
Kanghee Park
Review Bot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/views.py
        reviewboard/admin/read_only.py
        reviewboard/reviews/models/base_comment.py
        reviewboard/accounts/views.py
        reviewboard/reviews/templatetags/reviewtags.py
        reviewboard/reviews/default_actions.py
        reviewboard/webapi/tests/test_base.py
        reviewboard/reviews/models/review_request.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/starManagerView.js
        reviewboard/templates/reviews/review_reply_section.html
        reviewboard/templates/base/navbar.html
        reviewboard/templates/base.html
        reviewboard/templates/base/_nav_support_menu.html
        reviewboard/static/rb/js/models/userSessionModel.js
        reviewboard/static/rb/js/views/commentDialogView.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/static/rb/js/pages/views/datagridPageView.js
        reviewboard/static/rb/js/models/commentEditorModel.js
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/views.py
        reviewboard/admin/read_only.py
        reviewboard/reviews/models/base_comment.py
        reviewboard/accounts/views.py
        reviewboard/reviews/templatetags/reviewtags.py
        reviewboard/reviews/default_actions.py
        reviewboard/webapi/tests/test_base.py
        reviewboard/reviews/models/review_request.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/starManagerView.js
        reviewboard/templates/reviews/review_reply_section.html
        reviewboard/templates/base/navbar.html
        reviewboard/templates/base.html
        reviewboard/templates/base/_nav_support_menu.html
        reviewboard/static/rb/js/models/userSessionModel.js
        reviewboard/static/rb/js/views/commentDialogView.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/static/rb/js/pages/views/datagridPageView.js
        reviewboard/static/rb/js/models/commentEditorModel.js
    
    
  2. 
      
Christian Hammond
  1. This is a great start! Some comments about next steps and fixes/improvements for the current implementation.

  2. While this change wires off some pages (New Review Request, My Account, etc.), that doesn't stop users from actually going to those pages. You'll need a solution for those pages as well.

    One option is to show different content completely for the pages, letting the user know the site is in read-only mode and they can't post new changes for review or modify settings.

    1. I've have them redirecting to the dashboard for now. What do you think?

  3. Another thing that modifies the database today is changing columns for a datagrid (dashboard, All Review Requests, etc.). Users can reorder columns or add/remove columns. There's no harm in continuing to allow those operations to continue, but you should prevent saving in the database in the backend.

    1. I found this a bit harder to test since, if I've understood correctly, the issue is that in djblets the columns get changed on the profile and saved. I've refactored the djblets load_state to be able to take a third optional argument, and overrode it in reviewboard. This is because djblets is agnostic about read-only mode (for now..?). Is there a better way to go about this?

  4. You'll also need to do work to block off write access to the API, and handle this in RB.apiCall in JavaScript.

    1. I've made RB.apiCall return early when doing non GET requests while in read-only mode.

  5. reviewboard/admin/read_only.py (Diff revision 5)
     
     
     
     
     

    Instead of this, we should have a file-level docstring. There are examples elsewhere in the codebase.

    1. Replaced with """Provide utility methods for read-only mode."""

  6. reviewboard/admin/read_only.py (Diff revision 5)
     
     

    The name makes it sound like the user is read-only, but really we're saying "the user can make changes to the site." I'd instead go with: is_site_read_only_for(user).

  7. reviewboard/admin/read_only.py (Diff revision 5)
     
     
     
     
     
     

    Needs Args and Returns.

  8. reviewboard/admin/read_only.py (Diff revision 5)
     
     

    Needs double-backticks. This is in ReStructuredText format, and single backticks is a syntax error.

  9. reviewboard/admin/read_only.py (Diff revision 5)
     
     
     
     
     

    This method gets called a lot, so it's going to be important for it to be fast and not have to re-calculate all the time.

    What you can do is store a caching variable on user and return it, like this:

    if not hasattr(user, '_cache_site_is_read_only'):
        user._cache_site_is_read_only = ...
    
    return user._cache_site_is_read_only
    
    1. This is cool, didn't know you could create an instance variable from outside of the class file! And because the user object is one per request, we don't have to worry about the cache being invalidated, I presume. We'd lose the user object after every page load.

  10. Should be aligned like:

    var showMenu = (count > 0 &&
                    !RB.UserSession.instance.get(...));
    
  11. This should be computed only once. You can do so earlier in the file by defining a variable.

  12. Missing space after the comma.

  13. reviewboard/static/rb/js/views/reviewRequestEditorView.js (Diff revision 5)
     
     
     
     
     
     
     

    Indentation on the loop should be fixed.

  14. Blank line between these.

  15. reviewboard/templates/base.html (Diff revision 5)
     
     
     
     

    We're going to want the logic to be identical between here (and other template code) and is_user_read_only, now and in the future. Instead of doing a check here, you can add a function to reviewboard/admin/context_processors.py that you'd then add in the list of context processors in reviewboard/settings.py. This would call out to is_user_read_only and return the result as a variable that can be used in the templates.

    1. Thanks, was wanting to ask whether something like this was possible!

  16. 
      
Kanghee Park
Review Bot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/views.py
        reviewboard/admin/read_only.py
        reviewboard/webapi/tests/test_base.py
        reviewboard/reviews/models/base_comment.py
        reviewboard/webapi/base.py
        reviewboard/accounts/views.py
        reviewboard/reviews/default_actions.py
        reviewboard/reviews/models/review_request.py
        reviewboard/admin/context_processors.py
        reviewboard/settings.py
        reviewboard/reviews/templatetags/reviewtags.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/starManagerView.js
        reviewboard/templates/reviews/review_reply_section.html
        reviewboard/templates/base/navbar.html
        reviewboard/templates/base.html
        reviewboard/templates/base/_nav_support_menu.html
        reviewboard/static/rb/js/models/userSessionModel.js
        reviewboard/static/rb/js/views/commentDialogView.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/static/rb/js/pages/views/datagridPageView.js
        reviewboard/static/rb/js/models/commentEditorModel.js
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/views.py
        reviewboard/admin/read_only.py
        reviewboard/webapi/tests/test_base.py
        reviewboard/reviews/models/base_comment.py
        reviewboard/webapi/base.py
        reviewboard/accounts/views.py
        reviewboard/reviews/default_actions.py
        reviewboard/reviews/models/review_request.py
        reviewboard/admin/context_processors.py
        reviewboard/settings.py
        reviewboard/reviews/templatetags/reviewtags.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/starManagerView.js
        reviewboard/templates/reviews/review_reply_section.html
        reviewboard/templates/base/navbar.html
        reviewboard/templates/base.html
        reviewboard/templates/base/_nav_support_menu.html
        reviewboard/static/rb/js/models/userSessionModel.js
        reviewboard/static/rb/js/views/commentDialogView.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/static/rb/js/pages/views/datagridPageView.js
        reviewboard/static/rb/js/models/commentEditorModel.js
    
    
  2. reviewboard/admin/context_processors.py (Diff revision 6)
     
     
    Col: 1
     E302 expected 2 blank lines, found 1
    
  3. reviewboard/admin/context_processors.py (Diff revision 6)
     
     
    Col: 1
     W191 indentation contains tabs
    
  4. reviewboard/admin/context_processors.py (Diff revision 6)
     
     
    Col: 1
     E101 indentation contains mixed spaces and tabs
    
  5. reviewboard/admin/context_processors.py (Diff revision 6)
     
     
    Col: 1
     W191 indentation contains tabs
    
  6. reviewboard/admin/context_processors.py (Diff revision 6)
     
     
    Col: 1
     W191 indentation contains tabs
    
  7. reviewboard/admin/context_processors.py (Diff revision 6)
     
     
    Col: 1
     W191 indentation contains tabs
    
  8. reviewboard/settings.py (Diff revision 6)
     
     
     'django_reset' imported but unused
    
  9. reviewboard/settings.py (Diff revision 6)
     
     
     'from settings_local import *' used; unable to detect undefined names
    
  10. 
      
Kanghee Park
Review Bot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/views.py
        reviewboard/admin/read_only.py
        reviewboard/reviews/models/base_comment.py
        reviewboard/webapi/base.py
        reviewboard/accounts/views.py
        reviewboard/reviews/default_actions.py
        reviewboard/reviews/models/review_request.py
        reviewboard/datagrids/grids.py
        reviewboard/admin/context_processors.py
        reviewboard/settings.py
        reviewboard/reviews/templatetags/reviewtags.py
    
    Ignored Files:
        reviewboard/static/rb/js/pages/views/dashboardView.js
        reviewboard/static/rb/js/views/starManagerView.js
        reviewboard/templates/reviews/review_reply_section.html
        reviewboard/templates/base/navbar.html
        reviewboard/static/rb/js/utils/apiUtils.es6.js
        reviewboard/templates/base.html
        reviewboard/templates/base/_nav_support_menu.html
        reviewboard/static/rb/js/models/userSessionModel.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/static/rb/js/models/reviewRequestEditorModel.js
        reviewboard/static/rb/js/views/commentDialogView.js
        reviewboard/static/rb/js/models/commentEditorModel.js
    
    
  2. reviewboard/settings.py (Diff revision 7)
     
     
     'django_reset' imported but unused
    
  3. reviewboard/settings.py (Diff revision 7)
     
     
     'from settings_local import *' used; unable to detect undefined names
    
  4. 
      
Review Bot
  1. Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/views.py
        reviewboard/admin/read_only.py
        reviewboard/reviews/models/base_comment.py
        reviewboard/webapi/base.py
        reviewboard/accounts/views.py
        reviewboard/reviews/default_actions.py
        reviewboard/reviews/models/review_request.py
        reviewboard/datagrids/grids.py
        reviewboard/admin/context_processors.py
        reviewboard/settings.py
        reviewboard/reviews/templatetags/reviewtags.py
    
    Ignored Files:
        reviewboard/static/rb/js/pages/views/dashboardView.js
        reviewboard/static/rb/js/views/starManagerView.js
        reviewboard/templates/reviews/review_reply_section.html
        reviewboard/templates/base/navbar.html
        reviewboard/static/rb/js/utils/apiUtils.es6.js
        reviewboard/templates/base.html
        reviewboard/templates/base/_nav_support_menu.html
        reviewboard/static/rb/js/models/userSessionModel.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/static/rb/js/models/reviewRequestEditorModel.js
        reviewboard/static/rb/js/views/commentDialogView.js
        reviewboard/static/rb/js/models/commentEditorModel.js
    
    
  2. 
      
Kanghee Park
Review request changed

Status: Discarded

Loading...