From 4ee7380f59cd2c89c181d83ee1339679b76cc092 Mon Sep 17 00:00:00 2001 From: PekopT Date: Fri, 26 Aug 2016 16:20:48 +0300 Subject: [PATCH 1/2] active urls --- archilance/settings/base.py | 26 +++++++++++++++++++++- archilance/urls.py | 8 +++++-- cms_pages/__init__.py | 0 cms_pages/admin.py | 3 +++ cms_pages/apps.py | 5 +++++ cms_pages/migrations/0001_initial.py | 33 ++++++++++++++++++++++++++++ cms_pages/migrations/__init__.py | 0 cms_pages/models.py | 26 ++++++++++++++++++++++ cms_pages/tests.py | 3 +++ cms_pages/views.py | 3 +++ templates/cms_pages/cms_page.html | 22 +++++++++++++++++++ templates/partials/header.html | 6 ++--- 12 files changed, 129 insertions(+), 6 deletions(-) create mode 100644 cms_pages/__init__.py create mode 100644 cms_pages/admin.py create mode 100644 cms_pages/apps.py create mode 100644 cms_pages/migrations/0001_initial.py create mode 100644 cms_pages/migrations/__init__.py create mode 100644 cms_pages/models.py create mode 100644 cms_pages/tests.py create mode 100644 cms_pages/views.py create mode 100644 templates/cms_pages/cms_page.html diff --git a/archilance/settings/base.py b/archilance/settings/base.py index 13c9b8e..728111d 100644 --- a/archilance/settings/base.py +++ b/archilance/settings/base.py @@ -58,7 +58,26 @@ LOCAL_APPS = [ 'ratings', ] -INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS +WAGTAIL = [ + 'wagtail.wagtailforms', + 'wagtail.wagtailredirects', + 'wagtail.wagtailembeds', + 'wagtail.wagtailsites', + 'wagtail.wagtailusers', + 'wagtail.wagtailsnippets', + 'wagtail.wagtaildocs', + 'wagtail.wagtailimages', + 'wagtail.wagtailsearch', + 'wagtail.wagtailadmin', + 'wagtail.wagtailcore', + + 'modelcluster', + 'taggit', + + 'cms_pages', +] + +INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS + WAGTAIL MIDDLEWARE_CLASSES = [ 'django.middleware.security.SecurityMiddleware', @@ -70,6 +89,9 @@ MIDDLEWARE_CLASSES = [ 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'common.middleware.SetLastVisitMiddleware', + + 'wagtail.wagtailcore.middleware.SiteMiddleware', + 'wagtail.wagtailredirects.middleware.RedirectMiddleware', ] ROOT_URLCONF = 'archilance.urls' @@ -286,3 +308,5 @@ else: 'shop_id': 0, 'scid': 0, }) + +WAGTAIL_SITE_NAME = 'PROEKTON' diff --git a/archilance/urls.py b/archilance/urls.py index c77fca5..8c7bfa5 100644 --- a/archilance/urls.py +++ b/archilance/urls.py @@ -8,6 +8,9 @@ from django.views.generic import TemplateView from .views import HomeTemplateView, TestChatTemplateView from wallets.views import TmpCheckOrderView, TmpPaymentAvisoView +from wagtail.wagtailadmin import urls as wagtailadmin_urls +from wagtail.wagtailcore import urls as wagtail_urls + urlpatterns = [ url(r'^$', HomeTemplateView.as_view()), @@ -26,8 +29,9 @@ urlpatterns = [ url(r'^users/', include('registration.backends.default.urls')), url(r'^admin/', admin.site.urls), url(r'^api/', include('api.urls')), - - + url(r'^cms/', include(wagtailadmin_urls)), + url(r'^pages/', include(wagtail_urls)), + # TODO: Move URLs into the "wallets" app (Yandex Money settings modification needed): url(r'^yandex/check$', TmpCheckOrderView.as_view(), name='tmp-check-order'), diff --git a/cms_pages/__init__.py b/cms_pages/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/cms_pages/admin.py b/cms_pages/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/cms_pages/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/cms_pages/apps.py b/cms_pages/apps.py new file mode 100644 index 0000000..5734504 --- /dev/null +++ b/cms_pages/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class CmsPagesConfig(AppConfig): + name = 'cms_pages' diff --git a/cms_pages/migrations/0001_initial.py b/cms_pages/migrations/0001_initial.py new file mode 100644 index 0000000..ff087b4 --- /dev/null +++ b/cms_pages/migrations/0001_initial.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-08-26 12:44 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +import wagtail.wagtailcore.blocks +import wagtail.wagtailcore.fields +import wagtail.wagtailimages.blocks + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('wagtailcore', '0029_unicode_slugfield_dj19'), + ] + + operations = [ + migrations.CreateModel( + name='CmsPage', + fields=[ + ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), + ('body', wagtail.wagtailcore.fields.StreamField((('heading', wagtail.wagtailcore.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.wagtailcore.blocks.RichTextBlock()), ('image', wagtail.wagtailimages.blocks.ImageChooserBlock())))), + ('date', models.DateField(verbose_name='Дата размещения')), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + ] diff --git a/cms_pages/migrations/__init__.py b/cms_pages/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/cms_pages/models.py b/cms_pages/models.py new file mode 100644 index 0000000..ef0038e --- /dev/null +++ b/cms_pages/models.py @@ -0,0 +1,26 @@ +from django.db import models +from wagtail.wagtailadmin.edit_handlers import StreamFieldPanel, FieldPanel +from wagtail.wagtailcore import blocks +from wagtail.wagtailcore.fields import StreamField +from wagtail.wagtailcore.models import Page +from wagtail.wagtailimages.blocks import ImageChooserBlock + +__author__ = 'PekopT' + + +class CmsPage(Page): + body = StreamField([ + ('heading', blocks.CharBlock(classname="full title")), + ('paragraph', blocks.RichTextBlock()), + ('image', ImageChooserBlock()), + ]) + date = models.DateField("Дата размещения") + + content_panels = Page.content_panels + [ + FieldPanel('date'), + StreamFieldPanel('body'), + ] + + # promote_panels = [ + # MultiFieldPanel(Page.promote_panels, "Common page configuration"), + # ] diff --git a/cms_pages/tests.py b/cms_pages/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/cms_pages/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/cms_pages/views.py b/cms_pages/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/cms_pages/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/templates/cms_pages/cms_page.html b/templates/cms_pages/cms_page.html new file mode 100644 index 0000000..a480c11 --- /dev/null +++ b/templates/cms_pages/cms_page.html @@ -0,0 +1,22 @@ +{% extends 'partials/base.html' %} + +{% block content %} +
+ {% include 'partials/header.html' %} +
+
+

{{ page.title }}

+
+
+
+ + {% for block in page.body %} + {% if block.block_type == 'heading' %} +

{{ block.value }}

+ {% else %} +
+ {{ block }} +
+ {% endif %} + {% endfor %} +{% endblock %} \ No newline at end of file diff --git a/templates/partials/header.html b/templates/partials/header.html index 2f88de2..248cd94 100644 --- a/templates/partials/header.html +++ b/templates/partials/header.html @@ -111,9 +111,9 @@ Настройки -{#
  • #} -{# FAQ#} -{#
  • #} +
  • + FAQ +
  • Выйти From a0cb16c0e418982d76a39b075364a66f82e6b7be Mon Sep 17 00:00:00 2001 From: PekopT Date: Fri, 26 Aug 2016 16:26:29 +0300 Subject: [PATCH 2/2] reqs --- requirements/base.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements/base.txt b/requirements/base.txt index 1c0f8de..19894cb 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -42,3 +42,4 @@ gunicorn==19.6.0 rest-framework-generic-relations django-hitcount django-activeurl==0.1.9 +wagtail==1.6