diff --git a/blog_ext/__init__.py b/blog_ext/__init__.py new file mode 100644 index 0000000..391e166 --- /dev/null +++ b/blog_ext/__init__.py @@ -0,0 +1 @@ +default_app_config = 'blog_ext.apps.PinaxBlogExtConfig' diff --git a/blog_ext/admin.py b/blog_ext/admin.py new file mode 100644 index 0000000..aa9f951 --- /dev/null +++ b/blog_ext/admin.py @@ -0,0 +1,53 @@ +from django.contrib import admin +from django.utils.translation import ugettext_lazy as _ + +from ckeditor_uploader.widgets import CKEditorUploadingWidget + +from pinax.blog.admin import PostAdmin as BasePostAdmin, SectionAdmin as BaseSectionAdmin, \ + PostImageSet as BasePostImageSet +from pinax.blog.models import ( + Post as PinaxPost, + Section as PinaxSection, +) +from pinax.images.admin import ImageInline + +from blog_ext.forms import AdminPostForm +from blog_ext.models import Post, Section, ImageSet + + +@admin.register(Post) +class PostAdmin(BasePostAdmin): + form = AdminPostForm + + def formfield_for_dbfield(self, db_field, **kwargs): + if db_field.name in ['content', 'teaser', 'description']: + kwargs['widget'] = CKEditorUploadingWidget( + config_name='awesome_ckeditor', + attrs={'class': 'mt mt-field-content-%s' % db_field.name.replace('content', '')} + ) + return super(PostAdmin, self).formfield_for_dbfield(db_field, **kwargs) + + +@admin.register(Section) +class SectionAdmin(BaseSectionAdmin): + pass + + +class PostImageSet(ImageSet): + class Meta: + proxy = True + verbose_name = _('Изображение') + verbose_name_plural = _('Изображения') + + + +admin.site.unregister(BasePostImageSet) + +admin.site.register( + PostImageSet, + list_display=["blog_post", "primary_image", "created_by", "created_at"], + raw_id_fields=["created_by"], + inlines=[ImageInline], +) +admin.site.unregister(PinaxSection) +admin.site.unregister(PinaxPost) diff --git a/blog_ext/apps.py b/blog_ext/apps.py new file mode 100644 index 0000000..a6e2f88 --- /dev/null +++ b/blog_ext/apps.py @@ -0,0 +1,8 @@ +from django.apps import AppConfig + +from django.utils.translation import ugettext_lazy as _ + + +class PinaxBlogExtConfig(AppConfig): + name = 'blog_ext' + verbose_name = _('Новости') diff --git a/blog_ext/forms.py b/blog_ext/forms.py new file mode 100644 index 0000000..a72ce69 --- /dev/null +++ b/blog_ext/forms.py @@ -0,0 +1,12 @@ +from django.utils.translation import ugettext_lazy as _ + +from pinax.blog.forms import AdminPostForm as BaseAdminPostForm + + +class AdminPostForm(BaseAdminPostForm): + pass + + +AdminPostForm.declared_fields.get('teaser').label = _('Превью') +AdminPostForm.declared_fields.get('content').label = _('Содержимое') +AdminPostForm.declared_fields.get('description').label = _('Описание') diff --git a/blog_ext/models.py b/blog_ext/models.py new file mode 100644 index 0000000..b973740 --- /dev/null +++ b/blog_ext/models.py @@ -0,0 +1,86 @@ +import uuid + +from django.db import models +from django.utils.translation import ugettext_lazy as _ + +# Create your models here. +from pinax.blog.models import ( + Post as BasePost, + Revision as BaseRevision, + ReviewComment as BaseReviewComment, + Section as BaseSection +) +from pinax.images.models import ( + ImageSet as BaseImageSet, + Image as BaseImage, + image_upload_to) + +from core.models import AbstractStatusModel, AbstractDateTimeModel + + +class Section(BaseSection, AbstractDateTimeModel): + pass + + class Meta: + verbose_name = _('Секция') + verbose_name_plural = _('Секции') + + +Section._meta.get_field('name').verbose_name = _('Название') +Section._meta.get_field('enabled').verbose_name = _('Включенно') + + +class Post(BasePost, AbstractStatusModel): + pass + + class Meta: + verbose_name = _('Пост') + verbose_name_plural = _('Посты') + + +Post._meta.get_field('blog').verbose_name = _('Блог') +Post._meta.get_field('section').verbose_name = _('Секция') +Post._meta.get_field('title').verbose_name = _('Название') +Post._meta.get_field('slug').verbose_name = _('Slug') +Post._meta.get_field('author').verbose_name = _('Автор') +Post._meta.get_field('markup').verbose_name = _('Разметка') +Post._meta.get_field('teaser_html').verbose_name = _('Превью') +Post._meta.get_field('content_html').verbose_name = _('Контент') +Post._meta.get_field('image_set').verbose_name = _('Изображения') +Post._meta.get_field('published').verbose_name = _('Опубликованно') +Post._meta.get_field('state').verbose_name = _('Статус') +Post._meta.get_field('secret_key').verbose_name = _('Секретный ключ') +Post._meta.get_field('view_count').verbose_name = _('Кол-во просмотров') + + +class Revision(BaseRevision): + pass + + class Meta: + verbose_name = _('Ревизия') + verbose_name_plural = _('Ревизии') + + +class ReviewComment(BaseReviewComment): + pass + + class Meta: + verbose_name = _('Комментарий') + verbose_name_plural = _('Комментарий') + + +ReviewComment._meta.get_field('post').verbose_name = _('Пост') +ReviewComment._meta.get_field('review_text').verbose_name = _('Текст') +ReviewComment._meta.get_field('timestamp').verbose_name = _('Время') +ReviewComment._meta.get_field('addressed').verbose_name = _('Отправленно') + + +class ImageSet(BaseImageSet, AbstractDateTimeModel): + pass + + class Meta: + verbose_name = _('Коллаж') + verbose_name_plural = ('Коллажи') + + +ImageSet._meta.get_field('primary_image').verbose_name = _('Главное изображение') diff --git a/blog_ext/tests.py b/blog_ext/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/blog_ext/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/blog_ext/views.py b/blog_ext/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/blog_ext/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/templates/pinax/blog/blog_list.html b/templates/pinax/blog/blog_list.html new file mode 100644 index 0000000..21f5da2 --- /dev/null +++ b/templates/pinax/blog/blog_list.html @@ -0,0 +1 @@ +{% extends 'base.html' %} diff --git a/templates/pinax/blog/post_list.html b/templates/pinax/blog/post_list.html new file mode 100644 index 0000000..63f5b1e --- /dev/null +++ b/templates/pinax/blog/post_list.html @@ -0,0 +1,176 @@ +{% extends 'base.html' %} +{% block content %} +

