This repository was archived by the owner on Dec 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathuser.rb
More file actions
125 lines (109 loc) · 3.65 KB
/
user.rb
File metadata and controls
125 lines (109 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
ActiveAdmin.register User do
permit_params :id, :email, :zip, :latitude, :longitude, :created_at, :updated_at,
:encrypted_password, :reset_password_token, :reset_password_sent_at,
:remember_created_at, :sign_in_count, :current_sign_in_at, :last_sign_in_at,
:current_sign_in_ip, :last_sign_in_ip, :mentor, :first_name,
:last_name, :timezone, :bio, :verified, :state, :address_1, :address_2, :city,
:username, :volunteer, :branch_of_service, :years_of_service, :pay_grade,
:military_occupational_specialty, :github, :twitter, :linkedin, :employment_status,
:education, :military_status, :company_role, :company_name, :education_level, :interests
scope :all
scope :mentors
scope :verified
## Action Items
## https://activeadmin.info/8-custom-actions.html#action-items
action_item :community_leader, only: :show do
link_to 'Community Leader', community_leader_admin_user_path(user), method: :put if !user.has_tag?(User::LEADER)
end
action_item :non_community_leader, only: :show do
link_to 'Remove Community Leader', non_community_leader_admin_user_path(user), method: :put if user.has_tag?(User::LEADER)
end
## Member Actions
## https://activeadmin.info/8-custom-actions.html#member-actions
member_action :community_leader, method: :put do
user = User.find(params[:id])
user.tag_list.add User::LEADER
user.save!
redirect_to admin_user_path(user), notice: "#{user.first_name} is now a #{User::LEADER}!"
end
member_action :non_community_leader, method: :put do
user = User.find(params[:id])
user.tag_list.remove User::LEADER
user.save!
redirect_to admin_user_path(user), notice: "#{user.first_name} is no longer a #{User::LEADER}"
end
## Index as a Table
## https://activeadmin.info/3-index-pages/index-as-table.html
index do
selectable_column
column :id
column :email
column :zip
column :created_at
column :sign_in_count
column :last_sign_in_at
column :mentor
column :first_name
column :last_name
column :timezone
column :bio
column :verified
column :state
column :city
column :username
column :volunteer
column :branch_of_service
column :years_of_service
column :pay_grade
column :military_occupational_specialty
column :github
column :twitter
column :linkedin
column :employment_status
column :education
column :military_status
column :company_role
column :company_name
column :education_level
column :interests
actions
end
preserve_default_filters!
filter :state, as: :select, collection: -> { User.uniq_states }
remove_filter :tags
remove_filter :base_tags
remove_filter :taggings
remove_filter :tag_taggings
filter :with_tags, label: 'Tagged With', as: :select, collection: -> { User.all_tag_names }
form do |f|
f.inputs do
f.input :email
f.input :zip
f.input :mentor
f.input :first_name
f.input :last_name
f.input :timezone
f.input :bio
f.input :verified
f.input :state
f.input :city
f.input :username
f.input :volunteer
f.input :branch_of_service
f.input :years_of_service
f.input :military_status, as: :select, collection: User::MILITARY_STATUSES.map { |status| [status, status].compact }.reject(&:empty?), include_blank: true
f.input :pay_grade
f.input :military_occupational_specialty
f.input :github
f.input :twitter
f.input :linkedin
f.input :employment_status
f.input :education
f.input :company_role
f.input :company_name
f.input :education_level
f.input :interests
end
f.actions
end
end