-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a 'in cooperation with' field to site submissions #120
Changes from all commits
faae854
79cb983
589e441
1443c5c
07e9d43
aa7692b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.7 on 2018-05-04 09:19 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('core', '0010_wagtailsitepage_screenshot'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='wagtailsitepage', | ||
name='in_cooperation_with', | ||
field=models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name='+', | ||
to='core.WagtailCompanyPage' | ||
), | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,13 @@ | |
from operator import itemgetter | ||
|
||
from bs4 import BeautifulSoup | ||
from core import panels | ||
from core.forms import SubmitFormBuilder | ||
from core.utilities import has_recaptcha, validate_only_one_instance | ||
from django.core.exceptions import ObjectDoesNotExist | ||
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator | ||
from django.db import models | ||
from django.db.models import Count | ||
from django.db.models import Count, Q | ||
from django.utils.encoding import python_2_unicode_compatible | ||
from django.utils.html import mark_safe | ||
from modelcluster.fields import ParentalKey | ||
|
@@ -18,10 +21,6 @@ | |
from wagtail.wagtailsearch import index | ||
from wagtailcaptcha.models import WagtailCaptchaEmailForm | ||
|
||
from core import panels | ||
from core.forms import SubmitFormBuilder | ||
from core.utilities import has_recaptcha, validate_only_one_instance | ||
|
||
|
||
class IndexPage(models.Model): | ||
""" | ||
|
@@ -346,7 +345,9 @@ def children(self): | |
|
||
def get_context(self, request, *args, **kwargs): | ||
# Get pages | ||
pages = self.children() | ||
pages = WagtailSitePage.objects.filter( | ||
Q(path__startswith=self.path) | Q(in_cooperation_with=self) | ||
).distinct() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is losing the custom ordering defined in the It should be possible to re-add the ordering without much issue for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe I can add an option to a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While adding an additional option would indeed help covering all the use-cases, I would rather keep it simple for now (until we have a need for more control):
How does that sound? |
||
# Pagination | ||
page = request.GET.get('page') | ||
paginator = Paginator(pages, 12) # Show 12 pages per page | ||
|
@@ -405,6 +406,14 @@ class WagtailSitePage(WagtailPage): | |
help_text='The URL of your site, something like "https://www.springload.co.nz"', | ||
) | ||
|
||
in_cooperation_with = models.ForeignKey( | ||
'core.WagtailCompanyPage', | ||
null=True, | ||
blank=True, | ||
on_delete=models.SET_NULL, | ||
related_name='+', | ||
) | ||
|
||
search_fields = Page.search_fields + [ | ||
index.SearchField('site_url'), | ||
index.SearchField('body_text') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those imports should stay where they were as it is enforced by isort.
I'm not sure why the CI didn't run on this PR. If it still doesn't run on next commit, you can run
make lint-py
from within the Vagrant box to verify that it's all good.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allright I'll revert that change.