hackathon_manager 0.12.2 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/assets/javascripts/hackathon_manager/manage/lib/setupDataTables.js +2 -1
  4. data/app/controllers/manage/admins_controller.rb +2 -3
  5. data/app/controllers/manage/application_controller.rb +6 -2
  6. data/app/controllers/manage/configs_controller.rb +1 -1
  7. data/app/controllers/manage/dashboard_controller.rb +1 -1
  8. data/app/controllers/manage/questionnaires_controller.rb +1 -1
  9. data/app/controllers/manage/trackable_events_controller.rb +8 -3
  10. data/app/datatables/admin_datatable.rb +6 -4
  11. data/app/datatables/questionnaire_datatable.rb +2 -2
  12. data/app/mailers/mailer.rb +1 -1
  13. data/app/models/user.rb +12 -1
  14. data/app/views/layouts/manage/_page_title.html.haml +1 -1
  15. data/app/views/layouts/manage/application.html.haml +1 -1
  16. data/app/views/manage/admins/_form.html.haml +1 -1
  17. data/app/views/manage/admins/index.html.haml +2 -1
  18. data/app/views/manage/admins/show.html.haml +10 -6
  19. data/app/views/manage/bus_lists/show.html.haml +5 -7
  20. data/app/views/manage/dashboard/index.html.haml +6 -5
  21. data/app/views/manage/questionnaires/_checkin.html.haml +1 -1
  22. data/app/views/manage/questionnaires/index.html.haml +1 -1
  23. data/app/views/manage/questionnaires/show.html.haml +3 -3
  24. data/app/views/manage/trackable_events/index.html.haml +5 -3
  25. data/app/views/manage/trackable_tags/show.html.haml +1 -1
  26. data/app/workers/bulk_message_worker.rb +2 -2
  27. data/config/locales/en.yml +1 -1
  28. data/config/routes.rb +1 -1
  29. data/db/migrate/20190118204143_add_role_to_users.rb +16 -0
  30. data/lib/hackathon_manager/version.rb +1 -1
  31. data/test/factories/users.rb +3 -4
  32. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 220ec7094ad0a190a71e4064736d8c707558cbd48775941022294f9aa6b4b14f
4
- data.tar.gz: 36170ae1c9b391f39aa44a0abd3aeefec5eed045b3bfd24822114d76e5ee5392
3
+ metadata.gz: ac76ddc635787194b110815a1d4644597c6764de671879e922f6aa16cdb95c4f
4
+ data.tar.gz: 322bfb6e07da66de298b84d5340c27b2955ce4e70b63a612809f66e05d1c973a
5
5
  SHA512:
6
- metadata.gz: 87b23b3213fe9e6be20e4abb2d9649d615dbf48ff01c2a711bd938e4b15f5076f311ee524e5470f46ada7119a3bd952034f2d8b58ba4699cc17b908578a97df9
7
- data.tar.gz: 259d7ca3386713bc78a14d09ff8f0610833d14fd606c3ca36389204be3d9a5681604bdebb1089e9b5f90fa2f988e2ea16608caae2bc41f9f2ec5a3da609d1176
6
+ metadata.gz: 3ebb6b641937dc02641948d780a63a6e4bbd62537883eee58f98d09e3e329ea4d19a5fb77e70a36eb0110c70b2d5e652d56effee3528ccd476fa57190f9b5a83
7
+ data.tar.gz: 839c8439546cffd2efba661f119b1fbdbff1c834944296cdaea6ce12b3427adfccdf37c6c591cc65f5c245fd465e004dd6e578069c281bb90453c7733cacb4e1
data/README.md CHANGED
@@ -35,7 +35,7 @@ Steps to get the basic flow working:
35
35
 
36
36
  2. Once you have at least one user in the system, you can promote them to an admin to access the management interface. Open up a console session with `bin/rails console`:
37
37
  ```ruby
38
- >> User.last.update_attribute(:admin, true)
38
+ >> User.last.update_attribute(:role, :admin)
39
39
  => true
40
40
  ```
41
41
 
@@ -27,7 +27,8 @@ var setupDataTables = function() {
27
27
  columns : [
28
28
  { orderable: true, data: 'id', visible: false },
29
29
  { orderable: true, data: 'email' },
30
- { orderable: true, data: 'admin_limited_access' }
30
+ { orderable: true, data: 'role' },
31
+ { orderable: true, data: 'created_at' }
31
32
  ]
32
33
  });
