diff --git a/backend/src/zango/api/platform/tenancy/v1/serializers.py b/backend/src/zango/api/platform/tenancy/v1/serializers.py index e8c898ca..ce614523 100644 --- a/backend/src/zango/api/platform/tenancy/v1/serializers.py +++ b/backend/src/zango/api/platform/tenancy/v1/serializers.py @@ -45,6 +45,20 @@ def update(self, instance, validated_data): if extra_config_str: try: extra_config_json = json.loads(extra_config_str) + default_branch_config = { + "dev": "development", + "staging": "staging", + "prod": "main", + } + if extra_config_json.get("git_config", None): + extra_config_json["git_config"]["branch"] = { + **extra_config_json["git_config"]["branch"], + **{ + k: v + for k, v in default_branch_config.items() + if extra_config_json["git_config"]["branch"][k] is None + }, + } validated_data["extra_config"] = extra_config_json except json.JSONDecodeError: raise serializers.ValidationError( diff --git a/backend/src/zango/api/platform/tenancy/v1/views.py b/backend/src/zango/api/platform/tenancy/v1/views.py index bdcd1d30..01ff41c1 100644 --- a/backend/src/zango/api/platform/tenancy/v1/views.py +++ b/backend/src/zango/api/platform/tenancy/v1/views.py @@ -4,6 +4,7 @@ from django_celery_results.models import TaskResult +from django.conf import settings from django.db.models import Q from django.utils.decorators import method_decorator @@ -199,8 +200,10 @@ def put(self, request, *args, **kwargs): new_repo_url = new_git_config.get("repo_url") old_repo_url = old_git_config.get("repo_url") - if new_repo_url and ( - not old_git_config or new_repo_url != old_repo_url + if ( + new_repo_url + and (not old_git_config or new_repo_url != old_repo_url) + and settings.ENV == "dev" ): git_setup( [ diff --git a/backend/src/zango/apps/shared/tenancy/tasks.py b/backend/src/zango/apps/shared/tenancy/tasks.py index 9eae1b95..02fc0f7b 100644 --- a/backend/src/zango/apps/shared/tenancy/tasks.py +++ b/backend/src/zango/apps/shared/tenancy/tasks.py @@ -10,6 +10,8 @@ from django.core.management import call_command from django.utils import timezone +import zango + from .utils import DEFAULT_THEME_CONFIG, assign_policies_to_anonymous_user @@ -50,7 +52,10 @@ def initialize_workspace(tenant_uuid, app_template_path=None): template_directory = os.path.join( os.path.dirname(__file__), "workspace_folder_template" ) - cookiecutter_context = {"app_name": tenant.name} + cookiecutter_context = { + "app_name": tenant.name, + "zango_version": zango.__version__, + } cookiecutter.main.cookiecutter( template_directory, diff --git a/backend/src/zango/apps/shared/tenancy/workspace_folder_template/cookiecutter.json b/backend/src/zango/apps/shared/tenancy/workspace_folder_template/cookiecutter.json index c656bcab..5bd2b0a9 100644 --- a/backend/src/zango/apps/shared/tenancy/workspace_folder_template/cookiecutter.json +++ b/backend/src/zango/apps/shared/tenancy/workspace_folder_template/cookiecutter.json @@ -1,3 +1,4 @@ { - "app_name": "app_name" + "app_name": "app_name", + "zango_version": "zango_version" } diff --git a/backend/src/zango/apps/shared/tenancy/workspace_folder_template/{{cookiecutter.app_name}}/settings.json b/backend/src/zango/apps/shared/tenancy/workspace_folder_template/{{cookiecutter.app_name}}/settings.json index cb7212b9..c012989b 100644 --- a/backend/src/zango/apps/shared/tenancy/workspace_folder_template/{{cookiecutter.app_name}}/settings.json +++ b/backend/src/zango/apps/shared/tenancy/workspace_folder_template/{{cookiecutter.app_name}}/settings.json @@ -3,5 +3,6 @@ "modules": [], "app_routes": [], "package_routes": [], - "app_name": "{{cookiecutter.app_name}}" + "app_name": "{{cookiecutter.app_name}}", + "zango_version": ">={{cookiecutter.zango_version}}" }