From f0113d7b4a17b445fa96ba2b7f397b2a76c8eb00 Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Fri, 21 Jun 2024 17:57:23 +0300 Subject: [PATCH 1/6] fixed extra zeros in min bid section --- app/components/modals/deposit/component.html.erb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/components/modals/deposit/component.html.erb b/app/components/modals/deposit/component.html.erb index 2067cf8e4..264894e54 100644 --- a/app/components/modals/deposit/component.html.erb +++ b/app/components/modals/deposit/component.html.erb @@ -23,22 +23,27 @@
<%= t('english_offers.show.min_bid') %>

- <%= number_with_precision(Money.from_amount(@auction.min_bids_step.to_f, Setting.find_by(code: 'auction_currency').retrieve, precision: 2)) %> € + <%#= @auction.min_bids_step.to_f %> + <%= number_with_precision(Money.from_amount(@auction.min_bids_step, Setting.find_by(code: 'auction_currency').retrieve), precision: 2, separator: '.') %> €

<%= t('english_offers.show.current_price') %> -

<%= @auction&.currently_winning_offer&.price || Money.new(0) %> €

+

+ + <%= number_with_precision(@auction&.currently_winning_offer&.price || Money.new(0), precision: 2, separator: '.') %> € + +

- <%= t('offers.new.deposit_description_html', deposit: number_with_precision(@auction.deposit, precision: 2)) %> + <%= t('offers.new.deposit_description_html', deposit: number_with_precision(@auction.deposit, precision: 2, separator: '.')) %>
<%= t('offers.new.deposit_enable') %> -

<%= "#{number_with_precision(@auction.deposit, precision: 2)} €" %>

+

<%= "#{number_with_precision(@auction.deposit, precision: 2, separator: '.')} €" %>

<%#= button_to t('offers.new.make_deposit'), english_offer_deposit_auction_path(uuid: @auction.uuid, current_user: @current_user), class: "c-btn c-btn-white c-btn--fs", method: :post, data: { turbo: false } %> From dc60c0ab29702ae78e084d7dc2381931fa67a492 Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Wed, 26 Jun 2024 09:45:28 +0300 Subject: [PATCH 2/6] added comma format to the change offer component --- app/components/modals/change_offer/component.html.erb | 6 +++++- app/components/modals/change_offer_po/component.html.erb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/components/modals/change_offer/component.html.erb b/app/components/modals/change_offer/component.html.erb index 4f9bedcc2..68a2c8662 100644 --- a/app/components/modals/change_offer/component.html.erb +++ b/app/components/modals/change_offer/component.html.erb @@ -23,7 +23,11 @@
<%= t('english_offers.show.min_bid') %> -

<%= Money.from_amount(@auction.min_bids_step.to_f, Setting.find_by(code: 'auction_currency').retrieve, precision: 2) %> €

+

+ + <%= number_with_precision(Money.from_amount(@auction.min_bids_step.to_f, Setting.find_by(code: 'auction_currency').retrieve), precision: 2, separator: '.') %> € + +

<%= t('english_offers.show.current_price') %> diff --git a/app/components/modals/change_offer_po/component.html.erb b/app/components/modals/change_offer_po/component.html.erb index 54977d1bc..db77172ad 100644 --- a/app/components/modals/change_offer_po/component.html.erb +++ b/app/components/modals/change_offer_po/component.html.erb @@ -23,7 +23,7 @@
<%= t('english_offers.show.min_bid') %> -

<%= Money.new(Setting.find_by(code: 'auction_minimum_offer').retrieve) %> €

+

<%= number_with_precision(Money.new(Setting.find_by(code: 'auction_minimum_offer').retrieve), precision: 2, separator: '.') %> €

<%= t('auctions.you') %> From 6a9f51ffade31af7214aeabea32eedb3f8da5c7e Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Fri, 28 Jun 2024 12:23:30 +0300 Subject: [PATCH 3/6] refactor static notice to component, fixed footer links, change message notifications for ban and restriction action --- app/components/application_view_component.rb | 4 + .../common/footer/component.html.erb | 8 +- app/components/common/footer/component.rb | 22 +++++- .../common/static_notice/component.html.erb} | 3 +- .../common/static_notice/component.rb | 75 +++++++++++++++++++ .../modals/change_offer/component.html.erb | 4 +- .../modals/change_offer_po/component.html.erb | 2 +- .../modals/deposit/component.html.erb | 10 +-- app/controllers/application_controller.rb | 6 +- app/helpers/application_helper.rb | 58 +------------- app/helpers/invalid_user_data_helper.rb | 14 ---- app/views/layouts/application.html.erb | 2 +- .../daily_auctions_broadcast_email.html.erb | 3 +- app/views/users/_user_info.html.erb | 2 +- config/locales/auctions.en.yml | 6 +- config/locales/auctions.et.yml | 6 +- config/locales/en.yml | 2 + config/locales/et.yml | 2 + config/locales/mailers/common_mailer.en.yml | 2 + config/locales/mailers/common_mailer.et.yml | 2 + 20 files changed, 138 insertions(+), 95 deletions(-) rename app/{views/common/_static_notices.html.erb => components/common/static_notice/component.html.erb} (98%) create mode 100644 app/components/common/static_notice/component.rb diff --git a/app/components/application_view_component.rb b/app/components/application_view_component.rb index 0981fe2d6..9098eadc3 100644 --- a/app/components/application_view_component.rb +++ b/app/components/application_view_component.rb @@ -34,4 +34,8 @@ def company_name def main_app Rails.application.class.routes.url_helpers end + + def price_format(price) + "#{number_to_currency(price, unit: '', separator: '.', delimiter: '', precision: 2)} €" + end end diff --git a/app/components/common/footer/component.html.erb b/app/components/common/footer/component.html.erb index 735b3d99e..10406cb89 100644 --- a/app/components/common/footer/component.html.erb +++ b/app/components/common/footer/component.html.erb @@ -44,7 +44,7 @@ <%= t('common.footer.faq')%> <%= t('common.footer.statistics')%>
- <%= t('common.footer.dispute_committee') %> + <%= t('common.footer.dispute_committee') %>
@@ -57,11 +57,11 @@

