Skip to content
This repository was archived by the owner on May 27, 2019. It is now read-only.

Commit 4ee78f2

Browse files
nazmulhasan85jjanssen
authored andcommitted
[Fix] Compitable with django 1.11 (#15)
* [Fix] Compitable with Wagtail 1.11
1 parent 8800765 commit 4ee78f2

11 files changed

Lines changed: 130 additions & 37 deletions

File tree

.travis.yml

Lines changed: 67 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,73 @@ cache: pip
33

44
matrix:
55
include:
6-
- env: TOXENV=py35-dj110-wt16
7-
python: 3.5
8-
- env: TOXENV=py34-dj110-wt16
9-
python: 3.4
10-
- env: TOXENV=py27-dj110-wt16
11-
python: 2.7
12-
- env: TOXENV=py35-dj19-wt16
13-
python: 3.5
14-
- env: TOXENV=py34-dj19-wt16
15-
python: 3.4
16-
- env: TOXENV=py27-dj19-wt16
17-
python: 2.7
18-
- env: TOXENV=py35-dj18-wt16
19-
python: 3.5
20-
- env: TOXENV=py34-dj18-wt16
21-
python: 3.4
22-
- env: TOXENV=py33-dj18-wt16
23-
python: 3.3
24-
- env: TOXENV=py27-dj18-wt16
25-
python: 2.7
6+
# Wagtail 1.8
7+
- env: TOXENV=py27-dj18-wt18
8+
python: 2.7
9+
- env: TOXENV=py34-dj18-wt18
10+
python: 3.4
11+
- env: TOXENV=py35-dj18-wt18
12+
python: 3.5
13+
- env: TOXENV=py27-dj110-wt18
14+
python: 2.7
15+
- env: TOXENV=py34-dj110-wt18
16+
python: 3.4
17+
- env: TOXENV=py35-dj110-wt18
18+
python: 3.5
19+
20+
# Wagtail 1.9
21+
- env: TOXENV=py27-dj18-wt19
22+
python: 2.7
23+
- env: TOXENV=py34-dj18-wt19
24+
python: 3.4
25+
- env: TOXENV=py35-dj18-wt19
26+
python: 3.5
27+
- env: TOXENV=py27-dj110-wt19
28+
python: 2.7
29+
- env: TOXENV=py34-dj110-wt19
30+
python: 3.4
31+
- env: TOXENV=py35-dj110-wt19
32+
python: 3.5
33+
34+
# Wagtail 1.10
35+
- env: TOXENV=py27-dj18-wt110
36+
python: 2.7
37+
- env: TOXENV=py34-dj18-wt110
38+
python: 3.4
39+
- env: TOXENV=py35-dj18-wt110
40+
python: 3.5
41+
- env: TOXENV=py27-dj110-wt110
42+
python: 2.7
43+
- env: TOXENV=py34-dj110-wt110
44+
python: 3.4
45+
- env: TOXENV=py35-dj110-wt110
46+
python: 3.5
47+
- env: TOXENV=py27-dj111-wt110
48+
python: 2.7
49+
- env: TOXENV=py34-dj111-wt110
50+
python: 3.4
51+
- env: TOXENV=py35-dj111-wt110
52+
python: 3.5
53+
54+
# Wagtail 1.11
55+
- env: TOXENV=py27-dj18-wt111
56+
python: 2.7
57+
- env: TOXENV=py34-dj18-wt111
58+
python: 3.4
59+
- env: TOXENV=py35-dj18-wt111
60+
python: 3.5
61+
- env: TOXENV=py27-dj110-wt111
62+
python: 2.7
63+
- env: TOXENV=py34-dj110-wt111
64+
python: 3.4
65+
- env: TOXENV=py35-dj110-wt111
66+
python: 3.5
67+
- env: TOXENV=py27-dj111-wt111
68+
python: 2.7
69+
- env: TOXENV=py34-dj111-wt111
70+
python: 3.4
71+
- env: TOXENV=py35-dj111-wt111
72+
python: 3.5
2673
install:
2774
- pip install -U codecov tox
2875
script:

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ Contributors
1212

1313
* Janneke Janssen
1414
* Mike Dingjan
15+
* Nazmul Hasan

tests/test_blocks.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,17 @@
33
----------------------------------
44
55
Tests for `wagtailsocialfeed.blocks`.
6+
7+
In Wagtail 1.8 Function accepting only one parameter and that's why its raising TypeError
8+
In Combination of Django 1.11 and Wagtail 1.9, `ImportError` Exception is occurring in wagtailimage.
9+
10+
from django.forms.widgets import flatatt
11+
ImportError: cannot import name flatatt
12+
13+
because it's moved to utils
14+
615
"""
16+
717
from __future__ import unicode_literals
818

919
from django.test import RequestFactory, TestCase
@@ -63,3 +73,32 @@ def test_render_form(self):
6373
self.assertEqual(
6474
soup.find(id='test-feedconfig').find_all('option')[1].text,
6575
'twitter (@wagtailcms)')
76+
77+
@feed_response('twitter')
78+
def test_get_context_with_parent_context(self, tweets):
79+
block = SocialFeedBlock()
80+
81+
value = {
82+
'feedconfig': self.feedconfig,
83+
'limit': 3
84+
}
85+
parent_context = {'has_parent': 'parent context'}
86+
87+
try:
88+
context = block.get_context(value, parent_context)
89+
self.assertEqual(context['has_parent'], parent_context['has_parent'])
90+
# In Wagtail 1.8 Function accepting only one parameter and that's why its raising TypeError
91+
except TypeError:
92+
self.skipTest(TestSocialFeedBlock)
93+
94+
@feed_response('twitter')
95+
def test_get_context_without_parent_context(self, tweets):
96+
block = SocialFeedBlock()
97+
98+
value = {
99+
'feedconfig': self.feedconfig,
100+
'limit': 3
101+
}
102+
103+
context = block.get_context(value)
104+
self.assertEqual(context['value'], value)

tox.ini

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ skipsdist = True
44
usedevelop = True
55

66
envlist =
7-
py{27,33,34,35}-dj{18,19,110}-wt16
7+
py{27,33,34,35}-dj{18,19,110,111}-wt{18,19,110,111}
88
flake8
99

1010

@@ -16,16 +16,18 @@ commands =
1616

1717
basepython =
1818
py27: python2.7
19-
py33: python3.3
2019
py34: python3.4
2120
py35: python3.5
2221

2322
deps =
24-
py27: enum34
2523
dj18: django~=1.8.0
2624
dj19: django~=1.9.0
2725
dj110: django~=1.10.0
28-
wt16: Wagtail~=1.6.0
26+
dj111: django~=1.11.0
27+
wt18: wagtail>=1.8,<1.9
28+
wt19: wagtail>=1.9,<1.10
29+
wt110: wagtail>=1.10,<1.11
30+
wt111: wagtail>=1.11,<1.12
2931

3032

3133
[testenv:flake8]

wagtailsocialfeed/blocks.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,14 @@ class Meta:
4848
icon = 'icon icon-fa-rss'
4949
template = 'wagtailsocialfeed/social_feed_block.html'
5050

51-
def get_context(self, value):
52-
context = super(SocialFeedBlock, self).get_context(value)
51+
def get_context(self, value, parent_context=None):
52+
if not parent_context:
53+
context = super(SocialFeedBlock, self).get_context(value)
54+
else:
55+
context = super(SocialFeedBlock, self).get_context(value, parent_context)
5356

5457
feedconfig = value['feedconfig']
55-
feed = None
58+
5659
if feedconfig:
5760
feed = get_feed_items(feedconfig, limit=value['limit'])
5861
else:

wagtailsocialfeed/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import absolute_import, unicode_literals
2+
23
from django.conf.urls import url
34

45
from . import views

wagtailsocialfeed/utils/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from __future__ import absolute_import, unicode_literals
22

3-
from django.conf import settings
43
from datetime import timedelta
54

5+
from django.conf import settings
6+
67
DEFAULTS = {
78
'CONFIG': {},
89
'CACHE_DURATION': 900,

wagtailsocialfeed/utils/feed/facebook.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
from enum import Enum
2+
13
from dateutil import parser as dateparser
24
from django.core.exceptions import ImproperlyConfigured
35
from facepy import GraphAPI
4-
56
from wagtailsocialfeed.utils.conf import get_socialfeed_setting
67

78
from . import AbstractFeed, AbstractFeedQuery, FeedItem
8-
from enum import Enum
99

1010

1111
class PostType(Enum):

wagtailsocialfeed/utils/feed/factory.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from .twitter import TwitterFeed, TwitterFeedItem
2-
from .instagram import InstagramFeed, InstagramFeedItem
3-
from .facebook import FacebookFeed, FacebookFeedItem
4-
51
from collections import namedtuple
62

3+
from .facebook import FacebookFeed, FacebookFeedItem
4+
from .instagram import InstagramFeed, InstagramFeedItem
5+
from .twitter import TwitterFeed, TwitterFeedItem
6+
77
FeedClasses = namedtuple('FeedClasses', ['feed', 'item'])
88

99
FEED_CONFIG = {

wagtailsocialfeed/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from django.views.decorators.csrf import csrf_exempt
77
from django.views.generic.base import View
88
from django.views.generic.detail import DetailView
9-
109
from wagtail.wagtailadmin.forms import SearchForm
1110

1211
from .models import ModeratedItem, SocialFeedConfiguration
@@ -61,6 +60,7 @@ def get_context_data(self, **kwargs):
6160

6261
return context
6362

63+
6464
error_messages = {
6565
'no_original':
6666
_('The original social feed post was not found in the POST data'),

0 commit comments

Comments
 (0)