It is a long established fact that a reader will be distracted by the + readable + content of a page when looking at its layout. The point of using Lorem + Ipsum is + that + it has a more-or-less normal distribution of letters, as opposed to + using + 'Content + here, content here', making it look like readable English. Many desktop + publishing + packages and web page editors now use Lorem Ipsum as their default model + text, + and a + search for 'lorem ipsum' will uncover many web sites still in their + infancy. + Various + versions have evolved over the years, sometimes by accident, sometimes + on + purpose + (injected humour and the like).
+
It is a long established fact that a reader will be distracted by the + readable + content of a page when looking at its layout. The point of using Lorem + Ipsum is + that + it has a more-or-less normal distribution of letters, as opposed to + using + 'Content + here, content here', making it look like readable English. Many desktop + publishing + packages and web page editors now use Lorem Ipsum as their default model + text, + and a + search for 'lorem ipsum' will uncover many web sites still in their + infancy. + Various + versions have evolved over the years, sometimes by accident, sometimes + on + purpose + (injected humour and the like).
+
It is a long established fact that a reader will be distracted by the + readable + content of a page when looking at its layout. The point of using Lorem + Ipsum is + that + it has a more-or-less normal distribution of letters, as opposed to + using + 'Content + here, content here', making it look like readable English. Many desktop + publishing + packages and web page editors now use Lorem Ipsum as their default model + text, + and a + search for 'lorem ipsum' will uncover many web sites still in their + infancy. + Various + versions have evolved over the years, sometimes by accident, sometimes + on + purpose + (injected humour and the like).
+
It is a long established fact that a reader will be distracted by the + readable + content of a page when looking at its layout. The point of using Lorem + Ipsum is + that + it has a more-or-less normal distribution of letters, as opposed to + using + 'Content + here, content here', making it look like readable English. Many desktop + publishing + packages and web page editors now use Lorem Ipsum as their default model + text, + and a + search for 'lorem ipsum' will uncover many web sites still in their + infancy. + Various + versions have evolved over the years, sometimes by accident, sometimes + on + purpose + (injected humour and the like).
+
It is a long established fact that a reader will be distracted by the + readable + content of a page when looking at its layout. The point of using Lorem + Ipsum is + that + it has a more-or-less normal distribution of letters, as opposed to + using + 'Content + here, content here', making it look like readable English. Many desktop + publishing + packages and web page editors now use Lorem Ipsum as their default model + text, + and a + search for 'lorem ipsum' will uncover many web sites still in their + infancy. + Various + versions have evolved over the years, sometimes by accident, sometimes + on + purpose + (injected humour and the like).
+