Skip to content

Commit

Permalink
Move IESG Statements under /about/group/iesg and out of /blog. Tempor…
Browse files Browse the repository at this point in the history
…arily disable the recursive chown on container entry.
  • Loading branch information
rjsparks committed Aug 27, 2019
1 parent ff93bbe commit 5d4ce64
Show file tree
Hide file tree
Showing 10 changed files with 737 additions and 19 deletions.
6 changes: 3 additions & 3 deletions docker-entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ if [ -n "${WWW_GID}" ]; then
groupmod -g "${WWW_GID}" www
fi

if [ -n "${WWWRUN_UID}" -o -n "${WWW_GID}" ]; then
chown -R wwwrun:www /code
fi
#if [ -n "${WWWRUN_UID}" -o -n "${WWW_GID}" ]; then
# chown -R wwwrun:www /code
#fi

if [ ! -f "ietf/settings/local.py" ]; then
echo "local.py not found. Exiting."
Expand Down
53 changes: 37 additions & 16 deletions ietf/blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,23 +324,44 @@ class BlogIndexPage(Page):
Use it to organise :model:`blog.BlogPage` models.
"""
def serve(self, request, *args, **kwargs):
blogs = ordered_live_annotated_blogs()
first_blog_url = blogs.first().url
query_string = "?"

# This is duplicated in BlogPage
for parameter, functions in parameter_functions_map.items():
search_query = request.GET.get(parameter)
if search_query:
try:
related_object = functions[0](search_query)
blogs = functions[1](blogs, related_object)
query_string += "%s=%s&" % (parameter, search_query)
except (ValueError, ObjectDoesNotExist):
pass
if blogs:
# IESG statements were moved under the IESG about/groups page. Queries to the
# base /blog/ page that used a query string to filter for IESG statements can't
# be redirected through ordinary redirection, so we're doing it here.
if request.GET.get('primary_topic')=='7':
query_string = ''
topic = request.GET.get('secondary_topic')
if topic:
query_string = query_string + 'topic=' + topic
date_from = request.GET.get('date_from')
if date_from:
separator = '&' if query_string else ''
query_string = query_string + separator + 'date_from=' + date_from
date_to = request.GET.get('date_to')
if date_to:
separator = '&' if query_string else ''
query_string = query_string + separator + 'date_to' + date_to
target_url = '/about/groups/iesg/statements'
if query_string:
target_url = target_url + '?' + query_string
return redirect(target_url)
else:
blogs = ordered_live_annotated_blogs()
first_blog_url = blogs.first().url
return redirect(first_blog_url + query_string)
query_string = "?"

# This is duplicated in BlogPage
for parameter, functions in parameter_functions_map.items():
search_query = request.GET.get(parameter)
if search_query:
try:
related_object = functions[0](search_query)
blogs = functions[1](blogs, related_object)
query_string += "%s=%s&" % (parameter, search_query)
except (ValueError, ObjectDoesNotExist):
pass
if blogs:
first_blog_url = blogs.first().url
return redirect(first_blog_url + query_string)

search_fields = []

Expand Down
Empty file added ietf/iesg_statement/__init__.py
Empty file.
125 changes: 125 additions & 0 deletions ietf/iesg_statement/management/commands/move_iesg_statements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
from django.core.management.base import BaseCommand
from django.contrib.auth.models import User

from wagtail.contrib.redirects.models import Redirect

from ietf.blog.models import BlogPage
from ietf.iesg_statement.models import IESGStatementPage, IESGStatementIndexPage, IESGStatementTopic
from ietf.standard.models import StandardPage
from ietf.snippets.models import PrimaryTopic

slug_map = {
'iesg-statement-maximizing-encrypted-access-ietf-information' : 'maximizing-encrypted-access',
'iesg-statement-internet-draft-authorship' : 'internet-draft-authorship',
'iesg-statement-designating-rfcs-historic' : 'designating-rfcs-historic-2014-07-20',
'discuss-criteria-iesg-review' : 'iesg-discuss-criteria',
'guidance-face-face-and-virtual-interim-meetings' : 'interim-meetings-guidance-2016-01-16',
'writable-mib-module-iesg-statement' : 'writable-mib-module',
'ietf-anti-harassment-policy' : 'anti-harassment-policy',
'iesg-statement-removal-internet-draft-ietf-web-site' : 'internet-draft-removal',
'iesg-statement-ethertypes' : 'ethertypes',
'iesg-statement-designating-rfcs-historic-2011-10-20' : 'designating-rfcs-historic-2011-10-20',
'iesg-statement-designating-rfcs-historic-2011-06-27' : 'designating-rfcs-historic-2011-06-27',
'iesg-statement-iesg-processing-rfc-errata-concerning-rfc-metadata' : 'rfc-metadata-errata',
'iesg-statement-document-shepherds' : 'document-shepherds',
'iesg-statement-nomcom-eligibility-and-day-passes' : 'nomcom-eligibility-day-passes',
'iesg-statement-usage-assignable-codepoints-addresses-and-names-specification-examples' : 'assignable-codepoints-addresses-names',
'iesg-statement-copyright' : 'copyright-2009-09-08',
'proposed-status-ietf-documents-reserving-resources-example-purposes' : 'reserving-resources-examples',
'guidance-interim-meetings-conference-calls-and-jabber-sessions' : 'interim-meetings-guidance-2008-09-02',
'iesg-processing-rfc-errata-ietf-stream' : 'processing-rfc-errata',
'iesg-statement-spam-control-ietf-mailing-lists' : 'spam-control-2008-04-14',
'guidance-spam-control-ietf-mailing-lists' : 'spam-control-2006-01-09',
'iesg-guidance-moderation-ietf-working-group-mailing-lists' : 'mailing-lists-moderation',
'iesg-statement-registration-requests-uris-containing-telephone-numbers' : 'registration-requests-uris',
'iesg-statement-rfc3406-and-urn-namespaces-registry-review' : 'urn-namespaces-registry',
'advice-wg-chairs-dealing-topic-postings' : 'off-topic-postings',
'appeals-iesg-and-area-director-actions-and-decisions' : 'appeals-actions-decisions',
'experimental-specification-new-congestion-control-algorithms' : 'experimental-congestion-control',
'guidance-area-director-sponsoring-documents' : 'area-director-sponsoring-documents',
'last-call-guidance-community' : 'last-call-guidance',
'iesg-statement-normative-and-informative-references' : 'normative-informative-references',
'iesg-statement-disruptive-posting' : 'disruptive-posting',
'iesg-statement-auth48-state' : 'auth48',
'syntax-format-definitions' : 'syntax-format-definitions',
'iesg-statement-idn' : 'idn',
'copyright-statement-mib-and-pib-modules' : 'copyright-2002-11-27',
'guidance-spam-control-ietf-mailing-lists-2002-03-13' : 'spam-control-2002-03-13',
'design-teams' : 'design-teams',
'guidelines-use-formal-languages-ietf-specifications' : 'formal-languages-use',
'establishment-temporary-sub-ip-area' : 'sub-ip-area-2001-03-21',
'plans-organize-sub-ip-technologies-ietf' : 'sub-ip-area-2000-11-20',
'new-ietf-work-area' : 'sub-ip-area-2000-12-06',
'guidance-interim-ietf-working-group-meetings-and-conference-calls' : 'interim-meetings-guidance-2000-08-29',
'ietf-meeting-photography-policy' : 'meeting-photography-policy',
'support-documents-ietf-working-groups' : 'support-documents',
'license-file-open-source-repositories' : 'open-source-repositories-license',
}


class Command(BaseCommand):
help = 'Moves the iesg statements from the blog app to the iesg_statements app'

def handle(self, *args, **options):
if IESGStatementPage.objects.exists():
print("IESGStatementPages exist. This command has probably already been run.")
print("Exiting without making any changes.")
return

iesg_page = StandardPage.objects.get(pk=1210)
index_page = IESGStatementIndexPage(
title='IESG Statements',
slug='statements',
url_path=iesg_page.url_path+'/statements/'
)
iesg_page.add_child(instance=index_page)
iesg_page.save()
for stmt in BlogPage.objects.filter(primary_topics__topic__title="IESG Statements"):

if stmt.slug in slug_map:
new_slug = slug_map[stmt.slug]
else:
new_slug = stmt.slug[15:] if stmt.slug.startswith('iesg-statement-') else stmt.slug

new_page = IESGStatementPage(
title = stmt.title,
slug = new_slug,
date_published = stmt.date_published,
introduction = stmt.introduction,
url_path = index_page.url_path+'/'+new_slug,
draft_title = stmt.draft_title,
owner = stmt.owner,
seo_title= stmt.seo_title,
live = stmt.live,
has_unpublished_changes = stmt.has_unpublished_changes,
show_in_menus = stmt.show_in_menus,
search_description = stmt.search_description,
go_live_at = stmt.go_live_at,
expire_at = stmt.expire_at,
expired = stmt.expired,
locked = stmt.locked,
first_published_at = stmt.first_published_at,
last_published_at = stmt.last_published_at,
latest_revision_created_at = stmt.latest_revision_created_at,
live_revision = stmt.live_revision,
)
index_page.add_child(instance=new_page)
# Intentionally not creating/publishing a new revision
new_page.body = stmt.body
new_page.save()
for st in stmt.secondary_topics.all():
IESGStatementTopic.objects.create(page=new_page,topic=st.topic)

Redirect.objects.create(
old_path=stmt.url[:-1] if stmt.url.endswith('/') else stmt.url,
is_permanent=True,
redirect_page=new_page
)


BlogPage.objects.filter(primary_topics__topic__title="IESG Statements").delete()
PrimaryTopic.objects.filter(title="IESG Statements").delete()

# todo - make this robust in case the iesg page gets edited before this is run on production
iesg_page.key_info[6].value.source = '<p><a href="statements">List\xa0All</a>\xa0\xa0| \xa0<a href="statements/?topic=20">On\xa0Mailing\xa0Lists</a>\xa0|\xa0<a href="statements?topic=21">On\xa0Meetings</a>\xa0|\xa0<a href="statements?topic=22">On\xa0Procedures</a>\xa0|\xa0<a href="statements?topic=23">On\xa0Technical\xa0Issues</a></p>'
iesg_page.save_revision(user=User.objects.get(username='robert.sparks')).publish()
61 changes: 61 additions & 0 deletions ietf/iesg_statement/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.22 on 2019-08-21 19:22
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
import modelcluster.fields
import wagtail.contrib.table_block.blocks
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.embeds.blocks
import wagtail.images.blocks


class Migration(migrations.Migration):

initial = True

dependencies = [
('snippets', '0026_auto_20170227_1401'),
('wagtailcore', '0040_page_draft_title'),
('images', '0009_ietfimage_file_hash'),
]

operations = [
migrations.CreateModel(
name='IESGStatementIndexPage',
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={
'verbose_name': 'IESG Statements Index Page',
},
bases=('wagtailcore.page',),
),
migrations.CreateModel(
name='IESGStatementPage',
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')),
('social_text', models.CharField(blank=True, help_text='Description of this page as it should appear when shared on social networks, or in Google results', max_length=255)),
('date_published', models.DateTimeField(blank=True, help_text='Use this field to override the date that the blog post appears to have been published.', null=True)),
('introduction', models.CharField(help_text='The page introduction text.', max_length=511)),
('body', wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(icon='title')), ('paragraph', wagtail.core.blocks.RichTextBlock(icon='pilcrow')), ('image', wagtail.images.blocks.ImageChooserBlock(icon='image', template='includes/imageblock.html')), ('embed', wagtail.embeds.blocks.EmbedBlock(icon='code')), ('raw_html', wagtail.core.blocks.RawHTMLBlock(icon='placeholder')), ('table', wagtail.contrib.table_block.blocks.TableBlock(table_options={'renderer': 'html'}))])),
('prepared_body', models.TextField(blank=True, help_text='The prepared body content after bibliography styling has been applied. Auto-generated on each save.', null=True)),
('feed_image', models.ForeignKey(blank=True, help_text='This image will be used in listings and indexes across the site, if no feed image is added, the social image will be used.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.IETFImage')),
('social_image', models.ForeignKey(blank=True, help_text="Image to appear alongside 'social text', particularly for sharing on social networks", null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.IETFImage')),
],
options={
'verbose_name': 'IESG Statement Page',
},
bases=('wagtailcore.page', models.Model),
),
migrations.CreateModel(
name='IESGStatementTopic',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('page', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='topics', to='iesg_statement.IESGStatementPage')),
('topic', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='snippets.SecondaryTopic')),
],
),
]
Empty file.
Loading

0 comments on commit 5d4ce64

Please sign in to comment.