|
6 | 6 | from arxiv.auth.auth import scopes |
7 | 7 | from arxiv.auth.auth.decorators import scoped |
8 | 8 | from arxiv.base import logging, alerts |
9 | | -from flask import Blueprint, make_response, redirect, request, render_template, url_for, send_file |
| 9 | +from flask import Blueprint, make_response, redirect, request, render_template, url_for, send_file, current_app |
10 | 10 | from flask import Response as FResponse |
11 | 11 | from markupsafe import Markup |
12 | 12 | from werkzeug import Response as WResponse |
@@ -223,21 +223,13 @@ def create_replacement(submission_id: str): |
223 | 223 |
|
224 | 224 |
|
225 | 225 | @UI.route('/<submission_id>', methods=["GET"]) |
226 | | -@scoped(scopes.VIEW_SUBMISSION, authorizer=is_owner, |
227 | | - unauthorized=redirect_to_login) |
228 | | -def submission_status(submission_id: str) -> Response: |
229 | | - """Display the current state of the submission.""" |
230 | | - return handle(cntrls.submission_status, 'submit/status.html', |
231 | | - 'Submission status', submission_id) |
232 | | - |
233 | | - |
234 | 226 | @UI.route('/<submission_id>/edit', methods=['GET']) |
235 | 227 | @scoped(scopes.VIEW_SUBMISSION, authorizer=is_owner, |
236 | 228 | unauthorized=redirect_to_login) |
237 | 229 | @flow_control() |
238 | 230 | def submission_edit(submission_id: str) -> Response: |
239 | 231 | """Redirects to current edit stage of the submission.""" |
240 | | - return handle(cntrls.submission_edit, 'submit/status.html', |
| 232 | + return handle(cntrls.submission_edit, 'debug/status.html', |
241 | 233 | 'Submission status', submission_id, flow_controlled=True) |
242 | 234 |
|
243 | 235 | # # TODO: remove me!! |
@@ -651,6 +643,39 @@ def debug_logout() -> Response: |
651 | 643 | return response |
652 | 644 |
|
653 | 645 |
|
| 646 | +@UI.route('/debug/mail', methods=["GET"]) |
| 647 | +@scoped(scopes.VIEW_SUBMISSION, authorizer=is_admin_or_dev, |
| 648 | + unauthorized=redirect_to_login) |
| 649 | +def get_debug_mail() -> Response: |
| 650 | + """Dev-only: show email captured by the in-memory email service. |
| 651 | +
|
| 652 | + Only available when ``EMAIL_MODE`` is ``TESTING`` and the configured |
| 653 | + email service is the in-memory ``EmailInMemory`` capture. In any other |
| 654 | + mode real mail was dispatched and there is nothing held in process to |
| 655 | + show, so this returns 404. |
| 656 | + """ |
| 657 | + from submit_ce.implementations.email.email_in_memory import EmailInMemory |
| 658 | + if settings.EMAIL_MODE != "TESTING": |
| 659 | + raise NotFound() |
| 660 | + service = current_app.api.get_email_service() |
| 661 | + if not isinstance(service, EmailInMemory): |
| 662 | + raise NotFound() |
| 663 | + return make_response( |
| 664 | + render_template('debug/debug_mail.html', |
| 665 | + pagetitle='Debug Mail', |
| 666 | + emails=service.sent), |
| 667 | + 200) |
| 668 | + |
| 669 | + |
| 670 | +@UI.route('/debug/<submission_id>', methods=["GET"]) |
| 671 | +@scoped(scopes.VIEW_SUBMISSION, authorizer=is_admin_or_dev, |
| 672 | + unauthorized=redirect_to_login) |
| 673 | +def get_debug_submission(submission_id: Optional[str] = None) -> Response: |
| 674 | + """Display the current state of the submission.""" |
| 675 | + return handle(cntrls.submission_status, 'debug/status.html', |
| 676 | + 'Submission status', submission_id) |
| 677 | + |
| 678 | + |
654 | 679 | @UI.route('/debug/<submission_id>/events', methods=["GET"]) |
655 | 680 | @scoped(scopes.VIEW_SUBMISSION, authorizer=is_admin_or_dev, |
656 | 681 | unauthorized=redirect_to_login) |
|
0 commit comments