")
@loginrequired
diff --git a/fosspay/currency.py b/fosspay/currency.py
new file mode 100644
index 0000000..d2e396a
--- /dev/null
+++ b/fosspay/currency.py
@@ -0,0 +1,21 @@
+from fosspay.config import _cfg
+
+class Currency:
+ def __init__(self, symbol, position):
+ self.symbol = symbol
+ self.position = position
+
+ def amount(self, amount):
+ if self.position == "right":
+ return amount + self.symbol
+ else:
+ return self.symbol + amount
+
+currencies = {
+ 'usd' : Currency("$", "left"),
+ 'eur' : Currency("€", "right")
+ # ... More currencies can be added here
+}
+
+currency = currencies[_cfg("currency")]
+
diff --git a/scripts/index.js b/scripts/index.js
index d679b45..0041b77 100644
--- a/scripts/index.js
+++ b/scripts/index.js
@@ -78,6 +78,7 @@
description: donation.type == "monthly" ? i18n["Monthly Donation"] : i18n["One-time Donation"],
panelLabel: i18n["Donate "] + "{{amount}}",
amount: donation.amount,
+ currency: currency,
token: function(token) {
e.target.setAttribute("disabled", "");
e.target.textContent = i18n["Submitting..."];
diff --git a/templates/admin.html b/templates/admin.html
index bc7f7c2..aeb2177 100644
--- a/templates/admin.html
+++ b/templates/admin.html
@@ -65,24 +65,24 @@
|
{{ project.name }} |
- ${{ "{:.2f}".format(one_times(project) / 100) }} |
- ${{ "{:.2f}".format(recurring(project) / 100) }} |
- ${{ "{:.2f}".format(recurring_ever(project) / 100) }} |
+ {{ currency.amount("{:.2f}".format(one_times(project) / 100)) }} |
+ {{ currency.amount("{:.2f}".format(recurring(project) / 100)) }} |
+ {{ currency.amount("{:.2f}".format(recurring_ever(project) / 100)) }} |
{% endfor %}
|
(not specified) |
- ${{ "{:.2f}".format(unspecified_one_times / 100) }} |
- ${{ "{:.2f}".format(unspecified_recurring / 100) }} |
- ${{ "{:.2f}".format(unspecified_recurring_ever / 100) }} |
+ {{ currency.amount("{:.2f}".format(unspecified_one_times / 100)) }} |
+ {{ currency.amount("{:.2f}".format(unspecified_recurring / 100)) }} |
+ {{ currency.amount("{:.2f}".format(unspecified_recurring_ever / 100)) }} |
|
Total |
- ${{ "{:.2f}".format(total_one_time / 100) }} |
- ${{ "{:.2f}".format(total_recurring / 100) }} |
- ${{ "{:.2f}".format(total_recurring_ever / 100) }} |
+ {{ currency.amount("{:.2f}".format(total_one_time / 100)) }} |
+ {{ currency.amount("{:.2f}".format(total_recurring / 100)) }} |
+ {{ currency.amount("{:.2f}".format(total_recurring_ever / 100)) }} |
@@ -118,7 +118,7 @@
{{ donation.user.email }} |
{{ donation.project.name if donation.project else "" }} |
{{ donation.comment if donation.comment else "" }} |
- ${{ "{:.2f}".format(donation.amount / 100) }} |
+ {{ currency.amount("{:.2f}".format(donation.amount / 100)) }} |
{{ "Once" if str(donation.type) == "DonationType.one_time" else "Monthly" }}
{{ "(cancelled)" if not donation.active else "" }}
diff --git a/templates/goal.html b/templates/goal.html
index 8be983f..b98c514 100644
--- a/templates/goal.html
+++ b/templates/goal.html
@@ -23,21 +23,21 @@
class="progress-bar progress-bar-primary"
style="width: {{ recurring_progress * 100 }}%; line-height: 2.5"
>
- ${{ "{:.0f}".format(recurring_sum / 100) }}
+ {{ currency.amount("{:.0f}".format(recurring_sum / 100)) }}
- ${{ "{:.0f}".format(patreon_sum / 100) }}
+ {{ currency.amount("{:.0f}".format(patreon_sum / 100)) }}
- ${{ "{:.0f}".format(lp_sum / 100) }}
+ {{ currency.amount("{:.0f}".format(lp_sum / 100)) }}
{% endif %}
@@ -47,13 +47,13 @@
|
{{ donation.created.strftime("%Y-%m-%d") }} |
- ${{ "{:.2f}".format(donation.amount / 100) }} |
+ {{ currency.amount("{:.2f}".format(donation.amount / 100)) }} |
{{ donation.project.name if donation.project else "Not specified" }} |
{% endfor %}
@@ -51,7 +51,7 @@
{% for donation in one_times(user) %}
{{ donation.created.strftime("%Y-%m-%d") }} |
- ${{ "{:.2f}".format(donation.amount / 100) }} |
+ {{ currency.amount("{:.2f}".format(donation.amount / 100)) }} |
{{ donation.project.name if donation.project else "Not specified" }} |
{% endfor %}