Skip to content

Commit

Permalink
Limit CURRENCIES context variable to active currencies
Browse files Browse the repository at this point in the history
  • Loading branch information
strycore committed Jan 20, 2015
1 parent a83fb4d commit 8f07301
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion currencies/context_processors.py
Expand Up @@ -2,7 +2,7 @@


def currencies(request):
currencies = Currency.objects.all()
currencies = Currency.objects.active()

if not request.session.get('currency'):
try:
Expand Down
7 changes: 7 additions & 0 deletions currencies/models.py
Expand Up @@ -2,6 +2,11 @@
from django.utils.translation import gettext_lazy as _


class CurrencyManager(models.Manager):
def active(self):
return self.get_query_set().filter(is_active=True)


class Currency(models.Model):
code = models.CharField(_('code'), max_length=3)
name = models.CharField(_('name'), max_length=35)
Expand All @@ -15,6 +20,8 @@ class Currency(models.Model):
is_default = models.BooleanField(_('default'), default=False,
help_text=_('Make this the default user currency.'))

objects = CurrencyManager()

class Meta:
ordering = ('name', )
verbose_name = _('currency')
Expand Down
6 changes: 3 additions & 3 deletions docs/index.rst
Expand Up @@ -7,7 +7,7 @@ About
=====

django-currencies allows you to define different currencies, and includes
template tags/filters to allow easy conversion between them.
template tags/filters to allow easy conversion between them.

Installation
============
Expand Down Expand Up @@ -49,7 +49,7 @@ need to do the following:
``TEMPLATE_CONTEXT_PROCESSORS`` setting of your Django project.

3. Add this line to your site's root URLConf::

(r'^currencies/', include('currencies.urls')),

4. Run the command ``python manage.py syncdb``.
Expand Down Expand Up @@ -93,7 +93,7 @@ Django currencies, provides a ``currencies.context_processors.currencies``,
which gives you the following template variables::

``CURRENCIES``
A list of the available currencies.
A list of the active currencies.

``CURRENCY``
The currently set currency
Expand Down

0 comments on commit 8f07301

Please sign in to comment.