Skip to content

Commit

Permalink
Bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
jieter committed May 18, 2017
1 parent ad900d0 commit ca62b51
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# django-modeltrans change log

## 0.0.4 (2017-05-19)
- Improve robustness of rewriting lookups in QuerySets

## 0.0.3 (2017-05-18)
- Add the `gin` index in the data migration.
- Added tests for the migration procedure.
2 changes: 1 addition & 1 deletion modeltrans/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
default_app_config = 'modeltrans.apps.RegistrationConfig'

__version__ = '0.0.3'
__version__ = '0.0.4'
6 changes: 3 additions & 3 deletions modeltrans/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ def add_i18n_annotation(self, field, annotation_name=None, fallback=True):
from the jsonb field to allow filtering and ordering.
Arguments:
fieldFieldDoesNotExist (str): the virtual field to create an annotation for.
field (TranslatedVirtualField): the virtual field to create an annotation for.
annotation_name (str): name of the annotation, if None (by default),
`<original_field>_<lang>_annotation` will be used.
fallback (bool): If `True`, `COALESCE` will be used to get the value
of the original field if the requested translation is not
available.
of the original field if the requested translation is not in the
`i18n` dict.
Returns:
the name of the annotation.
Expand Down
3 changes: 3 additions & 0 deletions tests/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class Attribute(models.Model):
slug = models.SlugField(verbose_name=_('slug'), unique=True)
name = models.CharField(_('name'), max_length=100, db_index=True)

def __str__(self):
return self.name_i18n


class Choice(models.Model):
attribute = models.ForeignKey(Attribute, on_delete=models.CASCADE)
Expand Down
8 changes: 3 additions & 5 deletions tests/test_querysets.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def test_filter_spanning_relation(self):

def test_filter_relations(self):
mass = Attribute.objects.create(slug='mass', name='Mean Mass')
length = Attribute.objects.create(slug='length', name='Lengh', name_nl='Lengte')
length = Attribute.objects.create(slug='length', name='Length', name_nl='Lengte')

dog = Blog.objects.create(title='Australian Kelpie Dog')
whale = Blog.objects.create(title='Blue Whale', title_nl='Blauwe vinvis')
Expand All @@ -136,10 +136,8 @@ def test_filter_relations(self):
BlogAttr.objects.create(object=whale, attribute=mass, value=181000)
BlogAttr.objects.create(object=whale, attribute=length, value=28)

# this raises:
# FieldDoesNotExist: Attribute has no field named 'blogattr__object_id'
# but should just pass fine.
Attribute.objects.filter(blogattr__object_id__in=Blog.objects.filter(title__contains='al'))
with override('nl'):
Attribute.objects.filter(blogattr__object_id__in=Blog.objects.filter(title__contains='al'))

@skip('Not yet implemented')
def test_filter_spanning_relation_from_non_translatable(self):
Expand Down

0 comments on commit ca62b51

Please sign in to comment.