mirror of
				https://github.com/SectorLabs/django-localized-fields.git
				synced 2025-11-04 12:08:57 +03:00 
			
		
		
		
	Merge branch 'master' into hstore_extension
This commit is contained in:
		
							
								
								
									
										92
									
								
								.circleci/config.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								.circleci/config.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,92 @@
 | 
				
			|||||||
 | 
					version: 2
 | 
				
			||||||
 | 
					jobs:
 | 
				
			||||||
 | 
					    test-python35:
 | 
				
			||||||
 | 
					        docker:
 | 
				
			||||||
 | 
					            - image: python:3.5-alpine
 | 
				
			||||||
 | 
					            - image: postgres:11.0
 | 
				
			||||||
 | 
					              environment:
 | 
				
			||||||
 | 
					                  POSTGRES_DB: 'localizedfields'
 | 
				
			||||||
 | 
					                  POSTGRES_USER: 'localizedfields'
 | 
				
			||||||
 | 
					                  POSTGRES_PASSWORD: 'localizedfields'
 | 
				
			||||||
 | 
					        steps:
 | 
				
			||||||
 | 
					            - checkout
 | 
				
			||||||
 | 
					            - run:
 | 
				
			||||||
 | 
					                name: Install packages
 | 
				
			||||||
 | 
					                command: apk add postgresql-libs gcc musl-dev postgresql-dev git
 | 
				
			||||||
 | 
					            - run:
 | 
				
			||||||
 | 
					                name: Install Python packages
 | 
				
			||||||
 | 
					                command: pip install -r requirements/test.txt
 | 
				
			||||||
 | 
					            - run:
 | 
				
			||||||
 | 
					                name: Run tests
 | 
				
			||||||
 | 
					                command: tox -e 'py35-dj{111,20,21}'
 | 
				
			||||||
 | 
					                environment:
 | 
				
			||||||
 | 
					                    DATABASE_URL: 'postgres://localizedfields:localizedfields@localhost:5432/localizedfields'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    test-python36:
 | 
				
			||||||
 | 
					        docker:
 | 
				
			||||||
 | 
					            - image: python:3.6-alpine
 | 
				
			||||||
 | 
					            - image: postgres:11.0
 | 
				
			||||||
 | 
					              environment:
 | 
				
			||||||
 | 
					                  POSTGRES_DB: 'localizedfields'
 | 
				
			||||||
 | 
					                  POSTGRES_USER: 'localizedfields'
 | 
				
			||||||
 | 
					                  POSTGRES_PASSWORD: 'localizedfields'
 | 
				
			||||||
 | 
					        steps:
 | 
				
			||||||
 | 
					            - checkout
 | 
				
			||||||
 | 
					            - run:
 | 
				
			||||||
 | 
					                name: Install packages
 | 
				
			||||||
 | 
					                command: apk add postgresql-libs gcc musl-dev postgresql-dev git
 | 
				
			||||||
 | 
					            - run:
 | 
				
			||||||
 | 
					                name: Install Python packages
 | 
				
			||||||
 | 
					                command: pip install -r requirements/test.txt
 | 
				
			||||||
 | 
					            - run:
 | 
				
			||||||
 | 
					                name: Run tests
 | 
				
			||||||
 | 
					                command: tox -e 'py36-dj{111,20,21}'
 | 
				
			||||||
 | 
					                environment:
 | 
				
			||||||
 | 
					                    DATABASE_URL: 'postgres://localizedfields:localizedfields@localhost:5432/localizedfields'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    test-python37:
 | 
				
			||||||
 | 
					        docker:
 | 
				
			||||||
 | 
					            - image: python:3.7-alpine
 | 
				
			||||||
 | 
					            - image: postgres:11.0
 | 
				
			||||||
 | 
					              environment:
 | 
				
			||||||
 | 
					                  POSTGRES_DB: 'localizedfields'
 | 
				
			||||||
 | 
					                  POSTGRES_USER: 'localizedfields'
 | 
				
			||||||
 | 
					                  POSTGRES_PASSWORD: 'localizedfields'
 | 
				
			||||||
 | 
					        steps:
 | 
				
			||||||
 | 
					            - checkout
 | 
				
			||||||
 | 
					            - run:
 | 
				
			||||||
 | 
					                name: Install packages
 | 
				
			||||||
 | 
					                command: apk add postgresql-libs gcc musl-dev postgresql-dev git
 | 
				
			||||||
 | 
					            - run:
 | 
				
			||||||
 | 
					                name: Install Python packages
 | 
				
			||||||
 | 
					                command: pip install -r requirements/test.txt
 | 
				
			||||||
 | 
					            - run:
 | 
				
			||||||
 | 
					                name: Run tests
 | 
				
			||||||
 | 
					                command: tox -e 'py37-dj{111,20,21}'
 | 
				
			||||||
 | 
					                environment:
 | 
				
			||||||
 | 
					                    DATABASE_URL: 'postgres://localizedfields:localizedfields@localhost:5432/localizedfields'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    lint:
 | 
				
			||||||
 | 
					        docker:
 | 
				
			||||||
 | 
					            - image: python:3.5-alpine
 | 
				
			||||||
 | 
					        steps:
 | 
				
			||||||
 | 
					            - checkout
 | 
				
			||||||
 | 
					            - run:
 | 
				
			||||||
 | 
					                name: Install packages
 | 
				
			||||||
 | 
					                command: apk add postgresql-libs gcc musl-dev postgresql-dev git
 | 
				
			||||||
 | 
					            - run:
 | 
				
			||||||
 | 
					                name: Install Python packages
 | 
				
			||||||
 | 
					                command: pip install -r requirements/test.txt
 | 
				
			||||||
 | 
					            - run:
 | 
				
			||||||
 | 
					                name: Lint code
 | 
				
			||||||
 | 
					                command: python setup.py lint
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					workflows:
 | 
				
			||||||
 | 
					    version: 2
 | 
				
			||||||
 | 
					    build:
 | 
				
			||||||
 | 
					        jobs:
 | 
				
			||||||
 | 
					            - test-python35
 | 
				
			||||||
 | 
					            - test-python36
 | 
				
			||||||
 | 
					            - test-python37
 | 
				
			||||||
 | 
					            - lint
 | 
				
			||||||
