kopia lustrzana https://github.com/wagtail/wagtail
Replace revisions_index view with a redirect to page history
rodzic
ae56813f2a
commit
6931663c7f
|
@ -1,15 +0,0 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block titletag %}{% blocktrans with title=page.get_admin_display_title %}Revisions of {{ title }}{% endblocktrans %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% trans "Revisions of" as revisions_str %}
|
||||
{% include "wagtailadmin/shared/header.html" with title=revisions_str subtitle=page.get_admin_display_title icon="doc-empty-inverse" %}
|
||||
|
||||
<div class="nice-padding">
|
||||
<div id="revision-results" class="revisions">
|
||||
{% include "wagtailadmin/pages/revisions/results.html" %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -1,40 +0,0 @@
|
|||
{% load i18n wagtailadmin_tags %}
|
||||
{% load l10n %}
|
||||
|
||||
<table class="listing">
|
||||
<col width="100%" />
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<a href="{% url 'wagtailadmin_pages:revisions_index' page.id %}?ordering={% if ordering == "created_at" %}-{% endif %}created_at" class="icon icon-arrow-{% if ordering == "created_at" %}up-after{% elif ordering == "-created_at" %}down-after{% else %}down-after{% endif %} {% if ordering == "created_at" or ordering == "-created_at" %}teal{% endif %}">
|
||||
{% trans 'Revision date' %}
|
||||
</a>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if revisions %}
|
||||
{% page_permissions page as page_perms %}
|
||||
{% for revision in revisions %}
|
||||
<tr {% if revision == page.get_latest_revision %}class="index"{% endif %}>
|
||||
<td class="title">
|
||||
<div class="title-wrapper">
|
||||
<a href="{% url 'wagtailadmin_pages:revisions_revert' page.id revision.id %}">{{ revision.created_at }}</a>
|
||||
<span class="unbold">
|
||||
{% trans 'by' context 'points to a user who created a revision' %}<span class="avatar small"><img src="{% avatar_url revision.user size=25 %}" alt="" /></span>{{ revision.user }}
|
||||
</span>
|
||||
{% if revision == page.get_latest_revision %}({% trans 'Current draft' %}){% endif %}
|
||||
{% if revision == page.live_revision %}({% trans 'Live version' %}){% endif %}
|
||||
{% if revision.approved_go_live_at %}({% trans 'Scheduled for' %} {{ revision.approved_go_live_at }}) {% endif %}
|
||||
</div>
|
||||
|
||||
{% include "wagtailadmin/pages/revisions/_actions.html" %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% block no_results %}<tr><td class="no-results-message"><p>{% trans 'No revisions of this page exist' %}</p></td></tr>{% endblock %}
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
|
@ -1,9 +0,0 @@
|
|||
{% load i18n wagtailadmin_tags %}
|
||||
|
||||
{% if revisions %}
|
||||
{% include "wagtailadmin/pages/revisions/list.html" %}
|
||||
|
||||
{% include "wagtailadmin/shared/pagination_nav.html" with items=revisions linkurl="wagtailadmin_pages:revisions_index" %}
|
||||
{% else %}
|
||||
<p>{% blocktrans %}No revision of this page exist{% endblocktrans %}</p>
|
||||
{% endif %}
|
|
@ -3,8 +3,6 @@ from django.contrib.auth import get_user_model
|
|||
from django.contrib.auth.models import Group, Permission
|
||||
from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
from django.utils import formats
|
||||
from django.utils.dateparse import parse_date
|
||||
from freezegun import freeze_time
|
||||
|
||||
from wagtail.admin.tests.pages.timestamps import local_datetime
|
||||
|
@ -44,31 +42,8 @@ class TestRevisions(TestCase, WagtailTestUtils):
|
|||
response = self.client.get(
|
||||
reverse('wagtailadmin_pages:revisions_index', args=(self.christmas_event.id, ))
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
self.assertContains(response, formats.localize(parse_date('2013-12-25')))
|
||||
last_christmas_preview_url = reverse(
|
||||
'wagtailadmin_pages:revisions_view',
|
||||
args=(self.christmas_event.id, self.last_christmas_revision.id)
|
||||
)
|
||||
last_christmas_revert_url = reverse(
|
||||
'wagtailadmin_pages:revisions_revert',
|
||||
args=(self.christmas_event.id, self.last_christmas_revision.id)
|
||||
)
|
||||
self.assertContains(response, last_christmas_preview_url)
|
||||
self.assertContains(response, last_christmas_revert_url)
|
||||
|
||||
self.assertContains(response, formats.localize(local_datetime(2014, 12, 25)))
|
||||
this_christmas_preview_url = reverse(
|
||||
'wagtailadmin_pages:revisions_view',
|
||||
args=(self.christmas_event.id, self.this_christmas_revision.id)
|
||||
)
|
||||
this_christmas_revert_url = reverse(
|
||||
'wagtailadmin_pages:revisions_revert',
|
||||
args=(self.christmas_event.id, self.this_christmas_revision.id)
|
||||
)
|
||||
self.assertContains(response, this_christmas_preview_url)
|
||||
self.assertContains(response, this_christmas_revert_url)
|
||||
history_url = reverse('wagtailadmin_pages:history', args=(self.christmas_event.id, ))
|
||||
self.assertRedirects(response, history_url)
|
||||
|
||||
def request_preview_revision(self):
|
||||
last_christmas_preview_url = reverse(
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.core.paginator import Paginator
|
||||
from django.http import Http404
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.template.loader import render_to_string
|
||||
|
@ -16,26 +15,8 @@ from wagtail.admin.views.pages.utils import get_valid_next_url_from_request
|
|||
from wagtail.core.models import Page, UserPagePermissionsProxy
|
||||
|
||||
|
||||
@user_passes_test(user_has_any_page_permission)
|
||||
def revisions_index(request, page_id):
|
||||
page = get_object_or_404(Page, id=page_id).specific
|
||||
|
||||
# Get page ordering
|
||||
ordering = request.GET.get('ordering', '-created_at')
|
||||
if ordering not in ['created_at', '-created_at', ]:
|
||||
ordering = '-created_at'
|
||||
|
||||
revisions = page.revisions.order_by(ordering)
|
||||
|
||||
paginator = Paginator(revisions, per_page=20)
|
||||
revisions = paginator.get_page(request.GET.get('p'))
|
||||
|
||||
return TemplateResponse(request, 'wagtailadmin/pages/revisions/index.html', {
|
||||
'page': page,
|
||||
'ordering': ordering,
|
||||
'pagination_query_params': "ordering=%s" % ordering,
|
||||
'revisions': revisions,
|
||||
})
|
||||
return redirect('wagtailadmin_pages:history', page_id)
|
||||
|
||||
|
||||
def revisions_revert(request, page_id, revision_id):
|
||||
|
|
Ładowanie…
Reference in New Issue