diff --git a/.gitignore b/.gitignore index d9a81db..514363c 100644 --- a/.gitignore +++ b/.gitignore @@ -26,9 +26,6 @@ pip-log.txt .tox nosetests.xml -# Translations -*.mo - # Mr Developer .mr.developer.cfg .project diff --git a/djangocms_blog/locale/ru/LC_MESSAGES/django.mo b/djangocms_blog/locale/ru/LC_MESSAGES/django.mo new file mode 100644 index 0000000..79b727e Binary files /dev/null and b/djangocms_blog/locale/ru/LC_MESSAGES/django.mo differ diff --git a/djangocms_blog/locale/ru/LC_MESSAGES/django.po b/djangocms_blog/locale/ru/LC_MESSAGES/django.po index 79246c1..7670e09 100644 --- a/djangocms_blog/locale/ru/LC_MESSAGES/django.po +++ b/djangocms_blog/locale/ru/LC_MESSAGES/django.po @@ -7,13 +7,16 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2014-02-27 15:00+0100\n" -"PO-Revision-Date: 2014-02-27 15:08+0100\n" +"PO-Revision-Date: 2014-02-27 16:45+0300\n" "Last-Translator: Max Vyaznikov \n" "Language: ru\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=3; plural=((((n%10)==1)&&((n%100)!=11))?(0):(((((n%10)>=2)&&((n%10)<=4))&&(((n%100)<10)||((n%100)>=20)))?(1):2));\n" +"Plural-Forms: nplurals=3; plural=((((n%10)==1)&&((n%100)!=11))?(0):(((((n%10)" +">=2)&&((n%10)<=4))&&(((n%100)<10)||((n%100)>=20)))?(1):2));\n" +"Language-Team: \n" +"X-Generator: Poedit 1.5.4\n" #: cms_app.py:8 cms_plugins.py:30 cms_plugins.py:43 cms_plugins.py:54 #: cms_plugins.py:65 cms_toolbar.py:13 @@ -70,10 +73,30 @@ msgstr "время изменения" msgid "name" msgstr "название" -#: models.py:33 models.py:84 +#: models.py:75 +msgid "Main image" +msgstr "Картинка для статьи" + +#: models.py:77 +msgid "Main image thumbnail" +msgstr "Уменьшенная копия" + +#: models.py:81 +msgid "Main image full" +msgstr "Полный размер" + +#: models.py:86 +msgid "Title" +msgstr "Заголовок" + +#: models.py:33 models.py:87 msgid "slug" msgstr "URL" +#: models.py:88 +msgid "Text" +msgstr "Текст" + #: models.py:40 msgid "blog category" msgstr "категория блога" @@ -82,6 +105,10 @@ msgstr "категория блога" msgid "blog categories" msgstr "категории блога" +#: models.py:64 +msgid "Author" +msgstr "Автор" + #: models.py:67 msgid "Published Since" msgstr "Опубликована с" @@ -90,6 +117,10 @@ msgstr "Опубликована с" msgid "Published Until" msgstr "Опубликована до" +#: models.py:72 +msgid "Publish" +msgstr "Показывать на сайте" + #: models.py:72 msgid "category" msgstr "категория" @@ -183,7 +214,7 @@ msgstr "продолжение" #, python-format msgid "1 article" msgid_plural "%(articles)s articles" -msgstr[0] "1 статья" +msgstr[0] "%(articles)s статья" msgstr[1] "%(articles)s статьи" msgstr[2] "%(articles)s статей" diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index f7df6aa..93729dc 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -61,7 +61,7 @@ class Post(TranslatableModel): """ Blog post """ - author = models.ForeignKey(User, null=True, blank=True) + author = models.ForeignKey(User, verbose_name=_('Author'), null=True, blank=True) date_created = models.DateTimeField(auto_now_add=True) date_modified = models.DateTimeField(auto_now=True) @@ -69,21 +69,23 @@ class Post(TranslatableModel): default=timezone.now) date_published_end = models.DateTimeField(_('Published Until'), null=True, blank=True) - publish = models.BooleanField(default=False) + publish = models.BooleanField(_('Publish'), default=False) categories = models.ManyToManyField(BlogCategory, verbose_name=_('category'), related_name='blog_posts',) - main_image = FilerImageField(blank=True, null=True) + main_image = FilerImageField(verbose_name=_('Main image'), blank=True, null=True) main_image_thumbnail = models.ForeignKey(ThumbnailOption, + verbose_name=_('Main image thumbnail'), related_name='blog_post_thumbnail', blank=True, null=True) main_image_full = models.ForeignKey(ThumbnailOption, + verbose_name=_('Main image full'), related_name='blog_post_full', blank=True, null=True) translations = TranslatedFields( - title=models.CharField(max_length=255), + title=models.CharField(_('Title'), max_length=255), slug=models.SlugField(_('slug'), blank=True, db_index=True), - abstract=HTMLField(), + abstract=HTMLField(_('Text')), meta={'unique_together': (('language_code', 'slug'),)} ) content = PlaceholderField("post_content") diff --git a/djangocms_blog/settings.py b/djangocms_blog/settings.py index bc37158..235e8b3 100644 --- a/djangocms_blog/settings.py +++ b/djangocms_blog/settings.py @@ -1,18 +1,21 @@ # -*- coding: utf-8 -*- -BLOG_IMAGE_THUMBNAIL_SIZE = { +from django.conf import settings + +BLOG_IMAGE_THUMBNAIL_SIZE = getattr(settings, 'BLOG_IMAGE_THUMBNAIL_SIZE', { 'size': '120x120', 'crop': True, 'upscale': False -} +}) -BLOG_IMAGE_FULL_SIZE = { +BLOG_IMAGE_FULL_SIZE = getattr(settings, 'BLOG_IMAGE_FULL_SIZE', { 'size': '640x120', 'crop': True, 'upscale': False -} +}) -BLOG_TAGCLOUD_MIN = 1 -BLOG_TAGCLOUD_MAX = 10 -BLOG_PAGINATION = 10 -BLOG_LATEST_POSTS = 5 \ No newline at end of file +BLOG_TAGCLOUD_MIN = getattr(settings, 'BLOG_TAGCLOUD_MIN', 1) +BLOG_TAGCLOUD_MAX = getattr(settings, 'BLOG_TAGCLOUD_MAX', 10) +BLOG_PAGINATION = getattr(settings, 'BLOG_PAGINATION', 10) +BLOG_LATEST_POSTS = getattr(settings, 'BLOG_LATEST_POSTS', 5) +BLOG_POSTS_LIST_TRUNCWORDS_COUNT = getattr(settings, 'BLOG_POSTS_LIST_TRUNCWORDS_COUNT', 100) diff --git a/djangocms_blog/templates/djangocms_blog/includes/blog_item.html b/djangocms_blog/templates/djangocms_blog/includes/blog_item.html index ca5f339..d44e10d 100644 --- a/djangocms_blog/templates/djangocms_blog/includes/blog_item.html +++ b/djangocms_blog/templates/djangocms_blog/includes/blog_item.html @@ -33,7 +33,13 @@ {{ post.main_image.default_alt_text }} {% endif %} -
{% render_model post "abstract" %}
+
+ {% if not TRUNCWORDS_COUNT %} + {% render_model post "abstract" %} + {% else %} + {% render_model post "abstract" "" "" 'truncatewords_html:TRUNCWORDS_COUNT' %} + {% endif %} +
diff --git a/djangocms_blog/templates/djangocms_blog/post_list.html b/djangocms_blog/templates/djangocms_blog/post_list.html index a4a2b2a..c735cd5 100644 --- a/djangocms_blog/templates/djangocms_blog/post_list.html +++ b/djangocms_blog/templates/djangocms_blog/post_list.html @@ -14,7 +14,7 @@ {% endblock %} {% for post in post_list %} - {% include "djangocms_blog/includes/blog_item.html" with post=post image="true" %} + {% include "djangocms_blog/includes/blog_item.html" with post=post image="true" TRUNCWORDS_COUNT=TRUNCWORDS_COUNT %} {% empty %}

{% trans "No article found." %}

{% endfor %} diff --git a/djangocms_blog/views.py b/djangocms_blog/views.py index ada03d8..cc3f6b5 100644 --- a/djangocms_blog/views.py +++ b/djangocms_blog/views.py @@ -8,7 +8,7 @@ from django.utils.translation import ugettext_lazy as _ from django.views.generic import ListView, DetailView from .models import Post, BlogCategory -from .settings import BLOG_PAGINATION +from .settings import BLOG_PAGINATION, BLOG_POSTS_LIST_TRUNCWORDS_COUNT class BaseBlogView(object): @@ -31,6 +31,10 @@ class PostListView(BaseBlogView, ListView): template_name = "djangocms_blog/post_list.html" paginate_by = BLOG_PAGINATION + def get_context_data(self, **kwargs): + context = super(PostListView, self).get_context_data(**kwargs) + context['TRUNCWORDS_COUNT'] = BLOG_POSTS_LIST_TRUNCWORDS_COUNT + return context class PostDetailView(BaseBlogView, DetailView): model = Post