Skip to content
Permalink
Browse files

'development' branch (#3596)

* Remove Google Sheet related fields from Petition model (#3585)

* Add BlogPageCategory Class and register it as snippet (#3594)

* Add BlogPageCategory Class and register it as snippet

* Add five initial categories

* Give the BlogPage a many-to-many relation to BlogPageCategory (#3595)

* Add blog category to Blog factory (#3605)

* Add blog category to Blog factory

* Update network-api/networkapi/wagtailpages/factory/blog.py

Co-Authored-By: Pomax <pomax@nihongoresources.com>

* Update network-api/networkapi/wagtailpages/factory/blog.py

Co-Authored-By: Pomax <pomax@nihongoresources.com>

* Update network-api/networkapi/wagtailpages/factory/blog.py

Co-Authored-By: Pomax <pomax@nihongoresources.com>

* Fix indentation

* removing remaining image_text2 instances (#3575)

* decrease margin top (#3574)

* Category pages (for Blog) (#3604)

* blog category subpage routes, with template updates specific to category cards

* Make tag/category list show on its own line (#3635)
  • Loading branch information...
mmmavis authored and Pomax committed Sep 10, 2019
1 parent 532548a commit 157a76997ae61537552872ee4c0548f30581f68b
@@ -88,22 +88,6 @@ def generate_image_text_mini_field():
}) })




def generate_image_text2_field():
image_id = choice(Image.objects.all()).id
image_text = fake.paragraph(nb_sentences=1, variable_nb_sentences=False)
url = fake.url(schemes=['https'])
alt_text = ' '.join(fake.words(nb=5))
small = fake.boolean()

return generate_field('image_text2', {
'image': image_id,
'text': image_text,
'url': url,
'altText': alt_text,
'small': small,
})


def generate_spacer_field(): def generate_spacer_field():
size = randint(1, 5) size = randint(1, 5)


@@ -169,7 +153,6 @@ def streamfield(self, fields=None):
'paragraph': generate_paragraph_field, 'paragraph': generate_paragraph_field,
'image': generate_image_field, 'image': generate_image_field,
'spacer': generate_spacer_field, 'spacer': generate_spacer_field,
'image_text2': generate_image_text2_field,
'quote': generate_quote_field, 'quote': generate_quote_field,
'image_text': generate_image_text_field, 'image_text': generate_image_text_field,
'image_text_mini': generate_image_text_mini_field, 'image_text_mini': generate_image_text_mini_field,
@@ -6,7 +6,7 @@
) )
from networkapi.utility.faker import StreamfieldProvider from networkapi.utility.faker import StreamfieldProvider


streamfield_fields = ['header', 'paragraph', 'image', 'spacer', 'image_text2', 'quote'] streamfield_fields = ['header', 'paragraph', 'image', 'spacer', 'image_text', 'quote']


sentence_faker: Faker = Faker('sentence', nb_words=3, variable_nb_words=False) sentence_faker: Faker = Faker('sentence', nb_words=3, variable_nb_words=False)
header_faker: Faker = Faker('sentence', nb_words=6, variable_nb_words=True) header_faker: Faker = Faker('sentence', nb_words=6, variable_nb_words=True)
@@ -1,5 +1,5 @@
from datetime import timezone from datetime import timezone
from random import shuffle from random import shuffle, choice
from django.conf import settings from django.conf import settings
from wagtail_factories import PageFactory from wagtail_factories import PageFactory
from factory import ( from factory import (
@@ -8,7 +8,7 @@
) )
from wagtail.core.models import Page as WagtailPage from wagtail.core.models import Page as WagtailPage


from networkapi.wagtailpages.models import BlogPage from networkapi.wagtailpages.models import BlogPage, BlogPageCategory
from networkapi.utility.faker.helpers import ( from networkapi.utility.faker.helpers import (
get_homepage, get_homepage,
reseed reseed
@@ -35,6 +35,12 @@ def add_tags(post):
post.save() post.save()




def add_category(post):
categories = BlogPageCategory.objects.all()
post.category.add(choice(categories))
post.save()


class BlogPageFactory(PageFactory): class BlogPageFactory(PageFactory):


class Meta: class Meta:
@@ -81,6 +87,7 @@ def generate(seed):
post = BlogPageFactory.create(parent=blog_namespace, title=title) post = BlogPageFactory.create(parent=blog_namespace, title=title)


add_tags(post) add_tags(post)
add_category(post)


for i in range(6): for i in range(6):
title = Faker('sentence', nb_words=6, variable_nb_words=False) title = Faker('sentence', nb_words=6, variable_nb_words=False)
@@ -92,3 +99,4 @@ def generate(seed):
post = BlogPageFactory.create(parent=blog_namespace, title=title) post = BlogPageFactory.create(parent=blog_namespace, title=title)


add_tags(post) add_tags(post)
add_category(post)
@@ -0,0 +1,55 @@
# Generated by Django 2.2.1 on 2019-08-27 22:35

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('wagtailpages', '0073_indexpage_page_size'),
]

operations = [
migrations.RemoveField(
model_name='petition',
name='checkbox_1_form_field',
),
migrations.RemoveField(
model_name='petition',
name='checkbox_2_form_field',
),
migrations.RemoveField(
model_name='petition',
name='email_form_field',
),
migrations.RemoveField(
model_name='petition',
name='given_name_form_field',
),
migrations.RemoveField(
model_name='petition',
name='google_forms_url',
),
migrations.RemoveField(
model_name='petition',
name='legacy_petition',
),
migrations.RemoveField(
model_name='petition',
name='newsletter_signup_form_field',
),
migrations.RemoveField(
model_name='petition',
name='surname_form_field',
),
migrations.AlterField(
model_name='petition',
name='checkbox_1',
field=models.CharField(blank=True, editable=False, help_text='label for the first checkbox option (may contain HTML)', max_length=1024),
),
migrations.AlterField(
model_name='petition',
name='checkbox_2',
field=models.CharField(blank=True, editable=False, help_text='label for the second checkbox option (may contain HTML)', max_length=1024),
),
]
@@ -0,0 +1,24 @@
# Generated by Django 2.2.4 on 2019-08-29 23:13

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('wagtailpages', '0073_indexpage_page_size'),
]

operations = [
migrations.CreateModel(
name='BlogPageCategory',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50)),
],
options={
'verbose_name': 'Blog Page Category',
'verbose_name_plural': 'Blog Page Categories',
},
),
]
@@ -0,0 +1,36 @@
# Generated by Django 2.2.4 on 2019-08-29 23:17

