summaryrefslogtreecommitdiff
path: root/foundation
diff options
context:
space:
mode:
authort-payne <tpayne.dev@gmail.com>2024-09-27 08:13:06 -0600
committerGitHub <noreply@github.com>2024-09-27 16:13:06 +0200
commit26976dc12335271fc10d3e1143ac018f29d0f103 (patch)
tree6f1efdc7d539e6f7c0767446757e1d3a9f452e39 /foundation
parentd031005647b0c7cca98824a898ac31d218f52be2 (diff)
Fixed #1597 -- Hardcoded currency choices in MoneyField
This should prevent spurious migrations being generated when updating django-money or babel.
Diffstat (limited to 'foundation')
-rw-r--r--foundation/migrations/0006_hardcode_currency_choices.py30
-rw-r--r--foundation/models.py12
2 files changed, 42 insertions, 0 deletions
diff --git a/foundation/migrations/0006_hardcode_currency_choices.py b/foundation/migrations/0006_hardcode_currency_choices.py
new file mode 100644
index 00000000..68faca8a
--- /dev/null
+++ b/foundation/migrations/0006_hardcode_currency_choices.py
@@ -0,0 +1,30 @@
+# Generated by Django 4.2.14 on 2024-09-26 11:12
+
+from decimal import Decimal
+from django.db import migrations
+import djmoney.models.fields
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('foundation', '0005_alter_approvedgrant_amount_currency_and_more'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='approvedgrant',
+ name='amount',
+ field=djmoney.models.fields.MoneyField(currency_choices=[('AUD', 'Australian Dollar'), ('EUR', 'Euro'), ('NGN', 'Nigerian Naira'), ('USD', 'US Dollar')], decimal_places=2, default=Decimal('0.0'), default_currency='USD', max_digits=10),
+ ),
+ migrations.AlterField(
+ model_name='approvedgrant',
+ name='amount_currency',
+ field=djmoney.models.fields.CurrencyField(choices=[('AUD', 'Australian Dollar'), ('EUR', 'Euro'), ('NGN', 'Nigerian Naira'), ('USD', 'US Dollar')], default='USD', editable=False, max_length=3),
+ ),
+ migrations.AlterField(
+ model_name='meeting',
+ name='treasurer_balance_currency',
+ field=djmoney.models.fields.CurrencyField(choices=[('USD', 'US Dollar')], default='USD', editable=False, max_length=3),
+ ),
+ ]
diff --git a/foundation/models.py b/foundation/models.py
index 4366ae8b..ddbb4517 100644
--- a/foundation/models.py
+++ b/foundation/models.py
@@ -5,6 +5,7 @@ from django.db import models
from django.urls import reverse
from django.utils.dateformat import format as date_format
from djmoney.models.fields import MoneyField
+from djmoney.settings import CURRENCIES
from docutils.core import publish_parts
from blog.models import BLOG_DOCUTILS_SETTINGS
@@ -131,6 +132,17 @@ class ApprovedGrant(models.Model):
decimal_places=2,
default_currency="USD",
default=Decimal("0.0"),
+ currency_choices=[
+ (c.code, c.name)
+ for i, c in CURRENCIES.items()
+ if c.code
+ in {
+ "USD",
+ "EUR",
+ "AUD",
+ "NGN",
+ } # This set of currencies was extracted from current usage
+ ],
)
approved_at = models.ForeignKey(
Meeting, related_name="grants_approved", on_delete=models.CASCADE