Skip to content

Commit

Permalink
Adapted test matrix and fixes issue with Django 2.x (django-cms#159)
Browse files Browse the repository at this point in the history
* adapted test matrix

* fixes issue with Django 3.c and latest CMS

* use `ref_page_site_id` instead of `ref_page.site_id`

* added missing changelog entry
  • Loading branch information
FinalAngel authored Dec 11, 2018
1 parent 331cf68 commit c5d3f06
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 21 deletions.
11 changes: 0 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,23 @@ matrix:
- python: 3.5
env: TOX_ENV='flake8'
# Django 1.11
- python: 3.5
env: DJANGO='dj111' CMS='cms34'
- python: 2.7
env: DJANGO='dj111' CMS='cms34'
- python: 3.5
env: DJANGO='dj111' CMS='cms35'
- python: 2.7
env: DJANGO='dj111' CMS='cms35'
- python: 3.5
env: DJANGO='dj111' CMS='cms36'
- python: 2.7
env: DJANGO='dj111' CMS='cms36'
# Django 2.0
- python: 3.6
env: DJANGO='dj20' CMS='cms36'
- python: 3.5
env: DJANGO='dj20' CMS='cms36'
# Django 2.1
- python: 3.6
env: DJANGO='dj21' CMS='cms36'
- python: 3.5
env: DJANGO='dj21' CMS='cms36'

install:
- pip install tox coverage
- "if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then export PY_VER=py27; fi"
- "if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then export PY_VER=py35; fi"
- "if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then export PY_VER=py36; fi"
- "if [[ ${DJANGO}z != 'z' ]]; then export TOX_ENV=$PY_VER-$DJANGO-$CMS; fi"

script:
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
Changelog
=========

2.3.0 (unreleased)
==================

* Fixed test matrix
* Fixed an issue when ``page.site`` is not available
* Fixed an issue generating ``'Page' object has no attribute 'site'``


2.2.2 (2018-01-03)
==================
Expand Down
11 changes: 6 additions & 5 deletions djangocms_link/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ def render(self, context, instance, placeholder):
def get_form(self, request, obj=None, **kwargs):
form_class = super(LinkPlugin, self).get_form(request, obj, **kwargs)

if obj and obj.page and obj.page.site:
site = obj.page.site
elif self.page and self.page.site:
site = self.page.site
else:
try:
if obj and obj.page and obj.page.site:
site = obj.page.site
elif self.page and self.page.site:
site = self.page.site
except:
# this might NOT give the result you expect
site = Site.objects.get_current()

Expand Down
2 changes: 1 addition & 1 deletion djangocms_link/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def get_link(self):
cms_page_site_id = getattr(cms_page, 'site_id', None)

if ref_page_site_id != cms_page_site_id:
ref_site = Site.objects._get_site_by_id(ref_page.site_id).domain
ref_site = Site.objects._get_site_by_id(ref_page_site_id).domain
link = '//{}{}'.format(ref_site, link)
elif self.external_link:
link = self.external_link
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
url='https://github.com/divio/djangocms-link',
license='BSD',
long_description=open('README.rst').read(),
packages=find_packages(),
packages=find_packages(exclude=['tests']),
include_package_data=True,
zip_safe=False,
install_requires=REQUIREMENTS,
Expand Down
2 changes: 1 addition & 1 deletion tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
'django_select2',
'djangocms_text_ckeditor',
],
'ALLOWED_HOSTS': ['localhost'],
'CMS_LANGUAGES': {
1: [{
'code': 'en',
'name': 'English',
}]
},
'LANGUAGE_CODE': 'en',
'ALLOWED_HOSTS': ['localhost'],
'DJANGOCMS_LINK_USE_SELECT2': True
}

Expand Down
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
[tox]
envlist =
flake8
py{27,34,35,36}-dj111-cms{36,35,34}
py{27,34,35,36}-dj111-cms{34,35,36}
py{34,35,36}-dj20-cms36
py{35,36}-dj21-cms36

skip_missing_interpreters=True


[testenv]
deps =
-r{toxinidir}/tests/requirements.txt
Expand Down

0 comments on commit c5d3f06

Please sign in to comment.