Clarify meta tags fields in BlogConfig
This commit is contained in:
parent
2490447f44
commit
0e9a80cb42
4 changed files with 25 additions and 2 deletions
|
@ -9,6 +9,7 @@ from django import forms
|
|||
from django.conf import settings
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from parler.admin import TranslatableAdmin
|
||||
|
||||
from .cms_appconfig import BlogConfig
|
||||
|
@ -157,16 +158,25 @@ class BlogConfigAdmin(BaseAppHookConfig, TranslatableAdmin):
|
|||
'fields': (
|
||||
'config.og_type', 'config.og_app_id', 'config.og_profile_id',
|
||||
'config.og_publisher', 'config.og_author_url', 'config.og_author',
|
||||
),
|
||||
'description': _(
|
||||
'You can provide plain strings, Post model attribute or method names'
|
||||
)
|
||||
}),
|
||||
('Twitter', {
|
||||
'fields': (
|
||||
'config.twitter_type', 'config.twitter_site', 'config.twitter_author',
|
||||
),
|
||||
'description': _(
|
||||
'You can provide plain strings, Post model attribute or method names'
|
||||
)
|
||||
}),
|
||||
('Google+', {
|
||||
'fields': (
|
||||
'config.gplus_type', 'config.gplus_author',
|
||||
),
|
||||
'description': _(
|
||||
'You can provide plain strings, Post model attribute or method names'
|
||||
)
|
||||
}),
|
||||
]
|
||||
|
|
|
@ -150,7 +150,7 @@ class Post(ModelMeta, TranslatableModel):
|
|||
'og_description': 'get_description',
|
||||
'twitter_description': 'get_description',
|
||||
'gplus_description': 'get_description',
|
||||
'locale': None,
|
||||
'locale': 'get_locale',
|
||||
'image': 'get_image_full_url',
|
||||
'object_type': 'get_meta_attribute',
|
||||
'og_type': 'get_meta_attribute',
|
||||
|
@ -233,6 +233,9 @@ class Post(ModelMeta, TranslatableModel):
|
|||
def get_keywords(self):
|
||||
return self.safe_translation_getter('meta_keywords').strip().split(',')
|
||||
|
||||
def get_locale(self):
|
||||
return self.get_current_language()
|
||||
|
||||
def get_description(self):
|
||||
description = self.safe_translation_getter('meta_description', any_language=True)
|
||||
if not description:
|
||||
|
|
|
@ -213,6 +213,9 @@ class ModelsTest(BaseTest):
|
|||
def test_model_attributes(self):
|
||||
self.get_pages()
|
||||
|
||||
self.app_config_1.app_data.config.gplus_author = 'RandomJoe'
|
||||
self.app_config_1.save()
|
||||
|
||||
post = self._get_post(self._post_data[0]['en'])
|
||||
post = self._get_post(self._post_data[0]['it'], post, 'it')
|
||||
post.main_image = self.create_filer_image_object()
|
||||
|
@ -225,6 +228,14 @@ class ModelsTest(BaseTest):
|
|||
self.assertEqual(meta_en.description, post.meta_description)
|
||||
self.assertEqual(meta_en.keywords, post.meta_keywords.split(','))
|
||||
self.assertEqual(meta_en.published_time, post.date_published)
|
||||
self.assertEqual(meta_en.locale, 'en')
|
||||
self.assertEqual(meta_en.twitter_site, '')
|
||||
self.assertEqual(meta_en.twitter_author, '')
|
||||
self.assertEqual(meta_en.twitter_type, 'summary')
|
||||
self.assertEqual(meta_en.gplus_author, 'RandomJoe')
|
||||
self.assertEqual(meta_en.gplus_type, 'Blog')
|
||||
self.assertEqual(meta_en.og_type, 'Article')
|
||||
self.assertEqual(meta_en.facebook_app_id, None)
|
||||
post.set_current_language('it')
|
||||
meta_it = post.as_meta()
|
||||
self.assertEqual(meta_it.title, post.title)
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
Post
|
||||
{% cms_toolbar %}
|
||||
<div style="width: 940px; margin:0 auto">
|
||||
<ul class="nav">
|
||||
|
|
Loading…
Reference in a new issue