Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Commit

Permalink
add new take badge
Browse files Browse the repository at this point in the history
  • Loading branch information
kalashnikovisme committed Apr 9, 2014
1 parent 56eaa90 commit bf33cba
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
10 changes: 5 additions & 5 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 7 additions & 3 deletions app/views/web/registrator/users/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
4 changes: 2 additions & 2 deletions config/locales/activerecord.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ ru:
user:
badge_state:
states:
not_get: Не выдан
get: Выдан
not_get_badge: Не выдан
get_badge: Выдан
events:
give_badge: Выдать бейдж
take_badge_back: Забрать бейдж
Expand Down

0 comments on commit bf33cba

Please sign in to comment.