Skip to content

Commit

Permalink
Merge pull request #2 from torchbox/wagtail-1.5-support
Browse files Browse the repository at this point in the history
Make compatible with Wagtail 1.5 +
  • Loading branch information
nimasmi authored Oct 31, 2016
2 parents a19ec20 + f580295 commit 455c292
Show file tree
Hide file tree
Showing 22 changed files with 83 additions and 64 deletions.
22 changes: 22 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
build:
flake8:
image: python:3.5
commands:
- XDG_CACHE_HOME=/drone/pip-cache pip install flake8
- flake8 wagtailmedia
isort:
image: python:3.5
commands:
- XDG_CACHE_HOME=/drone/pip-cache pip install -e .[testing]
- XDG_CACHE_HOME=/drone/pip-cache pip install isort
- isort --check-only --diff --recursive wagtailmedia
unittest:
image: python:3.5
commands:
- XDG_CACHE_HOME=/drone/pip-cache pip install -e .[testing,docs]
- python runtests.py

cache:
mount:
- node_modules
- /drone/pip-cache
10 changes: 9 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@ universal = 1

[flake8]
max-line-length=120
exclude=migrations
exclude=migrations

[isort]
known_first_party=wagtailmedia
known_django=django
skip=migrations
sections=FUTURE, STDLIB, DJANGO, THIRDPARTY, FIRSTPARTY, LOCALFOLDER
default_section=THIRDPARTY
multi_line_output=5
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
'Topic :: Internet :: WWW/HTTP :: Site Management',
],
install_requires=[
'Django>=1.8.1,<1.10',
'wagtail>=1.4',
'wagtail>=1.5.3',
],
extras_require={
'testing': testing_extras,
Expand Down
2 changes: 1 addition & 1 deletion wagtailmedia/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = '0.1.1'
__version__ = '0.1.2'

default_app_config = 'wagtailmedia.apps.WagtailMediaAppConfig'
3 changes: 1 addition & 2 deletions wagtailmedia/admin.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from django.contrib import admin
from django.conf import settings
from django.contrib import admin

from wagtailmedia.models import Media


if hasattr(settings, 'WAGTAILMEDIA_MEDIA_MODEL') and settings.WAGTAILMEDIA_MEDIA_MODEL != 'wagtailmedia.Media':
# This installation provides its own custom media class;
# to avoid confusion, we won't expose the unused wagtailmedia.Media class
Expand Down
3 changes: 1 addition & 2 deletions wagtailmedia/admin_urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django.conf.urls import url

from wagtailmedia.views import media, chooser

from wagtailmedia.views import chooser, media

urlpatterns = [
url(r'^$', media.index, name='index'),
Expand Down
3 changes: 2 additions & 1 deletion wagtailmedia/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
)

from wagtailmedia.models import Media
from wagtailmedia.permissions import permission_policy as media_permission_policy
from wagtailmedia.permissions import \
permission_policy as media_permission_policy


class BaseMediaForm(BaseCollectionMemberForm):
Expand Down
17 changes: 8 additions & 9 deletions wagtailmedia/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

import os.path

from taggit.managers import TaggableManager

from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import reverse
from django.db import models
from django.db.models.signals import pre_delete
from django.dispatch.dispatcher import receiver
from django.dispatch import Signal
from django.core.urlresolvers import reverse
from django.core.exceptions import ImproperlyConfigured
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from django.dispatch.dispatcher import receiver
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _

from taggit.managers import TaggableManager
from wagtail.wagtailadmin.taggable import TagSearchable
from wagtail.wagtailadmin.utils import get_object_usage
from wagtail.wagtailcore.models import CollectionMember
Expand Down Expand Up @@ -55,9 +54,9 @@ class AbstractMedia(CollectionMember, TagSearchable):

objects = MediaQuerySet.as_manager()

search_fields = TagSearchable.search_fields + CollectionMember.search_fields + (
search_fields = TagSearchable.search_fields + CollectionMember.search_fields + [
index.FilterField('uploaded_by_user'),
)
]

def __str__(self):
return self.title
Expand Down
4 changes: 1 addition & 3 deletions wagtailmedia/permissions.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from wagtail.wagtailcore.permission_policies.collections import (
from wagtail.wagtailcore.permission_policies.collections import \
CollectionOwnershipPermissionPolicy
)

from wagtailmedia.models import Media, get_media_model


permission_policy = CollectionOwnershipPermissionPolicy(
get_media_model(),
auth_model=Media,
Expand Down
2 changes: 1 addition & 1 deletion wagtailmedia/templates/wagtailmedia/chooser/chooser.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<div class="tab-content">
<section id="search" class="{% if not uploadform.errors %}active {% endif %}nice-padding">
<form class="media-search search-bar" action="{% url 'wagtailmedia:chooser' %}" method="GET">
<form class="media-search search-bar" action="{% url 'wagtailmedia:chooser' %}" method="GET" novalidate>
<ul class="fields">
{% for field in searchform %}
{% include "wagtailadmin/shared/field_as_li.html" with field=field %}
Expand Down
4 changes: 2 additions & 2 deletions wagtailmedia/templates/wagtailmedia/media/add.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
{% include "wagtailadmin/shared/header.html" with title=add_str icon="media" %}

<div class="nice-padding">
<form action="{% url 'wagtailmedia:add' media_type %}" method="POST" enctype="multipart/form-data">
<form action="{% url 'wagtailmedia:add' media_type %}" method="POST" enctype="multipart/form-data" novalidate>
{% csrf_token %}
<ul class="fields">
{% for field in form %}
{% include "wagtailadmin/shared/field_as_li.html" with field=field %}
{% endfor %}
<li>
<button type="submit" class="button-longrunning" data-clicked-text="{% trans 'Uploading...' %}"><span class="icon icon-spinner"></span><em>{% trans 'Upload' %}</em></button>
<button type="submit" class="button button-longrunning" data-clicked-text="{% trans 'Uploading...' %}"><span class="icon icon-spinner"></span><em>{% trans 'Upload' %}</em></button>
</li>
</ul>
</form>
Expand Down
4 changes: 2 additions & 2 deletions wagtailmedia/templates/wagtailmedia/media/confirm_delete.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

<div class="nice-padding">
<p>{% trans "Are you sure you want to delete this media file?" %}</p>
<form action="{% url 'wagtailmedia:delete' media.id %}" method="POST">
<form action="{% url 'wagtailmedia:delete' media.id %}" method="POST" novalidate>
{% csrf_token %}
<input type="submit" value='{% trans "Yes, delete" %}' class="serious" />
<input type="submit" value='{% trans "Yes, delete" %}' class="button serious" />
</form>
</div>
{% endblock %}
4 changes: 2 additions & 2 deletions wagtailmedia/templates/wagtailmedia/media/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<div class="row row-flush nice-padding">

<div class="col10 divider-after">
<form action="{% url 'wagtailmedia:edit' media.id %}" method="POST" enctype="multipart/form-data">
<form action="{% url 'wagtailmedia:edit' media.id %}" method="POST" enctype="multipart/form-data" novalidate>
{% csrf_token %}
<ul class="fields">
{% for field in form %}
Expand All @@ -36,7 +36,7 @@
{% endif %}
{% endfor %}
<li>
<input type="submit" value="{% trans 'Save' %}" />
<input class="button" type="submit" value="{% trans 'Save' %}" />
{% if user_can_delete %}
<a href="{% url 'wagtailmedia:delete' media.id %}" class="button button-secondary no">{% trans "Delete" %}</a>
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions wagtailmedia/templates/wagtailmedia/media/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h1 class="icon icon-media">
{{ media_str }}
</h1>
</div>
<form class="col search-form" action="{% url 'wagtailmedia:index' %}{% if query_parameters %}?{{ query_parameters }}{% endif %}" method="get">
<form class="col search-form" action="{% url 'wagtailmedia:index' %}{% if query_parameters %}?{{ query_parameters }}{% endif %}" method="get" novalidate>
<ul class="fields">
{% for field in search_form %}
{% include "wagtailadmin/shared/field_as_li.html" with field=field field_classes="field-small iconfield" input_classes="icon-search" %}
Expand Down Expand Up @@ -56,7 +56,7 @@ <h1 class="icon icon-media">

<div class="nice-padding">
{% if collections %}
<form class="image-search search-bar" action="{% url 'wagtailmedia:index' %}" method="GET">
<form class="image-search search-bar" action="{% url 'wagtailmedia:index' %}" method="GET" novalidate>
<ul class="fields">
{% include "wagtailadmin/shared/collection_chooser.html" %}
</ul>
Expand Down
1 change: 0 additions & 1 deletion wagtailmedia/tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os


WAGTAILMEDIA_ROOT = os.path.dirname(__file__)
STATIC_ROOT = os.path.join(WAGTAILMEDIA_ROOT, 'test-static')
MEDIA_ROOT = os.path.join(WAGTAILMEDIA_ROOT, 'test-media')
Expand Down
4 changes: 2 additions & 2 deletions wagtailmedia/tests/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from django.core.files.base import ContentFile
from django.core.urlresolvers import reverse
from django.test import TestCase
from six import b

from six import b
from wagtail.tests.utils import WagtailTestUtils
from wagtail.wagtailcore.models import GroupCollectionPermission, Collection
from wagtail.wagtailcore.models import Collection, GroupCollectionPermission

from wagtailmedia import models

Expand Down
27 changes: 11 additions & 16 deletions wagtailmedia/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
from __future__ import unicode_literals

import os
import unittest

import django
import mock

from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Permission, Group
from django.contrib.auth.models import Group, Permission
from django.core.files.base import ContentFile
from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test.utils import override_settings
from six import b

from six import b
from wagtail.tests.utils import WagtailTestUtils
from wagtail.wagtailcore.models import Page, Collection, GroupCollectionPermission
from wagtail.wagtailcore.models import (
Collection, GroupCollectionPermission, Page
)

from wagtailmedia import models
from wagtailmedia.tests.testapp.models import EventPage, EventPageRelatedMedia
Expand Down Expand Up @@ -110,7 +105,7 @@ def test_get_audio(self):
self.assertContains(response, 'Add audio')
self.assertContains(
response,
'<form action="{0}" method="POST" enctype="multipart/form-data">'.format(
'<form action="{0}" method="POST" enctype="multipart/form-data" novalidate>'.format(
reverse('wagtailmedia:add', args=('audio',))
),
count=1
Expand All @@ -123,7 +118,7 @@ def test_get_video(self):
self.assertContains(response, 'Add video')
self.assertContains(
response,
'<form action="{0}" method="POST" enctype="multipart/form-data">'.format(
'<form action="{0}" method="POST" enctype="multipart/form-data" novalidate>'.format(
reverse('wagtailmedia:add', args=('video',))
),
count=1
Expand All @@ -146,7 +141,7 @@ def test_get_audio_with_collections(self):
self.assertContains(response, 'Add audio')
self.assertContains(
response,
'<form action="{0}" method="POST" enctype="multipart/form-data">'.format(
'<form action="{0}" method="POST" enctype="multipart/form-data" novalidate>'.format(
reverse('wagtailmedia:add', args=('audio',))
),
count=1
Expand All @@ -165,7 +160,7 @@ def test_get_video_with_collections(self):
self.assertContains(response, 'Add video')
self.assertContains(
response,
'<form action="{0}" method="POST" enctype="multipart/form-data">'.format(
'<form action="{0}" method="POST" enctype="multipart/form-data" novalidate>'.format(
reverse('wagtailmedia:add', args=('video',))
),
count=1
Expand Down Expand Up @@ -315,7 +310,7 @@ def test_get_audio(self):
self.assertContains(response, 'Add audio')
self.assertContains(
response,
'<form action="{0}" method="POST" enctype="multipart/form-data">'.format(
'<form action="{0}" method="POST" enctype="multipart/form-data" novalidate>'.format(
reverse('wagtailmedia:add', args=('audio',))
),
count=1
Expand All @@ -332,7 +327,7 @@ def test_get_video(self):
self.assertContains(response, 'Add video')
self.assertContains(
response,
'<form action="{0}" method="POST" enctype="multipart/form-data">'.format(
'<form action="{0}" method="POST" enctype="multipart/form-data" novalidate>'.format(
reverse('wagtailmedia:add', args=('video',))
),
count=1
Expand Down
1 change: 0 additions & 1 deletion wagtailmedia/tests/testapp/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django.db import models

from modelcluster.fields import ParentalKey

from wagtail.wagtailadmin.edit_handlers import FieldPanel, InlinePanel
from wagtail.wagtailcore.fields import RichTextField
from wagtail.wagtailcore.models import Orderable, Page
Expand Down
2 changes: 1 addition & 1 deletion wagtailmedia/tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.conf.urls import include, url

from wagtail.wagtailcore import urls as wagtail_urls
from wagtail.wagtailadmin import urls as wagtailadmin_urls
from wagtail.wagtailcore import urls as wagtail_urls

urlpatterns = [
url(r'^admin/', include(wagtailadmin_urls)),
Expand Down
3 changes: 1 addition & 2 deletions wagtailmedia/views/chooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
from django.shortcuts import get_object_or_404, render

from wagtail.utils.pagination import paginate
from wagtail.wagtailadmin.modal_workflow import render_modal_workflow
from wagtail.wagtailadmin.forms import SearchForm
from wagtail.wagtailadmin.modal_workflow import render_modal_workflow
from wagtail.wagtailadmin.utils import PermissionPolicyChecker
from wagtail.wagtailcore.models import Collection

from wagtailmedia.models import get_media_model
from wagtailmedia.permissions import permission_policy


permission_checker = PermissionPolicyChecker(permission_policy)


Expand Down
15 changes: 8 additions & 7 deletions wagtailmedia/views/media.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
from __future__ import unicode_literals

from django.shortcuts import render, redirect, get_object_or_404
from django.core.urlresolvers import reverse
from django.shortcuts import get_object_or_404, redirect, render
from django.utils.translation import ugettext as _
from django.views.decorators.vary import vary_on_headers
from django.core.urlresolvers import reverse

from wagtail.utils.pagination import paginate
from wagtail.wagtailadmin.forms import SearchForm
from wagtail.wagtailadmin.utils import PermissionPolicyChecker, permission_denied
from wagtail.wagtailsearch.backends import get_search_backends
from wagtail.wagtailadmin import messages
from wagtail.wagtailadmin.forms import SearchForm
from wagtail.wagtailadmin.utils import (
PermissionPolicyChecker, permission_denied
)
from wagtail.wagtailcore.models import Collection
from wagtail.wagtailsearch.backends import get_search_backends

from wagtailmedia.models import get_media_model
from wagtailmedia.forms import get_media_form
from wagtailmedia.models import get_media_model
from wagtailmedia.permissions import permission_policy


permission_checker = PermissionPolicyChecker(permission_policy)


Expand Down
9 changes: 5 additions & 4 deletions wagtailmedia/wagtail_hooks.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from django.conf.urls import include, url
from django.contrib.staticfiles.templatetags.staticfiles import static
from django.core import urlresolvers
from django.utils.html import format_html, format_html_join
from django.utils.translation import ugettext_lazy as _, ungettext
from django.contrib.staticfiles.templatetags.staticfiles import static
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext

from wagtail.wagtailcore import hooks
from wagtail.wagtailadmin.menu import MenuItem
from wagtail.wagtailadmin.site_summary import SummaryItem
from wagtail.wagtailadmin.search import SearchArea
from wagtail.wagtailadmin.site_summary import SummaryItem
from wagtail.wagtailcore import hooks

from wagtailmedia import admin_urls
from wagtailmedia.forms import GroupMediaPermissionFormSet
Expand Down

0 comments on commit 455c292

Please sign in to comment.