Skip to content

Commit

Permalink
Updates Action without ignoring created_by (#1448)
Browse files Browse the repository at this point in the history
* Partly fixes #1431 to avoid changes to created_by

* Adds created_by to test_create_and_update_action

* Update action.py

* Update action.py

Check for created_by in data before deleting it

Co-authored-by: anna <ms.annaphilips@gmail.com>
  • Loading branch information
Algogator and Algogator authored Aug 18, 2020
1 parent 58ff0ed commit edca315
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions posthog/api/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ def update(self, request: request.Request, *args: Any, **kwargs: Any) -> Respons
)

serializer = ActionSerializer(action, context={"request": request})
if 'created_by' in request.data:
del request.data['created_by']
serializer.update(action, request.data)
action.is_calculating = True
calculate_action.delay(action_id=action.pk)
Expand Down
1 change: 1 addition & 0 deletions posthog/api/test/test_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def test_create_and_update_action(self, patch_delay):
},
{"href": "/a-new-link"},
],
"created_by" : {'id': 1, 'distinct_id': 'BLKJzxHq4z2d8P1icfpg5wo4eIHaSrMtnotkwdtD8Ok', 'first_name': 'person', 'email': 'person@email.com'},
},
content_type="application/json",
HTTP_ORIGIN="http://testserver",
Expand Down

0 comments on commit edca315

Please sign in to comment.