Skip to content

Commit

Permalink
fix(data-management): fix event definition loading (#19808)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusandra authored Jan 17, 2024
1 parent ed56f24 commit 8c4b1d2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const definitionLogic = kea<definitionLogicType>([
hasAvailableFeature(AvailableFeature.INGESTION_TAXONOMY) ||
hasAvailableFeature(AvailableFeature.TAGGING),
],
isEvent: [() => [router.selectors.location], ({ pathname }) => pathname.startsWith(urls.eventDefinitions())],
isEvent: [() => [router.selectors.location], ({ pathname }) => pathname.includes(urls.eventDefinitions())],
isProperty: [(s) => [s.isEvent], (isEvent) => !isEvent],
singular: [(s) => [s.isEvent], (isEvent): string => (isEvent ? 'event' : 'property')],
breadcrumbs: [
Expand Down
6 changes: 3 additions & 3 deletions posthog/api/event_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,19 @@ def get_object(self):
):
from ee.models.event_definition import EnterpriseEventDefinition

enterprise_event = EnterpriseEventDefinition.objects.filter(id=id).first()
enterprise_event = EnterpriseEventDefinition.objects.filter(id=id, team_id=self.team_id).first()
if enterprise_event:
return enterprise_event

non_enterprise_event = EventDefinition.objects.get(id=id)
non_enterprise_event = EventDefinition.objects.get(id=id, team_id=self.team_id)
new_enterprise_event = EnterpriseEventDefinition(
eventdefinition_ptr_id=non_enterprise_event.id, description=""
)
new_enterprise_event.__dict__.update(non_enterprise_event.__dict__)
new_enterprise_event.save()
return new_enterprise_event

return EventDefinition.objects.get(id=id)
return EventDefinition.objects.get(id=id, team_id=self.team_id)

def get_serializer_class(self) -> Type[serializers.ModelSerializer]:
serializer_class = self.serializer_class
Expand Down
6 changes: 3 additions & 3 deletions posthog/api/property_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,17 +573,17 @@ def get_object(self):
except ImportError:
pass
else:
enterprise_property = EnterprisePropertyDefinition.objects.filter(id=id).first()
enterprise_property = EnterprisePropertyDefinition.objects.filter(id=id, team_id=self.team_id).first()
if enterprise_property:
return enterprise_property
non_enterprise_property = PropertyDefinition.objects.get(id=id)
non_enterprise_property = PropertyDefinition.objects.get(id=id, team_id=self.team_id)
new_enterprise_property = EnterprisePropertyDefinition(
propertydefinition_ptr_id=non_enterprise_property.id, description=""
)
new_enterprise_property.__dict__.update(non_enterprise_property.__dict__)
new_enterprise_property.save()
return new_enterprise_property
return PropertyDefinition.objects.get(id=id)
return PropertyDefinition.objects.get(id=id, team_id=self.team_id)

@extend_schema(parameters=[PropertyDefinitionQuerySerializer])
def list(self, request, *args, **kwargs):
Expand Down

0 comments on commit 8c4b1d2

Please sign in to comment.