Fix unassign from device detail redirecting to dashboard
Pass a 'next' hidden field from the device detail unassign form so the route redirects back to the device page instead of the dashboard.
This commit is contained in:
@@ -205,7 +205,8 @@ def create_app(config_object="config"):
|
||||
battery.device_id = None
|
||||
db.commit()
|
||||
flash(f"{battery.label} unassigned and marked available.", "success")
|
||||
return redirect(url_for("dashboard"))
|
||||
next_url = request.form.get("next", "")
|
||||
return redirect(next_url if next_url.startswith("/") else url_for("dashboard"))
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
# Battery — retire
|
||||
|
||||
@@ -95,6 +95,7 @@ function addInstallRow() {
|
||||
<td class="text-muted">{{ b.notes or '—' }}</td>
|
||||
<td>
|
||||
<form class="inline" method="post" action="{{ url_for('battery_unassign', battery_id=b.id) }}">
|
||||
<input type="hidden" name="next" value="{{ url_for('device_detail', device_id=device.id) }}">
|
||||
<button class="btn btn-sm btn-warning" type="submit">Unassign</button>
|
||||
</form>
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user