Skip to content

Commit

Permalink
zango_version added, defaults added for branches and initialise skipp…
Browse files Browse the repository at this point in the history
…ed in staging and prod
  • Loading branch information
deepakdinesh1123 committed Oct 25, 2024
1 parent 643103d commit 8346246
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
14 changes: 14 additions & 0 deletions backend/src/zango/api/platform/tenancy/v1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 5 additions & 2 deletions backend/src/zango/api/platform/tenancy/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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(
[
Expand Down
7 changes: 6 additions & 1 deletion backend/src/zango/apps/shared/tenancy/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"app_name": "app_name"
"app_name": "app_name",
"zango_version": "zango_version"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"modules": [],
"app_routes": [],
"package_routes": [],
"app_name": "{{cookiecutter.app_name}}"
"app_name": "{{cookiecutter.app_name}}",
"zango_version": ">={{cookiecutter.zango_version}}"
}

0 comments on commit 8346246

Please sign in to comment.