-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from panosl/develop
Merging 0.4beta
- Loading branch information
Showing
46 changed files
with
1,175 additions
and
497 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*,cover | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ignore-paths: | ||
- south_migrations | ||
- migrations | ||
- example | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
language: python | ||
python: | ||
- "3.4" | ||
- "3.3" | ||
- "2.7" | ||
- "2.6" | ||
- "pypy" | ||
- "pypy3" | ||
env: | ||
- DJANGO_VERSION=1.4.2 | ||
- DJANGO_VERSION=1.5 | ||
- DJANGO_VERSION=1.6 | ||
- DJANGO_VERSION=1.7 | ||
- DJANGO_VERSION=1.8 | ||
before_install: | ||
- pip install -q django==$DJANGO_VERSION | ||
install: | ||
- python setup.py develop | ||
script: | ||
- python setup.py test | ||
matrix: | ||
exclude: | ||
- python: "pypy3" | ||
env: DJANGO_VERSION=1.4.2 | ||
- python: "3.4" | ||
env: DJANGO_VERSION=1.4.2 | ||
- python: "3.3" | ||
env: DJANGO_VERSION=1.4.2 | ||
- python: "2.6" | ||
env: DJANGO_VERSION=1.7 | ||
- python: "2.6" | ||
env: DJANGO_VERSION=1.8 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
Copyright (c) 2009 Panos Laganakos <[email protected]> | ||
Copyright (c) 2012 Jerome Leclanche <[email protected]> | ||
Copyright (c) 2015 Basil Shubin <[email protected]> | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
include *.txt | ||
include MANIFEST.in | ||
include README.md | ||
recursive-include docs * | ||
include LICENSE | ||
include README.rst | ||
recursive-include currencies/locale * | ||
recursive-include currencies/fixtures * | ||
recursive-include currencies/management * | ||
recursive-include currencies/management *.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
django-currencies | ||
================= | ||
|
||
django-currencies allows you to define different currencies, and | ||
includes template tags/filters to allow easy conversion between them. | ||
|
||
For more details, see the `documentation <http://django-currencies.readthedocs.org/en/latest/>`_ at Read The Docs. | ||
|
||
Authored by `Panos Laganakos <http://panoslaganakos.com/>`_, and some great | ||
`contributors <https://github.com/panosl/django-currencies/contributors>`_. | ||
|
||
Installation | ||
------------ | ||
|
||
1. Either clone this repository into your project, or install with ``pip``: | ||
|
||
.. code-block:: shell | ||
pip install django-currencies | ||
2. You'll need to add ``currencies`` to ``INSTALLED_APPS`` in your project's settings file: | ||
|
||
.. code-block:: python | ||
import django | ||
INSTALLED_APPS += ( | ||
'currencies', | ||
) | ||
if django.VERSION < (1, 7): | ||
INSTALLED_APPS += ( | ||
'south', | ||
) | ||
3. Be sure you have the ``currencies.context_processors.currencies`` processor: | ||
|
||
.. code-block:: python | ||
TEMPLATE_CONTEXT_PROCESSORS += ( | ||
'django.core.context_processors.request', # must be enabled | ||
'currencies.context_processors.currencies', | ||
) | ||
4. Update your ``urls.py`` file : | ||
|
||
.. code-block:: python | ||
urlpatterns += patterns('', | ||
url(r'^currencies/', include('currencies.urls')), | ||
) | ||
Then run ``./manage.py syncdb`` to create the required database tables | ||
|
||
Please see ``example`` application. This application is used to | ||
manually test the functionalities of this package. This also serves as | ||
a good example. | ||
|
||
You need Django 1.4 or above to run that. It might run on older | ||
versions but that is not tested. | ||
|
||
Upgrading from 0.3.3 | ||
~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Upgrading from 0.3.3 is likely to cause problems trying to apply a | ||
migration when the tables already exist. In this case a fake migration | ||
needs to be applied: | ||
|
||
.. code-block:: shell | ||
./manage.py migrate currencies 0001 --fake | ||
Configuration | ||
------------- | ||
|
||
django-currencies has built-in integration with | ||
`openexchangerates.org <http://openexchangerates.org/>`_. | ||
|
||
You will need to specify your API key in your settings file: | ||
|
||
.. code-block:: python | ||
OPENEXCHANGERATES_APP_ID = "c2b2efcb306e075d9c2f2d0b614119ea" | ||
You will then be able to use the management commands ``currencies`` | ||
and ``updatecurrencies``. The former will import any currencies that | ||
are defined on `openexchangerates.org <http://openexchangerates.org/>`_. | ||
You can selectively import currencies, for example bellow command will | ||
import USD and EUR currencies only: | ||
|
||
.. code-block:: shell | ||
./manage.py currencies --import=USD --import=EUR | ||
The ``updatecurrencies`` management command will update all your | ||
currencies against the rates returned by `openexchangerates.org <http://openexchangerates.org/>`_. | ||
Any missing currency will be left untouched. | ||
|
||
Usage | ||
----- | ||
|
||
First of all, load the ``currency`` in every template where you want to use it: | ||
|
||
.. code-block:: html+django | ||
|
||
{% load currency %} | ||
|
||
Use: | ||
|
||
.. code-block:: html+django | ||
|
||
{% change_currency [price] [currency_code] %} | ||
|
||
for example: | ||
|
||
.. code-block:: html+django | ||
|
||
{% change_currency product.price "USD" %} | ||
|
||
<!-- or if you have the ``currencies.context_processors.currencies`` available --> | ||
{% change_currency product.price CURRENCY.code %} | ||
|
||
or use the filter: | ||
|
||
.. code-block:: html+django | ||
|
||
{{ [price]|currency:[currency_code] }} | ||
|
||
for example: | ||
|
||
.. code-block:: html+django | ||
|
||
{{ product.price|currency:"USD" }} | ||
|
||
or set the ``CURRENCY_CODE`` context variable with a ``POST`` to the included view: | ||
|
||
.. code-block:: html+django | ||
|
||
{% url 'currencies_set_currency' [currency_code] %} | ||
|
||
License | ||
------- | ||
|
||
``django-currencies`` is released under the BSD license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from django.conf import settings | ||
|
||
SESSION_PREFIX = getattr(settings, 'CURRENCY_SESSION_PREFIX', 'session') | ||
SESSION_KEY = '%s:currency_code' % SESSION_PREFIX |
Oops, something went wrong.