Scattered fixes

This commit is contained in:
Iacopo Spalletti 2015-09-26 18:01:22 +02:00
parent 63adbb1131
commit 29df04208c
7 changed files with 28 additions and 19 deletions

View File

@ -51,11 +51,11 @@ class BlogConfigForm(AppDataForm):
)
object_type = forms.ChoiceField(
label=_('Object type'), required=False,
choices=get_setting('TYPES_GENERIC'), initial=get_setting('TYPE')
choices=get_setting('TYPES'), initial=get_setting('TYPE')
)
og_type = forms.ChoiceField(
label=_('Facebook type'), required=False,
choices=get_setting('TYPES_FACEBOOK'), initial=get_setting('TYPES_FACEBOOK')[0][0]
choices=get_setting('FB_TYPES'), initial=get_setting('FB_TYPES')[0][0]
)
og_app_id = forms.CharField(
max_length=200, label=_('Facebook application ID'), required=False,
@ -71,7 +71,7 @@ class BlogConfigForm(AppDataForm):
)
twitter_type = forms.ChoiceField(
label=_('Twitter type'), required=False,
choices=get_setting('TYPES_TWITTER'), initial=get_setting('TYPES_TWITTER')[0][0]
choices=get_setting('TWITTER_TYPES'), initial=get_setting('TWITTER_TYPES')[0][0]
)
twitter_site = forms.CharField(
max_length=200, label=_('Twitter site handle'), required=False
@ -79,9 +79,9 @@ class BlogConfigForm(AppDataForm):
twitter_author = forms.CharField(
max_length=200, label=_('Twitter author handle'), required=False
)
gplus_type = forms.CharField(
max_length=200, label=_('Google+ type'), required=False,
choices=get_setting('TYPES_GPLUS'), initial=get_setting('TYPES_GPLUS')[0][0]
gplus_type = forms.ChoiceField(
label=_('Google+ type'), required=False,
choices=get_setting('GPLUS_TYPES'), initial=get_setting('GPLUS_TYPES')[0][0]
)
gplus_author = forms.CharField(
max_length=200, label=_('Google+ author name'), required=False

View File

@ -141,6 +141,7 @@ class Post(ModelMeta, TranslatableModel):
_metadata = {
'title': 'get_title',
'description': 'get_description',
'keywords': 'get_keywords',
'og_description': 'get_description',
'twitter_description': 'get_description',
'gplus_description': 'get_description',

View File

@ -4,12 +4,14 @@ from __future__ import absolute_import, print_function, unicode_literals
def get_setting(name):
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from meta_mixin import settings as meta_settings
OBJECT_TYPES = {
'Article': _('Article'),
'Website': _('Website'),
}
OBJECT_TYPES = (
('Article', _('Article')),
('Website', _('Website')),
)
BLOG_TYPES = getattr(settings, 'BLOG_TYPES', OBJECT_TYPES)
default = {
'BLOG_IMAGE_THUMBNAIL_SIZE': getattr(settings, 'BLOG_IMAGE_THUMBNAIL_SIZE', {
@ -32,20 +34,20 @@ def get_setting(name):
settings, 'BLOG_POSTS_LIST_TRUNCWORDS_COUNT', 100
),
'BLOG_TYPE': getattr(settings, 'BLOG_TYPE', 'Article'),
'BLOG_TYPES': getattr(settings, 'BLOG_TYPES', ),
'BLOG_TYPES': BLOG_TYPES,
'BLOG_FB_TYPE': getattr(settings, 'BLOG_FB_TYPE', 'Article'),
'BLOG_FB_TYPES': getattr(settings, 'BLOG_FB_TYPES', OBJECT_TYPES.items()),
'BLOG_FB_TYPES': getattr(settings, 'BLOG_FB_TYPES', BLOG_TYPES),
'BLOG_FB_APPID': getattr(settings, 'BLOG_FB_APPID', meta_settings.FB_APPID),
'BLOG_FB_PROFILE_ID': getattr(settings, 'BLOG_FB_PROFILE_ID', meta_settings.FB_PROFILE_ID),
'BLOG_FB_PUBLISHER': getattr(settings, 'BLOG_FB_PUBLISHER', meta_settings.FB_PUBLISHER),
'BLOG_FB_AUTHOR_URL': getattr(settings, 'BLOG_FB_AUTHOR_URL', 'get_author_url'),
'BLOG_FB_AUTHOR': getattr(settings, 'BLOG_FB_AUTHOR', 'get_author_name'),
'BLOG_TWITTER_TYPE': getattr(settings, 'BLOG_TWITTER_TYPE', 'Summary'),
'BLOG_TWITTER_TYPES': getattr(settings, 'BLOG_TWITTER_TYPES', OBJECT_TYPES.items()),
'BLOG_TWITTER_TYPES': getattr(settings, 'BLOG_TWITTER_TYPES', BLOG_TYPES),
'BLOG_TWITTER_SITE': getattr(settings, 'BLOG_TWITTER_SITE', meta_settings.TWITTER_SITE),
'BLOG_TWITTER_AUTHOR': getattr(settings, 'BLOG_TWITTER_AUTHOR', 'get_author_twitter'),
'BLOG_GPLUS_TYPE': getattr(settings, 'BLOG_GPLUS_SCOPE_CATEGORY', 'Blog'),
'BLOG_GPLUS_TYPES': getattr(settings, 'BLOG_GPLUS_TYPES', OBJECT_TYPES.items()),
'BLOG_GPLUS_TYPES': getattr(settings, 'BLOG_GPLUS_TYPES', BLOG_TYPES),
'BLOG_GPLUS_AUTHOR': getattr(settings, 'BLOG_GPLUS_AUTHOR', 'get_author_gplus'),
'BLOG_ENABLE_COMMENTS': getattr(settings, 'BLOG_ENABLE_COMMENTS', True),
'BLOG_USE_ABSTRACT': getattr(settings, 'BLOG_USE_ABSTRACT', True),

View File

@ -127,6 +127,13 @@ class BaseTest(BaseTestCase):
cls.category_1.save()
cls.site_2 = Site.objects.create(domain='http://example2.com', name='example 2')
@classmethod
def tearDownClass(cls):
super(BaseTest, cls).tearDownClass()
BlogConfig.objects.all().delete()
BlogCategory.objects.all().delete()
ThumbnailOption.objects.all().delete()
def _get_category(self, data, category=None, lang='en'):
data = deepcopy(data)
for k, v in data.items():

View File

@ -7,6 +7,7 @@ import re
from cms.api import add_plugin
from django.core.urlresolvers import reverse
from django.utils.timezone import now
from djangocms_helper.utils import get_user_model
from taggit.models import Tag
from djangocms_blog.models import BlogCategory
@ -68,12 +69,10 @@ class PluginTest(BaseTest):
posts[1].save()
ph = pages[0].placeholders.get(slot='content')
plugin = add_plugin(ph, 'BlogAuthorPostsPlugin', language='en', app_config=self.app_config_1)
plugin.authors.add(self.user)
context = self.get_plugin_context(pages[0], 'en', plugin, edit=True)
rendered = plugin.render_plugin(context, ph)
self.assertTrue(rendered.find(reverse('djangocms_blog:posts-author', kwargs={'username': self.user.get_username()})) > -1)
self.assertTrue(rendered.find('2 articles') > -1)
self.assertTrue(rendered.find('No article found') > -1)
def test_plugin_tags(self):
pages = self.get_pages()
@ -150,4 +149,3 @@ class PluginTest(BaseTest):
self.assertEqual(plugin_class.get_render_template(context, plugin, ph), os.path.join('whatever', plugin_class.base_render_template))
self.app_config_1.app_data.config.template_prefix = ''
self.app_config_1.save()

View File

@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
from aldryn_apphooks_config.utils import get_app_instance
import os.path
from aldryn_apphooks_config.utils import get_app_instance
from django.contrib.auth.models import AnonymousUser
from django.http import Http404
from django.utils.timezone import now

View File

@ -15,6 +15,7 @@ deps =
cms30: https://github.com/divio/django-cms/archive/support/3.0.x.zip
cms31: https://github.com/divio/django-cms/archive/support/3.1.x.zip
cms32: https://github.com/divio/django-cms/archive/develop.zip
https://github.com/nephila/django-meta-mixin/archive/master.zip
https://github.com/nephila/djangocms-helper/archive/develop.zip
py26: unittest2
django-parler<1.5