Commit 455c2926 authored by Nick Smith's avatar Nick Smith Committed by GitHub
Browse files

Merge pull request #2 from torchbox/wagtail-1.5-support

Make compatible with Wagtail 1.5 +
parents a19ec202 f580295e
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
......@@ -3,4 +3,12 @@ universal = 1
[flake8]
max-line-length=120
exclude=migrations
\ No newline at end of file
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
......@@ -49,8 +49,7 @@ setup(
'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,
......
__version__ = '0.1.1'
__version__ = '0.1.2'
default_app_config = 'wagtailmedia.apps.WagtailMediaAppConfig'
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
......
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'),
......
......@@ -10,7 +10,8 @@ from wagtail.wagtailadmin.forms import (
)
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):
......
......@@ -2,18 +2,17 @@ from __future__ import unicode_literals
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
......@@ -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
......
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,
......
......@@ -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 %}
......
......@@ -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>
......
......@@ -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 %}
......@@ -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 %}
......@@ -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 %}
......
......@@ -28,7 +28,7 @@
{{ 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" %}
......@@ -56,7 +56,7 @@
<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>
......
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')
......
......@@ -5,10 +5,10 @@ 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 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
......
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
......@@ -110,7 +105,7 @@ class TestMediaAddView(TestCase, WagtailTestUtils):
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
......@@ -123,7 +118,7 @@ class TestMediaAddView(TestCase, WagtailTestUtils):
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
......@@ -146,7 +141,7 @@ class TestMediaAddView(TestCase, WagtailTestUtils):
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
......@@ -165,7 +160,7 @@ class TestMediaAddView(TestCase, WagtailTestUtils):
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
......@@ -315,7 +310,7 @@ class TestMediaAddViewWithLimitedCollectionPermissions(TestCase, WagtailTestUtil
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
......@@ -332,7 +327,7 @@ class TestMediaAddViewWithLimitedCollectionPermissions(TestCase, WagtailTestUtil
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
......
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
......
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)),
......
......@@ -4,15 +4,14 @@ from django.core.urlresolvers import reverse
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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment