Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

Commit

Permalink
Fix NewsblogConfig registration with aldryn-reversions. simple test c…
Browse files Browse the repository at this point in the history
…ase.
  • Loading branch information
Kirill Kniazev committed Sep 14, 2015
1 parent 55a0e77 commit 660c154
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions aldryn_newsblog/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def add_view(self, request, *args, **kwargs):

class NewsBlogConfigAdmin(
AllTranslationsMixin,
VersionedPlaceholderAdminMixin,
PlaceholderAdminMixin,
BaseAppHookConfig,
TranslatableAdmin
Expand Down
2 changes: 2 additions & 0 deletions aldryn_newsblog/cms_appconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from aldryn_apphooks_config.utils import setup_config
from aldryn_apphooks_config.models import AppHookConfig
from aldryn_reversion.core import version_controlled_content
from app_data import AppDataForm
from cms.models.fields import PlaceholderField
from parler.models import TranslatableModel
Expand All @@ -34,6 +35,7 @@
settings, 'ALDRYN_NEWSBLOG_TEMPLATE_PREFIXES', [])


@version_controlled_content
class NewsBlogConfig(TranslatableModel, AppHookConfig):
"""Adds some translatable, per-app-instance fields."""
translations = TranslatedFields(
Expand Down
30 changes: 30 additions & 0 deletions aldryn_newsblog/tests/test_reversion.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals
from django.core.urlresolvers import reverse

import reversion
import six
Expand All @@ -12,6 +13,7 @@
from parler.utils.context import switch_language

from . import NewsBlogTestCase
from aldryn_newsblog.cms_appconfig import NewsBlogConfig


class TestVersioning(NewsBlogTestCase):
Expand Down Expand Up @@ -173,3 +175,31 @@ def test_edit_plugin_directly(self):
response = self.client.get(article.get_absolute_url())
self.assertContains(response, content1)
self.assertNotContains(response, content2)

def test_blog_config_recovery_accessible(self):
with transaction.atomic():
with reversion.create_revision():
new_conf = NewsBlogConfig(
namespace='test_revocery_admin_url', paginate_by=15)
new_conf.save()
new_config_version = reversion.get_for_object(new_conf)[0]
new_config_pk = new_conf.pk
self.assertEqual(NewsBlogConfig.objects.filter(
pk=new_config_pk).count(), 1)
new_conf.delete()
self.assertEqual(NewsBlogConfig.objects.filter(
pk=new_config_pk).count(), 0)

# check that there is a a way to access recovery view
obj = new_config_version.object_version.object
opts = obj._meta
url = reverse(
'admin:{0}_{1}_{2}'.format(
opts.app_label,
obj._meta.model_name,
'recover'),
args=[new_config_version.pk])
# ust in case check the length, but at this step either a
# NoReverseMatch should occur or other error,
# if no exception is raised, it is a good sign
self.assertGreater(len(url), 4)

0 comments on commit 660c154

Please sign in to comment.