Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
meikelmosby committed Jan 31, 2025
1 parent 0c1a2a4 commit 634e27e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion posthog/api/hog_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def validate(self, attrs):
attrs["inputs"] = attrs.get("inputs") or {}

if hog_type == "transformation":
if not settings.HOG_TRANSFORMATIONS_ENABLED:
if not settings.HOG_TRANSFORMATIONS_CUSTOM_HOG_ENABLED:
if not template:
raise serializers.ValidationError(
{"template_id": "Transformation functions must be created from a template."}
Expand Down
6 changes: 3 additions & 3 deletions posthog/api/test/test_hog_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ def create(payload):
}
)

@override_settings(HOG_TRANSFORMATIONS_ENABLED=False)
@override_settings(HOG_TRANSFORMATIONS_CUSTOM_HOG_ENABLED=False)
def test_transformation_functions_require_template_when_disabled(self):
response = self.client.post(
f"/api/projects/{self.team.id}/hog_functions/",
Expand All @@ -1283,13 +1283,13 @@ def test_transformation_functions_require_template_when_disabled(self):
"attr": "template_id",
}

@override_settings(HOG_TRANSFORMATIONS_ENABLED=False)
@override_settings(HOG_TRANSFORMATIONS_CUSTOM_HOG_ENABLED=False)
def test_transformation_functions_preserve_template_code_when_disabled(self):
with patch("posthog.api.hog_function_template.HogFunctionTemplates.template") as mock_template:
mock_template.return_value = template_slack # Use existing template instead of creating mock

# First create with transformations enabled
with override_settings(HOG_TRANSFORMATIONS_ENABLED=True):
with override_settings(HOG_TRANSFORMATIONS_CUSTOM_HOG_ENABLED=True):
response = self.client.post(
f"/api/projects/{self.team.id}/hog_functions/",
data={
Expand Down
4 changes: 3 additions & 1 deletion posthog/settings/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,4 +418,6 @@ def static_varies_origin(headers, path, url):
REMOTE_CONFIG_CDN_PURGE_DOMAINS = get_list(os.getenv("REMOTE_CONFIG_CDN_PURGE_DOMAINS", ""))

# Whether to allow modification of transformation code
HOG_TRANSFORMATIONS_ENABLED = get_from_env("HOG_TRANSFORMATIONS_ENABLED", False, type_cast=str_to_bool)
HOG_TRANSFORMATIONS_CUSTOM_HOG_ENABLED = get_from_env(
"HOG_TRANSFORMATIONS_CUSTOM_HOG_ENABLED", False, type_cast=str_to_bool
)

0 comments on commit 634e27e

Please sign in to comment.