@@ -1,5 +1,3 @@
 | 
				
			|||||||
[run]
 | 
					[run]
 | 
				
			||||||
include = localized_fields/*
 | 
					include = localized_fields/*
 | 
				
			||||||
omit = *migrations*, *tests*
 | 
					omit = *migrations*, *tests*
 | 
				
			||||||
plugins =
 | 
					 | 
				
			||||||
    django_coverage_plugin
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,5 +1,6 @@
 | 
				
			|||||||
# Ignore virtual environments
 | 
					# Ignore virtual environments
 | 
				
			||||||
env/
 | 
					env/
 | 
				
			||||||
 | 
					.env/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Ignore Python byte code cache
 | 
					# Ignore Python byte code cache
 | 
				
			||||||
*.pyc
 | 
					*.pyc
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,34 +0,0 @@
 | 
				
			|||||||
checks:
 | 
					 | 
				
			||||||
    python:
 | 
					 | 
				
			||||||
        code_rating: true
 | 
					 | 
				
			||||||
        duplicate_code: true
 | 
					 | 
				
			||||||
tools:
 | 
					 | 
				
			||||||
    pylint:
 | 
					 | 
				
			||||||
        python_version: '3'
 | 
					 | 
				
			||||||
        config_file: .pylintrc
 | 
					 | 
				
			||||||
filter:
 | 
					 | 
				
			||||||
    excluded_paths:
 | 
					 | 
				
			||||||
        - '*/tests/*'
 | 
					 | 
				
			||||||
        - '*/migrations/*'
 | 
					 | 
				
			||||||
build:
 | 
					 | 
				
			||||||
    environment:
 | 
					 | 
				
			||||||
        python: '3.5.0'
 | 
					 | 
				
			||||||
        variables:
 | 
					 | 
				
			||||||
            DJANGO_SETTINGS_MODULES: settings
 | 
					 | 
				
			||||||
            DATABASE_URL: postgres://scrutinizer:scrutinizer@localhost:5434/localized_fields
 | 
					 | 
				
			||||||
        postgresql: true
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    dependencies:
 | 
					 | 
				
			||||||
        override:
 | 
					 | 
				
			||||||
            - 'pip install -r requirements/test.txt'
 | 
					 | 
				
			||||||
    tests:
 | 
					 | 
				
			||||||
        override:
 | 
					 | 
				
			||||||
            -
 | 
					 | 
				
			||||||
                command: pep8 ./localized_fields/
 | 
					 | 
				
			||||||
            -
 | 
					 | 
				
			||||||
                command: flake8 ./localized_fields/
 | 
					 | 
				
			||||||
            -
 | 
					 | 
				
			||||||
                command: tox
 | 
					 | 
				
			||||||
                coverage:
 | 
					 | 
				
			||||||
                    file: '.coverage'
 | 
					 | 
				
			||||||
                    format: 'py-cc'
 | 
					 | 
				
			||||||
@@ -1,11 +1,8 @@
 | 
				
			|||||||
django-localized-fields
 | 
					django-localized-fields
 | 
				
			||||||
=======================
 | 
					=======================
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.. image:: https://scrutinizer-ci.com/g/SectorLabs/django-localized-fields/badges/quality-score.png
 | 
					.. image:: https://circleci.com/gh/SectorLabs/django-localized-fields.svg?style=svg
 | 
				
			||||||
    :target: https://scrutinizer-ci.com/g/SectorLabs/django-localized-fields/
 | 
					    :target: https://circleci.com/gh/SectorLabs/django-localized-fields
 | 
				
			||||||
 | 
					 | 
				
			||||||
.. image:: https://scrutinizer-ci.com/g/SectorLabs/django-localized-fields/badges/coverage.png
 | 
					 | 
				
			||||||
    :target: https://scrutinizer-ci.com/g/SectorLabs/django-localized-fields/
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
.. image:: https://img.shields.io/github/license/SectorLabs/django-localized-fields.svg
 | 
					.. image:: https://img.shields.io/github/license/SectorLabs/django-localized-fields.svg
 | 
				
			||||||
    :target: https://github.com/SectorLabs/django-localized-fields/blob/master/LICENSE.md
 | 
					    :target: https://github.com/SectorLabs/django-localized-fields/blob/master/LICENSE.md
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,6 +5,7 @@ from django.db.utils import IntegrityError
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
from .field import LocalizedField
 | 
					from .field import LocalizedField
 | 
				
			||||||
from ..value import LocalizedValue, LocalizedIntegerValue
 | 
					from ..value import LocalizedValue, LocalizedIntegerValue
 | 
				
			||||||
 | 
					from ..forms import LocalizedIntegerFieldForm
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class LocalizedIntegerField(LocalizedField):
 | 
					class LocalizedIntegerField(LocalizedField):
 | 
				
			||||||
@@ -63,6 +64,15 @@ class LocalizedIntegerField(LocalizedField):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        return prepped_value
 | 
					        return prepped_value
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def formfield(self, **kwargs):
 | 
				
			||||||
 | 
					        """Gets the form field associated with this field."""
 | 
				
			||||||
 | 
					        defaults = {
 | 
				
			||||||
 | 
					            'form_class': LocalizedIntegerFieldForm
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        defaults.update(kwargs)
 | 
				
			||||||
 | 
					        return super().formfield(**defaults)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @staticmethod
 | 
					    @staticmethod
 | 
				
			||||||
    def _convert_localized_value(value: LocalizedValue) -> LocalizedIntegerValue:
 | 
					    def _convert_localized_value(value: LocalizedValue) -> LocalizedIntegerValue:
 | 
				
			||||||
        """Converts from :see:LocalizedValue to :see:LocalizedIntegerValue."""
 | 
					        """Converts from :see:LocalizedValue to :see:LocalizedIntegerValue."""
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,9 +6,9 @@ from django.core.exceptions import ValidationError
 | 
				
			|||||||
from django.forms.widgets import FILE_INPUT_CONTRADICTION
 | 
					from django.forms.widgets import FILE_INPUT_CONTRADICTION
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .value import LocalizedValue, LocalizedStringValue, \
 | 
					from .value import LocalizedValue, LocalizedStringValue, \
 | 
				
			||||||
    LocalizedFileValue
 | 
					    LocalizedFileValue, LocalizedIntegerValue
 | 
				
			||||||
from .widgets import LocalizedFieldWidget, LocalizedCharFieldWidget, \
 | 
					from .widgets import LocalizedFieldWidget, LocalizedCharFieldWidget, \
 | 
				
			||||||
    LocalizedFileWidget
 | 
					    LocalizedFileWidget, AdminLocalizedIntegerFieldWidget
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class LocalizedFieldForm(forms.MultiValueField):
 | 
					class LocalizedFieldForm(forms.MultiValueField):
 | 
				
			||||||
@@ -79,6 +79,14 @@ class LocalizedTextFieldForm(LocalizedFieldForm):
 | 
				
			|||||||
    value_class = LocalizedStringValue
 | 
					    value_class = LocalizedStringValue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class LocalizedIntegerFieldForm(LocalizedFieldForm):
 | 
				
			||||||
 | 
					    """Form for a localized integer field, allows editing
 | 
				
			||||||
 | 
					    the field in multiple languages."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    widget = AdminLocalizedIntegerFieldWidget
 | 
				
			||||||
 | 
					    value_class = LocalizedIntegerValue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class LocalizedFileFieldForm(LocalizedFieldForm, forms.FileField):
 | 
					class LocalizedFileFieldForm(LocalizedFieldForm, forms.FileField):
 | 
				
			||||||
    """Form for a localized file field, allows editing
 | 
					    """Form for a localized file field, allows editing
 | 
				
			||||||
    the field in multiple languages."""
 | 
					    the field in multiple languages."""
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -228,3 +228,9 @@ class LocalizedIntegerValue(LocalizedValue):
 | 
				
			|||||||
            return self.default_value
 | 
					            return self.default_value
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return int(value)
 | 
					        return int(value)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def __str__(self) -> str:
 | 
				
			||||||
 | 
					        """Returns string representation of value"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        value = self.translate()
 | 
				
			||||||
 | 
					        return str(value) if value is not None else None
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -120,3 +120,7 @@ class AdminLocalizedCharFieldWidget(AdminLocalizedFieldWidget):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class AdminLocalizedFileFieldWidget(AdminLocalizedFieldWidget):
 | 
					class AdminLocalizedFileFieldWidget(AdminLocalizedFieldWidget):
 | 
				
			||||||
    widget = widgets.AdminFileWidget
 | 
					    widget = widgets.AdminFileWidget
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class AdminLocalizedIntegerFieldWidget(AdminLocalizedFieldWidget):
 | 
				
			||||||
 | 
					    widget = widgets.AdminIntegerFieldWidget
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,15 +2,13 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
django-autoslug==1.9.3
 | 
					django-autoslug==1.9.3
 | 
				
			||||||
django-bleach==0.3.0
 | 
					django-bleach==0.3.0
 | 
				
			||||||
django-coverage-plugin==1.3.1
 | 
					 | 
				
			||||||
psycopg2==2.7.3.2
 | 
					psycopg2==2.7.3.2
 | 
				
			||||||
pylint==1.8.1
 | 
					pylint==1.8.1
 | 
				
			||||||
pylint-common==0.2.5
 | 
					pylint-common==0.2.5
 | 
				
			||||||
pylint-django==0.8.0
 | 
					pylint-django==0.8.0
 | 
				
			||||||
pylint-plugin-utils==0.2.6
 | 
					pylint-plugin-utils==0.2.6
 | 
				
			||||||
coverage==4.4.2
 | 
					coverage==4.4.2
 | 
				
			||||||
django-coverage-plugin==1.3.1
 | 
					flake8==3.6.0
 | 
				
			||||||
flake8==3.5.0
 | 
					 | 
				
			||||||
pep8==1.7.1
 | 
					pep8==1.7.1
 | 
				
			||||||
dj-database-url==0.4.2
 | 
					dj-database-url==0.4.2
 | 
				
			||||||
tox==2.9.1
 | 
					tox==2.9.1
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
[flake8]
 | 
					[flake8]
 | 
				
			||||||
max-line-length = 120
 | 
					max-line-length = 120
 | 
				
			||||||
 | 
					ignore = E252, W605
 | 
				
			||||||
exclude = env,.tox,.git,config/settings,*/migrations/*,*/static/CACHE/*,docs,node_modules
 | 
					exclude = env,.tox,.git,config/settings,*/migrations/*,*/static/CACHE/*,docs,node_modules
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[pep8]
 | 
					[pep8]
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										38
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								setup.py
									
									
									
									
									
								
							@@ -1,13 +1,39 @@
 | 
				
			|||||||
import os
 | 
					import os
 | 
				
			||||||
 | 
					import distutils.cmd
 | 
				
			||||||
 | 
					import subprocess
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from setuptools import find_packages, setup
 | 
					from setuptools import find_packages, setup
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class BaseCommand(distutils.cmd.Command):
 | 
				
			||||||
 | 
					    user_options = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def initialize_options(self):
 | 
				
			||||||
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def finalize_options(self):
 | 
				
			||||||
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def create_command(text, commands):
 | 
				
			||||||
 | 
					    """Creates a custom setup.py command."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    class CustomCommand(BaseCommand):
 | 
				
			||||||
 | 
					        description = text
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        def run(self):
 | 
				
			||||||
 | 
					            for cmd in commands:
 | 
				
			||||||
 | 
					                subprocess.check_call(cmd)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return CustomCommand
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
with open(os.path.join(os.path.dirname(__file__), 'README.rst'), encoding='utf-8') as readme:
 | 
					with open(os.path.join(os.path.dirname(__file__), 'README.rst'), encoding='utf-8') as readme:
 | 
				
			||||||
    README = readme.read()
 | 
					    README = readme.read()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
setup(
 | 
					setup(
 | 
				
			||||||
    name='django-localized-fields',
 | 
					    name='django-localized-fields',
 | 
				
			||||||
    version='5.0a3',
 | 
					    version='5.0a5',
 | 
				
			||||||
    packages=find_packages(exclude=['tests']),
 | 
					    packages=find_packages(exclude=['tests']),
 | 
				
			||||||
    include_package_data=True,
 | 
					    include_package_data=True,
 | 
				
			||||||
    license='MIT License',
 | 
					    license='MIT License',
 | 
				
			||||||
@@ -18,7 +44,7 @@ setup(
 | 
				
			|||||||
    author_email='open-source@sectorlabs.ro',
 | 
					    author_email='open-source@sectorlabs.ro',
 | 
				
			||||||
    keywords=['django', 'localized', 'language', 'models', 'fields'],
 | 
					    keywords=['django', 'localized', 'language', 'models', 'fields'],
 | 
				
			||||||
    install_requires=[
 | 
					    install_requires=[
 | 
				
			||||||
        'django-postgres-extra>=1.21a11',
 | 
					        'django-postgres-extra>=1.21a14',
 | 
				
			||||||
        'Django>=1.11',
 | 
					        'Django>=1.11',
 | 
				
			||||||
        'deprecation==2.0.3'
 | 
					        'deprecation==2.0.3'
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
@@ -32,5 +58,11 @@ setup(
 | 
				
			|||||||
        'Programming Language :: Python :: 3.5',
 | 
					        'Programming Language :: Python :: 3.5',
 | 
				
			||||||
        'Topic :: Internet :: WWW/HTTP',
 | 
					        'Topic :: Internet :: WWW/HTTP',
 | 
				
			||||||
        'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
 | 
					        'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
 | 
				
			||||||
    ]
 | 
					    ],
 | 
				
			||||||
 | 
					    cmdclass={
 | 
				
			||||||
 | 
					        'lint': create_command(
 | 
				
			||||||
 | 
					            'Lints the code',
 | 
				
			||||||
 | 
					            [['flake8', 'setup.py', 'localized_fields', 'tests']],
 | 
				
			||||||
 | 
					        ),
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,7 +33,6 @@ class LocalizedFieldTestCase(TestCase):
 | 
				
			|||||||
        field = LocalizedField(required=False)
 | 
					        field = LocalizedField(required=False)
 | 
				
			||||||
        assert field.required == []
 | 
					        assert field.required == []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    @staticmethod
 | 
					    @staticmethod
 | 
				
			||||||
    def test_from_db_value():
 | 
					    def test_from_db_value():
 | 
				
			||||||
        """Tests whether the :see:from_db_value function
 | 
					        """Tests whether the :see:from_db_value function
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -40,7 +40,6 @@ class LocalizedFieldFormTestCase(TestCase):
 | 
				
			|||||||
        for field in form.fields:
 | 
					        for field in form.fields:
 | 
				
			||||||
            assert not field.required
 | 
					            assert not field.required
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    @staticmethod
 | 
					    @staticmethod
 | 
				
			||||||
    def test_compress():
 | 
					    def test_compress():
 | 
				
			||||||
        """Tests whether the :see:compress function
 | 
					        """Tests whether the :see:compress function
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -148,7 +148,7 @@ class LocalizedIntegerFieldTestCase(TestCase):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        with connection.cursor() as cursor:
 | 
					        with connection.cursor() as cursor:
 | 
				
			||||||
            table_name = self.TestModel._meta.db_table
 | 
					            table_name = self.TestModel._meta.db_table
 | 
				
			||||||
            cursor.execute("update %s set score = 'en=>haha'" % table_name);
 | 
					            cursor.execute("update %s set score = 'en=>haha'" % table_name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        obj.refresh_from_db()
 | 
					        obj.refresh_from_db()
 | 
				
			||||||
        assert obj.score.get(settings.LANGUAGE_CODE) is None
 | 
					        assert obj.score.get(settings.LANGUAGE_CODE) is None
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,4 @@
 | 
				
			|||||||
from django.conf import settings
 | 
					 | 
				
			||||||
from django.test import TestCase
 | 
					from django.test import TestCase
 | 
				
			||||||
from django.utils import translation
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
from localized_fields.fields import LocalizedField
 | 
					from localized_fields.fields import LocalizedField
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -152,7 +152,7 @@ class LocalizedValueTestCase(TestCase):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        # with no value, we always expect it to return None
 | 
					        # with no value, we always expect it to return None
 | 
				
			||||||
        localized_value = LocalizedValue()
 | 
					        localized_value = LocalizedValue()
 | 
				
			||||||
        assert localized_value.translate() == None
 | 
					        assert localized_value.translate() is None
 | 
				
			||||||
        assert str(localized_value) == ''
 | 
					        assert str(localized_value) == ''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # with no value for the default language, the default
 | 
					        # with no value for the default language, the default
 | 
				
			||||||
@@ -164,7 +164,7 @@ class LocalizedValueTestCase(TestCase):
 | 
				
			|||||||
        })
 | 
					        })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        translation.activate(settings.LANGUAGE_CODE)
 | 
					        translation.activate(settings.LANGUAGE_CODE)
 | 
				
			||||||
        assert localized_value.translate() == None
 | 
					        assert localized_value.translate() is None
 | 
				
			||||||
        assert str(localized_value) == ''
 | 
					        assert str(localized_value) == ''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @staticmethod
 | 
					    @staticmethod
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										3
									
								
								tox.ini
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								tox.ini
									
									
									
									
									
								
							@@ -1,10 +1,11 @@
 | 
				
			|||||||
[tox]
 | 
					[tox]
 | 
				
			||||||
envlist = py35-dj{111,20}
 | 
					envlist = py35-dj{111,20,21}, py36-dj{111,20,21}, py37-dj{111,20,21}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[testenv]
 | 
					[testenv]
 | 
				
			||||||
deps =
 | 
					deps =
 | 
				
			||||||
    dj111: Django>=1.11,<1.12
 | 
					    dj111: Django>=1.11,<1.12
 | 
				
			||||||
    dj20: Django>=2.0,<2.1
 | 
					    dj20: Django>=2.0,<2.1
 | 
				
			||||||
 | 
					    dj21: Django>=2.1,<2.2
 | 
				
			||||||
    -rrequirements/test.txt
 | 
					    -rrequirements/test.txt
 | 
				
			||||||
setenv =
 | 
					setenv =
 | 
				
			||||||
    DJANGO_SETTINGS_MODULE=settings
 | 
					    DJANGO_SETTINGS_MODULE=settings
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user