Skip to content

Commit

Permalink
Merge pull request #65 from seasidesparrow/maint.20240510
Browse files Browse the repository at this point in the history
Maint.20240510
  • Loading branch information
seasidesparrow authored Jun 11, 2024
2 parents fa95000 + f23ccc2 commit 549e92c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
20 changes: 11 additions & 9 deletions journalsmanager/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ def task_delete_masterid(masterid):
qxo = session.query(editctrl).filter(editctrl.editstatus=='active').all()
if len(qxo) > 0:
checkouts = [getattr(x, "tablename") for x in qxo]
raise ActiveCheckoutException("You cannot delete via the command line if any sheets are currently checked out: %s" % (",".join(checkouts)))
raise ActiveCheckoutException("Deletion failed because the following tables are checked out: %s" % (",".join(checkouts)))
else:
new_status = editctrl(tablename="master",
editstatus="active",
Expand All @@ -839,7 +839,7 @@ def task_delete_masterid(masterid):
session.commit()
editid = new_status.editid

for dbname in ['names', 'abbrevs', 'idents', 'raster', 'titlehistory', 'master']:
for dbname in ['names', 'abbrevs', 'idents', 'raster', 'titlehistory', 'refsource', 'master']:
db = TABLES.get(dbname, None)
dbhist = TABLES.get(dbname+'_hist', None)

Expand All @@ -859,12 +859,13 @@ def task_delete_masterid(masterid):
if backup_rows:
try:
with app.session_scope() as session:
for row in backup_rows:
data = dbhist()
for k,v in row.items():
setattr(data, k, v)
session.add(data)
session.commit()
if dbname != 'refsource':
for row in backup_rows:
data = dbhist()
for k,v in row.items():
setattr(data, k, v)
session.add(data)
session.commit()
for row in delete_rows:
session.query(db).filter(db.masterid==row).delete()
session.commit()
Expand All @@ -876,5 +877,6 @@ def task_delete_masterid(masterid):
logger.debug("Nothing for table %s" % dbname)
task_setstatus(editid, "completed")
except Exception as err:
task_setstatus(editid, "failed")
if editid:
task_setstatus(editid, "failed")
raise Exception("Failed to delete masterid %s: %s" % (masterid, err))
1 change: 1 addition & 0 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ def main():
if masterid:
try:
tasks.task_delete_masterid(masterid)
tasks.task_export_classic_files()
except Exception as err:
logger.warning("Error deleting bibstem %s: %s" % (args.delete_stem, err))
else:
Expand Down

0 comments on commit 549e92c

Please sign in to comment.