add blog_ext app

remotes/origin/HEAD
Max Yakovenko 8 years ago
parent f88f902283
commit d82e6ebd90
  1. 1
      blog_ext/__init__.py
  2. 53
      blog_ext/admin.py
  3. 8
      blog_ext/apps.py
  4. 12
      blog_ext/forms.py
  5. 86
      blog_ext/models.py
  6. 3
      blog_ext/tests.py
  7. 3
      blog_ext/views.py
  8. 1
      templates/pinax/blog/blog_list.html
  9. 176
      templates/pinax/blog/post_list.html

@ -0,0 +1 @@
default_app_config = 'blog_ext.apps.PinaxBlogExtConfig'

@ -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)

@ -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 = _('Новости')

@ -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 = _('Описание')

@ -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 = _('Главное изображение')

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

@ -0,0 +1 @@
{% extends 'base.html' %}

@ -0,0 +1,176 @@
{% extends 'base.html' %}
{% block content %}
<div class="content__title">Новости</div>
<div class="news">
<div class="news__item">
<div class="row">
<div class="col-md-4 col-12">
<div class="news__image"><img src="./img/test-b.png" alt=""></div>
</div>
<div class="col-lg-6 col-md-8 col-12">
<div class="news__content">
<div class="news__title"><a href="#">Новость 1</a></div>
<div class="news__text">
<p>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).</p>
</div>
</div>
</div>
</div>
</div>
<div class="news__item">
<div class="row">
<div class="col-md-4 col-12">
<div class="news__image"><img src="./img/test-b.png" alt=""></div>
</div>
<div class="col-lg-6 col-md-8 col-12">
<div class="news__content">
<div class="news__title"><a href="#">Новость 1</a></div>
<div class="news__text">
<p>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).</p>
</div>
</div>
</div>
</div>
</div>
<div class="news__item">
<div class="row">
<div class="col-md-4 col-12">
<div class="news__image"><img src="./img/test-b.png" alt=""></div>
</div>
<div class="col-lg-6 col-md-8 col-12">
<div class="news__content">
<div class="news__title"><a href="#">Новость 1</a></div>
<div class="news__text">
<p>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).</p>
</div>
</div>
</div>
</div>
</div>
<div class="news__item">
<div class="row">
<div class="col-md-4 col-12">
<div class="news__image"><img src="./img/test-b.png" alt=""></div>
</div>
<div class="col-lg-6 col-md-8 col-12">
<div class="news__content">
<div class="news__title"><a href="#">Новость 1</a></div>
<div class="news__text">
<p>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).</p>
</div>
</div>
</div>
</div>
</div>
<div class="news__item">
<div class="row">
<div class="col-md-4 col-12">
<div class="news__image"><img src="./img/test-b.png" alt=""></div>
</div>
<div class="col-lg-6 col-md-8 col-12">
<div class="news__content">
<div class="news__title"><a href="#">Новость 1</a></div>
<div class="news__text">
<p>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).</p>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock content %}
Loading…
Cancel
Save