Skip to content

Commit

Permalink
Added revert button on compare view
Browse files Browse the repository at this point in the history
  • Loading branch information
jjarthur committed Mar 24, 2020
1 parent 49494a5 commit 495b4d5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions reversion_compare/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions reversion_compare/templates/reversion-compare/compare.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@
{% endblocktrans %}
</p>
&lsaquo; <a href="{{history_url}}">{% trans "Go back to history list" %}</a>
&vert;
<a href="{{save_url}}">{% trans "Revert to this version" %}</a> &rsaquo;

{% include "reversion-compare/compare_partial.html" %}

&lsaquo; <a href="{{history_url}}">{% trans "Go back to history list" %}</a>
&vert;
<a href="{{save_url}}">{% trans "Revert to this version" %}</a> &rsaquo;
</div>
{% endblock %}

0 comments on commit 495b4d5

Please sign in to comment.