From a7d59b4d7184eae4e20a8a1a8116e453923c3b5f Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Fri, 30 Nov 2018 17:03:25 +0500 Subject: [PATCH] Add confirmation button --- app/views/passports/show.html.erb | 38 ++++++++++++++++++++++++++++++ config/locales/activerecord/en.yml | 5 ++++ config/locales/activerecord/ru.yml | 5 ++++ 3 files changed, 48 insertions(+) diff --git a/app/views/passports/show.html.erb b/app/views/passports/show.html.erb index e34b906..200a25f 100644 --- a/app/views/passports/show.html.erb +++ b/app/views/passports/show.html.erb @@ -10,6 +10,30 @@
+
+ <%= Passport.human_attribute_name :confirmed %> +
+
+ <% if @passport.confirmed? %> + + <%= Passport.human_attribute_name 'confirmed.true' %> + + <% else %> + + <%= Passport.human_attribute_name 'confirmed.false' %> + + <% end %> + + +
+ <%= Passport.human_attribute_name :passport_confirmations_count %> +
+
+ <%= @passport.passport_confirmations.count %> + / + <%= Passport::REQUIRED_CONFIRMATIONS %> +
+
<%= Passport.human_attribute_name :surname %>
@@ -87,6 +111,20 @@ <%= localize @passport.date_of_issue %>
+ + <% if user_signed_in? %> + <% if @passport.passport_confirmations.where(user: current_user).exists? %> + + <% else %> + <%= link_to 'Confirm', + passport_passport_confirmations_path(@passport), + method: :post, + role: :button, + class: 'btn btn-primary' %> + <% end %> + <% end %>
diff --git a/config/locales/activerecord/en.yml b/config/locales/activerecord/en.yml index 7bb4c8b..b4e6c6e 100644 --- a/config/locales/activerecord/en.yml +++ b/config/locales/activerecord/en.yml @@ -25,6 +25,8 @@ en: comment: Comment passport: id: ID + confirmed: Confirmed? + passport_confirmations_count: Confirmations count image: Image surname: Surname given_name: Given names @@ -37,6 +39,9 @@ en: issued_by: Issued by unit_code: Unit code date_of_issue: Date of issue + passport/confirmed: + 'true': Confirmed + 'false': Unconfirmed passport/sex: male: Male female: Female diff --git a/config/locales/activerecord/ru.yml b/config/locales/activerecord/ru.yml index 63fb98d..2fce68a 100644 --- a/config/locales/activerecord/ru.yml +++ b/config/locales/activerecord/ru.yml @@ -25,6 +25,8 @@ ru: comment: Комментарий passport: id: ID + confirmed: Подтверждён? + passport_confirmations_count: Количество подтверждений image: Изображение surname: Фамилия given_name: Имя @@ -37,6 +39,9 @@ ru: issued_by: Кем выдан unit_code: Код подразделения date_of_issue: Дата выдачи + passport/confirmed: + 'true': Подтверждён + 'false': Не подтверждён passport/sex: male: Мужской female: Женский