Skip to content

Commit

Permalink
Merge pull request #4785 from rtibbles/acting_up
Browse files Browse the repository at this point in the history
Ensure actor_id gets passed in case channel creation API endpoint ends up in undeleting channel
  • Loading branch information
rtibbles authored Oct 9, 2024
2 parents dfffcb6 + bcc2873 commit 0232932
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
17 changes: 17 additions & 0 deletions contentcuration/contentcuration/tests/views/test_views_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,23 @@ def test_creates_channel(self):
except Channel.DoesNotExist:
self.fail("Channel was not created")

def test_updates_already_created_channel(self):
"""
Test that it creates a channel with the given id
"""
deleted_channel = channel()
deleted_channel.deleted = True
deleted_channel.save(actor_id=self.user.id)
self.channel_data.update({"name": "Updated name", "id": deleted_channel.id})
self.admin_client().post(
reverse_lazy("api_create_channel"), data={"channel_data": self.channel_data}, format="json"
)
try:
c = Channel.objects.get(id=self.channel_data["id"])
self.assertEqual(c.name, "Updated name")
except Channel.DoesNotExist:
self.fail("Channel was not created")

def test_creates_cheftree(self):
"""
Test that it creates a channel with the given id
Expand Down
4 changes: 3 additions & 1 deletion contentcuration/contentcuration/views/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,9 @@ def create_channel(channel_data, user):
if files:
map_files_to_node(user, channel.chef_tree, files)
channel.chef_tree.save()
channel.save()
# If the channel was previously deleted, this save will undelete it
# so will require the actor_id to be set
channel.save(actor_id=user.id)

# Delete chef tree if it already exists
if old_chef_tree and old_chef_tree != channel.staging_tree:
Expand Down

0 comments on commit 0232932

Please sign in to comment.