diff --git a/app/components/common/footer/component.rb b/app/components/common/footer/component.rb index 5a4d5cfa0..6d7c6439d 100644 --- a/app/components/common/footer/component.rb +++ b/app/components/common/footer/component.rb @@ -1,5 +1,25 @@ module Common module Footer - class Component < ApplicationViewComponent; end + class Component < ApplicationViewComponent + def footer_link(key) = I18n.locale == :et ? et_footer_links[key] : en_footer_links[key] + + def et_footer_links + { + "dispute_committee": 'https://www.internet.ee/domeenivaidlused/domeenivaidluste-komisjon', + "list_of_accredited_registrars": 'https://www.internet.ee/registripidaja/akrediteeritud-registripidajad', + "terms_and_conditions_for_registrars": 'https://www.internet.ee/registripidaja/kuidas-saada-ee-akrediteeritud-registripidajaks', + "partner_programme": 'https://www.internet.ee/registripidaja/kuidas-saada-ee-elite-partneriks' + } + end + + def en_footer_links + { + "dispute_committee": 'https://www.internet.ee/domain-disputes/domain-disputes-committee', + "list_of_accredited_registrars": 'https://www.internet.ee/registrar-portal/accredited-registrars', + "terms_and_conditions_for_registrars": 'https://www.internet.ee/registrar-portal/terms-and-conditions-for-becoming-a-registrar', + "partner_programme": 'https://www.internet.ee/registrar-portal/become-a-ee-elite-partner' + } + end + end end end diff --git a/app/views/common/_static_notices.html.erb b/app/components/common/static_notice/component.html.erb similarity index 98% rename from app/views/common/_static_notices.html.erb rename to app/components/common/static_notice/component.html.erb index 33ce2c3cf..26b0f3923 100644 --- a/app/views/common/_static_notices.html.erb +++ b/app/components/common/static_notice/component.html.erb @@ -7,6 +7,7 @@
<% end %> + <%= banned_banner %> <%= invalid_data_banner %> -
\ No newline at end of file +
diff --git a/app/components/common/static_notice/component.rb b/app/components/common/static_notice/component.rb new file mode 100644 index 000000000..4578317cc --- /dev/null +++ b/app/components/common/static_notice/component.rb @@ -0,0 +1,75 @@ +module Common + module StaticNotice + class Component < ViewComponent::Base + attr_accessor :current_user + + def initialize(current_user:) + super + + @current_user = current_user + end + + def banned_banner + return unless current_user&.current_bans + + domains, valid_until = current_user&.current_bans + message = ban_error_message(domains, valid_until) + return unless message + + content_tag(:div, class: 'c-toast js-toast c-toast--error') do + content_tag(:div, class: 'c-toast__content') do + concat(content_tag(:p, message)) + concat(content_tag(:p, violation_message(domains.size))) if eligible_violations_present?(domains:) + end + end + end + + def invalid_data_banner + return unless session['user.invalid_user_data'] + + if current_user.not_phone_number_confirmed_unique? + content_tag(:div, class: 'c-toast js-toast c-toast--error') do + content_tag(:div, t('already_confirmed'), class: 'c-toast__content') + end + else + content_tag(:div, class: 'c-toast js-toast c-toast--error') do + content_tag(:div, t('users.invalid_user_data'), class: 'c-toast__content') + end + end + end + + def start_of_procedure = Rails.configuration.customization[:start_of_procedure] + + def end_of_procdure = Rails.configuration.customization[:end_of_procedure] + + private + + def ban_error_message(domains, valid_until) + if current_user&.completely_banned? + t('auctions.banned_completely', valid_until: valid_until.to_date, + ban_number_of_strikes: Setting.find_by( + code: 'ban_number_of_strikes' + ).retrieve) + else + I18n.t('auctions.banned', domain_names: domains.join(', ')) + end + end + + def violation_message(domains_count) + link = Setting.find_by(code: 'violations_count_regulations_link').retrieve + t('auctions.violation_message_html', violations_count_regulations_link: link, + violations_count: domains_count, + ban_number_of_strikes: Setting.find_by( + code: 'ban_number_of_strikes' + ).retrieve) + end + + def eligible_violations_present?(domains: nil) + num_of_strikes = Setting.find_by(code: 'ban_number_of_strikes').retrieve + return true if domains && domains.size < num_of_strikes + + false + end + end + end +end diff --git a/app/components/modals/change_offer/component.html.erb b/app/components/modals/change_offer/component.html.erb index 68a2c8662..47b7bbb57 100644 --- a/app/components/modals/change_offer/component.html.erb +++ b/app/components/modals/change_offer/component.html.erb @@ -25,7 +25,7 @@ <%= t('english_offers.show.min_bid') %>

