From 8c8c05981fe1586180bfdec3096930bf52a46ef0 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 15 Dec 2016 22:00:42 +0000 Subject: [PATCH] Add metatags and more fields --- project/blog/models.py | 2 +- project/common/{fields.py => blocks.py} | 42 ++++++++++++--------- project/common/models.py | 3 +- project/pages/models.py | 2 +- project/projects/models.py | 2 +- project/settings.py | 16 +++++++- requirements.txt | 1 + static/src/scss/blocks.scss | 11 ++++++ templates/base.html | 4 +- templates/blocks/heading.html | 1 + templates/blocks/video.html | 9 +++++ templates/wagtailembeds/embed_frontend.html | 1 + 12 files changed, 70 insertions(+), 24 deletions(-) rename project/common/{fields.py => blocks.py} (63%) create mode 100644 templates/blocks/heading.html create mode 100644 templates/blocks/video.html create mode 100644 templates/wagtailembeds/embed_frontend.html diff --git a/project/blog/models.py b/project/blog/models.py index cfbafa7..7756e7d 100644 --- a/project/blog/models.py +++ b/project/blog/models.py @@ -1,5 +1,5 @@ from django.db import models -from project.common.fields import build_stream_field +from project.common.blocks import build_stream_field from wagtail.wagtailcore.models import Page from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel from wagtail.wagtailimages.edit_handlers import ImageChooserPanel diff --git a/project/common/fields.py b/project/common/blocks.py similarity index 63% rename from project/common/fields.py rename to project/common/blocks.py index 8778ad5..55b5e38 100644 --- a/project/common/fields.py +++ b/project/common/blocks.py @@ -3,19 +3,35 @@ from wagtail.wagtailcore import blocks from wagtail.wagtailimages.blocks import ImageChooserBlock from wagtail.wagtaildocs.blocks import DocumentChooserBlock from wagtailmarkdown.blocks import MarkdownBlock +from wagtail.wagtailembeds.blocks import EmbedBlock -def build_header_fields(): - for i in range(6): - h_tag = "h" + str(i + 1) - yield (h_tag, blocks.CharBlock(classname=h_tag, label=h_tag.upper(), icon="title")) +HEADING_CHOICES = [('h' + str(i), 'H' + str(i)) for i in range(1, 6)] -def build_fixed_fields(): - return [ +class HeadingBlock(blocks.StructBlock): + size = blocks.ChoiceBlock(choices=HEADING_CHOICES) + value = blocks.CharBlock() + + class Meta: + icon = 'title' + template = 'blocks/heading.html' + + +class VideoBlock(blocks.StructBlock): + video = EmbedBlock() + caption = blocks.CharBlock() + + class Meta: + template = 'blocks/video.html' + + +def build_stream_field(): + return StreamField([ ('ansi', blocks.TextBlock(template="blocks/ansi.html")), ('document', DocumentChooserBlock()), ('gist', blocks.CharBlock(icon="code", template="blocks/gist.html")), + ('heading', HeadingBlock()), ('image', ImageChooserBlock()), ('markdown', MarkdownBlock()), ('ol', blocks.ListBlock(blocks.CharBlock(label="List Item"), icon="list-ol", label="Ordered List", template='blocks/ordered-list.html')), @@ -23,15 +39,5 @@ def build_fixed_fields(): ('raw_html', blocks.RawHTMLBlock(label="Raw HTML")), ('secret', blocks.RichTextBlock(icon="password", template='blocks/secret.html')), ('ul', blocks.ListBlock(blocks.CharBlock(label="List Item"), icon="list-ul", label="Unordered List")), - ] - - -def build_stream_field(): - fields = [] - for field_builder in [ - build_header_fields, - build_fixed_fields - ]: - for field in field_builder(): - fields.append(field) - return StreamField(fields) + ('video', VideoBlock()) + ]) diff --git a/project/common/models.py b/project/common/models.py index cf58f72..fb26ccd 100644 --- a/project/common/models.py +++ b/project/common/models.py @@ -1,8 +1,9 @@ from wagtail.wagtailcore.models import Page from django.db import models +from wagtailmetadata.models import MetadataPageMixin -class Entity(Page): +class Entity(MetadataPageMixin, Page): is_home = False created = models.DateTimeField(auto_now_add=True) diff --git a/project/pages/models.py b/project/pages/models.py index 8d89e6c..59ceb3c 100644 --- a/project/pages/models.py +++ b/project/pages/models.py @@ -1,5 +1,5 @@ from django.db import models -from project.common.fields import build_stream_field +from project.common.blocks import build_stream_field from project.common.models import Entity from wagtail.wagtailcore.models import Page from wagtail.wagtailcore.fields import RichTextField diff --git a/project/projects/models.py b/project/projects/models.py index 373a6b5..5a03170 100644 --- a/project/projects/models.py +++ b/project/projects/models.py @@ -1,6 +1,6 @@ from django.db import models from django.core.exceptions import ValidationError -from project.common.fields import build_stream_field +from project.common.blocks import build_stream_field from wagtail.wagtailcore.models import Page from wagtail.wagtaildocs.edit_handlers import DocumentChooserPanel from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel diff --git a/project/settings.py b/project/settings.py index 697a151..ae82e55 100755 --- a/project/settings.py +++ b/project/settings.py @@ -41,6 +41,8 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', + 'wagtailmetadata', + 'project.blog', 'project.common', 'project.home', @@ -79,7 +81,7 @@ MIDDLEWARE = [ 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'wagtail.wagtailcore.middleware.SiteMiddleware', - 'wagtail.wagtailredirects.middleware.RedirectMiddleware', + 'wagtail.wagtailredirects.middleware.RedirectMiddleware' ] ROOT_URLCONF = 'project.urls' @@ -163,3 +165,15 @@ WAGTAILSEARCH_BACKENDS = { # e.g. in notification emails. Don't include '/admin' or a trailing slash BASE_URL = 'https://theorangeone.net' SITE_URL = BASE_URL + + +# Password policy settings +SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer' +PASSWORD_CHECK_ONLY_AT_LOGIN = True +PASSWORD_MIN_LENGTH = 7 +PASSWORD_MAX_LENGTH = 25 +PASSWORD_HISTORY_COUNT = 6 +PASSWORD_MIN_LETTERS = 1 +PASSWORD_MIN_NUMBERS = 1 +PASSWORD_MIN_SYMBOLS = 1 +PASSWORD_DIFFERENCE_DISTANCE = 3 diff --git a/requirements.txt b/requirements.txt index 13ae424..9f3bfe9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,6 +9,7 @@ psycopg2==2.6.2 pygments-style-github==0.4 safety==0.5.1 wagtail>=1.7,<1.8 +wagtail-metadata==0.3.0 git+https://github.com/RealOrangeOne/wagtail-markdown waitress==1.0.1 whitenoise==3.2.2 diff --git a/static/src/scss/blocks.scss b/static/src/scss/blocks.scss index b601eae..4d825be 100644 --- a/static/src/scss/blocks.scss +++ b/static/src/scss/blocks.scss @@ -5,3 +5,14 @@ max-height: 100vh; } } + +.block-video { + iframe { + width: 100%; + height: 50vh; + } + + span { + font-style: italic; + } +} diff --git a/templates/base.html b/templates/base.html index 1fd52fb..ba27f88 100755 --- a/templates/base.html +++ b/templates/base.html @@ -1,4 +1,4 @@ -{% load static wagtailuserbar %} +{% load static wagtailuserbar wagtailmetadata_tags %} @@ -11,6 +11,8 @@ + {% meta_tags %} + {% block extra_css %}{% endblock %} diff --git a/templates/blocks/heading.html b/templates/blocks/heading.html new file mode 100644 index 0000000..3a59ef2 --- /dev/null +++ b/templates/blocks/heading.html @@ -0,0 +1 @@ +<{{ value.size }}>{{ value.value }} diff --git a/templates/blocks/video.html b/templates/blocks/video.html new file mode 100644 index 0000000..d735aa5 --- /dev/null +++ b/templates/blocks/video.html @@ -0,0 +1,9 @@ +{% load wagtailcore_tags %} + +{% include_block value.video %} + +{% if value.caption %} + + {% include_block value.caption %} + +{% endif %} diff --git a/templates/wagtailembeds/embed_frontend.html b/templates/wagtailembeds/embed_frontend.html new file mode 100644 index 0000000..8deaa8f --- /dev/null +++ b/templates/wagtailembeds/embed_frontend.html @@ -0,0 +1 @@ +{{ embed.html|safe }}