diff --git a/services/cms/.gitignore b/services/cms/.gitignore new file mode 100644 index 0000000..c59768b --- /dev/null +++ b/services/cms/.gitignore @@ -0,0 +1 @@ +media/ \ No newline at end of file diff --git a/services/cms/blog/__init__.py b/services/cms/blog/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/services/cms/blog/admin.py b/services/cms/blog/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/services/cms/blog/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/services/cms/blog/apps.py b/services/cms/blog/apps.py new file mode 100644 index 0000000..7930587 --- /dev/null +++ b/services/cms/blog/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class BlogConfig(AppConfig): + name = 'blog' diff --git a/services/cms/blog/migrations/0001_initial.py b/services/cms/blog/migrations/0001_initial.py new file mode 100644 index 0000000..7c7e6e2 --- /dev/null +++ b/services/cms/blog/migrations/0001_initial.py @@ -0,0 +1,28 @@ +# Generated by Django 2.1.2 on 2018-11-11 02:20 + +from django.db import migrations, models +import django.db.models.deletion +import wagtail.core.fields + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('wagtailcore', '0040_page_draft_title'), + ] + + operations = [ + migrations.CreateModel( + name='BlogIndexPage', + 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')), + ('intro', wagtail.core.fields.RichTextField(blank=True)), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + ] diff --git a/services/cms/blog/migrations/0002_blogpage.py b/services/cms/blog/migrations/0002_blogpage.py new file mode 100644 index 0000000..3b517eb --- /dev/null +++ b/services/cms/blog/migrations/0002_blogpage.py @@ -0,0 +1,29 @@ +# Generated by Django 2.1.2 on 2018-11-11 02:58 + +from django.db import migrations, models +import django.db.models.deletion +import wagtail.core.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailcore', '0040_page_draft_title'), + ('blog', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='BlogPage', + 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')), + ('date', models.DateField(verbose_name='Post date')), + ('intro', models.CharField(max_length=250)), + ('body', wagtail.core.fields.RichTextField(blank=True)), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + ] diff --git a/services/cms/blog/migrations/__init__.py b/services/cms/blog/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/services/cms/blog/models.py b/services/cms/blog/models.py new file mode 100644 index 0000000..34f5208 --- /dev/null +++ b/services/cms/blog/models.py @@ -0,0 +1,30 @@ +from django.db import models + +from wagtail.core.models import Page +from wagtail.core.fields import RichTextField +from wagtail.admin.edit_handlers import FieldPanel +from wagtail.search import index + +class BlogIndexPage(Page): + intro = RichTextField(blank=True) + + content_panels = Page.content_panels + [ + FieldPanel('intro', classname="full") + ] + + +class BlogPage(Page): + date = models.DateField("Post date") + intro = models.CharField(max_length=250) + body = RichTextField(blank=True) + + search_fields = Page.search_fields + [ + index.SearchField("intro"), + index.SearchField("body") + ] + + content_panels = Page.content_panels + [ + FieldPanel('date'), + FieldPanel('intro'), + FieldPanel('body', classname="full"), + ] \ No newline at end of file diff --git a/services/cms/blog/templates/blog/blog_index_page.html b/services/cms/blog/templates/blog/blog_index_page.html new file mode 100644 index 0000000..dd6af10 --- /dev/null +++ b/services/cms/blog/templates/blog/blog_index_page.html @@ -0,0 +1,34 @@ +{% extends "base.html" %} + +{% load wagtailcore_tags %} + +{% block body_class %}helvetica{% endblock %} + +{% block content %} + +
+

{{ page.title }}

+ + {% for post in page.get_children %} +
+ +
+
+

{{ post.title }}

+

{{ post.specific.intro }}

+
+
+ Photo of a dimly lit room with a computer interface terminal. +
+
+

By {{ post.owner }}

+ +
+
+ {% endfor %} + +
+ + +{% endblock %} diff --git a/services/cms/blog/templates/blog/blog_page.html b/services/cms/blog/templates/blog/blog_page.html new file mode 100644 index 0000000..2b61e7d --- /dev/null +++ b/services/cms/blog/templates/blog/blog_page.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} + +{% load wagtailcore_tags %} + +{% block body_class %}helvetica{% endblock %} + +{% block content %} +

{{ page.title }}

+

{{ page.date }}

+ +
{{ page.intro }}
+ {{ page.body|richtext }} +

Return to blog

+{% endblock %} \ No newline at end of file diff --git a/services/cms/blog/tests.py b/services/cms/blog/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/services/cms/blog/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/services/cms/blog/views.py b/services/cms/blog/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/services/cms/blog/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/services/cms/cms/settings/base.py b/services/cms/cms/settings/base.py index 07a787f..ac5d375 100644 --- a/services/cms/cms/settings/base.py +++ b/services/cms/cms/settings/base.py @@ -25,6 +25,7 @@ BASE_DIR = os.path.dirname(PROJECT_DIR) INSTALLED_APPS = [ "home", + "blog", "search", "wagtail.contrib.forms", "wagtail.contrib.redirects", diff --git a/services/cms/cms/settings/dev.py b/services/cms/cms/settings/dev.py index c800aaa..ace826a 100644 --- a/services/cms/cms/settings/dev.py +++ b/services/cms/cms/settings/dev.py @@ -14,7 +14,7 @@ EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql", - "NAME": "datasketch", + "NAME": "datasketch_dev", "USER": "datasketch", "PASSWORD": os.environ.get("DB_PASSWD") if os.environ.get("DB_PASSWD") else "", "HOST": os.environ.get("DB_HOST") if os.environ.get("DB_HOST") else "127.0.0.1",