Skip to content

Commit

Permalink
Merge pull request #1127 from mcneilco/ACAS-718
Browse files Browse the repository at this point in the history
ACAS-718: Fallback LR ownership update to service user
  • Loading branch information
brianbolt authored Oct 26, 2023
2 parents 62b36ab + 7df15ec commit 70dfbf7
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,25 @@ def make_acas_live_report(api, compound_ids, assays_to_add, experiment_code, log
lr = LiveReport(experiment_code, "Contains the data just loaded", project_id=project_id)

lr = api.create_live_report(lr)
#change LR owner to logged in user
lr.owner = logged_in_user

#put the LR in the Autogenerated ACAS Reports folder
lr.tags = [folder_id]
#Make the LR read-only
if readonly:
lr.update_policy = LiveReport.NEVER
#Update LR
api.update_live_report(lr.id, lr)

lr = api.update_live_report(lr.id, lr)

# Attempt to set the owner to the logged in user but fall back if there is a permissions error (user may not have LD or project access in LD)
original_owner = lr.owner
try:
lr.owner = logged_in_user
lr = api.update_live_report(lr.id, lr)
except Exception as e:
eprint("Unable to set owner to " + logged_in_user + " due to error: " + str(e))
# Set the original owner back so that we can continue with the LR updates
lr.owner = original_owner
eprint("Live Report owner will be:" + str(lr.owner))

lr_id = int(lr.id)
eprint("Live Report ID is:" + str(lr_id))
Expand Down

0 comments on commit 70dfbf7

Please sign in to comment.