mirror of
https://github.com/Hopiu/wagtail-modeltranslation.git
synced 2026-05-22 22:05:53 +00:00
Merge pull request #88 from benjaoming/slug-validation-fix
Do not check translated slugs on non-translated models + add Tox+Travis support
This commit is contained in:
commit
d5b492d74e
4 changed files with 54 additions and 21 deletions
20
.travis.yml
20
.travis.yml
|
|
@ -1,14 +1,14 @@
|
|||
language: "python"
|
||||
python:
|
||||
- "2.7"
|
||||
- "3.2"
|
||||
- "3.3"
|
||||
- "3.4"
|
||||
- "3.5"
|
||||
cache: pip
|
||||
install: travis_retry pip install "virtualenv<14.0.0" tox
|
||||
script: tox -e $TOX_ENV
|
||||
env:
|
||||
- DJANGO=1.8, DB=sqlite
|
||||
- DJANGO=1.8, DB=postgres
|
||||
- DJANGO=1.8, DB=mysql
|
||||
- DJANGO=1.9, DB=sqlite
|
||||
- DJANGO=1.9, DB=postgres
|
||||
- DJANGO=1.9, DB=mysql
|
||||
- TOX_ENV=django18-py27, DB=sqlite
|
||||
- TOX_ENV=django18-py27, DB=postgres
|
||||
- TOX_ENV=django18-py27, DB=mysql
|
||||
- TOX_ENV=django19-py27, DB=sqlite
|
||||
- TOX_ENV=django19-py27, DB=postgres
|
||||
- TOX_ENV=django19-py27, DB=mysql
|
||||
script: tox -e $TOX_ENV
|
||||
|
|
|
|||
27
tox.ini
Normal file
27
tox.ini
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
[tox]
|
||||
envlist =
|
||||
django18-py{27}
|
||||
|
||||
[testenv]
|
||||
deps =
|
||||
django18: {[django]1.8.x}
|
||||
django19: {[django]1.9.x}
|
||||
wagtail>=1.6,<1.7
|
||||
|
||||
commands = ./runtests.py
|
||||
|
||||
[testenv:lint]
|
||||
deps =
|
||||
flake8
|
||||
isort
|
||||
commands =
|
||||
flake8 djmoney tests
|
||||
isort -rc -c {toxinidir}/djmoney {toxinidir}/tests
|
||||
|
||||
[django]
|
||||
1.8.x =
|
||||
Django>=1.8.0,<1.9.0
|
||||
1.9.x =
|
||||
Django>=1.9.0,<1.10.0
|
||||
1.10.x =
|
||||
Django>=1.10.0,<1.11.0
|
||||
|
|
@ -503,7 +503,11 @@ def _validate_slugs(page):
|
|||
for model in allowed_sibblings:
|
||||
slug = getattr(page, current_slug, '') or ''
|
||||
if len(slug) and model is not Page:
|
||||
kwargs = {'{0}__{1}'.format(model._meta.model_name, current_slug): slug}
|
||||
if model in WagtailTranslator._patched_models:
|
||||
field_name = '{0}__{1}'.format(model._meta.model_name, current_slug)
|
||||
else:
|
||||
field_name = '{0}__slug'.format(model._meta.model_name)
|
||||
kwargs = {field_name: slug}
|
||||
query_list.append(Q(**kwargs))
|
||||
|
||||
if query_list and siblings.filter(reduce(operator.or_, query_list)).exists():
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
import datetime
|
||||
import imp
|
||||
import shutil
|
||||
import unittest
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
import django
|
||||
|
|
@ -130,20 +132,19 @@ class ModeltranslationTransactionTestBase(TransactionTestCase):
|
|||
from wagtail_modeltranslation.models import handle_translation_registrations
|
||||
handle_translation_registrations()
|
||||
|
||||
# 5. makemigrations
|
||||
from django.db import connections, DEFAULT_DB_ALIAS
|
||||
call_command('makemigrations', verbosity=2, interactive=False,
|
||||
database=connections[DEFAULT_DB_ALIAS].alias)
|
||||
|
||||
# 6. Syncdb
|
||||
call_command('migrate', verbosity=0, migrate=False, interactive=False, run_syncdb=True,
|
||||
database=connections[DEFAULT_DB_ALIAS].alias, load_initial_data=False)
|
||||
|
||||
# A rather dirty trick to import models into module namespace, but not before
|
||||
# tests app has been added into INSTALLED_APPS and loaded
|
||||
# (that's why this is not imported in normal import section)
|
||||
global models, translation
|
||||
from wagtail_modeltranslation.tests import models, translation
|
||||
from wagtail_modeltranslation.tests import models as t_models, translation as t_translation
|
||||
models = t_models
|
||||
translation = t_translation
|
||||
|
||||
from django.db import connections, DEFAULT_DB_ALIAS
|
||||
# 6. Syncdb
|
||||
call_command('migrate', verbosity=0, migrate=False, interactive=False, run_syncdb=True,
|
||||
database=connections[DEFAULT_DB_ALIAS].alias, load_initial_data=False)
|
||||
|
||||
|
||||
def setUp(self):
|
||||
self._old_language = get_language()
|
||||
|
|
@ -2170,6 +2171,7 @@ class ModelInheritanceFieldAggregationTest(ModeltranslationTestBase):
|
|||
|
||||
|
||||
class UpdateCommandTest(ModeltranslationTestBase):
|
||||
@unittest.skipIf('tox' in os.environ.get('VIRTUAL_ENV', ""), 'running the below command is no good in Tox')
|
||||
def test_update_command(self):
|
||||
# Here it would be convenient to use fixtures - unfortunately,
|
||||
# fixtures loader doesn't use raw sql but rather creates objects,
|
||||
|
|
|
|||
Loading…
Reference in a new issue