- <%= number_with_precision(Money.from_amount(@auction.min_bids_step.to_f, Setting.find_by(code: 'auction_currency').retrieve), precision: 2, separator: '.') %> € + <%= price_format(Money.from_amount(@auction.min_bids_step.to_f, Setting.find_by(code: 'auction_currency').retrieve)) %>

@@ -33,7 +33,7 @@ <%= t('english_offers.show.current_price') %>

- <%= current_price %> € + <%= price_format(current_price) %>

<%= current_bidder %> diff --git a/app/components/modals/change_offer_po/component.html.erb b/app/components/modals/change_offer_po/component.html.erb index db77172ad..8786c7fb3 100644 --- a/app/components/modals/change_offer_po/component.html.erb +++ b/app/components/modals/change_offer_po/component.html.erb @@ -23,7 +23,7 @@
<%= t('english_offers.show.min_bid') %> -

<%= number_with_precision(Money.new(Setting.find_by(code: 'auction_minimum_offer').retrieve), precision: 2, separator: '.') %> €

+

<%= price_format(Money.new(Setting.find_by(code: 'auction_minimum_offer').retrieve)) %>

<%= t('auctions.you') %> diff --git a/app/components/modals/deposit/component.html.erb b/app/components/modals/deposit/component.html.erb index 264894e54..9b18845ac 100644 --- a/app/components/modals/deposit/component.html.erb +++ b/app/components/modals/deposit/component.html.erb @@ -24,28 +24,26 @@ <%= t('english_offers.show.min_bid') %>

<%#= @auction.min_bids_step.to_f %> - <%= number_with_precision(Money.from_amount(@auction.min_bids_step, Setting.find_by(code: 'auction_currency').retrieve), precision: 2, separator: '.') %> € + <%= price_format(Money.from_amount(@auction.min_bids_step, Setting.find_by(code: 'auction_currency').retrieve)) %>

<%= t('english_offers.show.current_price') %>

- <%= number_with_precision(@auction&.currently_winning_offer&.price || Money.new(0), precision: 2, separator: '.') %> € + <%= price_format(@auction&.currently_winning_offer&.price || Money.new(0)) %>

- <%= t('offers.new.deposit_description_html', deposit: number_with_precision(@auction.deposit, precision: 2, separator: '.')) %> + <%= t('offers.new.deposit_description_html', deposit: price_format(@auction.deposit)) %>
<%= t('offers.new.deposit_enable') %> -

<%= "#{number_with_precision(@auction.deposit, precision: 2, separator: '.')} €" %>

- <%#= button_to t('offers.new.make_deposit'), english_offer_deposit_auction_path(uuid: @auction.uuid, current_user: @current_user), - class: "c-btn c-btn-white c-btn--fs", method: :post, data: { turbo: false } %> +

<%= "#{price_format(@auction.deposit)}" %>

