File tree Expand file tree Collapse file tree 3 files changed +18
-0
lines changed
Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -253,3 +253,5 @@ RESTART_POLICY_WINDOW=120s
253253
254254DEFAULT_MAX_UPLOAD_SIZE = 5368709120
255255DEFAULT_MAX_PARALLEL_UPLOADS_PER_USER = 5
256+
257+ # FORCE_READ_ONLY_MODE=False Override the read-only value saved in the configuration
Original file line number Diff line number Diff line change @@ -666,6 +666,17 @@ def test_maintenance_true(self):
666666
667667 self .assertEqual (response .status_code , 503 , "User is allowed to get index page" )
668668
669+ @patch .dict (os .environ , {"FORCE_READ_ONLY_MODE" : "True" })
670+ def test_readonly_overwrite_by_env (self ):
671+ config = Configuration .load ()
672+ self .assertTrue (config .read_only )
673+
674+ @patch .dict (os .environ , {"FORCE_READ_ONLY_MODE" : "False" })
675+ def test_readonly_is_not_overwrite_by_env (self ):
676+ # will take the value from the db
677+ config = Configuration .load ()
678+ self .assertFalse (config .read_only )
679+
669680
670681class TestOwnerRightsRequestUtils (TestCase ):
671682 def setUp (self ):
Original file line number Diff line number Diff line change 2020
2121# Geonode functionality
2222
23+ import os
24+ import ast
2325from django .db import models
2426
2527
@@ -38,6 +40,9 @@ class Meta:
3840 @classmethod
3941 def load (cls ):
4042 obj , _ = cls .objects .get_or_create (pk = 1 )
43+ val = os .getenv ("FORCE_READ_ONLY_MODE" , None )
44+ if val is not None :
45+ setattr (obj , "read_only" , ast .literal_eval (val ))
4146 return obj
4247
4348 def save (self , * args , ** kwargs ):
You can’t perform that action at this time.
0 commit comments