From 495b4d5378d3835faade4b8b13edaec189902251 Mon Sep 17 00:00:00 2001
From: jjarthur
Date: Tue, 24 Mar 2020 18:00:09 +1100
Subject: [PATCH] Added revert button on compare view
---
reversion_compare/admin.py | 7 ++++---
reversion_compare/templates/reversion-compare/compare.html | 4 ++++
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/reversion_compare/admin.py b/reversion_compare/admin.py
index 06b4a43..4bf016d 100644
--- a/reversion_compare/admin.py
+++ b/reversion_compare/admin.py
@@ -175,13 +175,14 @@ def compare_view(self, request, object_id, extra_context=None):
"version1": version1,
"version2": version2,
"changelist_url": reverse(f"{self.admin_site.name}:{opts.app_label}_{opts.model_name}_changelist"),
- "change_url": reverse(
- f"{self.admin_site.name}:{opts.app_label}_{opts.model_name}_change", args=(quote(obj.pk),)
- ),
"original": obj,
"history_url": reverse(
f"{self.admin_site.name}:{opts.app_label}_{opts.model_name}_history", args=(quote(obj.pk),)
),
+ "save_url": reverse(
+ f"{self.admin_site.name}:{opts.app_label}_{opts.model_name}_revision",
+ args=(quote(version1.object_id), version1.id),
+ ),
}
# don't use urlencode with dict for generate prev/next-urls
diff --git a/reversion_compare/templates/reversion-compare/compare.html b/reversion_compare/templates/reversion-compare/compare.html
index 8ba701f..dd1ef65 100644
--- a/reversion_compare/templates/reversion-compare/compare.html
+++ b/reversion_compare/templates/reversion-compare/compare.html
@@ -47,9 +47,13 @@
{% endblocktrans %}
‹ {% trans "Go back to history list" %}
+ |
+ {% trans "Revert to this version" %} ›
{% include "reversion-compare/compare_partial.html" %}
‹ {% trans "Go back to history list" %}
+ |
+ {% trans "Revert to this version" %} ›
{% endblock %}