Skip to content

Commit

Permalink
Update related cleanup function
Browse files Browse the repository at this point in the history
Updates the related cleanup function to use the get_latest_hepsubmission function to ensure it always gets the most recent version, as prior versions may/will not have related data.
  • Loading branch information
ItIsJordan committed Nov 15, 2023
1 parent ee8cf60 commit 6ac785c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions hepdata/modules/records/utils/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,11 @@ def cleanup_data_related_recid(recid):
:param recid: The record ID of the HEPSubmission object to be cleaned
:return:
"""
hepsubmission = HEPSubmission.query.filter_by(publication_recid=recid).first()
for related in hepsubmission.related_recids:
db.session.delete(related)
db.session.commit()
hepsubmission = get_latest_hepsubmission(publication_recid=recid)
if hepsubmission:
for related in hepsubmission.related_recids:
db.session.delete(related)
db.session.commit()


def process_data_file(recid, version, basepath, data_obj, datasubmission, main_file_path, tablenum, overall_status):
Expand Down

0 comments on commit 6ac785c

Please sign in to comment.