Skip to content

Commit

Permalink
Articles, authors, Bootstrap, Webpack...
Browse files Browse the repository at this point in the history
  • Loading branch information
kochman committed Sep 19, 2018
1 parent 73653d8 commit 61861fb
Show file tree
Hide file tree
Showing 34 changed files with 8,145 additions and 14 deletions.
6 changes: 6 additions & 0 deletions .gitignore
@@ -0,0 +1,6 @@
/*.sqlite3
/node_modules/
/pipeline/static/webpack_bundles/
/media/
/webpack-stats.json
/.vscode/
3 changes: 3 additions & 0 deletions Pipfile
Expand Up @@ -5,6 +5,9 @@ name = "pypi"

[packages]
wagtail = "*"
"bs4" = "*"
django-debug-toolbar = "*"
django-webpack-loader = "*"

[dev-packages]

Expand Down
32 changes: 31 additions & 1 deletion Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
3 changes: 3 additions & 0 deletions articles/admin.py
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions articles/apps.py
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class ArticlesConfig(AppConfig):
name = 'articles'
30 changes: 30 additions & 0 deletions articles/migrations/0001_initial.py
@@ -0,0 +1,30 @@
# Generated by Django 2.0.7 on 2018-07-08 18:01

from django.db import migrations, models
import django.db.models.deletion
import wagtail.core.blocks
import wagtail.core.fields


class Migration(migrations.Migration):

initial = True

dependencies = [
('wagtailcore', '0040_page_draft_title'),
]

operations = [
migrations.CreateModel(
name='ArticlePage',
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()),
('body', wagtail.core.fields.StreamField([('paragraph', wagtail.core.blocks.RichTextBlock())])),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
]
20 changes: 20 additions & 0 deletions articles/migrations/0002_articlepage_headline.py
@@ -0,0 +1,20 @@
# Generated by Django 2.0.7 on 2018-07-10 01:42

from django.db import migrations
import wagtail.core.fields


class Migration(migrations.Migration):

dependencies = [
('articles', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='articlepage',
name='headline',
field=wagtail.core.fields.RichTextField(default='hi'),
preserve_default=False,
),
]
25 changes: 25 additions & 0 deletions articles/migrations/0003_articlesindex.py
@@ -0,0 +1,25 @@
# Generated by Django 2.0.7 on 2018-07-12 03:09

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('wagtailcore', '0040_page_draft_title'),
('articles', '0002_articlepage_headline'),
]

operations = [
migrations.CreateModel(
name='ArticlesIndex',
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')),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
]
Empty file added articles/migrations/__init__.py
Empty file.
32 changes: 32 additions & 0 deletions articles/models.py
@@ -0,0 +1,32 @@
from django.db import models

from wagtail.core.models import Page
from wagtail.core.fields import RichTextField, StreamField
from wagtail.core.blocks import RichTextBlock
from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel

from bs4 import BeautifulSoup


class ArticlePage(Page):
headline = RichTextField(features=['italic'])
date = models.DateField()
body = StreamField([
('paragraph', RichTextBlock()),
])

content_panels = [
FieldPanel('headline'),
FieldPanel('date'),
StreamFieldPanel('body'),
]

def clean(self):
super().clean()

soup = BeautifulSoup(self.headline)
self.title = soup.text


class ArticlesIndex(Page):
subpage_types = ['ArticlePage']
3 changes: 3 additions & 0 deletions articles/tests.py
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions articles/views.py
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
Empty file added authors/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions authors/admin.py
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions authors/apps.py
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class AuthorsConfig(AppConfig):
name = 'authors'
22 changes: 22 additions & 0 deletions authors/migrations/0001_initial.py
@@ -0,0 +1,22 @@
# Generated by Django 2.0.7 on 2018-07-11 15:11

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Author',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(max_length=255)),
('last_name', models.CharField(max_length=255)),
],
),
]
30 changes: 30 additions & 0 deletions authors/migrations/0002_auto_20180711_1547.py
@@ -0,0 +1,30 @@
# Generated by Django 2.0.7 on 2018-07-11 15:47

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('wagtailcore', '0040_page_draft_title'),
('authors', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='AuthorPage',
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')),
('first_name', models.CharField(max_length=255)),
('last_name', models.CharField(max_length=255)),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
migrations.DeleteModel(
name='Author',
),
]
25 changes: 25 additions & 0 deletions authors/migrations/0003_authorsindexpage.py
@@ -0,0 +1,25 @@
# Generated by Django 2.0.7 on 2018-07-11 15:56

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('wagtailcore', '0040_page_draft_title'),
('authors', '0002_auto_20180711_1547'),
]

operations = [
migrations.CreateModel(
name='AuthorsIndexPage',
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')),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
]
Empty file added authors/migrations/__init__.py
Empty file.
36 changes: 36 additions & 0 deletions authors/models.py
@@ -0,0 +1,36 @@
from django.db import models
from django.utils.text import slugify

from wagtail.core.models import Page
from wagtail.core.fields import RichTextField
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.snippets.models import register_snippet
from wagtail.search import index


class AuthorPage(Page):
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)

content_panels = [
FieldPanel('first_name'),
FieldPanel('last_name'),
]

search_fields = [
index.SearchField('first_name'),
index.SearchField('last_name'),
]

def clean(self):
super().clean()
self.title = f'{self.first_name} {self.last_name}'

# AuthorPage.slug.default = 'blank-slug'


class AuthorsIndexPage(Page):
subpage_types = ['AuthorPage']

def get_authors(self):
return AuthorPage.objects.live().descendant_of(self).order_by('title')
9 changes: 9 additions & 0 deletions authors/templates/authors/author_page.html
@@ -0,0 +1,9 @@
{% extends "base.html" %}

{% load wagtailcore_tags %}

{% block body_class %}template-homepage{% endblock %}

{% block content %}
<h1>{{ page.title }}</h1>
{% endblock %}
14 changes: 14 additions & 0 deletions authors/templates/authors/authors_index_page.html
@@ -0,0 +1,14 @@
{% extends "base.html" %}

{% load wagtailcore_tags %}

{% block body_class %}template-homepage{% endblock %}

{% block content %}
<h1>Authors</h1>

{% for author in page.get_authors %}
<a href="{% pageurl author %}">{{ author.title }}</a>
{% endfor %}

{% endblock %}
3 changes: 3 additions & 0 deletions authors/tests.py
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions authors/views.py
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
9 changes: 9 additions & 0 deletions home/templates/home/home_page.html
Expand Up @@ -3,6 +3,15 @@
{% block body_class %}template-homepage{% endblock %}

{% block content %}

<div class="jumbotron p-3 p-md-5 text-white rounded bg-dark">
<div class="col-md-6 px-0">
<h1 class="display-4 font-italic">Title of a longer featured blog post</h1>
<p class="lead my-3">Multiple lines of text that form the lede, informing new readers quickly and efficiently about what's most interesting in this post's contents.</p>
<p class="lead mb-0"><a href="#" class="text-white font-weight-bold">Continue reading...</a></p>
</div>
</div>

<h1>Welcome to your new Wagtail site!</h1>

<p>You can access the admin interface <a href="{% url 'wagtailadmin_home' %}">here</a> (make sure you have run "./manage.py createsuperuser" in the console first).</p>
Expand Down

0 comments on commit 61861fb

Please sign in to comment.