diff --git a/app/models/user.rb b/app/models/user.rb index 3cb84bda..fc62bb0a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -101,17 +101,17 @@ class User < ActiveRecord::Base end end - state_machine :badge_state, initial: :not_get do - state :not_get - state :get + state_machine :badge_state, initial: :not_get_badge do + state :not_get_badge + state :get_badge event :give_badge do - transition not_get: :get + transition not_get_badge: :get_badge end #0_0 may be ;) event :take_badge_back do - transition get: :not_get + transition get_badge: :not_get_badge end end diff --git a/app/views/web/registrator/users/index.html.haml b/app/views/web/registrator/users/index.html.haml index 30a7a19f..26508cef 100644 --- a/app/views/web/registrator/users/index.html.haml +++ b/app/views/web/registrator/users/index.html.haml @@ -44,10 +44,14 @@ %td= user.first_name %td= user.email %td= user.city - %td= user.pay_state - %td= user.badge_state + %td= I18n.t("activerecord.state_machines.user.pay_state.states.#{user.pay_state}") + %td= I18n.t("activerecord.state_machines.user.badge_state.states.#{user.badge_state}") %td=l user.created_at - %td= link_to t('.give_badge'), give_badge_registrator_user_path(user), method: :put, class: 'btn btn-success btn-mini' + - if user.not_get_badge? + %td= link_to t('.give_badge'), give_badge_registrator_user_path(user), method: :put, class: 'btn btn-success btn-mini' + - else + %td= link_to t('.take_badge_back'), take_badge_back_registrator_user_path(user), method: :put, class: 'btn btn-success btn-mini' + = paginate @users -#= link_to t('.new_user'), new_admin_user_path, :class => 'btn btn-primary' diff --git a/config/locales/activerecord.yml b/config/locales/activerecord.yml index 4fb38a46..41e7044b 100644 --- a/config/locales/activerecord.yml +++ b/config/locales/activerecord.yml @@ -4,8 +4,8 @@ ru: user: badge_state: states: - not_get: Не выдан - get: Выдан + not_get_badge: Не выдан + get_badge: Выдан events: give_badge: Выдать бейдж take_badge_back: Забрать бейдж