33
34
 
@@ -4,7 +4,7 @@ class Manage::AdminsController < Manage::ApplicationController
4
4
  respond_to :html, :json
5
5
 
6
6
  def index
7
- respond_with(:manage, User.where(admin: true))
7
+ respond_with(:manage, User.where(role: [:admin, :admin_limited_access, :event_tracking]))
8
8
  end
9
9
 
10
10
  def datatable
@@ -26,7 +26,6 @@ class Manage::AdminsController < Manage::ApplicationController
26
26
  def create
27
27
  @user = ::User.new(user_params.merge(password: Devise.friendly_token.first(10)))
28
28
  if @user.save
29
- @user.update_attribute(:admin, true)
30
29
  @user.send_reset_password_instructions
31
30
  end
32
31
  respond_with(:manage, @user, location: manage_admins_path)
@@ -46,7 +45,7 @@ class Manage::AdminsController < Manage::ApplicationController
46
45
 
47
46
  def user_params
48
47
  params.require(:user).permit(
49
- :email, :password, :password_confirmation, :remember_me, :admin_limited_access
48
+ :email, :password, :password_confirmation, :remember_me, :role
50
49
  )
51
50
  end
52
51
 
@@ -1,15 +1,19 @@
1
1
  class Manage::ApplicationController < ApplicationController
2
2
  before_action :logged_in
3
+ before_action :require_admin_or_limited_admin
3
4
  before_action :limit_admin_access, only: ["edit", "update", "new", "create", "destroy", "convert_to_admin", "deliver", "merge", "perform_merge", "toggle_bus_captain", "duplicate", "update_acc_status", "send_update_email", "live_preview"]
4
5
  skip_before_action :verify_authenticity_token, if: :json_request?
5
6
 
6
7
  def logged_in
7
8
  authenticate_user!
8
- return redirect_to root_path unless current_user.try(:admin?)
9
+ end
10
+
11
+ def require_admin_or_limited_admin
12
+ return redirect_to root_path unless current_user.try(:admin?) || current_user.try(:admin_limited_access?)
9
13
  end
10
14
 
11
15
  def limit_admin_access
12
- redirect_to url_for(controller: controller_name, action: :index) if current_user.admin_limited_access
16
+ redirect_to url_for(controller: controller_name, action: :index) unless current_user.try(:admin?)
13
17
  end
14
18
 
15
19
  def json_request?
@@ -10,6 +10,6 @@ class Manage::ConfigsController < Manage::ApplicationController
10
10
  private
11
11
 
12
12
  def limit_access_admin
13
- redirect_to manage_root_path if current_user.admin_limited_access
13
+ redirect_to manage_root_path unless current_user.admin?
14
14
  end
15
15
  end
@@ -32,7 +32,7 @@ class Manage::DashboardController < Manage::ApplicationController
32
32
  total_stats_data = {}
33
33
  total_count = Questionnaire.count
34
34
  rit_count = Questionnaire.where("school_id = \"2304\"").count
35
- total_stats_data["Non-Applied Users"] = User.where(admin: false).count - total_count
35
+ total_stats_data["Non-Applied Users"] = User.without_questionnaire.count
36
36
  total_stats_data["Non-RIT Applications"] = total_count - rit_count
37
37
  total_stats_data["RIT Applications"] = rit_count
38
38
  render json: total_stats_data
@@ -86,7 +86,7 @@ class Manage::QuestionnairesController < Manage::ApplicationController
86
86
  def convert_to_admin
87
87
  user = @questionnaire.user
88
88
  @questionnaire.destroy
89
- user.update_attributes(admin: true, admin_limited_access: true)
89
+ user.update_attributes(role: :admin)
90
90
  redirect_to edit_manage_admin_path(user)
91
91
  end
92
92
 
@@ -9,7 +9,7 @@ class Manage::TrackableEventsController < Manage::ApplicationController
9
9
  @trackable_events = TrackableEvent.all
10
10
  @params = {}
11
11
  if params[:trackable_event]
