Ensure used_in_edit is always set on new shots.

This commit is contained in:
2016-11-04 16:31:03 +01:00
parent 6f7090eedc
commit 5ee3c0d54f
2 changed files with 16 additions and 4 deletions

View File

@@ -79,6 +79,17 @@ def activity_after_creating_shots(nodes):
activity_after_creating_shot(node)
@only_for_shot
def set_default_used_in_edit(shot):
"""Ensures that used_in_edit is always set."""
shot.setdefault('properties', {}).setdefault('used_in_edit', True)
def nodes_set_default_used_in_edit(nodes):
for node in nodes:
set_default_used_in_edit(node)
@only_for_shot
def activity_after_deleting_shot(shot):
register_shot_activity(shot, 'deleted shot "%s"' % shot['name'])
@@ -86,6 +97,7 @@ def activity_after_deleting_shot(shot):
def setup_app(app):
app.on_replaced_nodes += activity_after_replacing_shot
app.on_insert_nodes += nodes_set_default_used_in_edit
app.on_inserted_nodes += activity_after_creating_shots
app.on_deleted_item_nodes += activity_after_deleting_shot
app.on_deleted_resource_nodes += activity_after_deleting_shot

View File

@@ -347,7 +347,7 @@ class PatchShotTest(AbstractShotTest):
url = '/api/nodes/%s' % shot._id
dbnode = self.get(url, auth_token='token').json()
self.assertNotIn('used_in_edit', dbnode['properties'])
self.assertTrue(dbnode['properties']['used_in_edit'])
patch = {'op': 'unlink'}
self.patch(url, json=patch, auth_token='token')
@@ -383,12 +383,12 @@ class PatchShotTest(AbstractShotTest):
self.create_valid_auth_token(ctd.EXAMPLE_PROJECT_OWNER_ID, 'token')
url = '/api/nodes/%s' % shot._id
self.patch(url, json={'op': 'unlink'}, auth_token='token')
dbnode = self.get(url, auth_token='token').json()
self.assertNotIn('used_in_edit', dbnode['properties'])
self.assertFalse(dbnode['properties']['used_in_edit'])
patch = {'op': 'relink'}
self.patch(url, json=patch, auth_token='token')
self.patch(url, json={'op': 'relink'}, auth_token='token')
dbnode = self.get(url, auth_token='token').json()
self.assertTrue(dbnode['properties']['used_in_edit'])