diff options
author | Yaroslav de la Peña Smirnov <contact@yaroslavps.com> | 2018-05-31 15:04:45 +0300 |
---|---|---|
committer | Yaroslav de la Peña Smirnov <contact@yaroslavps.com> | 2018-05-31 15:04:45 +0300 |
commit | 5a7466204b4030873405b1a0fcb8b208762453ee (patch) | |
tree | bc73cccb953b6ba25afdb7dffbee505a296e94ac /weblog | |
parent | be41310b3dc4aec12d3a950cf9fe737811436499 (diff) | |
download | w3blog-5a7466204b4030873405b1a0fcb8b208762453ee.tar.gz w3blog-5a7466204b4030873405b1a0fcb8b208762453ee.zip |
Ability to pin posts, updated to bootstrap 4, fixes
Diffstat (limited to 'weblog')
44 files changed, 298 insertions, 227 deletions
diff --git a/weblog/__init__.py b/weblog/__init__.py index a97f18a..8c180c5 100644..100755 --- a/weblog/__init__.py +++ b/weblog/__init__.py @@ -1,79 +1,6 @@ from . import apps from django.conf import settings -try: - apps.SETTINGS['enable_comments'] = settings.WEBLOG_ENABLE_COMMENTS -except AttributeError: - pass -except NameError: - pass - -try: - apps.SETTINGS['allow_anon_comments'] = settings.WEBLOG_ALLOW_ANON_COMMENTS -except AttributeError: - pass -except NameError: - pass - -try: - apps.SETTINGS['multilingual'] = settings.WEBLOG_MULTILINGUAL -except AttributeError: - pass -except NameError: - pass - -try: - apps.SETTINGS['blog_title'] = settings.WEBLOG_TITLE -except AttributeError: - pass -except NameError: - pass - -try: - apps.SETTINGS['base_template'] = settings.WEBLOG_BASE_TEMPLATE -except AttributeError: - pass -except NameError: - pass - -try: - apps.SETTINGS['show_author'] = settings.WEBLOG_SHOW_AUTHOR -except AttributeError: - pass -except NameError: - pass - -try: - apps.SETTINGS['use_authors_username'] = settings.WEBLOG_USE_AUTHORS_USERNAME -except AttributeError: - pass -except NameError: - pass - -try: - apps.SETTINGS['show_sidebar'] = settings.WEBLOG_SHOW_SIDEBAR -except AttributeError: - pass -except NameError: - pass - -try: - apps.SETTINGS['show_categories'] = settings.WEBLOG_SHOW_CATEGORIES -except AttributeError: - pass -except NameError: - pass - -try: - apps.SETTINGS['show_archive'] = settings.WEBLOG_SHOW_ARCHIVE -except AttributeError: - pass -except NameError: - pass - -try: - apps.SETTINGS['posts_per_page'] = settings.WEBLOG_POSTS_PER_PAGE -except AttributeError: - pass -except NameError: - pass
\ No newline at end of file +if settings.WEBLOG_SETTINGS: + for key, value in settings.WEBLOG_SETTINGS.items(): + apps.SETTINGS[key] = value diff --git a/weblog/admin.py b/weblog/admin.py index 1b4e128..1b4e128 100644..100755 --- a/weblog/admin.py +++ b/weblog/admin.py diff --git a/weblog/apps.py b/weblog/apps.py index 3389f92..6f2db71 100644..100755 --- a/weblog/apps.py +++ b/weblog/apps.py @@ -2,10 +2,10 @@ from django.apps import AppConfig SETTINGS = { 'enable_comments': False, - 'allow_anon_comments': True, + 'allow_anon_comments': False, 'multilingual': True, 'blog_title': 'Django-Weblog', - 'base_template': 'base.html', + 'base_template': 'weblog_base.html', 'show_author': True, 'use_authors_username': True, 'show_sidebar': True, diff --git a/weblog/locale/es/LC_MESSAGES/django.mo b/weblog/locale/es/LC_MESSAGES/django.mo Binary files differindex 9558ef1..51b607c 100644..100755 --- a/weblog/locale/es/LC_MESSAGES/django.mo +++ b/weblog/locale/es/LC_MESSAGES/django.mo diff --git a/weblog/locale/es/LC_MESSAGES/django.po b/weblog/locale/es/LC_MESSAGES/django.po index 5afb637..b3b69ff 100644..100755 --- a/weblog/locale/es/LC_MESSAGES/django.po +++ b/weblog/locale/es/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-01-31 08:00+0300\n" +"POT-Creation-Date: 2018-05-31 14:31+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -18,249 +18,280 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: weblog/models.py:8 weblog/models.py:23 +#: models.py:8 models.py:23 msgctxt "Noun, not personal name" msgid "Name" msgstr "Nombre" -#: weblog/models.py:9 weblog/models.py:45 +#: models.py:9 models.py:45 msgid "Slug (URL)" msgstr "" -#: weblog/models.py:10 +#: models.py:10 msgid "Parent category" msgstr "Categoría raíz" -#: weblog/models.py:19 weblog/models.py:25 +#: models.py:19 models.py:25 msgctxt "Post category" msgid "Category" msgstr "Categoría" -#: weblog/models.py:20 weblog/models.py:46 weblog/templates/weblog/post.html:16 -#: weblog/templates/weblog/sidebar_categories.html:3 +#: models.py:20 models.py:46 templates/weblog/post.html:16 +#: templates/weblog/sidebar_categories.html:3 msgctxt "Post categories" msgid "Categories" msgstr "Categorías" -#: weblog/models.py:24 weblog/models.py:67 +#: models.py:24 models.py:69 msgid "Language (ISO)" msgstr "Idioma (ISO)" -#: weblog/models.py:34 +#: models.py:34 msgid "Category name translation" msgstr "Traducción de la categoría" -#: weblog/models.py:35 +#: models.py:35 msgid "Category name translations" msgstr "Traducciones de categorías" -#: weblog/models.py:39 weblog/models.py:78 +#: models.py:39 models.py:80 msgid "Author" msgstr "Autor" -#: weblog/models.py:40 weblog/models.py:68 +#: models.py:40 models.py:70 msgctxt "As in name" msgid "Title" msgstr "Título" -#: weblog/models.py:41 weblog/models.py:69 weblog/models.py:80 +#: models.py:41 models.py:71 models.py:82 msgctxt "Of post, comment, article, etc." msgid "Content" msgstr "Contenido" -#: weblog/models.py:42 weblog/models.py:70 +#: models.py:42 models.py:72 msgid "Preview image" msgstr "Imágen de vista previa" -#: weblog/models.py:43 weblog/models.py:71 +#: models.py:43 models.py:73 msgid "Preview Text" msgstr "Texto de vista previa" -#: weblog/models.py:44 +#: models.py:44 msgid "Original language (ISO)" msgstr "Idioma original" -#: weblog/models.py:47 +#: models.py:47 +msgid "Pin blog post" +msgstr "Anclar entrada de blog" + +#: models.py:48 +msgid "Pinned post priority (if pinned)" +msgstr "Prioridad (entre entradas ancladas)" + +#: models.py:49 msgctxt "Make post viewable" msgid "Published" msgstr "Publicado" -#: weblog/models.py:48 +#: models.py:50 msgid "Publish date" msgstr "Fecha de publicación" -#: weblog/models.py:62 +#: models.py:64 msgid "Blog Post" msgstr "Entrada de blog" -#: weblog/models.py:63 +#: models.py:65 msgid "Blog Posts" msgstr "Entradas de blog" -#: weblog/models.py:66 weblog/models.py:79 +#: models.py:68 models.py:81 #, fuzzy #| msgid "Blog Post" msgctxt "Noun, as in blog post" msgid "Post" msgstr "Entrada" -#: weblog/models.py:74 +#: models.py:76 msgid "Translation" msgstr "Traducción" -#: weblog/models.py:75 +#: models.py:77 msgid "Translations" msgstr "Traducciones" -#: weblog/models.py:83 +#: models.py:85 msgctxt "Noun" msgid "Comment" msgstr "Comentario" -#: weblog/models.py:84 +#: models.py:86 msgctxt "Noun" msgid "Comments" msgstr "Comentarios" -#: weblog/templates/weblog/index.html:6 weblog/templatetags/weblog_extras.py:43 -#: weblog/views.py:75 weblog/views.py:150 +#: templates/weblog/index.html:6 templatetags/weblog_extras.py:43 views.py:94 +#: views.py:178 msgctxt "Posts without category" msgid "Uncategorized" msgstr "Sin categoría" -#: weblog/templates/weblog/index.html:17 +#: templates/weblog/index.html:11 templates/weblog/index.html:28 +msgctxt "Home page" +msgid "Home" +msgstr "Página principal" + +#: templates/weblog/index.html:17 msgctxt "Uncategorized page title" msgid "Uncategorized posts" msgstr "Entradas sin categoría" -#: weblog/templates/weblog/index.html:19 +#: templates/weblog/index.html:19 #, python-format msgctxt "Posts in category" msgid "Posts in %(category_name)s" msgstr "Entradas en %(category_name)s" -#: weblog/templates/weblog/index.html:28 weblog/templates/weblog/post.html:7 +#: templates/weblog/index.html:23 +#, python-format +msgctxt "Posts from archive (year/month,year)" +msgid "Posts from %(month)s, %(year)s" +msgstr "Entradas de %(month)s, %(year)s" + +#: templates/weblog/index.html:25 +#, python-format +msgctxt "Posts from archive (year/month,year)" +msgid "Posts from %(year)s" +msgstr "Entradas del %(year)s" + +#: templates/weblog/index.html:34 +msgid "Important post" +msgstr "Importante" + +#: templates/weblog/index.html:36 templates/weblog/index.html:51 +#: templates/weblog/post.html:7 #, python-format msgid "Published on %(publish_date)s" msgstr "Publicado el %(publish_date)s" -#: weblog/templates/weblog/index.html:28 weblog/templates/weblog/post.html:7 +#: templates/weblog/index.html:36 templates/weblog/index.html:51 +#: templates/weblog/post.html:7 #, python-format msgctxt "Written by (Author)" msgid ", by %(author)s" msgstr ", por %(author)s" -#: weblog/templates/weblog/index.html:34 +#: templates/weblog/index.html:42 templates/weblog/index.html:57 msgid "Read more..." msgstr "Leer más..." -#: weblog/templates/weblog/index.html:41 +#: templates/weblog/index.html:64 msgctxt "Page" msgid "First" msgstr "Primera" -#: weblog/templates/weblog/index.html:42 +#: templates/weblog/index.html:65 msgctxt "Page" msgid "Previous" msgstr "Anterior" -#: weblog/templates/weblog/index.html:70 +#: templates/weblog/index.html:93 msgctxt "Page" msgid "Next" msgstr "Siguiente" -#: weblog/templates/weblog/index.html:71 +#: templates/weblog/index.html:94 msgctxt "Page" msgid "Last" msgstr "Última" -#: weblog/templates/weblog/index.html:76 +#: templates/weblog/index.html:100 msgid "Nothing has been posted yet." msgstr "No hay ninguna publicación." -#: weblog/templates/weblog/post.html:24 +#: templates/weblog/post.html:24 msgid "Leave a comment" msgstr "Dejar un comentario" -#: weblog/templates/weblog/post.html:31 +#: templates/weblog/post.html:31 msgid "Submit comment" msgstr "Enviar comentario" -#: weblog/templates/weblog/post.html:35 +#: templates/weblog/post.html:35 msgid "To leave a comment you need to sign in" msgstr "Para poder comentar, necesitar iniciar sesión." -#: weblog/templates/weblog/post.html:47 +#: templates/weblog/post.html:47 msgid "Comment submited successfully" msgstr "Comentario enviado exitosamente" -#: weblog/templates/weblog/post.html:54 +#: templates/weblog/post.html:54 msgctxt "Unauthenticated comment poster" msgid "Anonymous" msgstr "Anónimo" -#: weblog/templates/weblog/post.html:62 +#: templates/weblog/post.html:62 msgid "Nobody has left a comment on this post yet" msgstr "No hay ningún comentario relacionado a esta entrada" -#: weblog/templates/weblog/sidebar_archive.html:2 +#: templates/weblog/sidebar_archive.html:2 msgctxt "Blog archive" msgid "Archive" msgstr "Archivo" -#: weblog/templatetags/weblog_extras.py:12 +#: templatetags/weblog_extras.py:12 msgid "January" msgstr "" -#: weblog/templatetags/weblog_extras.py:13 +#: templatetags/weblog_extras.py:13 msgid "February" msgstr "" -#: weblog/templatetags/weblog_extras.py:14 +#: templatetags/weblog_extras.py:14 msgid "March" msgstr "" -#: weblog/templatetags/weblog_extras.py:15 +#: templatetags/weblog_extras.py:15 msgid "April" msgstr "" -#: weblog/templatetags/weblog_extras.py:16 +#: templatetags/weblog_extras.py:16 msgid "May" msgstr "" -#: weblog/templatetags/weblog_extras.py:17 +#: templatetags/weblog_extras.py:17 msgid "June" msgstr "" -#: weblog/templatetags/weblog_extras.py:18 +#: templatetags/weblog_extras.py:18 msgid "July" msgstr "" -#: weblog/templatetags/weblog_extras.py:19 +#: templatetags/weblog_extras.py:19 msgid "August" msgstr "" -#: weblog/templatetags/weblog_extras.py:20 +#: templatetags/weblog_extras.py:20 msgid "September" msgstr "" -#: weblog/templatetags/weblog_extras.py:21 +#: templatetags/weblog_extras.py:21 msgid "October" msgstr "" -#: weblog/templatetags/weblog_extras.py:22 +#: templatetags/weblog_extras.py:22 msgid "November" msgstr "" -#: weblog/templatetags/weblog_extras.py:23 +#: templatetags/weblog_extras.py:23 msgid "December" msgstr "" -#: weblog/views.py:171 +#: views.py:199 msgid "You need to sign in to submit a comment" msgstr "Para poder comentar necesita iniciar sesión" -#: weblog/views.py:173 +#: views.py:201 msgid "Error submitting comment: Invalid data" msgstr "Error al intentar enviar el comentario: Información invalida" diff --git a/weblog/locale/ru/LC_MESSAGES/django.mo b/weblog/locale/ru/LC_MESSAGES/django.mo Binary files differindex a419335..723a8e1 100644..100755 --- a/weblog/locale/ru/LC_MESSAGES/django.mo +++ b/weblog/locale/ru/LC_MESSAGES/django.mo diff --git a/weblog/locale/ru/LC_MESSAGES/django.po b/weblog/locale/ru/LC_MESSAGES/django.po index e586fbd..6af07da 100644..100755 --- a/weblog/locale/ru/LC_MESSAGES/django.po +++ b/weblog/locale/ru/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-01-31 08:00+0300\n" +"POT-Creation-Date: 2018-05-31 14:31+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -20,247 +20,278 @@ msgstr "" "%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n" "%100>=11 && n%100<=14)? 2 : 3);\n" -#: weblog/models.py:8 weblog/models.py:23 +#: models.py:8 models.py:23 msgctxt "Noun, not personal name" msgid "Name" msgstr "Название" -#: weblog/models.py:9 weblog/models.py:45 +#: models.py:9 models.py:45 msgid "Slug (URL)" msgstr "" -#: weblog/models.py:10 +#: models.py:10 msgid "Parent category" msgstr "Корневая категория" -#: weblog/models.py:19 weblog/models.py:25 +#: models.py:19 models.py:25 msgctxt "Post category" msgid "Category" msgstr "Категория" -#: weblog/models.py:20 weblog/models.py:46 weblog/templates/weblog/post.html:16 -#: weblog/templates/weblog/sidebar_categories.html:3 +#: models.py:20 models.py:46 templates/weblog/post.html:16 +#: templates/weblog/sidebar_categories.html:3 msgctxt "Post categories" msgid "Categories" msgstr "Категории" -#: weblog/models.py:24 weblog/models.py:67 +#: models.py:24 models.py:69 msgid "Language (ISO)" msgstr "Язык (В стандарте ISO)" -#: weblog/models.py:34 +#: models.py:34 msgid "Category name translation" msgstr "Перевод названия категории" -#: weblog/models.py:35 +#: models.py:35 msgid "Category name translations" msgstr "Переводы названия категории" -#: weblog/models.py:39 weblog/models.py:78 +#: models.py:39 models.py:80 msgid "Author" msgstr "Автор" -#: weblog/models.py:40 weblog/models.py:68 +#: models.py:40 models.py:70 msgctxt "As in name" msgid "Title" msgstr "Название" -#: weblog/models.py:41 weblog/models.py:69 weblog/models.py:80 +#: models.py:41 models.py:71 models.py:82 msgctxt "Of post, comment, article, etc." msgid "Content" msgstr "Содержание" -#: weblog/models.py:42 weblog/models.py:70 +#: models.py:42 models.py:72 msgid "Preview image" msgstr "Картинка предпросмотра" -#: weblog/models.py:43 weblog/models.py:71 +#: models.py:43 models.py:73 msgid "Preview Text" msgstr "Текст предпросмотра" -#: weblog/models.py:44 +#: models.py:44 msgid "Original language (ISO)" msgstr "Язык оригинала (в стандарте ISO)" -#: weblog/models.py:47 +#: models.py:47 +msgid "Pin blog post" +msgstr "Прикрепить запись блога" + +#: models.py:48 +msgid "Pinned post priority (if pinned)" +msgstr "Приоритет прикрепленной записи" + +#: models.py:49 msgctxt "Make post viewable" msgid "Published" msgstr "Опубликовать" -#: weblog/models.py:48 +#: models.py:50 msgid "Publish date" msgstr "Дата публикации" -#: weblog/models.py:62 +#: models.py:64 msgid "Blog Post" msgstr "Запись блога" -#: weblog/models.py:63 +#: models.py:65 msgid "Blog Posts" msgstr "Записи блога" -#: weblog/models.py:66 weblog/models.py:79 +#: models.py:68 models.py:81 msgctxt "Noun, as in blog post" msgid "Post" msgstr "Запись" -#: weblog/models.py:74 +#: models.py:76 msgid "Translation" msgstr "Перевод" -#: weblog/models.py:75 +#: models.py:77 msgid "Translations" msgstr "Переводы" -#: weblog/models.py:83 +#: models.py:85 msgctxt "Noun" msgid "Comment" msgstr "Комментарий" -#: weblog/models.py:84 +#: models.py:86 msgctxt "Noun" msgid "Comments" msgstr "Комментарии" -#: weblog/templates/weblog/index.html:6 weblog/templatetags/weblog_extras.py:43 -#: weblog/views.py:75 weblog/views.py:150 +#: templates/weblog/index.html:6 templatetags/weblog_extras.py:43 views.py:94 +#: views.py:178 msgctxt "Posts without category" msgid "Uncategorized" msgstr "Без категории" -#: weblog/templates/weblog/index.html:17 +#: templates/weblog/index.html:11 templates/weblog/index.html:28 +msgctxt "Home page" +msgid "Home" +msgstr "Главная" + +#: templates/weblog/index.html:17 msgctxt "Uncategorized page title" msgid "Uncategorized posts" msgstr "Записи без категории" -#: weblog/templates/weblog/index.html:19 +#: templates/weblog/index.html:19 #, python-format msgctxt "Posts in category" msgid "Posts in %(category_name)s" msgstr "Записи в %(category_name)s" -#: weblog/templates/weblog/index.html:28 weblog/templates/weblog/post.html:7 +#: templates/weblog/index.html:23 +#, python-format +msgctxt "Posts from archive (year/month,year)" +msgid "Posts from %(month)s, %(year)s" +msgstr "Архив: %(month)s, %(year)s" + +#: templates/weblog/index.html:25 +#, python-format +msgctxt "Posts from archive (year/month,year)" +msgid "Posts from %(year)s" +msgstr "Архив: %(year)s" + +#: templates/weblog/index.html:34 +msgid "Important post" +msgstr "Прикрепленная запись" + +#: templates/weblog/index.html:36 templates/weblog/index.html:51 +#: templates/weblog/post.html:7 #, python-format msgid "Published on %(publish_date)s" msgstr "Опубликовано %(publish_date)s" -#: weblog/templates/weblog/index.html:28 weblog/templates/weblog/post.html:7 +#: templates/weblog/index.html:36 templates/weblog/index.html:51 +#: templates/weblog/post.html:7 #, python-format msgctxt "Written by (Author)" msgid ", by %(author)s" msgstr ". %(author)s" -#: weblog/templates/weblog/index.html:34 +#: templates/weblog/index.html:42 templates/weblog/index.html:57 msgid "Read more..." msgstr "Читать далее..." -#: weblog/templates/weblog/index.html:41 +#: templates/weblog/index.html:64 msgctxt "Page" msgid "First" msgstr "Первая" -#: weblog/templates/weblog/index.html:42 +#: templates/weblog/index.html:65 msgctxt "Page" msgid "Previous" msgstr "Предыдущая" -#: weblog/templates/weblog/index.html:70 +#: templates/weblog/index.html:93 msgctxt "Page" msgid "Next" msgstr "Следующая" -#: weblog/templates/weblog/index.html:71 +#: templates/weblog/index.html:94 msgctxt "Page" msgid "Last" msgstr "Последняя" -#: weblog/templates/weblog/index.html:76 +#: templates/weblog/index.html:100 msgid "Nothing has been posted yet." msgstr "Нет записи на данный момент." -#: weblog/templates/weblog/post.html:24 +#: templates/weblog/post.html:24 msgid "Leave a comment" msgstr "Оставьте комментарий" -#: weblog/templates/weblog/post.html:31 +#: templates/weblog/post.html:31 msgid "Submit comment" msgstr "Отправить комметарий" -#: weblog/templates/weblog/post.html:35 +#: templates/weblog/post.html:35 msgid "To leave a comment you need to sign in" msgstr "Для того чтобы оставить комментарий, зайдите в свою учетную запись" -#: weblog/templates/weblog/post.html:47 +#: templates/weblog/post.html:47 msgid "Comment submited successfully" msgstr "Ваш комментарий был успешно отправлен" -#: weblog/templates/weblog/post.html:54 +#: templates/weblog/post.html:54 msgctxt "Unauthenticated comment poster" msgid "Anonymous" msgstr "Анонимный" -#: weblog/templates/weblog/post.html:62 +#: templates/weblog/post.html:62 msgid "Nobody has left a comment on this post yet" msgstr "У этой записи нет комментарии." -#: weblog/templates/weblog/sidebar_archive.html:2 +#: templates/weblog/sidebar_archive.html:2 msgctxt "Blog archive" msgid "Archive" msgstr "Архив" -#: weblog/templatetags/weblog_extras.py:12 +#: templatetags/weblog_extras.py:12 msgid "January" msgstr "" -#: weblog/templatetags/weblog_extras.py:13 +#: templatetags/weblog_extras.py:13 msgid "February" msgstr "" -#: weblog/templatetags/weblog_extras.py:14 +#: templatetags/weblog_extras.py:14 msgid "March" msgstr "" -#: weblog/templatetags/weblog_extras.py:15 +#: templatetags/weblog_extras.py:15 msgid "April" msgstr "" -#: weblog/templatetags/weblog_extras.py:16 +#: templatetags/weblog_extras.py:16 msgid "May" msgstr "" -#: weblog/templatetags/weblog_extras.py:17 +#: templatetags/weblog_extras.py:17 msgid "June" msgstr "" -#: weblog/templatetags/weblog_extras.py:18 +#: templatetags/weblog_extras.py:18 msgid "July" msgstr "" -#: weblog/templatetags/weblog_extras.py:19 +#: templatetags/weblog_extras.py:19 msgid "August" msgstr "" -#: weblog/templatetags/weblog_extras.py:20 +#: templatetags/weblog_extras.py:20 msgid "September" msgstr "" -#: weblog/templatetags/weblog_extras.py:21 +#: templatetags/weblog_extras.py:21 msgid "October" msgstr "" -#: weblog/templatetags/weblog_extras.py:22 +#: templatetags/weblog_extras.py:22 msgid "November" msgstr "" -#: weblog/templatetags/weblog_extras.py:23 +#: templatetags/weblog_extras.py:23 msgid "December" msgstr "" -#: weblog/views.py:171 +#: views.py:199 msgid "You need to sign in to submit a comment" msgstr "Для того чтобы оставить комментарий, зайдите в свою учетную запись" -#: weblog/views.py:173 +#: views.py:201 msgid "Error submitting comment: Invalid data" msgstr "Ошибка: неправильный формат данных" diff --git a/weblog/migrations/0001_initial.py b/weblog/migrations/0001_initial.py index 2ab0238..2ab0238 100644..100755 --- a/weblog/migrations/0001_initial.py +++ b/weblog/migrations/0001_initial.py diff --git a/weblog/migrations/0002_auto_20180113_1606.py b/weblog/migrations/0002_auto_20180113_1606.py index 8eb3789..8eb3789 100644..100755 --- a/weblog/migrations/0002_auto_20180113_1606.py +++ b/weblog/migrations/0002_auto_20180113_1606.py diff --git a/weblog/migrations/0003_auto_20180119_0156.py b/weblog/migrations/0003_auto_20180119_0156.py index 73ca4e1..73ca4e1 100644..100755 --- a/weblog/migrations/0003_auto_20180119_0156.py +++ b/weblog/migrations/0003_auto_20180119_0156.py diff --git a/weblog/migrations/0004_auto_20180119_0156.py b/weblog/migrations/0004_auto_20180119_0156.py index 937b7a0..937b7a0 100644..100755 --- a/weblog/migrations/0004_auto_20180119_0156.py +++ b/weblog/migrations/0004_auto_20180119_0156.py diff --git a/weblog/migrations/0005_auto_20180119_0231.py b/weblog/migrations/0005_auto_20180119_0231.py index 42b1bd0..42b1bd0 100644..100755 --- a/weblog/migrations/0005_auto_20180119_0231.py +++ b/weblog/migrations/0005_auto_20180119_0231.py diff --git a/weblog/migrations/0006_auto_20180121_1002.py b/weblog/migrations/0006_auto_20180121_1002.py index db56a3f..db56a3f 100644..100755 --- a/weblog/migrations/0006_auto_20180121_1002.py +++ b/weblog/migrations/0006_auto_20180121_1002.py diff --git a/weblog/migrations/0007_auto_20180122_1943.py b/weblog/migrations/0007_auto_20180122_1943.py index cae0a4f..cae0a4f 100644..100755 --- a/weblog/migrations/0007_auto_20180122_1943.py +++ b/weblog/migrations/0007_auto_20180122_1943.py diff --git a/weblog/migrations/0008_auto_20180531_0329.py b/weblog/migrations/0008_auto_20180531_0329.py new file mode 100644 index 0000000..d79446b --- /dev/null +++ b/weblog/migrations/0008_auto_20180531_0329.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.8 on 2018-05-31 03:29 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('weblog', '0007_auto_20180122_1943'), + ] + + operations = [ + migrations.AddField( + model_name='blogpost', + name='pin_priority', + field=models.IntegerField(default=0, verbose_name='Pinned post priority (if pinned)'), + ), + migrations.AddField( + model_name='blogpost', + name='pinned', + field=models.BooleanField(default=False, verbose_name='Pin blog post'), + ), + ] diff --git a/weblog/migrations/__init__.py b/weblog/migrations/__init__.py index e69de29..e69de29 100644..100755 --- a/weblog/migrations/__init__.py +++ b/weblog/migrations/__init__.py diff --git a/weblog/migrations/__pycache__/0001_initial.cpython-36.pyc b/weblog/migrations/__pycache__/0001_initial.cpython-36.pyc Binary files differnew file mode 100755 index 0000000..b917027 --- /dev/null +++ b/weblog/migrations/__pycache__/0001_initial.cpython-36.pyc diff --git a/weblog/migrations/__pycache__/0002_auto_20180113_1606.cpython-36.pyc b/weblog/migrations/__pycache__/0002_auto_20180113_1606.cpython-36.pyc Binary files differnew file mode 100755 index 0000000..31d68d5 --- /dev/null +++ b/weblog/migrations/__pycache__/0002_auto_20180113_1606.cpython-36.pyc diff --git a/weblog/migrations/__pycache__/0003_auto_20180119_0156.cpython-36.pyc b/weblog/migrations/__pycache__/0003_auto_20180119_0156.cpython-36.pyc Binary files differnew file mode 100755 index 0000000..92a494b --- /dev/null +++ b/weblog/migrations/__pycache__/0003_auto_20180119_0156.cpython-36.pyc diff --git a/weblog/migrations/__pycache__/0004_auto_20180119_0156.cpython-36.pyc b/weblog/migrations/__pycache__/0004_auto_20180119_0156.cpython-36.pyc Binary files differnew file mode 100755 index 0000000..c19f139 --- /dev/null +++ b/weblog/migrations/__pycache__/0004_auto_20180119_0156.cpython-36.pyc diff --git a/weblog/migrations/__pycache__/0005_auto_20180119_0231.cpython-36.pyc b/weblog/migrations/__pycache__/0005_auto_20180119_0231.cpython-36.pyc Binary files differnew file mode 100755 index 0000000..d3ab56c --- /dev/null +++ b/weblog/migrations/__pycache__/0005_auto_20180119_0231.cpython-36.pyc diff --git a/weblog/migrations/__pycache__/0006_auto_20180121_1002.cpython-36.pyc b/weblog/migrations/__pycache__/0006_auto_20180121_1002.cpython-36.pyc Binary files differnew file mode 100755 index 0000000..11fd025 --- /dev/null +++ b/weblog/migrations/__pycache__/0006_auto_20180121_1002.cpython-36.pyc diff --git a/weblog/migrations/__pycache__/0007_auto_20180122_1943.cpython-36.pyc b/weblog/migrations/__pycache__/0007_auto_20180122_1943.cpython-36.pyc Binary files differnew file mode 100755 index 0000000..21d3e78 --- /dev/null +++ b/weblog/migrations/__pycache__/0007_auto_20180122_1943.cpython-36.pyc diff --git a/weblog/migrations/__pycache__/0008_auto_20180531_0329.cpython-36.pyc b/weblog/migrations/__pycache__/0008_auto_20180531_0329.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..915bf26 --- /dev/null +++ b/weblog/migrations/__pycache__/0008_auto_20180531_0329.cpython-36.pyc diff --git a/weblog/migrations/__pycache__/__init__.cpython-36.pyc b/weblog/migrations/__pycache__/__init__.cpython-36.pyc Binary files differnew file mode 100755 index 0000000..2e5cba0 --- /dev/null +++ b/weblog/migrations/__pycache__/__init__.cpython-36.pyc diff --git a/weblog/models.py b/weblog/models.py index 80e917e..3c4935e 100644..100755 --- a/weblog/models.py +++ b/weblog/models.py @@ -11,7 +11,7 @@ class Category(models.Model): def get_absolute_url(self): return reverse('weblog:CategoryIndex', kwargs={'category_slug': self.slug}) - + def __str__(self): return self.name @@ -44,6 +44,8 @@ class BlogPost(models.Model): original_language = models.CharField(max_length=5, verbose_name=_('Original language (ISO)'), blank=True) slug = models.SlugField(max_length=100, verbose_name=_('Slug (URL)'), db_index=True, unique=True) categories = models.ManyToManyField(Category, verbose_name=pgettext_lazy('Post categories', 'Categories'), blank=True) + pinned = models.BooleanField(verbose_name=_('Pin blog post'), default=False) + pin_priority = models.IntegerField(verbose_name=_('Pinned post priority (if pinned)'), default=0) published = models.BooleanField(verbose_name=pgettext_lazy('Make post viewable', 'Published')) publish_date = models.DateTimeField(verbose_name=_('Publish date')) @@ -90,4 +92,4 @@ class PostCommentForm(ModelForm): labels = {'content': ''} widgets = { 'content': Textarea(attrs={'class': 'form-control', 'rows': '5'}), - }
\ No newline at end of file + } diff --git a/weblog/static/weblog/css/weblog.css b/weblog/static/weblog/css/weblog.css index cb1facc..cb1facc 100644..100755 --- a/weblog/static/weblog/css/weblog.css +++ b/weblog/static/weblog/css/weblog.css diff --git a/weblog/static/weblog/js/weblog.js b/weblog/static/weblog/js/weblog.js index b802841..b802841 100644..100755 --- a/weblog/static/weblog/js/weblog.js +++ b/weblog/static/weblog/js/weblog.js diff --git a/weblog/templates/weblog/index.html b/weblog/templates/weblog/index.html index c46da38..7231cf7 100644..100755 --- a/weblog/templates/weblog/index.html +++ b/weblog/templates/weblog/index.html @@ -8,7 +8,7 @@ {{ category.name }}
{% endif %}
{% else %}
-{{ blog_title }}
+{% trans "Home" context "Home page" %}
{% endif %}
{% endblock %}
{% block blog_content_block %}
@@ -18,9 +18,32 @@ {% else %}
<h1>{% blocktrans with category_name=category.name context 'Posts in category' %}Posts in {{ category_name }}{% endblocktrans %}</h1>
{% endif %}
+{% elif year %}
+{% if month %}
+<h1>{% blocktrans with category_name=category.name context 'Posts from archive (year/month,year)' %}Posts from {{ month }}, {{ year }}{% endblocktrans %}</h1>
{% else %}
-<h1>{{ blog_title }}</h1>
+<h1>{% blocktrans with category_name=category.name context 'Posts from archive (year/month,year)' %}Posts from {{ year }}{% endblocktrans %}</h1>
{% endif %}
+{% else %}
+<h1>{{ blog_title }} - {% trans "Home" context "Home page" %}</h1>
+{% endif %}
+ {% if posts or pinned_posts %}
+ {% if pinned_posts %}
+ {% for post in pinned_posts %}
+ <div class="container-fluid blogpost">
+ <p><span class="fas fa-thumbtack"></span> <i>{% trans 'Important post' %}</i></p>
+ <h2><a href="{{ post.url }}">{{ post.title }}</a></h2>
+ <p class="publish-info">{% blocktrans with publish_date=post.publish_date %}Published on {{ publish_date }}{% endblocktrans %}{% if post.author %}{% blocktrans with author=post.author context 'Written by (Author)' %}, by {{ author }}{% endblocktrans %}{% endif %}</p>
+ <hr>
+ {% if post.preview_image %}<img class="img-responsive preview-img" src="{{ post.preview_image.url }}">{% endif %}
+ {{ post.preview_text|safe }}
+ <hr>
+ <div class="text-right">
+ <a href="{{ post.url }}">{% trans 'Read more...' %}</a>
+ </div>
+ </div>
+ {% endfor %}
+ {% endif %}
{% if posts %}
{% for post in posts %}
<div class="container-fluid blogpost">
@@ -72,7 +95,8 @@ {% endif %}
</ul>
{% endif %}
+ {% endif %}
{% else %}
<div class="text-center"><h2>{% trans 'Nothing has been posted yet.' %}</h2></div>
{% endif %}
-{% endblock %}
\ No newline at end of file +{% endblock %}
diff --git a/weblog/templates/weblog/post.html b/weblog/templates/weblog/post.html index 364e17c..364e17c 100644..100755 --- a/weblog/templates/weblog/post.html +++ b/weblog/templates/weblog/post.html diff --git a/weblog/templates/weblog/sidebar_archive.html b/weblog/templates/weblog/sidebar_archive.html index 5953bfe..5953bfe 100644..100755 --- a/weblog/templates/weblog/sidebar_archive.html +++ b/weblog/templates/weblog/sidebar_archive.html diff --git a/weblog/templates/weblog/sidebar_categories.html b/weblog/templates/weblog/sidebar_categories.html index 7e7fa5c..7e7fa5c 100644..100755 --- a/weblog/templates/weblog/sidebar_categories.html +++ b/weblog/templates/weblog/sidebar_categories.html diff --git a/weblog/templates/weblog/weblog.html b/weblog/templates/weblog/weblog.html index 9980b54..e24c918 100644..100755 --- a/weblog/templates/weblog/weblog.html +++ b/weblog/templates/weblog/weblog.html @@ -3,18 +3,18 @@ {% load weblog_extras %} {% block title_block %}{% endblock %} {% block blog_block %} -<ol class="breadcrumb"> +<ul class="breadcrumb"> {% if breadcrumbs %} - <li><a href="{% url 'weblog:Index' %}">{{ blog_title }}</a></li> + <li class="breadcrumb-item"><a href="{% url 'weblog:Index' %}">{{ blog_title }}</a></li> {% for crumb in breadcrumbs %} {% if forloop.last %} - <li class="active">{{ crumb.name }}</li> - {% else %}<li><a href="{{ crumb.url }}">{{ crumb.name }}</a></li>{% endif %} + <li class="breadcrumb-item active">{{ crumb.name }}</li> + {% else %}<li class="breadcrumb-item"><a href="{{ crumb.url }}">{{ crumb.name }}</a></li>{% endif %} {% endfor %} {% else %} - <li class="active"><a href="{% url 'weblog:Index' %}">{{ blog_title }}</a></li> + <li class="breadcrumb-item active"><a href="{% url 'weblog:Index' %}">{{ blog_title }}</a></li> {% endif %} -</ol> +</ul> <div class="row"> <div class="{% if show_sidebar %}col-sm-9{% else %}container-fluid{% endif %}"> {% block blog_content_block %} @@ -39,4 +39,4 @@ </div> {% endif %} </div> -{% endblock %}
\ No newline at end of file +{% endblock %} diff --git a/weblog/templates/weblog_base.html b/weblog/templates/weblog_base.html index 536e736..9a739cb 100644..100755 --- a/weblog/templates/weblog_base.html +++ b/weblog/templates/weblog_base.html @@ -3,19 +3,20 @@ <html>
<head>
<meta charset="utf-8">
- <title>Simple blog - {% block title_block %} Home {% endblock %}</title>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
+ <meta content="width=device-width, initial-scale=1" name="viewport">
+ <title>{{ blog_title }} - {% block title_block %} Home {% endblock %}</title>
+ <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
<link rel="stylesheet" href="{% static '/weblog/css/weblog.css' %}">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js" defer></script>
+ <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
+ <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
<script src="{% static '/weblog/js/weblog.js' %}" defer></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" defer></script>
</head>
<body>
- <nav class="navbar navbar-inverse">
+ <nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<div class="container nav-container">
- <div class="navbar-header">
- <a class="navbar-brand" href="{% url 'weblog:Index' %}">{{ blog_title }}</a>
- </div>
+ <a class="navbar-brand" href="{% url 'weblog:Index' %}">{{ blog_title }}</a>
</div>
</nav>
<div class="container">
@@ -25,4 +26,4 @@ {% endblock %}
</div>
</body>
-</html>
\ No newline at end of file +</html>
diff --git a/weblog/templates/weblog_base_old.html b/weblog/templates/weblog_base_old.html index a4dbd30..a4dbd30 100644..100755 --- a/weblog/templates/weblog_base_old.html +++ b/weblog/templates/weblog_base_old.html diff --git a/weblog/templatetags/__init__.py b/weblog/templatetags/__init__.py index e69de29..e69de29 100644..100755 --- a/weblog/templatetags/__init__.py +++ b/weblog/templatetags/__init__.py diff --git a/weblog/templatetags/__pycache__/__init__.cpython-35.pyc b/weblog/templatetags/__pycache__/__init__.cpython-35.pyc Binary files differdeleted file mode 100644 index 8b2440b..0000000 --- a/weblog/templatetags/__pycache__/__init__.cpython-35.pyc +++ /dev/null diff --git a/weblog/templatetags/__pycache__/__init__.cpython-36.pyc b/weblog/templatetags/__pycache__/__init__.cpython-36.pyc Binary files differdeleted file mode 100644 index 8ec5021..0000000 --- a/weblog/templatetags/__pycache__/__init__.cpython-36.pyc +++ /dev/null diff --git a/weblog/templatetags/__pycache__/weblog_extras.cpython-35.pyc b/weblog/templatetags/__pycache__/weblog_extras.cpython-35.pyc Binary files differdeleted file mode 100644 index bcc8327..0000000 --- a/weblog/templatetags/__pycache__/weblog_extras.cpython-35.pyc +++ /dev/null diff --git a/weblog/templatetags/__pycache__/weblog_extras.cpython-36.pyc b/weblog/templatetags/__pycache__/weblog_extras.cpython-36.pyc Binary files differdeleted file mode 100644 index eb1b1e6..0000000 --- a/weblog/templatetags/__pycache__/weblog_extras.cpython-36.pyc +++ /dev/null diff --git a/weblog/templatetags/weblog_extras.py b/weblog/templatetags/weblog_extras.py index 1f72a86..25431f5 100644..100755 --- a/weblog/templatetags/weblog_extras.py +++ b/weblog/templatetags/weblog_extras.py @@ -46,6 +46,8 @@ def get_sidebar_categories(selected_cat_slug=None): @register.inclusion_tag('weblog/sidebar_archive.html') def get_sidebar_archive(): + if BlogPost.objects.all().count() < 1: + return {} now = datetime.datetime.now() oldest_post = BlogPost.objects.filter(published=True).reverse()[0] first_year = oldest_post.publish_date.year @@ -57,10 +59,11 @@ def get_sidebar_archive(): c_year = first_year archive = [] while c_year <= latest_year: - if BlogPost.objects.filter(publish_date__year=c_year, publish_date__lte=now, published=True).count() > 0: + year_posts = BlogPost.objects.filter(publish_date__year=c_year, publish_date__lte=now, published=True) + if year_posts.count() > 0: this_years_months = [] while (c_year < latest_year or c_month <= latest_month) and c_month <= 12: - if BlogPost.objects.filter(publish_date__month=c_month, publish_date__lte=now, published=True).count() > 0: + if year_posts.filter(publish_date__month=c_month, publish_date__lte=now, published=True).count() > 0: this_years_months.append((c_month, MONTHS[c_month-1])) c_month+=1 archive.append((c_year, this_years_months)) diff --git a/weblog/tests.py b/weblog/tests.py index 7ce503c..7ce503c 100644..100755 --- a/weblog/tests.py +++ b/weblog/tests.py diff --git a/weblog/urls.py b/weblog/urls.py index 643e8c7..643e8c7 100644..100755 --- a/weblog/urls.py +++ b/weblog/urls.py diff --git a/weblog/views.py b/weblog/views.py index 8a05bcc..e082d05 100644..100755 --- a/weblog/views.py +++ b/weblog/views.py @@ -5,10 +5,10 @@ from django.utils import translation from django.utils.translation import ugettext_lazy as _, pgettext_lazy from .apps import SETTINGS as blog_settings from .models import BlogPost, Translation, PostComment, Category, CategoryTranslation, PostCommentForm +from .templatetags.weblog_extras import MONTHS import datetime -#Why the hell didn't I just pass the variables to the context_dict in the first place?? -#Need to remove this later +#Need to change the way this works later IS_MULTILINGUAL = blog_settings['multilingual'] BASE_TEMPLATE = blog_settings['base_template'] BLOG_TITLE = blog_settings['blog_title'] @@ -24,6 +24,8 @@ def Index(request, **kwargs): now = datetime.datetime.now() all_pages = BlogPost.objects.filter(published=True, publish_date__lte=now) category = None + + # Check for arguments to see if it is the main page, category page, or archive if kwargs is not None: category_slug = kwargs.get('category_slug') year = kwargs.get('year') @@ -37,9 +39,16 @@ def Index(request, **kwargs): context_dict['category'] = category all_pages = BlogPost.objects.filter(published=True, publish_date__lte=now, categories__slug=category_slug) if year: + context_dict['year'] = year all_pages = BlogPost.objects.filter(published=True, publish_date__lte=now, publish_date__year=year) + context_dict['breadcrumbs'] = [{'url': reverse('weblog:ArchiveIndex', kwargs={'year': year}), 'name': str(year)},] if month: - all_pages = BlogPost.objects.filter(published=True, publish_date__lte=now, publish_date__month=month) + context_dict['month'] = MONTHS[int(month)-1] + all_pages = all_pages.filter(published=True, publish_date__lte=now, publish_date__month=month) + context_dict['breadcrumbs'].append({'url': reverse('weblog:ArchiveIndex', kwargs={'year': year, 'month': month}), 'name': MONTHS[int(month)-1]}) + + # Check how many blog posts are there in total, to calculate into how many pages + # the index needs to be divided post_count = all_pages.count() if post_count < 1: return render(request, 'weblog/index.html', context_dict) @@ -58,12 +67,22 @@ def Index(request, **kwargs): else: last_page = int(post_count/POSTS_PER_PAGE)+1 context_dict['last_page'] = last_page - posts_raw = all_pages[slice_start:slice_end] - if category_slug: - posts_raw = all_pages[slice_start:slice_end] + + # Check for pinned posts if it is the home page of the blog + # and get the pinned and necessary posts depending on the page + posts_raw = list(all_pages[slice_start:slice_end]) + if category is None: + for pinned_post in BlogPost.objects.filter(pinned=True).order_by('-pin_priority'): + if pinned_post in posts_raw: + posts_raw.remove(pinned_post) + posts_raw.append(pinned_post) + + # Get the language from the user agent, if there's none, use the default current_language = translation.get_language() if current_language is None: current_language = settings.LANGUAGE_CODE + + # If it is a category page, get the category url and breadcrumbs if category_slug: if IS_MULTILINGUAL and category_slug != 'misc': category_translations = CategoryTranslation.objects.filter(category=category) @@ -75,7 +94,12 @@ def Index(request, **kwargs): context_dict['breadcrumbs'] = [{'url': reverse('weblog:CategoryIndex', kwargs={'category_slug': category_slug}), 'name': pgettext_lazy('Posts without category', 'Uncategorized')},] else: context_dict['breadcrumbs'] = [{'url': reverse('weblog:CategoryIndex', kwargs={'category_slug': category_slug}), 'name': context_dict['category']},] + + # Earlier we got just the posts from BlogPost model, now, if we are using the localization capabilities + # we check for the language in use and select the appropiate translation language if available + # otherwise default to the original blog post, or fallback language posts = [] + pinned_posts = [] for post_raw in posts_raw: post = {'publish_date': post_raw.publish_date, 'url': post_raw.get_absolute_url()} if SHOW_AUTHOR: @@ -120,8 +144,12 @@ def Index(request, **kwargs): post['preview_text'] = post_raw.preview_text else: post['preview_text'] = post_raw.content.split('</p>', 1)[0]+'</p>' - posts.append(post) + if post_raw.pinned: + pinned_posts.append(post) + else: + posts.append(post) context_dict['posts'] = posts + context_dict['pinned_posts'] = pinned_posts return render(request, 'weblog/index.html', context_dict) @@ -166,7 +194,7 @@ def PostView(request, category_slug, post_slug): new_comment.save() elif ALLOW_ANON_COMMENTS: new_comment = PostComment(post=post, content=comment_content) - new_comment.save() + new_comment.save() else: context_dict['comment_submission_error'] = _('You need to sign in to submit a comment') else: @@ -193,7 +221,7 @@ def PostView(request, category_slug, post_slug): if current_language[0:2] == post_translation.language[0:2]: context_dict['post_translation'] = post_translation if 'post_translation' in context_dict: - context_dict['breadcrumbs'].append({'url': post.get_absolute_url(), 'name': post_translation.title}) + context_dict['breadcrumbs'].append({'url': post.get_absolute_url(), 'name': post_translation.title}) else: context_dict['breadcrumbs'].append({'url': post.get_absolute_url(), 'name': post.title}) return render(request, 'weblog/post.html', context_dict) @@ -204,4 +232,3 @@ def ChangeLanguage(request, language): if request.GET.get('next'): return HttpResponseRedirect(request.GET['next']) return HttpResponseRedirect(reverse('weblog:Index')) -
\ No newline at end of file |