12
- @params = params.require(:trackable_event).permit(:user_id, :band_id).reject{|_, v| v.blank?}
12
+ @params = params.require(:trackable_event).permit(:user_id, :band_id, :trackable_tag_id).reject { |_, v| v.blank? }
13
13
  @trackable_events = @trackable_events.where(@params)
14
14
  end
15
15
  respond_with(:manage, @trackable_events)
@@ -78,13 +78,18 @@ class Manage::TrackableEventsController < Manage::ApplicationController
78
78
  params.require(:trackable_event).permit(:band_id, :trackable_tag_id)
79
79
  end
80
80
 
81
+ # Permit everyone but regular users to access this controller
82
+ def require_admin_or_limited_admin
83
+ redirect_to root_path if current_user.try(:user?)
84
+ end
85
+
81
86
  # Permit limited-access admins (overrides Manage::ApplicationController#limit_admin_access)
82
87
  def limit_admin_access
83
88
  end
84
89
 
85
- # If the admin is limited, scope changes only to those they created
90
+ # If the user isn't a full admin, scope changes only to those they created
86
91
  def scope_limited_admin_access
87
- return if !current_user.admin_limited_access || @trackable_event.blank? || @trackable_event.user.blank?
92
+ return if current_user.admin? || @trackable_event.blank? || @trackable_event.user.blank?
88
93
  redirect_to manage_trackable_events_path, notice: 'You may not view events you did not create.' if @trackable_event.user != current_user
89
94
  end
90
95
  end
@@ -1,11 +1,12 @@
1
1
  class AdminDatatable < AjaxDatatablesRails::Base
2
- def_delegators :@view, :link_to, :manage_admin_path, :bold
2
+ def_delegators :@view, :link_to, :manage_admin_path, :bold, :display_datetime
3
3
 
4
4
  def view_columns
5
5
  @view_columns ||= {
6
6
  id: { source: 'User.id' },
7
7
  email: { source: 'User.email' },
8
- admin_limited_access: { source: 'User.admin_limited_access', searchable: false }
8
+ role: { source: 'User.role', searchable: false },
9
+ created_at: { source: 'User.created_at', searchable: false }
9
10
  }
10
11
  end
11
12
 
@@ -16,14 +17,15 @@ class AdminDatatable < AjaxDatatablesRails::Base
16
17
  {
17
18
  id: record.id,
18
19
  email: link_to(bold(record.email), manage_admin_path(record)),
19
- admin_limited_access: record.admin_limited_access ? 'Limited Access' : 'Full Access'
20
+ role: record.role.titleize,
21
+ created_at: display_datetime(record.created_at)
20
22
  }
21
23
  end
22
24
  end
23
25
 
24
26
  # rubocop:disable Naming/AccessorMethodName
25
27
  def get_raw_records
26
- User.where(admin: true)
28
+ User.where(role: [:admin, :admin_limited_access, :event_tracking])
27
29
  end
28
30
  # rubocop:enable Naming/AccessorMethodName
29
31
  end
@@ -10,7 +10,7 @@ class QuestionnaireDatatable < AjaxDatatablesRails::Base
10
10
  phone: { source: 'Questionnaire.phone' },
11
11
  gender: { source: 'Questionnaire.gender' },
12
12
  date_of_birth: { source: 'Questionnaire.date_of_birth', searchable: false },
13
- admin: { source: 'User.admin', cond: :eq, searchable: false },
13
+ role: { source: 'User.role', cond: :eq, searchable: false },
14
14
  acc_status: { source: 'Questionnaire.acc_status', searchable: true },
15
15
  checked_in: { source: 'Questionnaire.checked_in_at', searchable: false },
16
16
  school: { source: 'School.name' },
@@ -34,7 +34,7 @@ class QuestionnaireDatatable < AjaxDatatablesRails::Base
34
34
  def data
35
35
  records.map do |record|
