diff --git a/viewer/cset_upload.py b/viewer/cset_upload.py index cfe8cbde..b652bd4f 100644 --- a/viewer/cset_upload.py +++ b/viewer/cset_upload.py @@ -445,7 +445,6 @@ def set_descriptions(self, filename, computed_set: ComputedSet) -> List[str]: return mols def task(self) -> ComputedSet: - user = User.objects.get(id=self.user_id) sdf_filename = str(self.sdf_filename) set_name = ''.join( @@ -493,7 +492,12 @@ def task(self) -> ComputedSet: + '-' + "".join(self.submitter_method.split()) ) - computed_set.owner_user = user + if self.user_id: + computed_set.owner_user = User.objects.get(id=self.user_id) + else: + # The User ID may only be None if AUTHENTICATE_UPLOAD is False. + # Here the ComputedSet owner will take on a default (anonymous) value. + assert settings.AUTHENTICATE_UPLOAD is False computed_set.save() # set descriptions and get all other mols back @@ -502,7 +506,7 @@ def task(self) -> ComputedSet: ) # process every other mol - for i in range(0, len(mols_to_process)): + for i in range(len(mols_to_process)): self.process_mol( mols_to_process[i], self.target, diff --git a/viewer/tasks.py b/viewer/tasks.py index 4debd34b..9a53e4d0 100644 --- a/viewer/tasks.py +++ b/viewer/tasks.py @@ -103,6 +103,8 @@ def process_compound_set(validate_output): for cset in csets: cset.delete() + # We expect a User ID, but it may be None. + # If AUTHENTICATE_UPLOAD is False the User ID will be None. save_mols = MolOps( user_id=params['user_id'], sdf_filename=params['sdf'], diff --git a/viewer/views.py b/viewer/views.py index 0bd55484..65e80ad3 100644 --- a/viewer/views.py +++ b/viewer/views.py @@ -397,7 +397,8 @@ def post(self, request): update_set = request.POST.get('update_set') logger.info( - '+ UploadCSet POST choice="%s" target="%s" update_set="%s"', + '+ UploadCSet POST user.id=%s choice="%s" target="%s" update_set="%s"', + user.id, choice, target, update_set,