Skip to content

Commit

Permalink
Release version 1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
spectras committed Feb 8, 2017
1 parent 017c311 commit 47ff1a2
Show file tree
Hide file tree
Showing 21 changed files with 135 additions and 350 deletions.
20 changes: 10 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ python:
env:
- DJANGO=django==1.7.11 DRF=3.3.1 DATABASE_URL=mysql://root@localhost/test
- DJANGO=django==1.7.11 DRF=3.3.1 DATABASE_URL=postgres://postgres@localhost/test
- DJANGO=django==1.8.14 DRF=3.3.1 DATABASE_URL=mysql://root@localhost/test
- DJANGO=django==1.8.14 DRF=3.3.1 DATABASE_URL=postgres://postgres@localhost/test
- DJANGO=django==1.9.9 DRF=3.3.1 DATABASE_URL=mysql://root@localhost/test
- DJANGO=django==1.9.9 DRF=3.3.1 DATABASE_URL=postgres://postgres@localhost/test
- DJANGO=django==1.10.1 DRF=3.3.3 DATABASE_URL=mysql://root@localhost/test
- DJANGO=django==1.10.1 DRF=3.3.3 DATABASE_URL=postgres://postgres@localhost/test
- DJANGO=django==1.8.17 DRF=3.3.1 DATABASE_URL=mysql://root@localhost/test
- DJANGO=django==1.8.17 DRF=3.3.1 DATABASE_URL=postgres://postgres@localhost/test
- DJANGO=django==1.9.12 DRF=3.3.1 DATABASE_URL=mysql://root@localhost/test
- DJANGO=django==1.9.12 DRF=3.3.1 DATABASE_URL=postgres://postgres@localhost/test
- DJANGO=django==1.10.5 DRF=3.5.3 DATABASE_URL=mysql://root@localhost/test
- DJANGO=django==1.10.5 DRF=3.5.3 DATABASE_URL=postgres://postgres@localhost/test

sudo: false
install:
Expand All @@ -30,13 +30,13 @@ after_success:
matrix:
exclude:
- python: 3.3
env: DJANGO=django==1.9.9 DRF=3.3.1 DATABASE_URL=mysql://root@localhost/test
env: DJANGO=django==1.9.12 DRF=3.3.1 DATABASE_URL=mysql://root@localhost/test
- python: 3.3
env: DJANGO=django==1.9.9 DRF=3.3.1 DATABASE_URL=postgres://postgres@localhost/test
env: DJANGO=django==1.9.12 DRF=3.3.1 DATABASE_URL=postgres://postgres@localhost/test
- python: 3.3
env: DJANGO=django==1.10.1 DRF=3.3.3 DATABASE_URL=mysql://root@localhost/test
env: DJANGO=django==1.10.5 DRF=3.5.3 DATABASE_URL=mysql://root@localhost/test
- python: 3.3
env: DJANGO=django==1.10.1 DRF=3.3.3 DATABASE_URL=postgres://postgres@localhost/test
env: DJANGO=django==1.10.5 DRF=3.5.3 DATABASE_URL=postgres://postgres@localhost/test
- python: 3.5
env: DJANGO=django==1.7.11 DRF=3.3.1 DATABASE_URL=mysql://root@localhost/test
- python: 3.5
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ to continue the development.

.. |package| image:: https://badge.fury.io/py/django-hvad.svg
:target: https://pypi.python.org/pypi/django-hvad
.. |build| image:: https://secure.travis-ci.org/KristianOellegaard/django-hvad.png?branch=master
.. |coverage| image:: https://coveralls.io/repos/KristianOellegaard/django-hvad/badge.png
.. |build| image:: https://secure.travis-ci.org/KristianOellegaard/django-hvad.svg?branch=master
.. |coverage| image:: https://coveralls.io/repos/KristianOellegaard/django-hvad/badge.svg
:target: https://coveralls.io/r/KristianOellegaard/django-hvad

.. _documentation: http://django-hvad.readthedocs.org/
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
project = u'django-hvad'
copyright = u'2011-2015, Kristian Øllegaard, Jonas Obrist & contributors'

version = '1.6'
release = '1.6.0'
version = '1.7'
release = '1.7.0'


# The name of the Pygments (syntax highlighting) style to use.
Expand Down
4 changes: 2 additions & 2 deletions docs/public/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ descriptions and information about who wrote the description::
author = models.CharField(max_length=255)
translations = TranslatedFields(
description = models.TextField(),
description_author = models.CharField(max_length=255),
description=models.TextField(),
description_author=models.CharField(max_length=255),
)
def __unicode__(self):
Expand Down
6 changes: 4 additions & 2 deletions docs/public/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ Release Notes
#############

