Update auto_setup
This commit is contained in:
parent
f029608f0c
commit
ba044b34aa
|
@ -17,11 +17,16 @@ class BlogApp(AutoCMSAppMixin, CMSConfigApp):
|
|||
app_name = 'djangocms_blog'
|
||||
app_config = BlogConfig
|
||||
menus = [BlogCategoryMenu]
|
||||
auto_setup = get_setting('AUTO_SETUP')
|
||||
auto_app_title = get_setting('AUTO_APP_TITLE')
|
||||
auto_home_title = get_setting('AUTO_HOME_TITLE')
|
||||
auto_page_title = get_setting('AUTO_BLOG_TITLE')
|
||||
auto_namespace = get_setting('AUTO_NAMESPACE')
|
||||
|
||||
auto_setup = {
|
||||
'enabled': get_setting('AUTO_SETUP'),
|
||||
'home title': get_setting('AUTO_HOME_TITLE'),
|
||||
'page title': get_setting('AUTO_BLOG_TITLE'),
|
||||
'namespace': get_setting('AUTO_NAMESPACE'),
|
||||
'config_fields': {},
|
||||
'config_translated_fields': {
|
||||
'app_title': get_setting('AUTO_APP_TITLE'),
|
||||
'object_name': get_setting('DEFAULT_OBJECT_NAME')
|
||||
},
|
||||
}
|
||||
apphook_pool.register(BlogApp)
|
||||
BlogApp.setup()
|
||||
|
|
|
@ -18,7 +18,9 @@ class BlogConfig(TranslatableModel, AppHookConfig):
|
|||
"""
|
||||
translations = TranslatedFields(
|
||||
app_title=models.CharField(_('application title'), max_length=234),
|
||||
object_name=models.CharField(_('object name'), max_length=234, default='Post'),
|
||||
object_name=models.CharField(
|
||||
_('object name'), max_length=234, default=get_setting('DEFAULT_OBJECT_NAME')
|
||||
),
|
||||
)
|
||||
|
||||
def get_app_title(self):
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from django.utils.translation import ugettext_lazy as _
|
|
@ -4,6 +4,7 @@ from __future__ import unicode_literals
|
|||
from django.db import migrations, models
|
||||
import django.utils.timezone
|
||||
import aldryn_apphooks_config.fields
|
||||
from djangocms_blog.settings import get_setting
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -16,7 +17,7 @@ class Migration(migrations.Migration):
|
|||
migrations.AddField(
|
||||
model_name='blogconfigtranslation',
|
||||
name='object_name',
|
||||
field=models.CharField(verbose_name='object name', default='Post', max_length=234),
|
||||
field=models.CharField(verbose_name='object name', default=get_setting('DEFAULT_OBJECT_NAME'), max_length=234),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='authorentriesplugin',
|
||||
|
|
|
@ -74,6 +74,7 @@ def get_setting(name):
|
|||
'BLOG_DEFAULT_PUBLISHED': getattr(settings, 'BLOG_DEFAULT_PUBLISHED', False),
|
||||
'BLOG_AVAILABLE_PERMALINK_STYLES': getattr(settings, 'BLOG_AVAILABLE_PERMALINK_STYLES', PERMALINKS), # NOQA
|
||||
'BLOG_PERMALINK_URLS': getattr(settings, 'BLOG_PERMALINK_URLS', PERMALINKS_URLS),
|
||||
'BLOG_DEFAULT_OBJECT_NAME': getattr(settings, 'BLOG_DEFAULT_OBJECT_NAME', 'Article'),
|
||||
|
||||
'BLOG_AUTO_SETUP': getattr(settings, 'BLOG_AUTO_SETUP', True),
|
||||
'BLOG_AUTO_HOME_TITLE': getattr(settings, 'BLOG_AUTO_HOME_TITLE', 'Home'),
|
||||
|
|
|
@ -3,6 +3,7 @@ from south.utils import datetime_utils as datetime
|
|||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
from djangocms_blog.settings import get_setting
|
||||
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
@ -10,7 +11,7 @@ class Migration(SchemaMigration):
|
|||
def forwards(self, orm):
|
||||
# Adding field 'BlogConfigTranslation.object_name'
|
||||
db.add_column('djangocms_blog_blogconfig_translation', 'object_name',
|
||||
self.gf('django.db.models.fields.CharField')(default='Post', max_length=234),
|
||||
self.gf('django.db.models.fields.CharField')(default=get_setting('DEFAULT_OBJECT_NAME'), max_length=234),
|
||||
keep_default=False)
|
||||
|
||||
|
||||
|
@ -218,4 +219,4 @@ class Migration(SchemaMigration):
|
|||
}
|
||||
}
|
||||
|
||||
complete_apps = ['djangocms_blog']
|
||||
complete_apps = ['djangocms_blog']
|
||||
|
|
|
@ -17,34 +17,37 @@ class SetupTest(BaseTest):
|
|||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
# Skipping initialization to start with clean database
|
||||
super(BaseTest, cls).setUpClass()
|
||||
|
||||
def setUp(self):
|
||||
super(SetupTest, self).setUp()
|
||||
from cms.apphook_pool import apphook_pool
|
||||
|
||||
delete = [
|
||||
'djangocms_blog',
|
||||
'djangocms_blog.cms_app',
|
||||
'djangocms_blog.cms_apps',
|
||||
]
|
||||
for module in delete:
|
||||
if module in sys.modules:
|
||||
del sys.modules[module]
|
||||
BlogConfig.cmsapp = None
|
||||
apphook_pool.clear()
|
||||
|
||||
def test_setup_from_url(self):
|
||||
|
||||
# Tests starts with no page and no config
|
||||
self.assertFalse(Page.objects.exists())
|
||||
self.assertFalse(BlogConfig.objects.exists())
|
||||
|
||||
# importing admin triggers the auto setup
|
||||
from djangocms_blog import cms_toolbar # NOQA
|
||||
# importing cms_app triggers the auto setup
|
||||
from djangocms_blog import cms_app # NOQA
|
||||
|
||||
# Home and blog, published and draft
|
||||
self.assertEqual(Page.objects.count(), 4)
|
||||
self.assertEqual(BlogConfig.objects.count(), 1)
|
||||
|
||||
def setUp(self):
|
||||
from cms.toolbar_pool import toolbar_pool
|
||||
from djangocms_blog import cms_toolbar
|
||||
|
||||
toolbar_pool.unregister(cms_toolbar.BlogToolbar)
|
||||
delete = [
|
||||
'djangocms_blog',
|
||||
'djangocms_blog.cms_toolbar',
|
||||
]
|
||||
for module in delete:
|
||||
if module in sys.modules:
|
||||
del sys.modules[module]
|
||||
|
||||
def test_setup_filled(self):
|
||||
|
||||
# Tests starts with no page and no config
|
||||
|
@ -66,8 +69,8 @@ class SetupTest(BaseTest):
|
|||
)
|
||||
home.publish(lang)
|
||||
|
||||
# importing admin triggers the auto setup
|
||||
from djangocms_blog import cms_toolbar # NOQA
|
||||
# importing cms_app triggers the auto setup
|
||||
from djangocms_blog import cms_app # NOQA
|
||||
|
||||
# Home and blog, published and draft
|
||||
self.assertEqual(Page.objects.count(), 4)
|
||||
|
|
Loading…
Reference in New Issue