<%= form_with url: english_offer_deposit_auction_path(uuid: @auction.uuid, current_user: @current_user), data: { turbo: false} do |f| %> <%= component 'captcha', captcha_required: @captcha_required, show_checkbox_recaptcha: @show_checkbox_recaptcha, action: 'english_offer' %> diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d7b9c926d..3ce1892bb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -12,7 +12,11 @@ class ApplicationController < ActionController::Base end rescue_from CanCan::AccessDenied do |_exception| - flash[:alert] = I18n.t('unauthorized.message') + flash[:alert] = if current_user.banned? + I18n.t('unauthorized.banned.message') + else + I18n.t('unauthorized.message') + end if turbo_frame_request? render turbo_stream: turbo_stream.replace('flash', partial: 'common/flash', locals: { flash: }) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f274b004f..3d83a3d5c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -8,7 +8,7 @@ def application_name def google_analytics tracking_id = Rails.configuration.customization.dig(:google_analytics, :tracking_id) - GoogleAnalytics.new(tracking_id: tracking_id) + GoogleAnalytics.new(tracking_id:) end def component(name, *args, **kwargs, &block) @@ -29,31 +29,6 @@ def locale_links end end - def banned_banner - return unless current_user&.current_bans - - domains, valid_until = current_user&.current_bans - message = ban_error_message(domains, valid_until) - return unless message - - content_tag(:div, class: 'c-toast js-toast c-toast--error') do - content_tag(:div, class: 'c-toast__content') do - concat(content_tag(:p, message)) - if eligible_violations_present?(domains: domains) - concat(content_tag(:p, violation_message(domains.size))) - end - end - end - end - - def start_of_procedure - Rails.configuration.customization[:start_of_procedure] - end - - def end_of_procdure - Rails.configuration.customization[:end_of_procedure] - end - def show_cookie_dialog? cookies[:cookie_dialog] != 'accepted' end @@ -64,33 +39,6 @@ def show_google_analytics? private - def ban_error_message(domains, valid_until) - if current_user&.completely_banned? - t('auctions.banned_completely', valid_until: valid_until.to_date, - ban_number_of_strikes: Setting.find_by( - code: 'ban_number_of_strikes' - ).retrieve) - else - I18n.t('auctions.banned', domain_names: domains.join(', ')) - end - end - - def violation_message(domains_count) - link = Setting.find_by(code: 'violations_count_regulations_link').retrieve - t('auctions.violation_message_html', violations_count_regulations_link: link, - violations_count: domains_count, - ban_number_of_strikes: Setting.find_by( - code: 'ban_number_of_strikes' - ).retrieve) - end - - def eligible_violations_present?(domains: nil) - num_of_strikes = Setting.find_by(code: 'ban_number_of_strikes').retrieve - return true if domains && domains.size < num_of_strikes - - false - end - def links(links_list) links_list.each do |item| concat( @@ -106,12 +54,10 @@ def links(links_list) def locale_link_list locales = I18n.available_locales.reject { |item| item == I18n.locale } - items = locales.map do |item| + locales.map do |item| { name: I18n.t(:in_local_language, locale: item), path: locale_path(locale: item), method: :put, data: { "turbo-method": 'put' } } end - - items end def user_link_list diff --git a/app/helpers/invalid_user_data_helper.rb b/app/helpers/invalid_user_data_helper.rb index 94820f4a2..a8e9265b4 100644 --- a/app/helpers/invalid_user_data_helper.rb +++ b/app/helpers/invalid_user_data_helper.rb @@ -5,20 +5,6 @@ def set_invalid_data_flag_in_session session['user.invalid_user_data'] = user_data_invalid? end - def invalid_data_banner - return unless session['user.invalid_user_data'] - - if current_user.not_phone_number_confirmed_unique? - content_tag(:div, class: 'c-toast js-toast c-toast--error') do - content_tag(:div, t('already_confirmed'), class: 'c-toast__content') - end - else - content_tag(:div, class: 'c-toast js-toast c-toast--error') do - content_tag(:div, t('users.invalid_user_data'), class: 'c-toast__content') - end - end - end - private def user_data_invalid? diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 0152770b1..7e028d5fa 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -58,7 +58,7 @@
<%= turbo_frame_tag "modal", data: { turbo_temporary: true } %> <%= component 'common/hero', title: yield(:title) %> - <%= render "common/static_notices" %> + <%= component 'common/static_notice', current_user: current_user %> <%= yield %>
diff --git a/app/views/notification_mailer/daily_auctions_broadcast_email.html.erb b/app/views/notification_mailer/daily_auctions_broadcast_email.html.erb index 5e9228df7..477b73d3d 100644 --- a/app/views/notification_mailer/daily_auctions_broadcast_email.html.erb +++ b/app/views/notification_mailer/daily_auctions_broadcast_email.html.erb @@ -10,11 +10,12 @@ <%= auction.domain_name %> <%= auction.ends_at %> - <%= link_to(t('.submit_offer'), auction_url(auction.uuid)) %> <% end %> +

<%= t('.common_mailer.more_information', link: I18n.locale == :et ? "https://oksjon.internet.ee" : "https://auction.internet.ee") %>

+ <%= t('common_mailer.footer_html') %> <%= link_to t('unsubscribe_mailer_text'), unsubscribe_unsubscribe_url(id: @unsubscribe) %> diff --git a/app/views/users/_user_info.html.erb b/app/views/users/_user_info.html.erb index 0dd446f05..20fcb65a1 100644 --- a/app/views/users/_user_info.html.erb +++ b/app/views/users/_user_info.html.erb @@ -52,7 +52,7 @@
- <%= t('users.terms_and_conditions_link') %> + <%= t('users.terms_and_conditions_link') %>
<%= component 'common/links/link_button', link_title: t(:billing), href: billing_profiles_path, color: 'ghost', options: { target: '_top' } %> <%= component 'common/buttons/delete_button_with_text', path: user_path(@user.uuid), text: t('users.show.delete') %> diff --git a/config/locales/auctions.en.yml b/config/locales/auctions.en.yml index 89406fa16..9391adc59 100644 --- a/config/locales/auctions.en.yml +++ b/config/locales/auctions.en.yml @@ -136,8 +136,8 @@ en: You are banned from participating in .ee domain auctions for the following domain(s): %{domain_names}. banned_completely: | You are banned from participating in .ee domain auctions due to multiple overdue - invoices until %{valid_until}. According to clause 7.3.3 of the .ee Auction Environment User Agreement, a user may access the service if they have fewer than %{ban_number_of_strikes} unpaid invoices on their account. + invoices until %{valid_until}. According to clause 8.3.3 of the .ee Auction Environment User Agreement, a user may access the service if they have fewer than %{ban_number_of_strikes} unpaid invoices on their account. violation_message_html: >- - Number of current violations: + Number of current violations: %{violations_count}. - According to clause 7.3.3 of the .ee Auction Environment User Agreement, a user may access the service if they have fewer than %{ban_number_of_strikes} unpaid invoices on their account. + According to clause 8.3.3 of the .ee Auction Environment User Agreement, a user may access the service if they have fewer than %{ban_number_of_strikes} unpaid invoices on their account. diff --git a/config/locales/auctions.et.yml b/config/locales/auctions.et.yml index 91c457738..7599838fb 100644 --- a/config/locales/auctions.et.yml +++ b/config/locales/auctions.et.yml @@ -148,7 +148,7 @@ et: Sul on keelatud osaleda järgneva(te)l domeeninime(de) oksjoni(te)l: %{domain_names}. banned_completely: | Korduvalt tasumata jäetud arvete tõttu on Su õigus osaleda .ee domeenioksjonitel - peatatud kuni %{valid_until}. Tulenevalt Kasutajalepingu punktist 7.3.3. saab Teenuse kasutaja oksjonikeskkonna teenuseid kasutada, kui maksmata arveid on vähem kui %{ban_number_of_strikes}. + peatatud kuni %{valid_until}. Tulenevalt Kasutajalepingu punktist 8.3.3. saab Teenuse kasutaja oksjonikeskkonna teenuseid kasutada, kui maksmata arveid on vähem kui %{ban_number_of_strikes}. violation_message_html: >- - Oksjoni reeglite rikkumisi: - %{violations_count}. Tulenevalt Kasutajalepingu punktist 7.3.3. saab Teenuse kasutaja oksjonikeskkonna teenuseid kasutada juhul kui maksmata arveid on vähem kui %{ban_number_of_strikes}. + Oksjoni reeglite rikkumisi: + %{violations_count}. Tulenevalt Kasutajalepingu punktist 8.3.3. saab Teenuse kasutaja oksjonikeskkonna teenuseid kasutada juhul kui maksmata arveid on vähem kui %{ban_number_of_strikes}. diff --git a/config/locales/en.yml b/config/locales/en.yml index 7edf79ad1..2db552ff5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,5 +1,7 @@ en: unauthorized: + banned: + message: The operation is not allowed due to active violation of auction user agreement. message: You are not authorized to access this page. manage: user: "You are not authorized to manage profile. You are banned from participating in .ee domain auctions due to multiple overdue invoices." diff --git a/config/locales/et.yml b/config/locales/et.yml index 10f3871fb..232476c98 100644 --- a/config/locales/et.yml +++ b/config/locales/et.yml @@ -3,6 +3,8 @@ et: unauthorized: message: Teil ei ole õigust selle lehe kasutamiseks! + banned: + message: "Operatsioon ei ole lubatud kehtiva oksjoni kasutajalepingu rikkumise tõttu" manage: user: "Teil ei ole õigust oma profiili muuta. Teil on keelatud osaleda .ee domeenioksjonitel korduvalt tasumata arvete tõttu." new: "Uus" diff --git a/config/locales/mailers/common_mailer.en.yml b/config/locales/mailers/common_mailer.en.yml index e715a4517..8744469ac 100644 --- a/config/locales/mailers/common_mailer.en.yml +++ b/config/locales/mailers/common_mailer.en.yml @@ -5,3 +5,5 @@ en:

Respectfully,
Estonian Internet Foundation

+ + more_information_html: To participate in the auctions, go to https://auction.internet.ee. diff --git a/config/locales/mailers/common_mailer.et.yml b/config/locales/mailers/common_mailer.et.yml index ea53e73a6..b79477997 100644 --- a/config/locales/mailers/common_mailer.et.yml +++ b/config/locales/mailers/common_mailer.et.yml @@ -7,3 +7,5 @@ et:

Lugupidamisega
Eesti Interneti Sihtasutus

+ + more_information_html: Oksjonitel osalemiseks minge aadressile https://oksjon.internet.ee. From e41c4b46101fbef5239825e308892fed508f7bb2 Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Fri, 28 Jun 2024 13:31:38 +0300 Subject: [PATCH 4/6] fixed footer links render and tests --- .../common/footer/component.html.erb | 8 +- app/components/common/footer/component.rb | 22 ++-- test/components/common/footer_test.rb | 112 +++++++++--------- test/integration/invoices_test.rb | 7 +- 4 files changed, 77 insertions(+), 72 deletions(-) diff --git a/app/components/common/footer/component.html.erb b/app/components/common/footer/component.html.erb index 10406cb89..67f83a345 100644 --- a/app/components/common/footer/component.html.erb +++ b/app/components/common/footer/component.html.erb @@ -44,7 +44,7 @@ <%= t('common.footer.faq')%> <%= t('common.footer.statistics')%>
- <%= t('common.footer.dispute_committee') %> + <%= t('common.footer.dispute_committee') %>
@@ -57,11 +57,11 @@

- <%= t('common.footer.list_of_accredited_registrars')%>
+ <%= t('common.footer.list_of_accredited_registrars')%>
- <%= t('common.footer.terms_and_conditions_for_registrars') %> + <%= t('common.footer.terms_and_conditions_for_registrars') %>
- <%= t('common.footer.partner_programme') %> + <%= t('common.footer.partner_programme') %>
diff --git a/app/components/common/footer/component.rb b/app/components/common/footer/component.rb index 6d7c6439d..3481db72d 100644 --- a/app/components/common/footer/component.rb +++ b/app/components/common/footer/component.rb @@ -1,23 +1,27 @@ module Common module Footer class Component < ApplicationViewComponent - def footer_link(key) = I18n.locale == :et ? et_footer_links[key] : en_footer_links[key] + def footer_link(key) = if I18n.locale == :et + et_footer_links[key] + else + en_footer_links[key] + end def et_footer_links { - "dispute_committee": 'https://www.internet.ee/domeenivaidlused/domeenivaidluste-komisjon', - "list_of_accredited_registrars": 'https://www.internet.ee/registripidaja/akrediteeritud-registripidajad', - "terms_and_conditions_for_registrars": 'https://www.internet.ee/registripidaja/kuidas-saada-ee-akrediteeritud-registripidajaks', - "partner_programme": 'https://www.internet.ee/registripidaja/kuidas-saada-ee-elite-partneriks' + dispute_committee: 'https://www.internet.ee/domeenivaidlused/domeenivaidluste-komisjon', + list_of_accredited_registrars: 'https://www.internet.ee/registripidaja/akrediteeritud-registripidajad', + terms_and_conditions_for_registrars: 'https://www.internet.ee/registripidaja/kuidas-saada-ee-akrediteeritud-registripidajaks', + partner_programme: 'https://www.internet.ee/registripidaja/kuidas-saada-ee-elite-partneriks' } end def en_footer_links { - "dispute_committee": 'https://www.internet.ee/domain-disputes/domain-disputes-committee', - "list_of_accredited_registrars": 'https://www.internet.ee/registrar-portal/accredited-registrars', - "terms_and_conditions_for_registrars": 'https://www.internet.ee/registrar-portal/terms-and-conditions-for-becoming-a-registrar', - "partner_programme": 'https://www.internet.ee/registrar-portal/become-a-ee-elite-partner' + dispute_committee: 'https://www.internet.ee/domain-disputes/domain-disputes-committee', + list_of_accredited_registrars: 'https://www.internet.ee/registrar-portal/accredited-registrars', + terms_and_conditions_for_registrars: 'https://www.internet.ee/registrar-portal/terms-and-conditions-for-becoming-a-registrar', + partner_programme: 'https://www.internet.ee/registrar-portal/become-a-ee-elite-partner' } end end diff --git a/test/components/common/footer_test.rb b/test/components/common/footer_test.rb index e50676007..eda559d00 100644 --- a/test/components/common/footer_test.rb +++ b/test/components/common/footer_test.rb @@ -4,60 +4,62 @@ class FooterTest < ViewComponent::TestCase include ViewComponent::SystemTestHelpers def test_render_component - render_inline(Common::Footer::Component.new) - - expected_copyrigth_text = I18n.t('common.footer.copyright') - assert_selector '.c-footer__highlight__title div', text: expected_copyrigth_text - - expected_address = Setting.find_by(code: 'invoice_issuer_address').retrieve - expected_reg_no = Setting.find_by(code: 'invoice_issuer_reg_no').retrieve - expected_reg_no_text = I18n.t('reg_no') + ": " + expected_reg_no - - assert_selector '.c-footer__highlight__info', text: expected_address - assert_selector '.c-footer__highlight__info', text: expected_reg_no_text - - email = Setting.find_by(code: 'contact_organization_email').retrieve - phone = Setting.find_by(code: 'organization_phone').retrieve - - assert_selector '.c-footer__highlight__contact a[href^="mailto:"]', text: email - - assert_selector '.c-footer__highlight__contact a[href^="tel:"]', text: phone - - assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.help_and_info') - assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.domain_regulation') - assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.faq') - assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.statistics') - assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.dispute_committee') - - assert_selector '.c-footer__row__col.s-footer-col a[href="https://internet.ee/domains/ee-domain-regulation"]' - assert_selector '.c-footer__row__col.s-footer-col a[href="https://internet.ee/help-and-info/faq"]' - assert_selector '.c-footer__row__col.s-footer-col a[href="https://internet.ee/help-and-info/statistics"]' - assert_selector '.c-footer__row__col.s-footer-col a[href="https://internet.ee/domain-disputes/domain-disuptes-committee"]' - - assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.registrars') - assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.list_of_accredited_registrars') - assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.terms_and_conditions_for_registrars') - assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.partner_programme') - - assert_selector '.c-footer__row__col.s-footer-col a[href="https://internet.ee/registrars/accredited-registrars"]' - assert_selector '.c-footer__row__col.s-footer-col a[href="https://internet.ee/registrars/terms-and-conditions-for-becoming-a-registrar"]' - assert_selector '.c-footer__row__col.s-footer-col a[href="https://internet.ee/registrars/become-a-ee-elite-partner"]' - - assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.estonian_internet') - assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.contact_us') - assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.management') - assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.registrars_working_group') - - assert_selector '.c-footer__row__col.s-footer-col a[href="https://www.internet.ee/eif"]' - assert_selector '.c-footer__row__col.s-footer-col a[href="https://www.internet.ee/eif/tasks-and-management"]' - assert_selector '.c-footer__row__col.s-footer-col a[href="https://www.internet.ee/eif/registrars-workgroup"]' - - assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.social_media') - - assert_selector 'a.c-socials__link[href="https://www.facebook.com/EE-748656818569233/"]' - assert_selector 'a.c-socials__link[href="https://twitter.com/Eesti_Internet"]' - # assert_selector 'a.c-socials__link[href=""]', text: '' - assert_selector 'a.c-socials__link[href="https://www.youtube.com/channel/UC7nTB6zIwZYPFarlbKuEPRA"]' - assert_selector 'a.c-socials__link[href="https://internet.ee/index.rss"]' + I18n.with_locale(:en) do + render_inline(Common::Footer::Component.new) + + expected_copyrigth_text = I18n.t('common.footer.copyright') + assert_selector '.c-footer__highlight__title div', text: expected_copyrigth_text + + expected_address = Setting.find_by(code: 'invoice_issuer_address').retrieve + expected_reg_no = Setting.find_by(code: 'invoice_issuer_reg_no').retrieve + expected_reg_no_text = I18n.t('reg_no') + ": " + expected_reg_no + + assert_selector '.c-footer__highlight__info', text: expected_address + assert_selector '.c-footer__highlight__info', text: expected_reg_no_text + + email = Setting.find_by(code: 'contact_organization_email').retrieve + phone = Setting.find_by(code: 'organization_phone').retrieve + + assert_selector '.c-footer__highlight__contact a[href^="mailto:"]', text: email + + assert_selector '.c-footer__highlight__contact a[href^="tel:"]', text: phone + + assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.help_and_info') + assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.domain_regulation') + assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.faq') + assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.statistics') + assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.dispute_committee') + + assert_selector '.c-footer__row__col.s-footer-col a[href="https://internet.ee/domains/ee-domain-regulation"]' + assert_selector '.c-footer__row__col.s-footer-col a[href="https://internet.ee/help-and-info/faq"]' + assert_selector '.c-footer__row__col.s-footer-col a[href="https://internet.ee/help-and-info/statistics"]' + assert_selector '.c-footer__row__col.s-footer-col a[href="https://www.internet.ee/domain-disputes/domain-disputes-committee"]' + + assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.registrars') + assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.list_of_accredited_registrars') + assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.terms_and_conditions_for_registrars') + assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.partner_programme') + + assert_selector '.c-footer__row__col.s-footer-col a[href="https://www.internet.ee/registrar-portal/accredited-registrars"]' + assert_selector '.c-footer__row__col.s-footer-col a[href="https://www.internet.ee/registrar-portal/terms-and-conditions-for-becoming-a-registrar"]' + assert_selector '.c-footer__row__col.s-footer-col a[href="https://www.internet.ee/registrar-portal/become-a-ee-elite-partner"]' + + assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.estonian_internet') + assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.contact_us') + assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.management') + assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.registrars_working_group') + + assert_selector '.c-footer__row__col.s-footer-col a[href="https://www.internet.ee/eif"]' + assert_selector '.c-footer__row__col.s-footer-col a[href="https://www.internet.ee/eif/tasks-and-management"]' + assert_selector '.c-footer__row__col.s-footer-col a[href="https://www.internet.ee/eif/registrars-workgroup"]' + + assert_selector '.c-footer__row__col.s-footer-col', text: I18n.t('common.footer.social_media') + + assert_selector 'a.c-socials__link[href="https://www.facebook.com/EE-748656818569233/"]' + assert_selector 'a.c-socials__link[href="https://twitter.com/Eesti_Internet"]' + # assert_selector 'a.c-socials__link[href=""]', text: '' + assert_selector 'a.c-socials__link[href="https://www.youtube.com/channel/UC7nTB6zIwZYPFarlbKuEPRA"]' + assert_selector 'a.c-socials__link[href="https://internet.ee/index.rss"]' + end end end \ No newline at end of file diff --git a/test/integration/invoices_test.rb b/test/integration/invoices_test.rb index c811a8271..fcb01b888 100644 --- a/test/integration/invoices_test.rb +++ b/test/integration/invoices_test.rb @@ -38,8 +38,8 @@ def test_banned_user_cannot_pay_deposit post english_offer_deposit_auction_path(uuid: @auction.uuid, current_user: @user), params: nil, headers: {} - # assert_redirected_to root_path - assert_equal 'You are not authorized to access this page.', flash[:alert].to_s + + assert_equal I18n.t('unauthorized.banned.message'), flash[:alert].to_s end def test_completely_banned_user_cannot_pay_any_deposit @@ -54,9 +54,8 @@ def test_completely_banned_user_cannot_pay_any_deposit post english_offer_deposit_auction_path(uuid: @auction.uuid, current_user: @user), params: nil, headers: {} - # assert_redirected_to root_path - assert_equal 'You are not authorized to access this page.', flash[:alert].to_s + assert_equal I18n.t('unauthorized.banned.message'), flash[:alert].to_s end def test_should_send_e_invoice From 285cb82ed8e48892e12beb22c59dba4671b9dd29 Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Mon, 1 Jul 2024 10:45:39 +0300 Subject: [PATCH 5/6] move set offer to top level, fixed separator depends of locale --- app/components/application_view_component.rb | 4 +++- app/components/modals/change_offer/component.rb | 3 ++- app/controllers/concerns/english_offers/offerable.rb | 2 +- app/controllers/english_offers_controller.rb | 3 ++- .../controllers/autotax_counter_controller.js | 11 +++++++++-- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/components/application_view_component.rb b/app/components/application_view_component.rb index 9098eadc3..b8ebb63cc 100644 --- a/app/components/application_view_component.rb +++ b/app/components/application_view_component.rb @@ -36,6 +36,8 @@ def main_app end def price_format(price) - "#{number_to_currency(price, unit: '', separator: '.', delimiter: '', precision: 2)} €" + separator = I18n.locale == :en ? '.' : ',' + + "#{number_to_currency(price, unit: '', separator:, delimiter: '', precision: 2)} €" end end diff --git a/app/components/modals/change_offer/component.rb b/app/components/modals/change_offer/component.rb index 0a252935c..85c656a98 100644 --- a/app/components/modals/change_offer/component.rb +++ b/app/components/modals/change_offer/component.rb @@ -126,7 +126,8 @@ def offer_form_properties controller: 'autotax-counter', autotax_counter_template_value: t('english_offers.price_with_wat_template'), autotax_counter_tax_value: "#{offer.billing_profile.present? ? offer.billing_profile.vat_rate : 0.0}", - autotax_counter_defaulttemplate_value: t('offers.price_is_without_vat') + autotax_counter_defaulttemplate_value: t('offers.price_is_without_vat'), + autotax_counter_separator_value: I18n.locale == :en ? '.' : ',', } } end diff --git a/app/controllers/concerns/english_offers/offerable.rb b/app/controllers/concerns/english_offers/offerable.rb index f1dc6e388..331ae1082 100644 --- a/app/controllers/concerns/english_offers/offerable.rb +++ b/app/controllers/concerns/english_offers/offerable.rb @@ -30,7 +30,7 @@ def inform_about_invalid_bid_amount end def find_or_initialize_autobidder - @autobider = current_user&.autobiders&.find_or_initialize_by(domain_name: @auction.domain_name) + @autobider = current_user&.autobiders&.find_or_initialize_by(domain_name: @offer.auction.domain_name) end # rubocop:disable Metrics/AbcSize diff --git a/app/controllers/english_offers_controller.rb b/app/controllers/english_offers_controller.rb index a8e87137b..0e17a2cbf 100644 --- a/app/controllers/english_offers_controller.rb +++ b/app/controllers/english_offers_controller.rb @@ -1,12 +1,13 @@ # frozen_string_literal: true class EnglishOffersController < ApplicationController + before_action :set_offer, only: %i[show edit update] + include BeforeRender include Offerable protect_from_forgery with: :null_session # order is important - before_action :set_offer, only: %i[show edit update] include EnglishOffers::Offerable include RecaptchaValidatable diff --git a/app/javascript/controllers/autotax_counter_controller.js b/app/javascript/controllers/autotax_counter_controller.js index 317fb0776..8b2b570c3 100644 --- a/app/javascript/controllers/autotax_counter_controller.js +++ b/app/javascript/controllers/autotax_counter_controller.js @@ -6,7 +6,8 @@ export default class extends Controller { tax: String, template: String, defaulttemplate: String, - priceElement: { default: 'input[name="offer[price]"]', type: String } + priceElement: { default: 'input[name="offer[price]"]', type: String }, + separator: { default: '.', type: String } } connect() { @@ -22,7 +23,13 @@ export default class extends Controller { const taxAmount = value * tax; const totalAmount = value + taxAmount; - result.innerHTML = this.templateValue.replace('{price}', totalAmount.toFixed(2)).replace('{tax}', (tax * 100.0).toFixed(2)); + let tem = this.templateValue.replace('{price}', totalAmount.toFixed(2)).replace('{tax}', (tax * 100.0).toFixed(2)); + + if (this.separatorValue !== '.') { + tem = tem.replace('.', ',').replace('.', ','); + } + + result.innerHTML = tem } else { result.innerHTML = this.defaulttemplateValue; } From 318b4883f26685297ecaabc95fa2a111f0156dfb Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Tue, 2 Jul 2024 14:49:54 +0300 Subject: [PATCH 6/6] set comma everywhere, fix localize close message --- app/components/application_view_component.rb | 4 +--- app/components/modals/change_offer/component.rb | 1 - app/components/modals/deposit/component.html.erb | 2 +- app/javascript/controllers/autotax_counter_controller.js | 7 +------ 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/app/components/application_view_component.rb b/app/components/application_view_component.rb index b8ebb63cc..3817011d6 100644 --- a/app/components/application_view_component.rb +++ b/app/components/application_view_component.rb @@ -36,8 +36,6 @@ def main_app end def price_format(price) - separator = I18n.locale == :en ? '.' : ',' - - "#{number_to_currency(price, unit: '', separator:, delimiter: '', precision: 2)} €" + "#{number_to_currency(price, unit: '', separator: ',', delimiter: '', precision: 2)} €" end end diff --git a/app/components/modals/change_offer/component.rb b/app/components/modals/change_offer/component.rb index 85c656a98..360a6d23a 100644 --- a/app/components/modals/change_offer/component.rb +++ b/app/components/modals/change_offer/component.rb @@ -127,7 +127,6 @@ def offer_form_properties autotax_counter_template_value: t('english_offers.price_with_wat_template'), autotax_counter_tax_value: "#{offer.billing_profile.present? ? offer.billing_profile.vat_rate : 0.0}", autotax_counter_defaulttemplate_value: t('offers.price_is_without_vat'), - autotax_counter_separator_value: I18n.locale == :en ? '.' : ',', } } end diff --git a/app/components/modals/deposit/component.html.erb b/app/components/modals/deposit/component.html.erb index 9b18845ac..d45bc7053 100644 --- a/app/components/modals/deposit/component.html.erb +++ b/app/components/modals/deposit/component.html.erb @@ -38,7 +38,7 @@
<%= t('offers.new.deposit_description_html', deposit: price_format(@auction.deposit)) %> - +
diff --git a/app/javascript/controllers/autotax_counter_controller.js b/app/javascript/controllers/autotax_counter_controller.js index 8b2b570c3..ca76adddd 100644 --- a/app/javascript/controllers/autotax_counter_controller.js +++ b/app/javascript/controllers/autotax_counter_controller.js @@ -7,7 +7,6 @@ export default class extends Controller { template: String, defaulttemplate: String, priceElement: { default: 'input[name="offer[price]"]', type: String }, - separator: { default: '.', type: String } } connect() { @@ -24,11 +23,7 @@ export default class extends Controller { const totalAmount = value + taxAmount; let tem = this.templateValue.replace('{price}', totalAmount.toFixed(2)).replace('{tax}', (tax * 100.0).toFixed(2)); - - if (this.separatorValue !== '.') { - tem = tem.replace('.', ',').replace('.', ','); - } - + tem = tem.replace('.', ',').replace('.', ','); result.innerHTML = tem } else { result.innerHTML = this.defaulttemplateValue;