Skip to content

Commit

Permalink
Merge pull request #29 from panosl/develop
Browse files Browse the repository at this point in the history
Merging 0.4beta
  • Loading branch information
panosl committed May 17, 2016
2 parents d4fe020 + b09d368 commit f12a357
Show file tree
Hide file tree
Showing 46 changed files with 1,175 additions and 497 deletions.
57 changes: 57 additions & 0 deletions .gitignore
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/
5 changes: 5 additions & 0 deletions .landscape.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ignore-paths:
- south_migrations
- migrations
- example

32 changes: 32 additions & 0 deletions .travis.yml
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
24 changes: 0 additions & 24 deletions INSTALL.txt

This file was deleted.

1 change: 1 addition & 0 deletions LICENSE.txt → LICENSE
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
Expand Down
9 changes: 3 additions & 6 deletions MANIFEST.in
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
79 changes: 0 additions & 79 deletions README.md

This file was deleted.

144 changes: 144 additions & 0 deletions README.rst
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.
4 changes: 3 additions & 1 deletion currencies/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
from django.contrib import admin
from currencies.models import Currency

from .models import Currency


class CurrencyAdmin(admin.ModelAdmin):
Expand Down
6 changes: 6 additions & 0 deletions currencies/conf.py
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
Loading

0 comments on commit f12a357

Please sign in to comment.