Add siteconfig var and button for read-only mode

Review Request #8648 — Created Jan. 20, 2017 and submitted

Information

khp
Review Board
master
7ffda32...

Reviewers

Read-only mode is a new feature that allows users to view Review
Board while the site is being maintained or upgraded.
Added a toggle for read-only mode in Admin -> General Settings by
adding a checkbox.
Added a new attribute to siteconfig called site_read_only.
Toggling read-only mode will toggle the attribute to true/false.

In admin panel set new toggle to on/off and check that site_read_only
in siteconfig is set to true or false depending on whether the toggle
is checked or not.


Description From Last Updated

The description should tell a story about what this feature is for. See https://www.notion.so/reviewboard/Writing-Good-Change-Descriptions-10529e7c207743fa8ca90153d4b21fea. Basically, if I had no idea …

chipx86chipx86

The read-only feature should live in reviewboard.admin.features. This isn't specific to review requests.

chipx86chipx86

We prefer single quotes for strings wherever possible.

chipx86chipx86

This requires us to maintain two lists, which will easily lead to problems down the road. It also means that …

chipx86chipx86

As above, we don't need to map this to a setting.

chipx86chipx86

Col: 22 E241 multiple spaces after ':'

reviewbotreviewbot

Comments should have a trailing period.

chipx86chipx86

If this setting is being managed by siteconfig, we don't actually need a value in settings.py. We put things here …

chipx86chipx86

'django_reset' imported but unused

reviewbotreviewbot

'from settings_local import *' used; unable to detect undefined names

reviewbotreviewbot

non-superusers

brenniebrennie

Col: 13 E128 continuation line under-indented for visual indent

reviewbotreviewbot
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/admin/siteconfig.py
        reviewboard/admin/forms.py
        reviewboard/reviews/features.py
        reviewboard/settings.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/admin/siteconfig.py
        reviewboard/admin/forms.py
        reviewboard/reviews/features.py
        reviewboard/settings.py
    
    
  2. reviewboard/admin/siteconfig.py (Diff revision 1)
     
     
    Show all issues
    Col: 22
     E241 multiple spaces after ':'
    
  3. reviewboard/settings.py (Diff revision 1)
     
     
    Show all issues
     'django_reset' imported but unused
    
  4. reviewboard/settings.py (Diff revision 1)
     
     
    Show all issues
     'from settings_local import *' used; unable to detect undefined names
    
  5. 
      
chipx86
  1. 
      
  2. Show all issues

    The description should tell a story about what this feature is for. See https://www.notion.so/reviewboard/Writing-Good-Change-Descriptions-10529e7c207743fa8ca90153d4b21fea.

    Basically, if I had no idea what read-only mode was already, I wouldn't learn anything from the description. Write the description so that if your friend saw it, they'd know what you're working on.

  3. reviewboard/admin/forms.py (Diff revision 1)
     
     
    Show all issues

    The read-only feature should live in reviewboard.admin.features. This isn't specific to review requests.

  4. reviewboard/admin/forms.py (Diff revision 1)
     
     
     
     
    Show all issues

    We prefer single quotes for strings wherever possible.

  5. reviewboard/admin/forms.py (Diff revision 1)
     
     
     
     
     
     
     
     
     
     
    Show all issues

    This requires us to maintain two lists, which will easily lead to problems down the road. It also means that if the feature is dynamically enabled/disabled at runtime, the lists will be stale for any existing Apache threads.

    There's a way around that, but I want to discuss where Features really come in.

    A Feature is something we use to hide functionality from end users, unless the server has opted into it. The Read Only support is a global setting, and one we probably wouldn't ship until it's ready. I don't know that we need to hide it behind a Feature. (David and Barret might disagree -- if so, let's meet and discuss this.)

    If we do keep it, what we'd want to do is instead do this check in the form's __init__, dynamically removing the field from the instance if the feature is disabled.

    1. Hey Christian, thanks for the comment. I talked to Barret about it and explained your reasoning a bit more. I wasn't aware the code doesn't have to land until its fully ready, so I wanted to keep it hidden in the meanwhile.

  6. reviewboard/admin/siteconfig.py (Diff revision 1)
     
     
    Show all issues

    As above, we don't need to map this to a setting.

  7. reviewboard/settings.py (Diff revision 1)
     
     
    Show all issues

    Comments should have a trailing period.

  8. reviewboard/settings.py (Diff revision 1)
     
     
    Show all issues

    If this setting is being managed by siteconfig, we don't actually need a value in settings.py. We put things here for modules that expect to read from settings, but anything reading/writing from/to siteconfig can just make use of siteconfig.

    1. This makes more sense today. Got it.

  9. 
      
KH
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/admin/siteconfig.py
        reviewboard/admin/forms.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/admin/siteconfig.py
        reviewboard/admin/forms.py
    
    
  2. 
      
brennie
  1. 
      
  2. reviewboard/admin/forms.py (Diff revision 2)
     
     
     
    Show all issues

    non-superusers

  3. 
      
KH
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/admin/siteconfig.py
        reviewboard/admin/forms.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/admin/siteconfig.py
        reviewboard/admin/forms.py
    
    
  2. reviewboard/admin/forms.py (Diff revision 3)
     
     
    Show all issues
    Col: 13
     E128 continuation line under-indented for visual indent
    
  3. 
      
KH
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/admin/siteconfig.py
        reviewboard/admin/forms.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/admin/siteconfig.py
        reviewboard/admin/forms.py
    
    
  2. 
      
KH
Review request changed
Status:
Completed
Change Summary:
Pushed to release-4.0.x (833f3b2)