mirror of
https://github.com/Hopiu/django-uuslug.git
synced 2026-03-16 20:10:24 +00:00
Fix: False alarm on model/instance check. (konradhalas)
This commit is contained in:
parent
29f3d346d7
commit
d398136ade
6 changed files with 19 additions and 24 deletions
24
.travis.yml
24
.travis.yml
|
|
@ -1,17 +1,16 @@
|
|||
sudo: false
|
||||
language: python
|
||||
|
||||
python:
|
||||
- "3.5"
|
||||
- "3.4"
|
||||
- "3.3"
|
||||
- "3.2"
|
||||
- "2.7"
|
||||
- "2.6"
|
||||
- pypy
|
||||
|
||||
env:
|
||||
- DJANGO="django==1.8.2"
|
||||
- DJANGO="django==1.7.7"
|
||||
- DJANGO="django==1.4.20"
|
||||
- DJANGO="django==1.9"
|
||||
- DJANGO="django==1.8.7"
|
||||
|
||||
install:
|
||||
- pip install $DJANGO
|
||||
|
|
@ -27,19 +26,10 @@ before_script:
|
|||
|
||||
matrix:
|
||||
exclude:
|
||||
- python: "3.4"
|
||||
env: DJANGO="django==1.4.20"
|
||||
- python: "3.3"
|
||||
env: DJANGO="django==1.4.20"
|
||||
- python: "3.2"
|
||||
env: DJANGO="django==1.4.20"
|
||||
- python: "2.6"
|
||||
env: DJANGO="django==1.7.7"
|
||||
- python: "2.6"
|
||||
env: DJANGO="django==1.8.2"
|
||||
env: DJANGO="django==1.9"
|
||||
|
||||
script:
|
||||
- coverage run --source=uuslug manage.py test
|
||||
script: coverage run --source=uuslug manage.py test
|
||||
|
||||
after_success:
|
||||
- coveralls
|
||||
coveralls
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Django>=1.4.20
|
||||
Django>=1.4+
|
||||
|
|
|
|||
5
setup.py
5
setup.py
|
|
@ -14,7 +14,7 @@ url = 'https://github.com/un33k/django-uuslug'
|
|||
author = 'Val Neekman'
|
||||
author_email = 'info@neekware.com'
|
||||
license = 'BSD'
|
||||
install_requires = ['python-slugify>=1.1.3']
|
||||
install_requires = ['python-slugify>=1.1.4']
|
||||
classifiers = [
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Environment :: Web Environment',
|
||||
|
|
@ -63,8 +63,7 @@ if sys.argv[-1] == 'publish':
|
|||
os.system("python setup.py sdist upload")
|
||||
args = {'version': get_version(package)}
|
||||
print("You probably want to also tag the version now:")
|
||||
print(" git tag -a %(version)s -m 'version %(version)s'" % args)
|
||||
print(" git push --tags")
|
||||
print(" git tag -a %(version)s -m 'version %(version)s' && git push --tags" % args)
|
||||
sys.exit()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ from .uuslug import *
|
|||
|
||||
__author__ = 'Val Neekman @ Neekware Inc. [@vneekman]'
|
||||
__description__ = 'A Python slugify application that also handles Unicode'
|
||||
__version__ = '1.1.6'
|
||||
__version__ = '1.1.7'
|
||||
|
||||
default_app_config = 'uuslug.apps.AppConfig'
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from django.test import TestCase
|
|||
# http://pypi.python.org/pypi/django-tools/
|
||||
# from django_tools.unittest_utils.print_sql import PrintQueries
|
||||
|
||||
from uuslug import slugify
|
||||
from uuslug import slugify, uuslug
|
||||
from uuslug.models import (CoolSlug, AnotherSlug, TruncatedSlug,
|
||||
SmartTruncatedSlug, SmartTruncatedExactWordBoundrySlug,
|
||||
CoolSlugDifferentSeparator, TruncatedSlugDifferentSeparator,
|
||||
|
|
@ -265,3 +265,8 @@ class SlugMaxLengthTestCase(TestCase):
|
|||
# 10 is field max_length, 20 is uuslug function max_length
|
||||
obj = AutoTruncatedSlug.objects.create(name=name)
|
||||
self.assertEqual(obj.slug, "jaja-lol-1")
|
||||
|
||||
|
||||
class ModelInstanceExeptionTestCase(TestCase):
|
||||
def test_uuslug_checks_for_model_instance(self):
|
||||
self.assertRaises(Exception, uuslug, 'test_slug', CoolSlug)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
from django.db.models.base import ModelBase
|
||||
from slugify import slugify as pyslugify
|
||||
from django.utils import six
|
||||
if six.PY3:
|
||||
|
|
@ -24,7 +25,7 @@ def uuslug(s, instance, entities=True, decimal=True, hexadecimal=True,
|
|||
|
||||
""" This method tries a little harder than django's django.template.defaultfilters.slugify. """
|
||||
|
||||
if hasattr(instance, 'objects'):
|
||||
if isinstance(instance, ModelBase):
|
||||
raise Exception("Error: you must pass an instance to uuslug, not a model.")
|
||||
|
||||
queryset = instance.__class__.objects.all()
|
||||
|
|
|
|||
Loading…
Reference in a new issue