From 2a92fe70109946d8f405f3280024fb25a69b4da2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= <fpeters@entrouvert.com>
Date: Mon, 13 Apr 2020 14:12:59 +0200
Subject: [PATCH] misc: remove django-reversion dependency (#41641)

---
 debian/control                          |  1 -
 requirements.txt                        |  1 -
 setup.py                                |  1 -
 welco/kb/models.py                      |  2 --
 welco/kb/templates/kb/page_detail.html  |  1 -
 welco/kb/templates/kb/page_history.html | 24 ---------------
 welco/kb/templates/kb/page_version.html | 26 -----------------
 welco/kb/views.py                       | 39 -------------------------
 welco/settings.py                       |  2 --
 welco/urls.py                           |  2 --
 10 files changed, 99 deletions(-)
 delete mode 100644 welco/kb/templates/kb/page_history.html
 delete mode 100644 welco/kb/templates/kb/page_version.html

diff --git a/debian/control b/debian/control
index 2781bd2..fd4567b 100644
--- a/debian/control
+++ b/debian/control
@@ -12,7 +12,6 @@ Depends: ${misc:Depends}, ${python3:Depends},
     python3-gadjo,
     python3-requests (>= 2.11),
     python3-django-haystack (>= 2.4.0),
-    python3-django-reversion (>= 2.0.12),
     python3-django-taggit (>= 0.17.4),
     libjs-pdf (<< 1.1)
 Recommends: python3-django-mellon
diff --git a/requirements.txt b/requirements.txt
index 6aaed43..55415bc 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,5 +3,4 @@ gadjo
 django-select2
 -e git+https://git.entrouvert.org/debian/django-ckeditor.git#egg=django_ckeditor
 django-haystack
-django-reversion
 django-taggit
diff --git a/setup.py b/setup.py
index 2036ee2..1567303 100644
--- a/setup.py
+++ b/setup.py
@@ -112,7 +112,6 @@ setup(
         'gadjo',
         'django-ckeditor<4.5.4',
         'django-haystack<2.8',
-        'django-reversion>=2.0,<3',
         'django-taggit',
         'djangorestframework>=3.3, <3.8',
         'requests',
diff --git a/welco/kb/models.py b/welco/kb/models.py
index e89c720..1e3b817 100644
--- a/welco/kb/models.py
+++ b/welco/kb/models.py
@@ -19,11 +19,9 @@ from django.db import models
 from django.utils.translation import ugettext_lazy as _
 
 from ckeditor.fields import RichTextField
-import reversion
 from taggit.managers import TaggableManager
 
 
-@reversion.register
 class Page(models.Model):
     title = models.CharField(_('Title'), max_length=200)
     slug = models.SlugField(_('Slug'))
diff --git a/welco/kb/templates/kb/page_detail.html b/welco/kb/templates/kb/page_detail.html
index 9fb7842..34b9c3f 100644
--- a/welco/kb/templates/kb/page_detail.html
+++ b/welco/kb/templates/kb/page_detail.html
@@ -5,7 +5,6 @@
 <h2>{% trans 'Knowledge Base' %} - {{ object.title }}</h2>
 {% if can_manage %}
 <a rel="popup" href="{% url 'kb-page-delete' slug=object.slug %}">{% trans 'Delete' %}</a>
-<a href="{% url 'kb-page-history' slug=object.slug %}">{% trans 'History' %}</a>
 <a href="{% url 'kb-page-edit' slug=object.slug %}">{% trans 'Edit' %}</a>
 {% endif %}
 {% endblock %}
diff --git a/welco/kb/templates/kb/page_history.html b/welco/kb/templates/kb/page_history.html
deleted file mode 100644
index 46a1276..0000000
--- a/welco/kb/templates/kb/page_history.html
+++ /dev/null
@@ -1,24 +0,0 @@
-{% extends "kb/page_detail.html" %}
-{% load i18n %}
-
-{% block appbar %}
-<h2>{% trans 'Knowledge Base' %} - {{ object.title }}</h2>
-<a href="{% url 'kb-page-view' slug=object.slug %}">{% trans 'Back to page' %}</a>
-{% endblock %}
-
-{% block breadcrumb %}
-{{ block.super }}
-<a href=".">{% trans 'History' %}</a>
-{% endblock %}
-
-{% block content %}
-
-<div id="page-history">
-<ul>
-{% for version in versions_list %}
-<li>{{ version.revision.date_created }}, <a href="{% url 'kb-page-version' slug=object.slug version=version.id %}">{% trans 'view' %}</a></li>
-{% endfor %}
-</ul>
-</div>
-
-{% endblock %}
diff --git a/welco/kb/templates/kb/page_version.html b/welco/kb/templates/kb/page_version.html
deleted file mode 100644
index 106745c..0000000
--- a/welco/kb/templates/kb/page_version.html
+++ /dev/null
@@ -1,26 +0,0 @@
-{% extends "kb/page_detail.html" %}
-{% load i18n %}
-
-{% block appbar %}
-<h2>{% trans 'Knowledge Base' %} - {{ object.title }}</h2>
-<a href="{% url 'kb-page-view' slug=object.slug %}">{% trans 'Back to page' %}</a>
-<a href="{% url 'kb-page-history' slug=object.slug %}">{% trans 'History' %}</a>
-{% endblock %}
-
-{% block content %}
-
-<div class="old-version warning-notice">
-<p>
-{% trans 'Warning: this is an old version of this page.' %}
-</p>
-
-<form method="POST">
-  {% csrf_token %}
-  <button>{% trans 'Revert to this version' %}</button>
-</form>
-</div>
-
-{{block.super}}
-
-{% endblock %}
-
diff --git a/welco/kb/views.py b/welco/kb/views.py
index 4c21b7c..b2010d2 100644
--- a/welco/kb/views.py
+++ b/welco/kb/views.py
@@ -31,7 +31,6 @@ from django.views.generic import (DetailView, CreateView, UpdateView,
 from haystack.forms import SearchForm
 from haystack.generic_views import SearchView
 from haystack.query import SearchQuerySet
-from reversion.models import Version
 from taggit.models import Tag
 
 from .models import Page
@@ -134,44 +133,6 @@ class PageSearchView(SearchView):
 page_search = login_required(PageSearchView.as_view())
 
 
-class PageHistoryView(DetailView):
-    model = Page
-    template_name = 'kb/page_history.html'
-
-    def dispatch(self, request, *args, **kwargs):
-        check_request_perms(request)
-        return super(PageHistoryView, self).dispatch(request, *args, **kwargs)
-
-    def get_context_data(self, **kwargs):
-        context = super(PageHistoryView, self).get_context_data(**kwargs)
-        context['versions_list'] = Version.objects.get_for_object(self.get_object())
-        return context
-
-page_history = login_required(PageHistoryView.as_view())
-
-
-class PageVersionView(DetailView):
-    model = Page
-    template_name = 'kb/page_version.html'
-
-    def dispatch(self, request, *args, **kwargs):
-        check_request_perms(request)
-        return super(PageVersionView, self).dispatch(request, *args, **kwargs)
-
-    def get_context_data(self, **kwargs):
-        context = super(PageVersionView, self).get_context_data(**kwargs)
-        context['object'] = Version.objects.get(id=self.kwargs.get('version')).object
-        self.kwargs.get('version')
-        return context
-
-    def post(self, request, *args, **kwargs):
-        version = Version.objects.get(id=self.kwargs.get('version'))
-        version.revision.revert()
-        return HttpResponseRedirect(self.get_object().get_absolute_url())
-
-page_version = login_required(PageVersionView.as_view())
-
-
 class KbZone(TemplateView):
     template_name = 'kb/zone.html'
 
diff --git a/welco/settings.py b/welco/settings.py
index d307d42..03f93d1 100644
--- a/welco/settings.py
+++ b/welco/settings.py
@@ -41,7 +41,6 @@ INSTALLED_APPS = (
     'django.contrib.staticfiles',
     'ckeditor',
     'haystack',
-    'reversion',
     'taggit',
     'welco.sources.counter',
     'welco.sources.mail',
@@ -61,7 +60,6 @@ MIDDLEWARE = (
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware',
     'django.middleware.clickjacking.XFrameOptionsMiddleware',
-    'reversion.middleware.RevisionMiddleware',
 )
 
 ROOT_URLCONF = 'welco.urls'
diff --git a/welco/urls.py b/welco/urls.py
index 6350ef8..0ea3085 100644
--- a/welco/urls.py
+++ b/welco/urls.py
@@ -53,8 +53,6 @@ urlpatterns = [
     url(r'^ajax/kb/(?P<slug>[\w-]+)/$', welco.kb.views.page_detail_fragment, name='kb-page-fragment'),
     url(r'^kb/(?P<slug>[\w-]+)/edit$', welco.kb.views.page_edit, name='kb-page-edit'),
     url(r'^kb/(?P<slug>[\w-]+)/delete$', welco.kb.views.page_delete, name='kb-page-delete'),
-    url(r'^kb/(?P<slug>[\w-]+)/history$', welco.kb.views.page_history, name='kb-page-history'),
-    url(r'^kb/(?P<slug>[\w-]+)/version/(?P<version>\w+)/$', welco.kb.views.page_version, name='kb-page-version'),
 
     url(r'^ajax/contacts$', welco.contacts.views.zone, name='contacts-zone'),
     url(r'^contacts/search/json/$', welco.contacts.views.search_json, name='contacts-search-json'),
-- 
2.26.0

