diff --git a/openrepairplatform/event/models.py b/openrepairplatform/event/models.py index c7e1e92a..c4bbf5b3 100644 --- a/openrepairplatform/event/models.py +++ b/openrepairplatform/event/models.py @@ -1,4 +1,5 @@ from datetime import date, datetime, timedelta +import locale from django.db import models from django.urls import reverse @@ -32,9 +33,12 @@ def get_absolute_url(self): kwargs={"orga_slug": self.organization.slug}, ) + def price_w_currency(self): + return locale.currency(self.price, grouping=True) + def __str__(self): if self.price > 0: - return f"{self.name} - {self.price}€" + return f"{self.name} - {self.price_w_currency}" return self.name @@ -42,6 +46,12 @@ class ActivityCategory(models.Model): name = models.CharField(verbose_name=_("Activity type"), max_length=100) slug = models.SlugField(blank=True) history = HistoricalRecords() + index = models.PositiveIntegerField(verbose_name='Order', + default=0, + editable=True, + help_text='Order in which the activity types will be displayed') + # The index field must be editable to enable adminsortable2 to work + # for enabling the elements always to be displayed in the right order, even if new ones def save(self, *args, **kwargs): self.slug = slugify(self.name) @@ -50,6 +60,8 @@ def save(self, *args, **kwargs): def __str__(self): return self.name + class Meta: + ordering = ['index', ] class Activity(models.Model): name = models.CharField(verbose_name=_("Activity type"), max_length=100) @@ -87,6 +99,8 @@ def get_absolute_url(self): def next_events(self): return get_future_published_events(self.events)[0:3] + class Meta: + verbose_name_plural = 'Activities' class Event(models.Model): WEEKS = [ diff --git a/openrepairplatform/event/templates/event/condition/list.html b/openrepairplatform/event/templates/event/condition/list.html index badb96f8..8d679406 100644 --- a/openrepairplatform/event/templates/event/condition/list.html +++ b/openrepairplatform/event/templates/event/condition/list.html @@ -6,7 +6,7 @@
{{ event.organization.get_membership_system_display }} Elle {% if event.organization.advised_fee == event.organization.min_fee %} - est de {{event.organization.min_fee}}€ + est de {{event.organization.min_fee|currency}} {% else %} - va de {{event.organization.min_fee}}€ à {{event.organization.advised_fee}}€ + va de {{event.organization.min_fee|currency}} à {{event.organization.advised_fee|currency}} {% endif %} {% if event.organization.membership_url %} Vous pouvez @@ -303,7 +303,7 @@
{{ event.organization.get_membership_system_display }} Elle
{% if event.organization.advised_fee == event.organization.min_fee %}
- est de {{event.organization.min_fee}}€
+ est de {{event.organization.min_fee|currency}}
{% else %}
- va de {{event.organization.min_fee}}€ à {{event.organization.advised_fee}}€ .
+ va de {{event.organization.min_fee|currency}} à {{event.organization.advised_fee|currency}} .
{% endif %}
{% if event.organization.membership_url %}
diff --git a/openrepairplatform/event/templates/event/detail/registered_users.html b/openrepairplatform/event/templates/event/detail/registered_users.html
index c0caaecf..cbaecd2f 100644
--- a/openrepairplatform/event/templates/event/detail/registered_users.html
+++ b/openrepairplatform/event/templates/event/detail/registered_users.html
@@ -43,13 +43,13 @@
{{ event.organization.get_membership_system_display }} Elle {% if event.organization.advised_fee == event.organization.min_fee %} - est de {{event.organization.min_fee}}€ + est de {{event.organization.min_fee|currency}} {% else %} - va de {{event.organization.min_fee}}€ à {{event.organization.advised_fee}}€ + va de {{event.organization.min_fee|currency}} à {{event.organization.advised_fee|currency}} {% endif %}
diff --git a/openrepairplatform/event/templatetags/app_filters.py b/openrepairplatform/event/templatetags/app_filters.py index 0f2f42fc..e8689da0 100644 --- a/openrepairplatform/event/templatetags/app_filters.py +++ b/openrepairplatform/event/templatetags/app_filters.py @@ -1,6 +1,9 @@ from django import template from django.core import signing +import locale +# locale.setlocale(locale.LC_ALL, '') + from openrepairplatform.user.models import Fee register = template.Library() @@ -63,3 +66,8 @@ def query_transform(request, **kwargs): @register.simple_tag def sum_conditions(conditions): return sum(condition.price for condition in conditions) + + +@register.filter() +def currency(value): + return locale.currency(value, grouping=True) \ No newline at end of file diff --git a/openrepairplatform/settings/base.py b/openrepairplatform/settings/base.py index b3760b7d..7e97823e 100644 --- a/openrepairplatform/settings/base.py +++ b/openrepairplatform/settings/base.py @@ -118,7 +118,8 @@ # Internationalization # https://docs.djangoproject.com/en/1.11/topics/i18n/ -LANGUAGE_CODE = "fr-fr" +COUNTRY = 'FR' #'CH', 'US' +LANGUAGE_CODE = f"fr-{COUNTRY}" # fr_fr, fr_CH TIME_ZONE = "Europe/Paris" @@ -128,6 +129,15 @@ USE_THOUSAND_SEPARATOR = True + +CURRENCIES = { + 'FR' : ['EUR', '€'], + 'CH' : ['CHF', 'CHF'], + 'US' : ['USD', '$'], +} +CURRENCY_DISPLAY = CURRENCIES[COUNTRY][1] +CURRENCY_CODE = CURRENCIES[COUNTRY][0] + STATICFILES_DIRS = [join(PROJECT_DIR, "static")] STATIC_ROOT = join(BASE_DIR, "static") diff --git a/openrepairplatform/static/js/vue/apps/event-form/components/EventStepFour.vue b/openrepairplatform/static/js/vue/apps/event-form/components/EventStepFour.vue index 9033b3cd..e4299329 100644 --- a/openrepairplatform/static/js/vue/apps/event-form/components/EventStepFour.vue +++ b/openrepairplatform/static/js/vue/apps/event-form/components/EventStepFour.vue @@ -96,7 +96,7 @@- Tu es désormais membre de {{organization}}, depuis le {{date}}. Tu as donné {{paid}}€ pour ta première adhésion. + Tu es désormais membre de {{organization}}, depuis le {{date}}. Tu as donné {{paid|currency}} pour ta première adhésion.
diff --git a/openrepairplatform/user/templates/user/mail/membership.txt b/openrepairplatform/user/templates/user/mail/membership.txt index e1505189..9e9118ea 100644 --- a/openrepairplatform/user/templates/user/mail/membership.txt +++ b/openrepairplatform/user/templates/user/mail/membership.txt @@ -1,3 +1,3 @@ {{ user }}, -Tu es désormais membre de {{organization}}, depuis le {{date}}. Tu as donné {{paid}}€ pour ta première adhésion. +Tu es désormais membre de {{organization}}, depuis le {{date}}. Tu as donné {{paid|currency}} pour ta première adhésion. diff --git a/openrepairplatform/user/templates/user/organization/modal_more_info.html b/openrepairplatform/user/templates/user/organization/modal_more_info.html index 33db1ca3..b6a8cdaa 100644 --- a/openrepairplatform/user/templates/user/organization/modal_more_info.html +++ b/openrepairplatform/user/templates/user/organization/modal_more_info.html @@ -47,14 +47,14 @@
Note:
La contribution minimale pour cette organisation est de
- {{ object.min_fee }}€
+ {{ object.min_fee|currency }}
et la contribution totale conseillée est de
- {{ object.advised_fee }}€
+ {{ object.advised_fee|currency }}
{% if anonymous_user and anonymous_user.first_name %}
{% filter_orga queryset=anonymous_user.memberships organization=object as membership %}
{% if membership %}
- {{ anonymous_user }} a payé {{ membership.current_contribution }}€ depuis le {{ membership.first_payment|date:"d F Y" }}
+ {{ anonymous_user }} a payé {{ membership.current_contribution|currency }} depuis le {{ membership.first_payment|date:"d F Y" }}
{% else %}
{{ anonymous_user }} n'a pas encore contribué pour {{ object }}
{% endif %}
diff --git a/openrepairplatform/user/templates/user/user_card.html b/openrepairplatform/user/templates/user/user_card.html
index d76ac7af..48491396 100644
--- a/openrepairplatform/user/templates/user/user_card.html
+++ b/openrepairplatform/user/templates/user/user_card.html
@@ -11,14 +11,14 @@
{% filter_orga queryset=user.memberships organization=event.organization as membership %}
{% if membership %}
{% if membership.current_contribution == 0 %}
- 0€
+ {{0|currency}}
{% elif membership.current_contribution >= event.organization.advised_fee %}
- {{ membership.current_contribution }}€
+ {{ membership.current_contribution|currency }}
{% else %}
- {{ membership.current_contribution }}€
+ {{ membership.current_contribution|currency }}
{% endif %}
{% else %}
- 0€
+ {{0|currency}}
{% endif %}
{% endif %}
diff --git a/openrepairplatform/user/templates/user/user_detail.html b/openrepairplatform/user/templates/user/user_detail.html
index 0d898c12..1dedf66f 100644
--- a/openrepairplatform/user/templates/user/user_detail.html
+++ b/openrepairplatform/user/templates/user/user_detail.html
@@ -296,7 +296,7 @@