From 2f38abbde267c86c3d0a74bc84d84bb0e8fb1fd0 Mon Sep 17 00:00:00 2001 From: karser Date: Thu, 29 Dec 2022 10:12:55 +0200 Subject: [PATCH] don't reimport for loadedFromSingleFile ChildMindInstitute/mindlogger-applet-builder#910 --- girderformindlogger/external/fix_flankers.py | 13 +++++++++++++ girderformindlogger/utility/jsonld_expander.py | 6 +++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/girderformindlogger/external/fix_flankers.py b/girderformindlogger/external/fix_flankers.py index 20018f479..0f23ea581 100644 --- a/girderformindlogger/external/fix_flankers.py +++ b/girderformindlogger/external/fix_flankers.py @@ -91,6 +91,14 @@ def find_applet_by_activity(activity): return applet +def fix_editing(applet): + if 'editing' in applet['meta']['applet'] and applet['meta']['applet']['editing']: + applet['meta']['applet']['editing'] = False + Folder().setMetadata(folder=applet, metadata=applet['meta']) + return True + return False + + def fix_flankers(activityId, reImport = True): activityUrl = 'https://raw.githubusercontent.com/ChildMindInstitute/mindlogger-flanker-applet/master/activities/Flanker/Flanker_schema' print('Refreshing affected activity id=' + str(activityId)) @@ -110,6 +118,7 @@ def fix_flankers(activityId, reImport = True): jsonld_expander.formatLdObject(activity, 'activity', None, refreshCache=True, reimportFromUrl=False) applet = find_applet_by_activity(activity) print('Refreshing affected applet id:', str(applet['_id'])) + fix_editing(applet) jsonld_expander.formatLdObject(applet, 'applet', None, refreshCache=True, reimportFromUrl=False) @@ -157,3 +166,7 @@ def get_activities_for_account(email): main(activity['_id']) # activityId = ObjectId('6290ed45e50eef5716db579c') # main(activityId) + # fix_editing for applet + # applet = Folder().findOne(query={'_id': ObjectId('627d1e2de50eef3d5567ee55')}) + # if fix_editing(applet): + # jsonld_expander.formatLdObject(applet, 'applet', None, refreshCache=True, reimportFromUrl=False) diff --git a/girderformindlogger/utility/jsonld_expander.py b/girderformindlogger/utility/jsonld_expander.py index dd7c75d9a..9d83bcc86 100644 --- a/girderformindlogger/utility/jsonld_expander.py +++ b/girderformindlogger/utility/jsonld_expander.py @@ -1819,7 +1819,7 @@ def formatLdObject( activityIDMapping = {} for activity in activities: - formatted = formatLdObject(activity, 'activity', user, refreshCache=refreshCache, reimportFromUrl=reimportFromUrl) + formatted = formatLdObject(activity, 'activity', user, refreshCache=refreshCache, reimportFromUrl=False) if refreshCache: createCache(activity, formatted, 'activity', user, modelClasses) @@ -1835,7 +1835,7 @@ def formatLdObject( activityFlowIdMapping = {} for activityFlow in activityFlows: - formatted = formatLdObject(activityFlow, 'activityFlow', user, refreshCache=refreshCache, reimportFromUrl=reimportFromUrl) + formatted = formatLdObject(activityFlow, 'activityFlow', user, refreshCache=refreshCache, reimportFromUrl=False) if refreshCache: createCache(activityFlow, formatted, 'activityFlow', user, modelClasses) @@ -1884,7 +1884,7 @@ def formatLdObject( if not 'identifier' in item['meta']: item['meta']['identifier'] = '{}/{}'.format(str(obj['_id']), str(item['_id'])) identifier = item['meta']['identifier'] - itemFormatted = formatLdObject(item, 'screen', user, refreshCache=refreshCache, reimportFromUrl=reimportFromUrl) + itemFormatted = formatLdObject(item, 'screen', user, refreshCache=refreshCache, reimportFromUrl=False) activity['items'][identifier] = itemFormatted key = '{}/{}'.format(str(item['meta']['activityId']), str(item['_id']))