diff --git a/docker/ploughshares/app.py b/docker/ploughshares/app.py index a075787..86bd12b 100644 --- a/docker/ploughshares/app.py +++ b/docker/ploughshares/app.py @@ -308,6 +308,8 @@ def view_transaction(id): transaction = None prev_id = None next_id = None + prev_pending_id = None + next_pending_id = None try: with conn.cursor() as cur: @@ -325,6 +327,14 @@ def view_transaction(id): cur.execute('SELECT id FROM transactions WHERE id > %s ORDER BY id ASC LIMIT 1', (id,)) next_result = cur.fetchone() next_id = next_result['id'] if next_result else None + + cur.execute('SELECT id FROM transactions WHERE id < %s AND approved = FALSE ORDER BY id DESC LIMIT 1', (id,)) + prev_pending_result = cur.fetchone() + prev_pending_id = prev_pending_result['id'] if prev_pending_result else None + + cur.execute('SELECT id FROM transactions WHERE id > %s AND approved = FALSE ORDER BY id ASC LIMIT 1', (id,)) + next_pending_result = cur.fetchone() + next_pending_id = next_pending_result['id'] if next_pending_result else None except Exception as e: logger.error(f"Database error: {e}") abort(404) @@ -337,7 +347,7 @@ def view_transaction(id): if transaction is None: abort(404) - return render_template('view_transaction.html', transaction=transaction, documents=documents, prev_id=prev_id, next_id=next_id, version=VERSION, source = source) + return render_template('view_transaction.html', transaction=transaction, documents=documents, prev_id=prev_id, next_id=next_id, prev_pending_id=prev_pending_id, next_pending_id=next_pending_id, version=VERSION, source = source) @app.route('/document/') def view_document(document_id):