*****************************
1.7.0 - upcoming release
1.7.0 - current release
*****************************

Released on February 8, 2017

New features:

- Support for :meth:`~django.db.models.query.QuerySet.defer` and
Expand Down Expand Up @@ -34,7 +36,7 @@ Fixes:
change forms. — :issue:`317`.

*****************************
1.6.0 - current release
1.6.0
*****************************

Released on September 6, 2016
Expand Down
4 changes: 2 additions & 2 deletions hvad/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = '1.6.0'
VERSION = (1, 6, 0)
__version__ = '1.7.0'
VERSION = (1, 7, 0)
12 changes: 2 additions & 10 deletions hvad/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,13 @@
import warnings
from django.conf import settings
from django.contrib.admin.options import ModelAdmin, csrf_protect_m, InlineModelAdmin
if django.VERSION >= (1, 7):
from django.contrib.admin.utils import (flatten_fieldsets, unquote,
get_deleted_objects)
else: #pragma: no cover
from django.contrib.admin.util import (flatten_fieldsets, unquote,
get_deleted_objects)
from django.contrib.admin.utils import flatten_fieldsets, unquote, get_deleted_objects
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import PermissionDenied, ValidationError
from django.core.urlresolvers import reverse
from django.db import router, transaction
from django.forms.models import model_to_dict
if django.VERSION >= (1, 7):
from django.forms.utils import ErrorList
else: #pragma: no cover
from django.forms.util import ErrorList
from django.forms.utils import ErrorList
from django.http import Http404, HttpResponseRedirect, QueryDict
from django.shortcuts import render
from django.template import TemplateDoesNotExist
Expand Down
17 changes: 6 additions & 11 deletions hvad/descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
from django.db.models.fields import FieldDoesNotExist
from django.utils.translation import get_language
from hvad.utils import get_translation, set_cached_translation, get_cached_translation
if django.VERSION >= (1, 7):
from django.apps import registry
from django.apps import registry

