Skip to content

Commit

Permalink
don't reimport for loadedFromSingleFile ChildMindInstitute/mindlogger…
Browse files Browse the repository at this point in the history
  • Loading branch information
karser committed Dec 29, 2022
1 parent a91547a commit 2f38abb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 13 additions & 0 deletions girderformindlogger/external/fix_flankers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)


Expand Down Expand Up @@ -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)
6 changes: 3 additions & 3 deletions girderformindlogger/utility/jsonld_expander.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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']))
Expand Down

0 comments on commit 2f38abb

Please sign in to comment.