Skip to content

Commit

Permalink
Update py-moneyed compatibility (#290)
Browse files Browse the repository at this point in the history
* Update py-moneyed compatibility

* Fix Python 2.6 builds

* Fix for new py-moneyed behaviour.
  • Loading branch information
Stranger6667 committed May 10, 2017
1 parent 05fdb46 commit 7f492b8
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 11 deletions.
11 changes: 8 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,20 @@ env:
- TOX_ENV=django16-py33
- TOX_ENV=django16-py32
- TOX_ENV=django16-py27
- TOX_ENV=django16-py26
- TOX_ENV=django16-pypy
- TOX_ENV=django15-py27
- TOX_ENV=django15-py33
- TOX_ENV=django15-py32
- TOX_ENV=django15-py26
- TOX_ENV=django15-pypy
- TOX_ENV=django14-py27
- TOX_ENV=django14-py26
- TOX_ENV=django14-pypy
matrix:
include:
- python: "2.6"
env: TOX_ENV=django16-py26
- python: "2.6"
env: TOX_ENV=django15-py26
- python: "2.6"
env: TOX_ENV=django14-py26
after_success:
- codecov
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Via ``py-moneyed``, ``django-money`` gets:
Installation
------------

Django-money currently needs ``py-moneyed`` v0.4 (or later) to work.
Django-money currently needs ``py-moneyed`` v0.7 (or later) to work.

You can obtain the source code for ``django-money`` from here:

Expand Down
7 changes: 4 additions & 3 deletions djmoney/models/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,12 @@ def __get_current_locale(self):
language = translation.get_language() or settings.LANGUAGE_CODE
locale = translation.to_locale(language)

if _FORMATTER.get_formatting_definition(locale):
if locale.upper() in _FORMATTER.formatting_definitions:
return locale

if _FORMATTER.get_formatting_definition('%s_%s' % (locale, locale)):
return '%s_%s' % (locale, locale)
locale = ('%s_%s' % (locale, locale)).upper()
if locale in _FORMATTER.formatting_definitions:
return locale

return ''

Expand Down
2 changes: 1 addition & 1 deletion djmoney/templatetags/djmoney.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class MoneyLocalizeNode(template.Node):

def __repr__(self):
return '<MoneyLocalizeNode %r>' % self.money
return '<MoneyLocalizeNode %d %s>' % (self.money.amount, self.money.currency)

def __init__(self, money=None, amount=None, currency=None, use_l10n=None, var_name=None):
if money and (amount or currency):
Expand Down
1 change: 1 addition & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Changes in 0.11.0dev
- Added ability to set custom currency choices via ``CURRENCY_CHOICES`` settings option. `#211`_ (`Stranger6667`_, `ChessSpider`_)
- Fixed non-Money values support for ``in`` lookup. `#278`_ (`Stranger6667`_)
- Fixed available lookups with removing of needless lookup check. `#277`_ (`Stranger6667`_)
- Fixed compatibility with ``py-moneyed``. (`Stranger6667`_)

Changes in 0.10.2
-----------------
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def run_tests(self):
],
install_requires=[
'setuptools',
'Django >= 1.4',
'py-moneyed > 0.4'
'Django>=1.4',
'py-moneyed>=0.7'
],
platforms=['Any'],
keywords=['django', 'py-money', 'money'],
Expand All @@ -72,6 +72,7 @@ def run_tests(self):
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Framework :: Django',
Expand Down
2 changes: 1 addition & 1 deletion tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_args(value):


@pytest.mark.parametrize('value, kwargs, expected', (
(Money(10, 'RUB'), {}, 'руб.10.00'), # Issue 232
(Money(10, 'RUB'), {}, '10.00 руб.'), # Issue 232
(Money(1234), {'USE_L10N': True, 'USE_THOUSAND_SEPARATOR': True}, '1,234.00 XYZ'), # Issue 220
(Money(1000, 'SAR'), {'USE_I18N': True, 'LANGUAGE_CODE': 'en-us'}, 'ر.س1,000.00'), # Issue 196
(Money(1000, 'PLN'), {}, '1,000.00 zł'), # Issue 102
Expand Down

0 comments on commit 7f492b8

Please sign in to comment.