Cleanup E302 errors

pull/2000/head
Karl Hobley 2015-12-04 09:32:16 +00:00
rodzic 113f8e59ff
commit 1957af9ea8
27 zmienionych plików z 64 dodań i 2 usunięć

Wyświetl plik

@ -5,7 +5,7 @@ usedevelop = True
envlist = py{27,33,34,35}-dj{17,18}-{sqlite,postgres,mysql}, flake8
[flake8]
ignore = E501,E128,E302,E303,E124,E126
ignore = E501,E128,E303,E124,E126
exclude = wagtail/project_template/*
[testenv]

Wyświetl plik

@ -59,6 +59,7 @@ COMMANDS = {
'start': create_project,
}
def main():
# Parse options
parser = OptionParser(usage="Usage: %prog start project_name [directory]")

Wyświetl plik

@ -12,10 +12,10 @@ logger = logging.getLogger('wagtail.frontendcache')
class PurgeRequest(Request):
def get_method(self):
return 'PURGE'
class BaseBackend(object):
def purge(self, url):
raise NotImplementedError

Wyświetl plik

@ -156,9 +156,11 @@ class HomePage(Page):
class HomePageCarouselItem(Orderable, AbstractCarouselItem):
page = ParentalKey('HomePage', related_name='carousel_items')
class HomePageRelatedLink(Orderable, AbstractRelatedLink):
page = ParentalKey('HomePage', related_name='related_links')
HomePage.content_panels = Page.content_panels + [
FieldPanel('body', classname="full"),
@ -194,12 +196,15 @@ class StandardPage(Page):
index.SearchField('body'),
)
class StandardPageCarouselItem(Orderable, AbstractCarouselItem):
page = ParentalKey('StandardPage', related_name='carousel_items')
class StandardPageRelatedLink(Orderable, AbstractRelatedLink):
page = ParentalKey('StandardPage', related_name='related_links')
StandardPage.content_panels = Page.content_panels + [
FieldPanel('intro', classname="full"),
InlinePanel('carousel_items', label="Carousel items"),
@ -207,6 +212,7 @@ StandardPage.content_panels = Page.content_panels + [
InlinePanel('related_links', label="Related links"),
]
StandardPage.promote_panels = [
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
ImageChooserPanel('feed_image'),
@ -234,14 +240,17 @@ class StandardIndexPage(Page):
index.SearchField('intro'),
)
class StandardIndexPageRelatedLink(Orderable, AbstractRelatedLink):
page = ParentalKey('StandardIndexPage', related_name='related_links')
StandardIndexPage.content_panels = Page.content_panels + [
FieldPanel('intro', classname="full"),
InlinePanel('related_links', label="Related links"),
]
StandardIndexPage.promote_panels = [
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
ImageChooserPanel('feed_image'),
@ -280,15 +289,19 @@ class BlogEntryPage(Page):
# Find closest ancestor which is a blog index
return BlogIndexPage.ancestor_of(self).last()
class BlogEntryPageCarouselItem(Orderable, AbstractCarouselItem):
page = ParentalKey('BlogEntryPage', related_name='carousel_items')
class BlogEntryPageRelatedLink(Orderable, AbstractRelatedLink):
page = ParentalKey('BlogEntryPage', related_name='related_links')
class BlogEntryPageTag(TaggedItemBase):
content_object = ParentalKey('BlogEntryPage', related_name='tagged_items')
BlogEntryPage.content_panels = Page.content_panels + [
FieldPanel('date'),
FieldPanel('body', classname="full"),
@ -296,6 +309,7 @@ BlogEntryPage.content_panels = Page.content_panels + [
InlinePanel('related_links', label="Related links"),
]
BlogEntryPage.promote_panels = [
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
ImageChooserPanel('feed_image'),
@ -341,9 +355,11 @@ class BlogIndexPage(Page):
context['entries'] = entries
return context
class BlogIndexPageRelatedLink(Orderable, AbstractRelatedLink):
page = ParentalKey('BlogIndexPage', related_name='related_links')
BlogIndexPage.content_panels = Page.content_panels + [
FieldPanel('intro', classname="full"),
InlinePanel('related_links', label="Related links"),
@ -407,12 +423,15 @@ class EventPage(Page):
# Find closest ancestor which is an event index
return EventIndexPage.objects.ancester_of(self).last()
class EventPageCarouselItem(Orderable, AbstractCarouselItem):
page = ParentalKey('EventPage', related_name='carousel_items')
class EventPageRelatedLink(Orderable, AbstractRelatedLink):
page = ParentalKey('EventPage', related_name='related_links')
class EventPageSpeaker(Orderable, AbstractLinkFields):
page = ParentalKey('EventPage', related_name='speakers')
first_name = models.CharField("Name", max_length=255, blank=True)
@ -453,6 +472,7 @@ EventPage.content_panels = Page.content_panels + [
InlinePanel('related_links', label="Related links"),
]
EventPage.promote_panels = [
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
ImageChooserPanel('feed_image'),
@ -485,9 +505,11 @@ class EventIndexPage(Page):
return events
class EventIndexPageRelatedLink(Orderable, AbstractRelatedLink):
page = ParentalKey('EventIndexPage', related_name='related_links')
EventIndexPage.content_panels = Page.content_panels + [
FieldPanel('intro', classname="full"),
InlinePanel('related_links', label="Related links"),
@ -534,9 +556,11 @@ class PersonPage(Page, ContactFieldsMixin):
index.SearchField('biography'),
)
class PersonPageRelatedLink(Orderable, AbstractRelatedLink):
page = ParentalKey('PersonPage', related_name='related_links')
PersonPage.content_panels = Page.content_panels + [
FieldPanel('first_name'),
FieldPanel('last_name'),
@ -547,6 +571,7 @@ PersonPage.content_panels = Page.content_panels + [
InlinePanel('related_links', label="Related links"),
]
PersonPage.promote_panels = [
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
ImageChooserPanel('feed_image'),
@ -575,11 +600,13 @@ class ContactPage(Page, ContactFieldsMixin):
index.SearchField('body'),
)
ContactPage.content_panels = Page.content_panels + [
FieldPanel('body', classname="full"),
MultiFieldPanel(ContactFieldsMixin.panels, "Contact"),
]
ContactPage.promote_panels = [
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
ImageChooserPanel('feed_image'),

Wyświetl plik

@ -35,6 +35,7 @@ class RegisterFunction(models.Model):
pass
register_snippet(RegisterFunction)
@register_snippet
class RegisterDecorator(models.Model):
pass

Wyświetl plik

@ -420,6 +420,7 @@ TaggedPage.content_panels = [
FieldPanel('tags'),
]
class SingletonPage(Page):
@classmethod
def can_create_at(cls, parent):
@ -427,6 +428,7 @@ class SingletonPage(Page):
return super(SingletonPage, cls).can_create_at(parent) \
and not cls.objects.exists()
class PageChooserModel(models.Model):
page = models.ForeignKey('wagtailcore.Page', help_text='help text')

Wyświetl plik

@ -35,6 +35,7 @@ class KittensMenuItem(MenuItem):
def is_shown(self, request):
return not request.GET.get('hide-kittens', False)
@hooks.register('register_admin_menu_item')
def register_kittens_menu_item():
return KittensMenuItem('Kittens!', 'http://www.tomroyal.com/teaandkittens/', classnames='icon icon-kitten', attrs={'data-fluffy': 'yes'}, order=10000)

Wyświetl plik

@ -3,6 +3,7 @@ from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage
DEFAULT_PAGE_KEY = 'p'
def paginate(request, items, page_key=DEFAULT_PAGE_KEY, per_page=20):
page = request.GET.get(page_key, 1)

Wyświetl plik

@ -8,6 +8,7 @@ from django.utils.translation import ungettext, ugettext_lazy
from wagtail.wagtailadmin.widgets import AdminPageChooser
from wagtail.wagtailcore.models import Page
class URLOrAbsolutePathValidator(validators.URLValidator):
@staticmethod
def is_absolute_path(value):
@ -19,6 +20,7 @@ class URLOrAbsolutePathValidator(validators.URLValidator):
else:
return super(URLOrAbsolutePathValidator, self).__call__(value)
class URLOrAbsolutePathField(forms.URLField):
widget = TextInput
default_validators = [URLOrAbsolutePathValidator()]

Wyświetl plik

@ -25,6 +25,7 @@ class PagesSummaryItem(SummaryItem):
'total_pages': Page.objects.count() - 1, # subtract 1 because the root node is not a real page
}
@hooks.register('construct_homepage_summary_items')
def add_pages_summary_item(request, items):
items.append(PagesSummaryItem(request))

Wyświetl plik

@ -18,6 +18,7 @@ register = template.Library()
register.filter('intcomma', intcomma)
@register.inclusion_tag('wagtailadmin/shared/explorer_nav.html')
def explorer_nav():
return {
@ -41,6 +42,7 @@ def main_nav(context):
'request': request,
}
@register.simple_tag
def main_nav_js():
return admin_menu.media['js']
@ -171,6 +173,7 @@ def render_with_errors(bound_field):
else:
return bound_field.as_widget()
@register.filter
def has_unrendered_errors(bound_field):
"""

Wyświetl plik

@ -470,6 +470,7 @@ def preview(request):
"""
return render(request, 'wagtailadmin/pages/preview.html')
def preview_loading(request):
"""
This page is blank, but must be real HTML so its DOM can be written to once the preview of the page has rendered

Wyświetl plik

@ -27,6 +27,7 @@ class AdminAutoHeightTextInput(WidgetWithScript, widgets.Textarea):
def render_js_init(self, id_, name, value):
return 'autosize($("#{0}"));'.format(id_)
class AdminDateInput(WidgetWithScript, widgets.DateInput):
# Set a default date format to match the one that our JS date picker expects -
# it can still be overridden explicitly, but this way it won't be affected by

Wyświetl plik

@ -2,10 +2,12 @@ import re
# helpers for Javascript expression formatting
def indent(string, depth=1):
"""indent all non-empty lines of string by 'depth' 4-character tabs"""
return re.sub(r'(^|\n)([^\n]+)', '\g<1>' + (' ' * depth) + '\g<2>', string)
def js_dict(d):
"""
Return a Javascript expression string for the dict 'd'.

Wyświetl plik

@ -1,5 +1,6 @@
from django import forms
class PasswordPageViewRestrictionForm(forms.Form):
password = forms.CharField(label="Password", widget=forms.PasswordInput)
return_url = forms.CharField(widget=forms.HiddenInput)

Wyświetl plik

@ -17,6 +17,7 @@ from wagtail.wagtailcore import hooks
# elsewhere in the database and is liable to change - from real HTML representation
# to DB representation and back again.
class PageLinkHandler(object):
"""
PageLinkHandler will be invoked whenever we encounter an <a> element in HTML content
@ -56,6 +57,7 @@ LINK_HANDLERS = {
has_loaded_embed_handlers = False
has_loaded_link_handlers = False
def get_embed_handler(embed_type):
global EMBED_HANDLERS, has_loaded_embed_handlers
@ -68,6 +70,7 @@ def get_embed_handler(embed_type):
return EMBED_HANDLERS[embed_type]
def get_link_handler(link_type):
global LINK_HANDLERS, has_loaded_link_handlers

Wyświetl plik

@ -2,6 +2,7 @@ from django.core.urlresolvers import reverse
from wagtail.wagtailcore import hooks
@hooks.register('before_serve_page')
def check_view_restrictions(page, request, serve_args, serve_kwargs):
"""

Wyświetl plik

@ -5,6 +5,7 @@ from django.utils.html import format_html
from wagtail.wagtailcore.blocks import ChooserBlock
class DocumentChooserBlock(ChooserBlock):
@cached_property
def target_model(self):

Wyświetl plik

@ -18,12 +18,15 @@ from wagtail.utils.deprecation import RemovedInWagtail14Warning
class EmbedException(Exception):
pass
class EmbedNotFoundException(EmbedException):
pass
class EmbedlyException(EmbedException):
pass
class AccessDeniedEmbedlyException(EmbedlyException):
pass

Wyświetl plik

@ -3,6 +3,7 @@ from django.core.validators import URLValidator
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
def validate_url(url):
validator = URLValidator()
try:

Wyświetl plik

@ -303,6 +303,7 @@ OEMBED_ENDPOINTS = {
# Compile endpoints into regular expression objects
import re
def compile_endpoints():
endpoints = {}
for endpoint in OEMBED_ENDPOINTS.keys():

Wyświetl plik

@ -429,6 +429,7 @@ class TestDeleteFormSubmission(TestCase):
# Check that the deletion has not happened
self.assertEqual(FormSubmission.objects.count(), 2)
class TestIssue798(TestCase):
fixtures = ['test.json']

Wyświetl plik

@ -14,6 +14,7 @@ from wagtail.wagtailforms.models import FormSubmission, get_forms_for_user
from wagtail.wagtailforms.forms import SelectDateForm
from wagtail.wagtailadmin import messages
def index(request):
form_pages = get_forms_for_user(request.user)
@ -23,6 +24,7 @@ def index(request):
'form_pages': form_pages,
})
def delete_submission(request, page_id, submission_id):
if not get_forms_for_user(request.user).filter(id=page_id).exists():
raise PermissionDenied
@ -41,6 +43,7 @@ def delete_submission(request, page_id, submission_id):
'submission': submission
})
def list_submissions(request, page_id):
form_page = get_object_or_404(Page, id=page_id).specific

Wyświetl plik

@ -2,6 +2,7 @@ from django.utils.functional import cached_property
from wagtail.wagtailcore.blocks import ChooserBlock
class ImageChooserBlock(ChooserBlock):
@cached_property
def target_model(self):

Wyświetl plik

@ -31,6 +31,7 @@ def remove_duplicate_renditions(apps, schema_editor):
) AND focal_point_key IS NULL
""")
class Migration(migrations.Migration):
dependencies = [

Wyświetl plik

@ -5,6 +5,7 @@ from django.contrib.contenttypes.models import ContentType
from wagtail.wagtailcore.blocks import ChooserBlock
class SnippetChooserBlock(ChooserBlock):
def __init__(self, target_model, **kwargs):
super(SnippetChooserBlock, self).__init__(**kwargs)

Wyświetl plik

@ -24,6 +24,7 @@ class SnippetsMenuItem(MenuItem):
def is_shown(self, request):
return user_can_edit_snippets(request.user)
@hooks.register('register_admin_menu_item')
def register_snippets_menu_item():
return SnippetsMenuItem(_('Snippets'), urlresolvers.reverse('wagtailsnippets:index'), classnames='icon icon-snippet', order=500)