From 3ce41f0c5c0e572e7fc3c79e0ce63ced8a9434c8 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Thu, 24 Nov 2016 18:17:49 +0100 Subject: [PATCH] [to test] send cash coupon to user by mail --- .../javascripts/directives/coupon.coffee.erb | 2 +- .../notify_member_about_coupon.html.erb | 19 ++++++++++++++----- config/locales/app.shared.en.yml | 2 +- config/locales/app.shared.fr.yml | 2 +- config/locales/mails.en.yml | 3 ++- config/locales/mails.fr.yml | 3 ++- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/directives/coupon.coffee.erb b/app/assets/javascripts/directives/coupon.coffee.erb index 3101a7013..4392297bf 100644 --- a/app/assets/javascripts/directives/coupon.coffee.erb +++ b/app/assets/javascripts/directives/coupon.coffee.erb @@ -38,7 +38,7 @@ Application.Directives.directive 'coupon', [ '$rootScope', 'Coupon', 'growl', '_ if res.type == 'percent_off' growl.success(_t('the_coupon_has_been_applied_you_get_PERCENT_discount', {PERCENT: res.percent_off})) else - growl.success(_t('the_coupon_has_been_applied_you_get_DISCOUNT_CURRENCY', {DISCOUNT: res.amount_off, CURRENCY: $rootScope.currencySymbol})) + growl.success(_t('the_coupon_has_been_applied_you_get_AMOUNT_CURRENCY', {AMOUNT: res.amount_off, CURRENCY: $rootScope.currencySymbol})) , (err) -> $scope.status = 'invalid' $scope.coupon = null diff --git a/app/views/notifications_mailer/notify_member_about_coupon.html.erb b/app/views/notifications_mailer/notify_member_about_coupon.html.erb index 08b3ccd8d..04f6fa0d5 100644 --- a/app/views/notifications_mailer/notify_member_about_coupon.html.erb +++ b/app/views/notifications_mailer/notify_member_about_coupon.html.erb @@ -1,10 +1,18 @@ <%= render 'notifications_mailer/shared/hello', recipient: @recipient %> -

<%= t('.body.enjoy_a_discount_of_PERCENT_with_code_CODE', - PERCENT: @attached_object.percent_off, - CODE: @attached_object.code - ) %> -

+<% if @attached_object.type == 'percent_off' %> +

<%= t('.body.enjoy_a_discount_of_PERCENT_with_code_CODE', + PERCENT: @attached_object.percent_off, + CODE: @attached_object.code + ) %> +

+<% else %> +

<%= t('.body.enjoy_a_discount_of_AMOUNT_with_code_CODE', + AMOUNT: number_to_currency(@attached_object.amount_off / 100.00), + CODE: @attached_object.code + ) %> +

+<% end %> <% # we must tell the use if he could use the code just once or many times (in case we won't specify) @@ -21,6 +29,7 @@ <%= _t('.body.this_coupon_is_valid_USAGE_times_until_DATE_for_all_your_purchases', { USAGE: usages, + TYPE: @attached_object.type, DATE: @attached_object.valid_until.nil? ? 'NO-DATE' : I18n.l(@attached_object.valid_until.to_date) }) # messageFormat diff --git a/config/locales/app.shared.en.yml b/config/locales/app.shared.en.yml index 470a94a2a..8913ea48e 100644 --- a/config/locales/app.shared.en.yml +++ b/config/locales/app.shared.en.yml @@ -368,7 +368,7 @@ en: i_have_a_coupon: "I have a coupon!" code_: "Code:" the_coupon_has_been_applied_you_get_PERCENT_discount: "The coupon has been applied. You get a {{PERCENT}}% discount." # angular interpolation - the_coupon_has_been_applied_you_get_DISCOUNT_CURRENCY: "The coupon has been applied. You get a discount of {{DISCOUNT}} {{CURRENCY}}." # angular interpolation + the_coupon_has_been_applied_you_get_AMOUNT_CURRENCY: "The coupon has been applied. You get a discount of {{AMOUNT}} {{CURRENCY}}." # angular interpolation unable_to_apply_the_coupon_because_disabled: "Unable to apply the coupon: this code was disabled." unable_to_apply_the_coupon_because_expired: "Unable to apply the coupon: this code has expired." unable_to_apply_the_coupon_because_sold_out: "Unable to apply the coupon: this code reached its quota." diff --git a/config/locales/app.shared.fr.yml b/config/locales/app.shared.fr.yml index 0fe631285..fa1cdb010 100644 --- a/config/locales/app.shared.fr.yml +++ b/config/locales/app.shared.fr.yml @@ -368,7 +368,7 @@ fr: i_have_a_coupon: "J'ai un code promo !" code_: "Code :" the_coupon_has_been_applied_you_get_PERCENT_discount: "Le code promo a bien été appliqué. Vous bénéficiez d'une remise de {{PERCENT}} %." # angular interpolation - the_coupon_has_been_applied_you_get_DISCOUNT_CURRENCY: "Le code promo a bien été appliqué. Vous bénéficiez d'une remise de {{DISCOUNT}} {{CURRENCY}}." # angular interpolation + the_coupon_has_been_applied_you_get_AMOUNT_CURRENCY: "Le code promo a bien été appliqué. Vous bénéficiez d'une remise de {{AMOUNT}} {{CURRENCY}}." # angular interpolation unable_to_apply_the_coupon_because_disabled: "Impossible d'appliquer la réduction : ce code promo a été désactivé." unable_to_apply_the_coupon_because_expired: "Impossible d'appliquer la réduction : ce code promo a expiré." unable_to_apply_the_coupon_because_sold_out: "Impossible d'appliquer la réduction : ce code promo a atteint son quota." diff --git a/config/locales/mails.en.yml b/config/locales/mails.en.yml index 38140941f..56b7901f3 100644 --- a/config/locales/mails.en.yml +++ b/config/locales/mails.en.yml @@ -278,7 +278,8 @@ en: subject: "Coupon" body: enjoy_a_discount_of_PERCENT_with_code_CODE: "Enjoy a discount of %{PERCENT}% on the whole site with the code %{CODE}." - this_coupon_is_valid_USAGE_times_until_DATE_for_all_your_purchases: "This coupon is valid {USAGE, plural, =1{just once} other{many times}}: for all your purchases, from now {DATE, select, NO-DATE{and without time limit} other{and until {DATE}}}." + enjoy_a_discount_of_AMOUNT_with_code_CODE: "Enjoy a discount of %{AMOUNT} on the whole site with the code %{CODE}." + this_coupon_is_valid_USAGE_times_until_DATE_for_all_your_purchases: "This coupon is valid {USAGE, plural, =1{just once} other{many times}}: for all your purchases {TYPE, select, amount_off{at least equal to the amount of the coupon} other{}}, from now {DATE, select, NO-DATE{and without time limit} other{and until {DATE}}}." shared: hello: "Hello %{user_name}" diff --git a/config/locales/mails.fr.yml b/config/locales/mails.fr.yml index 3efa19f5d..14d1ee941 100644 --- a/config/locales/mails.fr.yml +++ b/config/locales/mails.fr.yml @@ -278,7 +278,8 @@ fr: subject: "Code promo" body: enjoy_a_discount_of_PERCENT_with_code_CODE: "Bénéficiez d'une remise de %{PERCENT} % sur tout le site en utilisant le code promo %{CODE}." - this_coupon_is_valid_USAGE_times_until_DATE_for_all_your_purchases: "Ce code promo est valable {USAGE, plural, =1{une seule fois} other{plusieurs fois}} : pour tous vos achats, dès maintenant {DATE, select, NO-DATE{et sans limitation de durée} other{et jusqu'au {DATE}}}." + enjoy_a_discount_of_AMOUNT_with_code_CODE: "Bénéficiez d'une remise de %{AMOUNT} sur tout le site en utilisant le code promo %{CODE}." + this_coupon_is_valid_USAGE_times_until_DATE_for_all_your_purchases: "Ce code promo est valable {USAGE, plural, =1{une seule fois} other{plusieurs fois}} : pour tous vos achats {TYPE, select, amount_off{dont le montant est au moins de celui du code promo} other{}}, dès maintenant {DATE, select, NO-DATE{et sans limitation de durée} other{et jusqu'au {DATE}}}." shared: hello: "Bonjour %{user_name}"