diff --git a/app/routes/issues.py b/app/routes/issues.py index 0814243..2676ff1 100644 --- a/app/routes/issues.py +++ b/app/routes/issues.py @@ -56,10 +56,20 @@ def index(): q = q.filter(Issue.status == status_filter) issues = q.paginate(page=page, per_page=25, error_out=False) + + # Build a set of issue IDs the current user is following so the template + # can render the following badge and inline unfollow button without an + # additional query per row. + followed_ids = { + f.issue_id + for f in IssueFollower.query.filter_by(user_id=current_user.id).all() + } + return render_template('issues/list.html', issues=issues, severity_filter=severity_filter, - status_filter=status_filter) + status_filter=status_filter, + followed_ids=followed_ids) # ── View / Update ───────────────────────────────────────────────────────────── @@ -276,7 +286,11 @@ def unfollow(issue_id): flash('You have unfollowed this issue.', 'info') else: flash('You are not following this issue.', 'info') - return redirect(url_for('issues.view', issue_id=issue_id)) + + # Respect an explicit next URL (e.g. return to the list page). + # Fall back to the issue view if none is provided. + next_url = request.form.get('next') or url_for('issues.view', issue_id=issue_id) + return redirect(next_url) # ── Standalone create ───────────────────────────────────────────────────────── diff --git a/app/templates/issues/list.html b/app/templates/issues/list.html index 207e744..a138f9a 100644 --- a/app/templates/issues/list.html +++ b/app/templates/issues/list.html @@ -45,11 +45,19 @@
| Reported | Severity | Facility / Area | -Description | Status | Assigned | |
|---|---|---|---|---|---|---|
| Reported | +Severity | +Facility / Area | +Description | +Status | +Assigned | ++ |
| {{ issue.reported_at.strftime('%Y-%m-%d %H:%M') }} | @@ -71,8 +79,27 @@ {% if issue.assigned_user %}{{ issue.assigned_user.username }} {% else %}—{% endif %} | -- + | + {# Following badge + inline unfollow #} + {% if is_following %} + + Following + + + {% endif %} + + {% if current_user.role in ['admin','supervisor'] or issue.assigned_to == current_user.id %} Edit {% else %} @@ -85,19 +112,22 @@ |