36
36
  {
37
- bulk: current_user.admin_limited_access ? '' : "<input type=\"checkbox\" data-bulk-row-edit=\"#{record.id}\">".html_safe,
37
+ bulk: current_user.admin? ? "<input type=\"checkbox\" data-bulk-row-edit=\"#{record.id}\">".html_safe : '',
38
38
  link: link_to('<i class="fa fa-search"></i>'.html_safe, manage_questionnaire_path(record)),
39
39
  note: note(record),
40
40
  id: record.id,
@@ -16,7 +16,7 @@ class Mailer < ApplicationMailer
16
16
 
17
17
  def incomplete_reminder_email(user_id)
18
18
  @user = User.find_by_id(user_id)
19
- return if @user.blank? || @user.admin || @user.questionnaire || Time.now.to_date > Rails.configuration.hackathon['last_day_to_apply']
19
+ return if @user.blank? || @user.admin? || @user.questionnaire || Time.now.to_date > Rails.configuration.hackathon['last_day_to_apply']
20
20
  mail(
21
21
  to: @user.email,
22
22
  subject: "Incomplete Application"
data/app/models/user.rb CHANGED
@@ -13,6 +13,13 @@ class User < ApplicationRecord
13
13
 
14
14
  after_create :queue_reminder_email
15
15
 
16
+ enum role: { user: 0, event_tracking: 1, admin_limited_access: 2, admin: 3 }
17
+ after_initialize :set_default_role, if: :new_record?
18
+
19
+ def set_default_role
20
+ self.role ||= :user
21
+ end
22
+
16
23
  def active_for_authentication?
17
24
  true
18
25
  end
@@ -56,7 +63,11 @@ class User < ApplicationRecord
56
63
  end
57
64
  end
58
65
 
66
+ def self.non_admins
67
+ User.where.not(role: :admin).where.not(role: :admin_limited_access)
68
+ end
69
+
59
70
  def self.without_questionnaire
60
- User.left_outer_joins(:questionnaire).where(questionnaires: { id: nil }, admin: false)
71
+ non_admins.left_outer_joins(:questionnaire).where(questionnaires: { id: nil })
61
72
  end
62
73
  end
@@ -4,5 +4,5 @@
4
4
  - if defined?(subtitle) && subtitle.present?
5
5
  %small.text-muted= subtitle
6
6
 
7
- - unless current_user.admin_limited_access?
7
+ - if current_user.try(:admin?)
8
8
  = yield
@@ -59,7 +59,7 @@
59
59
  = active_link_to manage_trackable_tags_path, class: "nav-link" do
60
60
  .fa.fa-tag.fa-fw.icon-space-r-half
61
61
  Trackable Tags
62
- - unless current_user.admin_limited_access?
62
+ - if current_user.admin?
63
63
  %h6.sidebar-heading.d-flex.justify-content-between.align-items-center.px-3.mt-4.mb-1.text-muted
64
64
  %span Advanced
65
65
  %ul.nav.flex-column.mb-2
@@ -11,7 +11,7 @@
11
11
 
12
12
  .form-inputs
13
13
  = f.input :email, input_html: { "data-validate" => "presence" }, required: true
14
- = f.input :admin_limited_access, label: "Limited Access"
14
+ = f.input :role, collection: User.roles.to_a.collect{|c| [c[0].titleize, c[0]]}, include_blank: false
15
15
 
16
16
  .center
17
17
  = f.button :submit, value: ( @user.new_record? ? 'Create' : 'Save' ), class: 'btn-primary'
@@ -7,5 +7,6 @@
7
7
  %tr
8
8
  %th ID
9
9
  %th Email
10
- %th Access Level
10
+ %th Role
11
+ %th Registered on
11
12
  %tbody
@@ -1,13 +1,17 @@
1
1
  = render "layouts/manage/page_title", title: @user.email do
2
- - unless current_user.admin_limited_access
3
- .btn-group
4
- = link_to 'Edit', edit_manage_admin_path(@user), class: 'btn btn-sm btn-outline-secondary'
5
- = link_to 'Delete', manage_admin_path(@user), method: :delete, data: { confirm: "Are you sure? #{@user.email} will be permanently deleted. This action is irreversible." }, class: 'btn btn-sm btn-outline-secondary'
2
+ .btn-group
3
+ = link_to 'Edit', edit_manage_admin_path(@user), class: 'btn btn-sm btn-outline-secondary'
4
+ = link_to 'Delete', manage_admin_path(@user), method: :delete, data: { confirm: "Are you sure? #{@user.email} will be permanently deleted. This action is irreversible." }, class: 'btn btn-sm btn-outline-secondary'
6
5
 
7
6
  %div
8
7
  %p
9
8
  %b Email address:
10
9
  = @user.email
10
+
11
+ %p
12
+ %b Role:
13
+ = @user.role.titleize
14
+
11
15
  %p
12
- %b Access level:
13
- = @user.admin_limited_access ? "Limited Access" : "Full Access"
16
+ %b Registered:
17
+ = display_datetime(@user.created_at)
@@ -9,8 +9,6 @@
9
9
  .dropdown-menu.dropdown-menu-right{"aria-labelledby" => "title-actions"}
10
10
  = link_to 'Send Bus Notes Update', send_update_email_manage_bus_list_path(@bus_list), method: :patch, data: { confirm: "Are you sure? All passengers for \"#{@bus_list.name}\" will be immediatley emailed the current bus notes." }, class: 'dropdown-item'
11
11
  = link_to 'Create message (signed up passengers)', new_manage_message_path(type: 'bulk', recipients: ["bus-list::#{@bus_list.id}"]), class: 'dropdown-item'
12
- = link_to 'Create message (eligible, not signed up)', new_manage_message_path(type: 'bulk', recipients: ["bus-list::#{@bus_list.id}"]), class: 'dropdown-item'
13
- = link_to 'Create message (applied/not yet accepted)', new_manage_message_path(type: 'bulk', recipients: ["bus-list::#{@bus_list.id}"]), class: 'dropdown-item'
14
12
 
15
13
  .row
16
14
  .col-lg-6
@@ -71,14 +69,14 @@
71
69
  %td= link_to p.school.name, manage_school_path(p.school)
72
70
  %td= p.boarded_bus? ? '<span class="text-success">Yes</span>'.html_safe : 'No'
73
71
  %td= p.checked_in? ? '<span class="text-success">Yes</span>'.html_safe : 'No'
74
- - if current_user.admin_limited_access
75
- %td= p.is_bus_captain? ? "Yes" : "No"
76
- - else
72
+ - if current_user.admin?
77
73
  %td
78
74
  - if p.is_bus_captain?
79
75
  = link_to "Remove", toggle_bus_captain_manage_bus_list_path(@bus_list, questionnaire_id: p.id, bus_captain: '0'), method: 'post', class: 'text-danger'
80
76
  - else
81
77
  = link_to "Promote", toggle_bus_captain_manage_bus_list_path(@bus_list, questionnaire_id: p.id, bus_captain: '1'), method: 'post', data: { confirm: "Are you sure you want to make #{p.full_name} a bus captain? They will receive a confirmation email." }
78
+ - else
79
+ %td= p.is_bus_captain? ? "Yes" : "No"
82
80
 
83
81
  - if @bus_list.needs_bus_captain
84
82
  %h4.mt-4.pb-2 Possible Bus Captains
@@ -91,7 +89,7 @@
91
89
  %th Email
92
90
  %th Phone Number
93
91
  %th School
94
- - unless current_user.admin_limited_access
92
+ - if current_user.admin?
95
93
  %th Actions
96
94
  %tbody
97
95
  - @bus_list.passengers.select { |q| q.bus_captain_interest }.each do |p|
@@ -102,7 +100,7 @@
102
100
  %td= p.email
103
101
  %td= phone_link_to p.phone
104
102
  %td= link_to p.school.name, manage_school_path(p.school)
105
- - unless current_user.admin_limited_access
103
+ - if current_user.admin?
106
104
  %td
107
105
  - if p.is_bus_captain?
108
106
  = link_to "Remove Bus Captain", toggle_bus_captain_manage_bus_list_path(@bus_list, questionnaire_id: p.id, bus_captain: '0'), method: 'post', class: 'text-danger'
@@ -11,11 +11,12 @@
11
11
 
12
12
  = render "layouts/manage/page_title", title: "Dashboard"
13
13
 
14
- .row
15
- .col
16
- #map
17
- :javascript
18
- $('#map').initMap();
14
+ -#
15
+ .row
16
+ .col
17
+ #map
18
+ :javascript
19
+ $('#map').initMap();
19
20
 
20
21
  .row
21
22
  .col-7
@@ -8,7 +8,7 @@
8
8
  %small
9
9
  = @questionnaire.acc_status_author_id ? @questionnaire.acc_status_author.email : "(no author)"
10
10
  = @questionnaire.acc_status_date ? display_datetime(@questionnaire.acc_status_date, in_sentence: true) : "(no date)"
11
- - unless current_user.admin_limited_access?
11
+ - if current_user.admin?
12
12
  = bs_vertical_simple_form @questionnaire, url: url_for(action: "update_acc_status", controller: "questionnaires") do |f|
13
13
  = f.input :acc_status, as: :select, collection: Questionnaire::POSSIBLE_ACC_STATUS.invert, include_blank: false, label: "Acceptance Status:", hint: "Updating this status may trigger an automatic email to the applicant - see #{link_to('messages', manage_messages_path(anchor: 'triggered-email-overview'))} for details.".html_safe
14
14
  = f.button :submit, value: "Update Status", class: 'btn-primary'
@@ -6,7 +6,7 @@
6
6
  %thead
7
7
  %tr
8
8
  %th
9
- - unless current_user.admin_limited_access?
9
+ - if current_user.admin?
10
10
  %input{ type: "checkbox", name: "select_allc", value: "1", data: { bulk_row_select: "" } }
11
11
  %th
12
12
  %th
@@ -9,14 +9,14 @@
9
9
  = render 'check_in_badge'
10
10
 
11
11
  .btn-group{role: "group"}
12
- - unless current_user.admin_limited_access
12
+ - if current_user.admin?
13
13
  = link_to 'Edit', edit_manage_questionnaire_path(@questionnaire), class: 'btn btn-sm btn-outline-secondary'
14
- - unless current_user.admin_limited_access
14
+ - if current_user.admin?
15
15
  .btn-group{role: "group"}
16
16
  %button.btn.btn-sm.btn-outline-secondary.dropdown-toggle#title-actions{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", type: "button"}
17
17
  .fa.fa-cog
18
18
  .dropdown-menu.dropdown-menu-right{"aria-labelledby" => "title-actions"}
19
- = link_to 'Convert to Admin', convert_to_admin_manage_questionnaire_path(@questionnaire), method: :patch, data: { confirm: "Are you sure? The questionnaire for \"#{@questionnaire.full_name}\" will be permanently erased. This action is irreversible." }, class: 'dropdown-item'
19
+ = link_to 'Convert to Admin', convert_to_admin_manage_questionnaire_path(@questionnaire), method: :patch, data: { confirm: "Are you sure? The questionnaire for \"#{@questionnaire.full_name}\" will be permanently erased, and \"#{@questionnaire.email}\" will become an admin. This action is irreversible." }, class: 'dropdown-item'
20
20
 
21
21
  = render 'overview'
22
22
 
@@ -2,10 +2,12 @@
2
2
 
3
3
  = bs_horizontal_simple_form_for :trackable_event, method: 'get' do |f|
4
4
  .form-row
5
- .col-auto
6
- = f.input :user_id, collection: User.where(admin: true), label_method: :email, value_method: :id, include_blank: '(show all)', required: false, selected: @params['user_id']
7
5
  .col-auto
8
6
  = f.input :band_id, as: :string, required: false, input_html: { value: @params['band_id'] }, placeholder: '(show all)'
7
+ .col-auto
8
+ = f.input :trackable_tag_id, collection: TrackableTag.all, label_method: :name, value_method: :id, include_blank: '(show all)', required: false, selected: @params['trackable_tag_id']
9
+ .col-auto
10
+ = f.input :user_id, collection: User.where.not(role: :user), label_method: :email, value_method: :id, include_blank: '(show all)', required: false, selected: @params['user_id']
9
11
  .col-auto
10
12
  = f.button :submit, 'Filter', class: 'btn btn-primary'
11
13
 
@@ -26,7 +28,7 @@
26
28
  %td= trackable_event.trackable_tag.name
27
29
  %td= trackable_event.user.email
28
30
  %td= link_to 'Show', manage_trackable_event_path(trackable_event)
29
- - unless current_user.admin_limited_access && current_user != trackable_event.user
31
+ - if current_user.admin? || current_user == trackable_event.user
30
32
  %td= link_to 'Edit', edit_manage_trackable_event_path(trackable_event)
31
33
  %td= link_to 'Destroy', manage_trackable_event_path(trackable_event), method: :delete, data: { confirm: 'Are you sure?' }
32
34
  - else
@@ -27,5 +27,5 @@
27
27
  %td= trackable_event.band_id
28
28
  %td= trackable_event.user.email
29
29
  %td
30
- - unless current_user.admin_limited_access && current_user != trackable_event.user
30
+ - if current_user.admin? || current_user == trackable_event.user
31
31
  = link_to 'Edit', edit_manage_trackable_event_path(trackable_event)
@@ -27,9 +27,9 @@ class BulkMessageWorker
27
27
  def self.user_ids(type)
28
28
  case type
29
29
  when "all"
30
- User.where(admin: false).pluck(:id)
30
+ User.non_admins.pluck(:id)
31
31
  when "incomplete"
32
- User.where(admin: false).pluck(:id) - Questionnaire.pluck(:user_id)
32
+ User.non_admins.pluck(:id) - Questionnaire.pluck(:user_id)
33
33
  when "complete"
34
34
  Questionnaire.pluck(:user_id)
35
35
  when "accepted"
@@ -39,7 +39,7 @@ en:
39
39
  If many people have already RSVP'd, consider sending a message out to this bus list asking for interest as well.
40
40
  notes: Notes are shared with applicants. Supports Markdown and HTML.
41
41
  user:
42
- admin_limited_access: Limited access prevents the admin from adding, modifying, or deleting any records. Modifications through the check-in process are allowed.
42
+ role: Limited access prevents the admin from adding, modifying, or deleting any records; modifications through the check-in process are allowed. Event tracking limits to only event tracking.
43
43
  message:
44
44
  type: Bulk emails are sent once, manually. Automated emails are sent upon a desired trigger/event.
45
45
  name: A friendly name to recognize this email. Applicants won't see this.
data/config/routes.rb CHANGED
@@ -8,7 +8,7 @@ Rails.application.routes.draw do
8
8
 
9
9
  mount MailPreview => 'mail_view' if Rails.env.development?
10
10
 
11
- authenticate :user, ->(u) { u.admin? && !u.admin_limited_access? } do
11
+ authenticate :user, ->(u) { u.admin? } do
12
12
  mount Sidekiq::Web => '/sidekiq'
13
13
  mount Blazer::Engine, at: "blazer"
14
14
  end
@@ -0,0 +1,16 @@
1
+ class AddRoleToUsers < ActiveRecord::Migration[5.2]
2
+ def up
3
+ add_column :users, :role, :integer, default: 0
4
+
5
+ User.where(admin: true).each do |user|
6
+ user.update_attribute(:role, :admin)
7
+ end
8
+
9
+ User.where(admin_limited_access: true).each do |user|
10
+ user.update_attribute(:role, :admin_limited_access)
11
+ end
12
+
13
+ remove_column :users, :admin, :boolean
14
+ remove_column :users, :admin_limited_access, :boolean
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module HackathonManager
2
- VERSION = '0.12.2'.freeze
2
+ VERSION = '0.13.0'.freeze
3
3
  end
@@ -4,21 +4,20 @@ FactoryBot.define do
4
4
  "foo#{n}@example.com"
5
5
  end
6
6
  password { "password" }
7
+ role { :user }
7
8
 
8
9
  factory :admin do
9
10
  sequence :email do |n|
10
11
  "admin#{n}@example.com"
11
12
  end
12
- admin { true }
13
- admin_limited_access { false }
13
+ role { :admin }
14
14
  end
15
15
 
16
16
  factory :limited_access_admin do
17
17
  sequence :email do |n|
18
18
  "limited_admin#{n}@example.com"
19
19
  end
20
- admin { true }
21
- admin_limited_access { true }
20
+ role { :admin_limited_access }
22
21
  end
23
22
  end
24
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hackathon_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.2
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Olivera
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-17 00:00:00.000000000 Z
11
+ date: 2019-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -707,6 +707,7 @@ files:
707
707
  - db/migrate/20190107232955_create_trackable_tags.rb
708
708
  - db/migrate/20190107233210_create_trackable_events.rb
709
709
  - db/migrate/20190113231044_refactor_bus_lists.rb
710
+ - db/migrate/20190118204143_add_role_to_users.rb
710
711
  - db/schools.csv
711
712
  - db/seed_messages/questionnaire--accepted.md
712
713
  - db/seed_messages/questionnaire--denied.md