blezz-tech 1 месяц назад
Родитель
Сommit
0d20afc65c
4 измененных файлов с 14 добавлено и 10 удалено
  1. 3 3
      README.md
  2. 0 4
      bin/install.cfg.example
  3. 4 0
      core/_settings_vars.py
  4. 7 3
      sharix_admin/signals.py

+ 3 - 3
README.md

@@ -11,9 +11,9 @@ The base Django project of a service web application to which other modules are
 
 ### Test Users
 
-During the installation/upgrade, you can pass the `TEST_USERS=true` is set
-in the `install.cfg` file to automatically create test users. These users
-will be assigned to the **TEST** group. Additionally, if the `DEBUG`
+During the installation/upgrade, you can pass the envvar: `TEST_USERS=true` or set
+`GENERATE_TEST_USERS = True` in core/settings_vars.py to automatically create test
+users. These users will be assigned to the **TEST** group. Additionally, if the `DEBUG`
 setting is enabled (`DEBUG=True` in *core/settings_vars.py*), these test
 users will be marked as active and can log in. If `DEBUG` is disabled
 (`DEBUG=False`), the users will be inactive and unable to log in.

+ 0 - 4
bin/install.cfg.example

@@ -28,7 +28,3 @@ WEBSERVICE_RUNNING_BRANCH="unstable"
 DESIGN_TEMPLATE_BRANCH="unstable"
 
 LANDING_BRANCH="module-figma"
-
-
-#Create test users
-TEST_USERS=true

+ 4 - 0
core/_settings_vars.py

@@ -60,3 +60,7 @@ EJ_HOST = "ej.sharix-app.org"
 
 # Service name that is used in generating ejabber rooms
 WEBSERVICE_NAME = "open"
+WEBSERVICE__ID = 1
+
+#Create test users
+GENERATE_TEST_USERS = True

+ 7 - 3
sharix_admin/signals.py

@@ -8,6 +8,8 @@ from django.db.models.signals import post_migrate
 from django.dispatch import receiver
 from tickets.models import TicketList
 
+from core.settings_vars import GENERATE_TEST_USERS
+
 User = get_user_model()
 
 
@@ -37,10 +39,12 @@ def create_initial_groups(sender, **kwargs):
 @receiver(post_migrate)
 def create_test_users(sender, **kwargs):
     """
-    Создает тестовых пользователей, но только если установочный скрипт был запущен с параметром --test-users
-    или была задана переменная окружения TEST_USERS=true.
+    Создает тестовых пользователей, если:
+    
+    - В файле settings_vers.py переменная GENERATE_TEST_USERS = True
+    - Или была задана переменная окружения TEST_USERS=true
     """
-    if os.getenv('TEST_USERS') == 'true':
+    if os.getenv('TEST_USERS') == 'true' or GENERATE_TEST_USERS:
         password = make_password("sharix-open-test")
         test_group = Group.objects.get(pk=99)