diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 35f0c2b42..e322b0eae 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,6 +8,10 @@ Changes ------- Unreleased ========== +2019-11-25: v0.6.6 +^^^^^^^^^^^^^^^^^^ +* :ambulance: Fix `POST response/applet/activity` route + 2019-11-25: v0.6.5 ^^^^^^^^^^^^^^^^^^ * :pencil: Allow invitations for roles other than "user" diff --git a/girderformindlogger/api/v1/response.py b/girderformindlogger/api/v1/response.py index 6c66ee749..12b15fe58 100644 --- a/girderformindlogger/api/v1/response.py +++ b/girderformindlogger/api/v1/response.py @@ -323,7 +323,16 @@ def getLast7Days( .errorResponse() .errorResponse('Write access was denied on the parent folder.', 403) ) - def createResponseItem(self, applet, activity, metadata, subject_id, pending, params): + def createResponseItem( + self, + applet, + activity, + metadata, + subject_id, + pending, + params + ): + from girderformindlogger.models.profile import Profile try: from girderformindlogger.utility.response import aggregateAndSave # TODO: pending @@ -348,26 +357,17 @@ def createResponseItem(self, applet, activity, metadata, subject_id, pending, pa informant['_id'] ) - # subject_id = [ - # getUserCipher( - # appletAssignment=assignment, - # user=subject_id - # ) for assignment in appletAssignments - # ][0] - try: - subject_info = Folder().load( - id=subject_id, - user=informant, - level=AccessType.READ - ) - except AccessException: - subject_info = {} - - metadata['subject'] = subject_info.get('meta', {}) if isinstance( - subject_info, - dict - ) else {} - metadata['subject']['@id'] = subject_id + subject_id = Profile().createProfile( + applet, + subject_id + ).get('_id') + + print(subject_id) + + if isinstance(metadata.get('subject'), dict): + metadata['subject']['@id'] = subject_id + else: + metadata['subject'] = {'@id': subject_id} now = datetime.now(tzlocal.get_localzone()) appletName=AppletModel().preferredName(applet) UserResponsesFolder = ResponseFolderModel().load( @@ -380,12 +380,13 @@ def createResponseItem(self, applet, activity, metadata, subject_id, pending, pa name=appletName, reuseExisting=True, public=False) AppletSubjectResponsesFolder = Folder().createFolder( parent=UserAppletResponsesFolder, parentType='folder', - name=subject_id, reuseExisting=True, public=False) + name=str(subject_id), reuseExisting=True, public=False) try: newItem = self._model.createResponseItem( folder=AppletSubjectResponsesFolder, - name=now.strftime("%Y-%m-%d-%H-%M-%S-%Z"), creator=informant, + name=now.strftime("%Y-%m-%d-%H-%M-%S-%Z"), + creator=informant, description="{} response on {} at {}".format( Folder().preferredName(activity), now.strftime("%Y-%m-%d"), @@ -419,6 +420,7 @@ def createResponseItem(self, applet, activity, metadata, subject_id, pending, pa if metadata: newItem = self._model.setMetadata(newItem, metadata) + print(metadata) if not pending: # create a Thread to calculate and save aggregates @@ -428,7 +430,7 @@ def createResponseItem(self, applet, activity, metadata, subject_id, pending, pa # agg.start() aggregateAndSave(newItem, informant) newItem['readOnly'] = True - + print(newItem) return(newItem) except: import sys, traceback diff --git a/girderformindlogger/models/__init__.py b/girderformindlogger/models/__init__.py index 29ac4e84e..f17d31029 100644 --- a/girderformindlogger/models/__init__.py +++ b/girderformindlogger/models/__init__.py @@ -177,12 +177,19 @@ def smartImport(IRI, user=None, refreshCache=False, modelType=None): from girderformindlogger.utility.jsonld_expander import reprolibCanonize MODELS = MODELS() - - model, modelType = MODELS['screen']().getFromUrl( + mt1 = "screen" if modelType is None else modelType + model, modelType = MODELS[mt1]().getFromUrl( IRI, user=user, refreshCache=refreshCache ) + if mt1!=modelType: + MODELS[mt1]().remove(model) + model, modelType = MODELS[modelType]().getFromUrl( + IRI, + user=user, + refreshCache=refreshCache + ) return(( modelType, model, diff --git a/girderformindlogger/models/applet.py b/girderformindlogger/models/applet.py index 8df2f66ce..a50aa4e09 100644 --- a/girderformindlogger/models/applet.py +++ b/girderformindlogger/models/applet.py @@ -164,6 +164,20 @@ def formatThenUpdate(self, applet, user): ) self.updateUserCacheAllRoles(user) + def getResponseData(self, appletId, reviewer, filter={}): + """ + Function to collect response data available to given reviewer. + + :param appletId: ID of applet for which to get response data + :type appletId: ObjectId or str + :param reviewer: Reviewer making request + :type reviewer: dict + :param filter: reduction criteria (not yet implemented) + :type filter: dict + :reutrns: TBD + """ + pass + def updateRelationship(self, applet, relationship): """ :param applet: Applet to update