Editing the name of a shot/task/asset now logs the old and new name in the activity

This commit is contained in:
2016-11-10 09:34:32 +01:00
parent 1134bb82a0
commit 497bbb8273
4 changed files with 61 additions and 2 deletions

View File

@@ -76,8 +76,9 @@ def activity_after_replacing_shot_asset(shot_or_asset, original):
val_shot = val_shot[:80] + u''
if descr is None:
# A name change activity contains both the old and the new name.
descr = 'changed "%s" to "%s" in %s "%s"' % \
(human_key, val_shot, typename, shot_or_asset['name'])
(human_key, val_shot, typename, original['name'])
else:
descr = 'edited %s "%s"' % (typename, shot_or_asset['name'])

View File

@@ -154,7 +154,8 @@ def activity_after_replacing_task(task, original):
val_task = val_task[:80] + u''
if descr is None:
descr = 'changed %s to "%s" in task "%s"' % (human_key, val_task, task['name'])
# A name change activity contains both the old and the new name.
descr = 'changed %s to "%s" in task "%s"' % (human_key, val_task, original['name'])
else:
descr = 'edited task "%s"' % task['name']

View File

@@ -170,6 +170,34 @@ class PatchShotTest(AbstractShotTest):
self.assertEqual(123, dbnode['properties']['trim_start_in_frames'])
self.assertEqual(u'on_hold', dbnode['properties']['status'])
@responses.activate
def test_patch_activity(self):
"""Perform the edit, then check the resulting activity on the shot."""
shot = self.create_shot()
self.create_valid_auth_token(ctd.EXAMPLE_PROJECT_OWNER_ID, 'token')
url = '/api/nodes/%s' % shot._id
# Only change the name -- the activity should contain both the old and the new name.
old_name = shot['name']
new_name = u'"shot" is "geschoten" in Dutch'
patch = {
'op': 'from-blender',
'$set': {
'name': new_name,
}
}
self.patch(url, json=patch, auth_token='token')
with self.app.test_request_context():
acts = self.app.pillar_extensions['attract'].activities_for_node(shot._id)
self.assertEqual(2, acts['_meta']['total']) # Creation + edit
edit_act = acts['_items'][1]
self.assertIn(old_name, edit_act['verb'])
self.assertIn(new_name, edit_act['verb'])
pass
@responses.activate
def test_patch_from_web_happy(self):
shot = self.create_shot()

View File

@@ -84,6 +84,35 @@ class TaskWorkflowTest(AbstractAttractTest):
self.assertEqual(u'nööw name', found['name'])
self.assertEqual(u'€ ≠ ¥', found['description'])
@responses.activate
def test_edit_activity(self):
"""Perform the edit, then check the resulting activity on the shot."""
task = self.create_task()
# Only change the name -- the activity should contain both the old and the new name.
old_name = task['name']
new_name = u'nööw name'
with self.app.test_request_context():
# Log in as project admin user
pillar.auth.login_user(ctd.EXAMPLE_PROJECT_OWNER_ID)
self.mock_blenderid_validate_happy()
self.mngr.edit_task(task._id,
task_type=task['properties'].task_type,
name=new_name,
description=task.description,
status=u'todo',
_etag=task._etag)
with self.app.test_request_context():
acts = self.app.pillar_extensions['attract'].activities_for_node(task['_id'])
self.assertEqual(2, acts['_meta']['total']) # Creation + edit
edit_act = acts['_items'][1]
self.assertIn(old_name, edit_act['verb'])
self.assertIn(new_name, edit_act['verb'])
@responses.activate
def test_load_save_task(self):
"""Test for the Eve hooks -- we should be able to PUT what we GET."""