kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
				
				
				
			fix: set FORCE to 1 in dev env NOCHANGELOG
							rodzic
							
								
									73bd66404b
								
							
						
					
					
						commit
						6a79f048cd
					
				|  | @ -152,3 +152,6 @@ REST_FRAMEWORK.update( | |||
|         ], | ||||
|     } | ||||
| ) | ||||
| 
 | ||||
| # allows makemigrations and superuser creation | ||||
| FORCE = env("FORCE", default=1) | ||||
|  |  | |||
|  | @ -1,5 +1,4 @@ | |||
| import os | ||||
| 
 | ||||
| from django.conf import settings | ||||
| from django.contrib.auth.management.commands.createsuperuser import ( | ||||
|     Command as BaseCommand, | ||||
| ) | ||||
|  | @ -12,7 +11,8 @@ class Command(BaseCommand): | |||
|         Creating Django Superusers would bypass some of our username checks, which can lead to unexpected behaviour. | ||||
|         We therefore prohibit the execution of the command. | ||||
|         """ | ||||
|         if not os.environ.get("FORCE") == "1": | ||||
|         force = settings.FORCE | ||||
|         if not force == 1: | ||||
|             raise CommandError( | ||||
|                 "Running createsuperuser on your Funkwhale instance bypasses some of our checks " | ||||
|                 "which can lead to unexpected behavior of your instance. We therefore suggest to " | ||||
|  |  | |||
|  | @ -1,5 +1,4 @@ | |||
| import os | ||||
| 
 | ||||
| from django.conf import settings | ||||
| from django.core.management.base import CommandError | ||||
| from django.core.management.commands.makemigrations import Command as BaseCommand | ||||
| 
 | ||||
|  | @ -11,8 +10,8 @@ class Command(BaseCommand): | |||
| 
 | ||||
|         We ensure the command is disabled, unless a specific env var is provided. | ||||
|         """ | ||||
|         force = os.environ.get("FORCE") == "1" | ||||
|         if not force: | ||||
|         force = settings.FORCE | ||||
|         if not force == 1: | ||||
|             raise CommandError( | ||||
|                 "Running makemigrations on your Funkwhale instance can have desastrous" | ||||
|                 " consequences. This command is disabled, and should only be run in " | ||||
|  |  | |||
|  | @ -1,6 +1,5 @@ | |||
| import os | ||||
| 
 | ||||
| import pytest | ||||
| from django.conf import settings | ||||
| from django.core.management import call_command | ||||
| from django.core.management.base import CommandError | ||||
| 
 | ||||
|  | @ -119,12 +118,13 @@ commands = ["createsuperuser", "makemigrations"] | |||
| @pytest.mark.parametrize("command", commands) | ||||
| def test_blocked_commands(command): | ||||
|     with pytest.raises(CommandError): | ||||
|         setattr(settings, "FORCE", 0) | ||||
|         call_command(command) | ||||
| 
 | ||||
| 
 | ||||
| @pytest.mark.parametrize("command", commands) | ||||
| def test_unblocked_commands(command, mocker): | ||||
|     mocker.patch.dict(os.environ, {"FORCE": "1"}) | ||||
|     setattr(settings, "FORCE", 1) | ||||
| 
 | ||||
|     call_command(command) | ||||
| 
 | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 petitminion
						petitminion