Fix #446 -- Choices for Event.currenxy attribute (#452)

* Change event currency to a choice attribute

* Added pycountry to requirements for currency list

* Fixed issues from flake8

* Added tests for event currency and added pycountry to setup.py

* Removed whitespace from test/control/test_events.py
This commit is contained in:
Matthew Emerson
2017-04-06 06:08:55 -04:00
committed by Raphael Michel
parent 2e9d95b96a
commit 4accbef6a9
5 changed files with 51 additions and 1 deletions

View File

@@ -59,6 +59,7 @@ class Event(LoggedModel):
"""
settings_namespace = 'event'
CURRENCY_CHOICES = [(c.alpha_3, c.alpha_3 + " - " + c.name) for c in settings.CURRENCIES]
organizer = models.ForeignKey(Organizer, related_name="events", on_delete=models.PROTECT)
name = I18nCharField(
max_length=200,
@@ -83,6 +84,7 @@ class Event(LoggedModel):
related_name="events", )
currency = models.CharField(max_length=10,
verbose_name=_("Default currency"),
choices=CURRENCY_CHOICES,
default=settings.DEFAULT_CURRENCY)
date_from = models.DateTimeField(verbose_name=_("Event start time"))
date_to = models.DateTimeField(null=True, blank=True,

View File

@@ -1,6 +1,7 @@
import configparser
import os
import sys
from pycountry import currencies
import django.conf.locale
from django.contrib.messages import constants as messages # NOQA
@@ -85,6 +86,7 @@ PRETIX_PLUGINS_DEFAULT = config.get('pretix', 'plugins_default',
fallback='pretix.plugins.sendmail,pretix.plugins.statistics')
DEFAULT_CURRENCY = config.get('pretix', 'currency', fallback='EUR')
CURRENCIES = list(currencies)
ALLOWED_HOSTS = ['*']