diff --git a/routes/main.py b/routes/main.py index 7dba0fa..dd76b27 100644 --- a/routes/main.py +++ b/routes/main.py @@ -31,6 +31,7 @@ create_feedback_record, find_feedback, list_feedback, + next_feedback_status_options, save_feedback, update_feedback_status, ) @@ -1123,12 +1124,15 @@ def admin_feedback(): status_filter = '' if category_filter not in FEEDBACK_CATEGORY_LABELS: category_filter = '' + feedback_records = list_feedback( + status=status_filter or None, + category=category_filter or None, + ) + for record in feedback_records: + record['next_statuses'] = next_feedback_status_options(record.get('status')) return render_template( 'admin_feedback.html', - feedback_records=list_feedback( - status=status_filter or None, - category=category_filter or None, - ), + feedback_records=feedback_records, feedback_statuses=FEEDBACK_STATUS_OPTIONS, feedback_categories=FEEDBACK_CATEGORIES, status_filter=status_filter, diff --git a/services/feedback.py b/services/feedback.py index 8e4ac83..fcc02bb 100644 --- a/services/feedback.py +++ b/services/feedback.py @@ -45,6 +45,18 @@ } +def next_feedback_status_options(current_status: str | None) -> tuple[tuple[str, str], ...]: + """Return only the valid next workflow choices in display order.""" + + allowed_statuses = _FEEDBACK_STATUS_TRANSITIONS.get( + str(current_status or "").strip(), + set(), + ) + return tuple( + option for option in FEEDBACK_STATUS_OPTIONS if option[0] in allowed_statuses + ) + + class FeedbackValidationError(ValueError): """Raised when a feedback submission cannot be accepted safely.""" diff --git a/templates/admin_feedback.html b/templates/admin_feedback.html index f923f84..74e76a3 100644 --- a/templates/admin_feedback.html +++ b/templates/admin_feedback.html @@ -115,6 +115,12 @@ text-align: center; } + .feedback-workflow-complete { + margin: 1rem 0 0; + color: var(--medium); + font-size: 0.875rem; + } + .feedback-filters, .feedback-status-form { display: flex; @@ -251,15 +257,16 @@

{{ record.subject }}

  • {{ item.status_label }} ·
  • {% endfor %} + {% if record.next_statuses %}
    - - + {% for value, label in record.next_statuses %} + {% endfor %}
    @@ -268,8 +275,11 @@

    {{ record.subject }}

    - +
    + {% else %} +

    该反馈已关闭,不能继续修改状态。

    + {% endif %} {% else %}
    还没有收到反馈。
    diff --git a/tests/test_feedback_lifecycle_notifications_profile.py b/tests/test_feedback_lifecycle_notifications_profile.py index 5f97385..66bc064 100644 --- a/tests/test_feedback_lifecycle_notifications_profile.py +++ b/tests/test_feedback_lifecycle_notifications_profile.py @@ -1,5 +1,6 @@ import json import os +import re import tempfile import unittest @@ -74,6 +75,15 @@ def submit_feedback(self): self.assertEqual(response.status_code, 302) return response.headers['Location'].rstrip('/').split('/')[-1] + def status_options_for(self, page, feedback_id): + """Return the status values rendered in one feedback item's form.""" + + action = ( + f'action="/admin/feedback/{feedback_id}/status">'.encode('utf-8') + ) + form = page.data.split(action, 1)[1].split(b'', 1)[0] + return re.findall(rb'