from django.db import migrations



from django.db import migrations, models

def add_blog_category(apps, schema_editor):
BlogPageCategory = apps.get_model("wagtailpages", "BlogPageCategory")

mozfest_festival = BlogPageCategory(name='Mozilla Festival')
mozfest_festival.save()

open_leadership_and_events = BlogPageCategory(name='Open Leadership & Events')
open_leadership_and_events.save()

internet_health = BlogPageCategory(name='Internet Health')
internet_health.save()

fellowships_and_awards = BlogPageCategory(name='Fellowships & Awards')
fellowships_and_awards.save()

advocacy = BlogPageCategory(name='Advocacy')
advocacy.save()


class Migration(migrations.Migration):

dependencies = [
('wagtailpages', '0074_blogpagecategory'),
]

operations = [
migrations.RunPython(add_blog_category),
]
@@ -0,0 +1,14 @@
# Generated by Django 2.2.4 on 2019-08-30 18:23

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('wagtailpages', '0074_auto_20190827_2235'),
('wagtailpages', '0075_auto_20190829_2317'),
]

operations = [
]
@@ -0,0 +1,18 @@
# Generated by Django 2.2.4 on 2019-08-30 18:31

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('wagtailpages', '0076_merge_20190830_1823'),
]

operations = [
migrations.AddField(
model_name='blogpage',
name='category',
field=models.ManyToManyField(blank=True, help_text='Which blog categories is this blog page associated with?', to='wagtailpages.BlogPageCategory', verbose_name='Categories'),
),
]
@@ -0,0 +1,19 @@
# Generated by Django 2.2.4 on 2019-09-03 18:21

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


class Migration(migrations.Migration):

dependencies = [
('wagtailpages', '0077_blogpage_category'),
]

operations = [
migrations.AddField(
model_name='blogpagecategory',
name='intro',
field=wagtail.core.fields.RichTextField(blank=True),
),
]

0 comments on commit 157a769

Please sign in to comment.
You can’t perform that action at this time.