class BaseDescriptor(object):
"""
Expand Down Expand Up @@ -38,16 +37,12 @@ def __init__(self, opts, name):

def __get__(self, instance, instance_type=None):
if not instance:
if django.VERSION >= (1, 7) and not registry.apps.ready: #pragma: no cover
if not registry.apps.ready: #pragma: no cover
raise AttributeError('Attribute not available until registry is ready.')
# Don't raise an attribute error so we can use it in admin.
try:
if django.VERSION >= (1, 8):
return self.opts.translations_model._meta.get_field(self.name).default
else:
return self.opts.translations_model._meta.get_field_by_name(self.name)[0].default
except FieldDoesNotExist as e: #pragma: no cover (django 1.6 before models loaded)
raise AttributeError(*e.args)
if django.VERSION >= (1, 8):
return self.opts.translations_model._meta.get_field(self.name).default
else:
return self.opts.translations_model._meta.get_field_by_name(self.name)[0].default
return getattr(self.translation(instance), self.name)

def __set__(self, instance, value):
Expand Down
18 changes: 4 additions & 14 deletions hvad/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
from django.forms.models import (ModelForm, BaseModelForm, ModelFormMetaclass,
fields_for_model, model_to_dict, construct_instance, BaseInlineFormSet, BaseModelFormSet,
modelform_factory, inlineformset_factory, ALL_FIELDS)
if django.VERSION >= (1, 7):
from django.forms.utils import ErrorList
else: #pragma: no cover
from django.forms.util import ErrorList
from django.forms.utils import ErrorList
from django.forms.widgets import Select
from django.utils.translation import get_language, ugettext as _
from hvad.compat import with_metaclass
Expand Down Expand Up @@ -203,16 +200,9 @@ def save(self, commit=True):
return super(BaseTranslatableModelForm, self).save(commit=commit)


if django.VERSION >= (1, 7):
class TranslatableModelForm(with_metaclass(TranslatableModelFormMetaclass,
BaseTranslatableModelForm)):
pass
else: #pragma: no cover
# Older django version have buggy metaclass
class TranslatableModelForm(with_metaclass(TranslatableModelFormMetaclass,
BaseTranslatableModelForm, ModelForm)):
__metaclass__ = TranslatableModelFormMetaclass # Django 1.4 compatibility

class TranslatableModelForm(with_metaclass(TranslatableModelFormMetaclass,
BaseTranslatableModelForm)):
pass

#=============================================================================

Expand Down
48 changes: 15 additions & 33 deletions hvad/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,7 @@ def _add_language_filter(self):
))
else:
masteratt = self.model._meta.get_field('master').attname
nullable = ({'nullable': True} if django.VERSION >= (1, 7) else
{'nullable': True, 'outer_if_first': True})
nullable = {'nullable': True}
alias = self.query.join((self.query.get_initial_alias(), self.model._meta.db_table,
((masteratt, masteratt),)),
join_field=BetterTranslationsField(languages, master=masteratt),
Expand All @@ -441,15 +440,7 @@ def _add_language_filter(self):

else:
language_code = self._language_code or get_language()
for _, field_name in where_node_children(self.query.where):
if field_name == 'language_code':
# remove in 1.4
raise RuntimeError(
'Overriding language_code in get() or filter() is no longer supported. '
'Please set the language in Model.objects.language() instead, '
'or use language("all") to do manual filtering on languages.')
else:
self.query.add_filter(('language_code', language_code))
self.query.add_filter(('language_code', language_code))
self._add_select_related(language_code)

# if queryset is about to use the model's default ordering, we
Expand Down Expand Up @@ -572,13 +563,12 @@ def iterator(self):
yield obj

def create(self, **kwargs):
if 'language_code' in kwargs:
if self._language_code is not None:
# remove in 1.4
raise RuntimeError('Overriding language_code in create() is no longer allowed. '
'Please set the language with language() instead.')
else:
if 'language_code' not in kwargs:
kwargs['language_code'] = self._language_code or get_language()
elif self._language_code is not None:
raise ValueError('Overriding language_code in create() is not allowed. '
'Please set the language with language() instead.')

if kwargs['language_code'] == 'all':
raise ValueError('Cannot create an object with language \'all\'')
obj = self.shared_model(**kwargs)
Expand Down Expand Up @@ -622,13 +612,12 @@ def get_or_create(self, **kwargs):
params = dict([(k, v) for k, v in kwargs.items() if '__' not in k])
params.update(defaults)

if 'language_code' in params:
if self._language_code is not None:
# remove in 1.4
raise RuntimeError('Overriding language_code in get_or_create() is no longer allowed. '
'Please set the language in Model.objects.language() instead.')
else:
if 'language_code' not in params:
params['language_code'] = self._language_code or get_language()
elif self._language_code is not None:
raise ValueError('Overriding language_code in get_or_create() is not allowed. '
'Please set the language with language() instead.')

if params['language_code'] == 'all':
raise ValueError('Cannot create an object with language \'all\'')

Expand All @@ -644,7 +633,6 @@ def get_or_create(self, **kwargs):
except self.model.DoesNotExist:
raise exc_info[1]

@minimumDjangoVersion(1, 7)
def update_or_create(self, defaults=None, **kwargs):
raise NotImplementedError()

Expand Down Expand Up @@ -758,10 +746,8 @@ def select_related(self, *fields):
'you must provide a list of fields.')
if fields == (None,):
self._raw_select_related = []
elif django.VERSION >= (1, 7): # in newer versions, calls are cumulative
else:
self._raw_select_related.extend(fields)
else: #pragma: no cover # in older versions, they overwrite each other
self._raw_select_related = list(fields)
return self

def complex_filter(self, filter_obj):
Expand Down Expand Up @@ -985,8 +971,7 @@ def iterator(self):
True
))
else:
nullable = ({'nullable': True} if django.VERSION >= (1, 7) else
{'nullable': True, 'outer_if_first': True})
nullable = {'nullable': True}
alias1 = qs.query.join((qs.query.get_initial_alias(), tmodel._meta.db_table,
((qs.model._meta.pk.attname, masteratt),)),
join_field=getattr(qs.model, taccessor).related.field.rel,
Expand Down Expand Up @@ -1053,10 +1038,7 @@ def _make_queryset(self, klass, core_filters):
core_filters tells whether the queryset will bypass RelatedManager
mechanics and therefore needs to reapply the filters on its own.
'''
if django.VERSION >= (1, 7):
qs = klass(self.model, using=self.db, hints=self._hints)
else:
qs = klass(self.model, using=self.db) #pragma: no cover
qs = klass(self.model, using=self.db, hints=self._hints)
core_filters = getattr(self, 'core_filters', None) if core_filters else None
if core_filters:
qs = qs._next_is_sticky().filter(**core_filters)
Expand Down
Loading

0 comments on commit 47ff1a2

Please sign in to comment.