hackathon_manager 0.11.2 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4fb8ba46c7be1367d9b0e0930a225d74b1d0f8dd70cbb3ea05ac3a2328e5aeb1
4
- data.tar.gz: 7b3a5ab676f8324535a66b6adddb1fcb5cecff9b611036d281353522a1c14777
3
+ metadata.gz: 175ea3d064207e89723ec62b6728adc537d29f195c2dff8fa203042e2dfe32ea
4
+ data.tar.gz: a32a72ffe843713f7313c8dec519e63114b74341c96863f924b6f1d8bbdce903
5
5
  SHA512:
6
- metadata.gz: c8f0707e22cf530077a49d854106f8a70e90c30d05e4c128b84c82d00ed97f174c37ea5e7dc6c256365bb0a54ba39114edc462d61ae08af12e7e19798323f7ce
7
- data.tar.gz: 58438d3dd05085940d2f337fd8d54981c93bfd7b5c2ee1315b7c99b2f7b036b28bf292ac6d2c111b3e8f3b21f7605f03a3a6cab80d51d0b54f967132dbb2177f
6
+ metadata.gz: 3f12381081f623c54fcb89ede14b0518b7bf5f1ff143587cd7bbfc95c57fab04e9541aedf62ffae3fd244cb1d24f6402a53a0d91ca4d1295c5606e6f8676f208
7
+ data.tar.gz: 676fb9d13963f49b11b9b1015c387ace9176259149c03f2348fb76bf7112f239dcc0a29571492ab799ac5d0fd5268aa74ce11bd24c25345194977472d9af523b
@@ -51,8 +51,7 @@ var setupDataTables = function() {
51
51
  { orderable: true, data: 'name' },
52
52
  { orderable: true, data: 'city' },
53
53
  { orderable: true, data: 'state' },
54
- { orderable: true, data: 'questionnaire_count' },
55
- { orderable: false, data: 'bus_list' }
54
+ { orderable: true, data: 'questionnaire_count' }
56
55
  ]
57
56
  });
58
57
 
@@ -180,6 +180,9 @@ input[type=checkbox]
180
180
  .radio
181
181
  min-width: 170px
182
182
 
183
+ .radio_buttons_vertical .radio
184
+ min-width: 100%
185
+
183
186
  // checkbox
184
187
  input[type=radio]
185
188
  @include appearance(none)
@@ -20,7 +20,7 @@ class BusListsController < ApplicationController
20
20
  boarded_bus = params[:questionnaire][:boarded_bus].to_s
21
21
  questionnaire = Questionnaire.find_by_id(params[:questionnaire][:id])
22
22
 
23
- if !['true', 'false'].include?(boarded_bus) || questionnaire.blank? || !questionnaire.eligible_for_a_bus?
23
+ if !['true', 'false'].include?(boarded_bus) || questionnaire.blank?
24
24
  head :bad_request
25
25
  return
26
26
  end
@@ -32,9 +32,8 @@ class Manage::BusListsController < Manage::ApplicationController
32
32
  end
33
33
 
34
34
  def destroy
35
- School.where(bus_list_id: @bus_list.id).each do |school|
36
- school.questionnaires.where(riding_bus: true).map { |q| q.update_attribute(:riding_bus, false) }
37
- school.update_attribute(:bus_list_id, nil)
35
+ Questionnaire.where(bus_list_id: @bus_list.id).each do |questionnaire|
36
+ questionnaire.update_attribute(:bus_list_id, nil)
38
37
  end
39
38
  @bus_list.destroy
40
39
  respond_with(:manage, @bus_list)
@@ -46,7 +46,7 @@ class Manage::DashboardController < Manage::ApplicationController
46
46
 
47
47
  def schools_confirmed_data
48
48
  schools = Questionnaire.joins(:school).group('schools.name').where("acc_status = 'rsvp_confirmed'").order("schools.name ASC").count
49
- schools_riding = Questionnaire.joins(:school).group('schools.name').where("acc_status = 'rsvp_confirmed' AND riding_bus AND schools.bus_list_id").count
49
+ schools_riding = Questionnaire.joins(:school).group('schools.name').where("acc_status = 'rsvp_confirmed' AND bus_list_id").count
50
50
  schools = schools.map do |name, count|
51
51
  bus_count_row = schools_riding.select { |school_bus_name, _| school_bus_name == name }
52
52
  bus_count = bus_count_row ? bus_count_row[name] || 0 : 0
@@ -146,7 +146,7 @@ class Manage::QuestionnairesController < Manage::ApplicationController
146
146
  :date_of_birth, :interest, :school_id, :school_name, :major, :level_of_study,
147
147
  :shirt_size, :dietary_restrictions, :special_needs, :international,
148
148
  :portfolio_url, :vcs_url, :agreement_accepted, :bus_captain_interest,
149
- :riding_bus, :phone, :can_share_info, :code_of_conduct_accepted,
149
+ :phone, :can_share_info, :code_of_conduct_accepted,
150
150
  :travel_not_from_school, :travel_location, :data_sharing_accepted,
151
151
  :graduation_year, :race_ethnicity, :resume, :delete_resume, :why_attend,
152
152
  :is_bus_captain
@@ -78,7 +78,7 @@ class Manage::SchoolsController < Manage::ApplicationController
78
78
 
79
79
  def school_params
80
80
  params.require(:school).permit(
81
- :name, :address, :city, :state, :bus_list_id
81
+ :name, :address, :city, :state
82
82
  )
83
83
  end
84
84
 
@@ -125,7 +125,7 @@ class QuestionnairesController < ApplicationController
125
125
  :date_of_birth, :interest, :school_id, :school_name, :major, :level_of_study,
126
126
  :shirt_size, :dietary_restrictions, :special_needs, :international,
127
127
  :portfolio_url, :vcs_url, :agreement_accepted, :bus_captain_interest,
128
- :riding_bus, :phone, :can_share_info, :code_of_conduct_accepted,
128
+ :phone, :can_share_info, :code_of_conduct_accepted,
129
129
  :travel_not_from_school, :travel_location, :data_sharing_accepted,
130
130
  :graduation_year, :race_ethnicity, :resume, :delete_resume, :why_attend
131
131
  )
@@ -20,8 +20,8 @@ class RsvpsController < ApplicationController
20
20
  @questionnaire.acc_status_author_id = current_user.id
21
21
  @questionnaire.acc_status_date = Time.now
22
22
  if @questionnaire.save
23
- flash[:notice] = "Thank you for confirming your attendance! "
24
- flash[:notice] += @questionnaire.eligible_for_a_bus? ? "See below for additional bus information." : "You're all set to attend."
23
+ flash[:notice] = "Thank you for confirming your attendance! You're all set to attend."
24
+ flash[:notice] += " See below for additional bus information." if BusList.any?
25
25
  else
26
26
  flash[:notice] = rsvp_error_notice
27
27
  end
@@ -59,15 +59,14 @@ class RsvpsController < ApplicationController
59
59
  @questionnaire.acc_status_date = Time.now if @questionnaire.acc_status != params[:questionnaire][:acc_status]
60
60
  @questionnaire.acc_status = params[:questionnaire][:acc_status]
61
61
  @questionnaire.acc_status_author_id = current_user.id
62
- if !@questionnaire.riding_bus && params[:questionnaire][:riding_bus] == "true" && @questionnaire.bus_list && @questionnaire.bus_list.full?
63
- flash[:notice] = "Sorry, your bus is full! You may need to arrange other plans for transportation."
64
- @questionnaire.riding_bus = false
65
- @questionnaire.bus_captain_interest = false
66
- elsif !@questionnaire.eligible_for_a_bus?
67
- @questionnaire.riding_bus = false
68
- @questionnaire.bus_captain_interest = false
62
+
63
+ bus_list_id = params[:questionnaire][:bus_list_id].presence
64
+ is_joining_bus = !@questionnaire.bus_list_id && bus_list_id
65
+ bus_list = bus_list_id && BusList.find(bus_list_id)
66
+ if is_joining_bus && bus_list.full?
67
+ flash[:notice] = "Sorry, that bus is full! You may need to arrange other plans for transportation."
69
68
  else
70
- @questionnaire.riding_bus = params[:questionnaire][:riding_bus]
69
+ @questionnaire.bus_list_id = bus_list_id
71
70
  @questionnaire.bus_captain_interest = params[:questionnaire][:bus_captain_interest]
72
71
  end
73
72
 
@@ -78,6 +77,7 @@ class RsvpsController < ApplicationController
78
77
  end
79
78
 
80
79
  flash[:notice] = "Your RSVP has been updated." if flash[:notice].blank?
80
+ flash[:notice] += " See below for additional bus information!" if @questionnaire.bus_list_id?
81
81
 
82
82
  redirect_to rsvp_path
83
83
  end
@@ -1,5 +1,5 @@
1
1
  class SchoolDatatable < AjaxDatatablesRails::Base
2
- def_delegators :@view, :link_to, :manage_school_path, :manage_bus_list_path, :bold
2
+ def_delegators :@view, :link_to, :manage_school_path, :bold
3
3
 
4
4
  def view_columns
5
5
  @view_columns ||= {
@@ -20,8 +20,7 @@ class SchoolDatatable < AjaxDatatablesRails::Base
20
20
  name: link_to(bold(record.name), manage_school_path(record)),
21
21
  city: record.city,
22
22
  state: record.state,
23
- questionnaire_count: record.questionnaire_count,
24
- bus_list: record.bus_list ? link_to(record.bus_list.name, manage_bus_list_path(record.bus_list)) : ''
23
+ questionnaire_count: record.questionnaire_count
25
24
  }
26
25
  end
27
26
  end
@@ -2,7 +2,7 @@ class BusList < ApplicationRecord
2
2
  validates_presence_of :name, :capacity
3
3
  validates_uniqueness_of :name
4
4
 
5
- has_many :schools
5
+ has_many :questionnaires
6
6
 
7
7
  strip_attributes
8
8
 
@@ -11,7 +11,11 @@ class BusList < ApplicationRecord
11
11
  end
12
12
 
13
13
  def passengers
14
- Questionnaire.joins(:school).where("schools.bus_list_id = '#{id}' AND acc_status = 'rsvp_confirmed' AND riding_bus = true").order("schools.name ASC, last_name ASC")
14
+ questionnaires.where("acc_status = 'rsvp_confirmed'").order("last_name ASC")
15
+ end
16
+
17
+ def schools
18
+ passengers.joins(:school).map(&:school).uniq
15
19
  end
16
20
 
17
21
  def checked_in_passengers
@@ -103,9 +103,7 @@ class Message < ApplicationRecord
103
103
  option = ->(query, model) { [MessageRecipientQuery.friendly_name(query, model), query] }
104
104
  bus_list_recipients = BusList.select(:id, :name).map do |bus_list|
105
105
  [
106
- option.call("bus-list::#{bus_list.id}", bus_list),
107
- option.call("bus-list--eligible::#{bus_list.id}", bus_list),
108
- option.call("bus-list--applied::#{bus_list.id}", bus_list)
106
+ option.call("bus-list::#{bus_list.id}", bus_list)
109
107
  ]
110
108
  end
111
109
  bus_list_recipients.flatten!(1) # Required since we have multiple options for each bus list
@@ -25,7 +25,7 @@ class MessageRecipientQuery
25
25
  # Find the backing database model, ensuring the given ID exists for that model.
26
26
  model_name = nil
27
27
  case type
28
- when "bus-list", "bus-list--applied", "bus-list--eligible"
28
+ when "bus-list"
29
29
  model ||= BusList.find_by_id(id)
30
30
  model_name = "Bus List"
31
31
  when "school"
@@ -58,10 +58,6 @@ class MessageRecipientQuery
58
58
  case recipient_query.type
59
59
  when "bus-list"
60
60
  "Bus List: #{model.name} (signed up passengers)"
61
- when "bus-list--eligible"
62
- "Bus List: #{model.name} (eligible, not signed up for bus)"
63
- when "bus-list--applied"
64
- "Bus List: #{model.name} (applied/not yet accepted)"
65
61
  when "school"
66
62
  "Confirmed or Accepted: #{model.name}"
67
63
  when "blazer"
@@ -28,6 +28,7 @@ class Questionnaire < ApplicationRecord
28
28
  validates_format_of :vcs_url, with: %r{((github.com\/\w+\/?)|(bitbucket.org\/\w+\/?))}, allow_blank: true, message: "Must be a GitHub or BitBucket url"
29
29
 
30
30
  belongs_to :school
31
+ belongs_to :bus_list, optional: true
31
32
 
32
33
  strip_attributes
33
34
 
@@ -183,15 +184,6 @@ class Questionnaire < ApplicationRecord
183
184
  ['rsvp_confirmed', 'rsvp_denied'].include? acc_status
184
185
  end
185
186
 
186
- def eligible_for_a_bus?
187
- school.present? && school.bus_list_id?
188
- end
189
-
190
- def bus_list
191
- return unless eligible_for_a_bus?
192
- school.bus_list
193
- end
194
-
195
187
  def message_events
196
188
  return [] unless ENV['SPARKPOST_API_KEY']
197
189
 
data/app/models/school.rb CHANGED
@@ -6,7 +6,6 @@ class School < ApplicationRecord
6
6
  strip_attributes
7
7
 
8
8
  has_many :questionnaires
9
- belongs_to :bus_list, optional: true
10
9
 
11
10
  def full_name
12
11
  out = ""
@@ -26,11 +25,6 @@ class School < ApplicationRecord
26
25
  out
27
26
  end
28
27
 
29
- def bus_list
30
- return unless bus_list_id
31
- BusList.find(bus_list_id)
32
- end
33
-
34
28
  def fips_code
35
29
  Fips.where(city: city, state: state).first
36
30
  end
@@ -1,9 +1,9 @@
1
1
  %p
2
- - accepted = Questionnaire.joins(:school).where("schools.bus_list_id = '#{bus_list.id}' AND acc_status = 'accepted'").count
2
+ - accepted = Questionnaire.joins(:school).where("bus_list_id = '#{bus_list.id}' AND acc_status = 'accepted'").count
3
3
  = pluralize(accepted, 'person has', 'people have')
4
4
  been accepted but not yet RSVP'd.
5
5
 
6
6
  %p
7
- - accepted = Questionnaire.joins(:school).where("schools.bus_list_id = '#{bus_list.id}' AND acc_status = 'rsvp_confirmed' AND riding_bus = false").count
7
+ - accepted = Questionnaire.joins(:school).where("bus_list_id = '#{bus_list.id}' AND acc_status = 'rsvp_confirmed'").count
8
8
  = pluralize(accepted, 'person has', 'people have')
9
9
  RSVP'd as attending but didn't sign up for the bus.
@@ -6,5 +6,5 @@
6
6
  - if current_user.questionnaire.present? && current_user.questionnaire.can_rsvp?
7
7
  = active_link_to 'RSVP', rsvp_path, class: 'account-nav__link', active_class: 'account-nav__link--active'
8
8
  = active_link_to 'Application', questionnaires_path, class: 'account-nav__link', active_class: 'account-nav__link--active'
9
- - if current_user.questionnaire.present? && current_user.questionnaire.eligible_for_a_bus? && current_user.questionnaire.is_bus_captain?
9
+ - if current_user.questionnaire.present? && current_user.questionnaire.bus_list_id && current_user.questionnaire.is_bus_captain?
10
10
  = active_link_to 'Bus Captain'.html_safe, bus_list_path, class: 'account-nav__link', active_class: 'account-nav__link--active'
@@ -30,7 +30,7 @@
30
30
  %br
31
31
  %small.text-muted
32
32
  - accepted = school.questionnaires.where(acc_status: 'accepted').count
33
- - no_bus = school.questionnaires.where(acc_status: 'rsvp_confirmed', riding_bus: false).count
33
+ - no_bus = school.questionnaires.where(acc_status: 'rsvp_confirmed', bus_list_id: nil).count
34
34
  #{accepted} yet to RSVP, #{no_bus} attending but not using bus
35
35
 
36
36
  .col-lg-6
@@ -48,10 +48,8 @@
48
48
  = f.input :travel_not_from_school, label: "I will not be traveling from my school"
49
49
  = f.input :travel_location, input_html: { "data-validate" => "presence", disabled: !travel_state }, wrapper_html: { style: travel_state ? "" : "display: none" }, label: "Travel Location"
50
50
 
51
- = f.input :riding_bus, label: "Riding Bus", disabled: !@questionnaire.eligible_for_a_bus?
52
- = f.input :is_bus_captain, label: "Is Bus Captain", disabled: !@questionnaire.eligible_for_a_bus?
53
- - if !@questionnaire.eligible_for_a_bus?
54
- %p (school not eligible for bus)
51
+ = f.input :bus_list_id, label: "Bus list"
52
+ = f.input :is_bus_captain, label: "Is Bus Captain"
55
53
 
56
54
  %hr
57
55
 
@@ -10,7 +10,6 @@
10
10
  = f.input :address
11
11
  = f.input :city
12
12
  = f.input :state
13
- = f.association :bus_list, include_blank: "(none)"
14
13
 
15
14
  .center
16
15
  = f.button :submit, value: ( @school.new_record? ? 'Create' : 'Save' ), class: 'btn-primary'
@@ -10,5 +10,4 @@
10
10
  %th City
11
11
  %th State
12
12
  %th Count
13
- %th Bus List
14
13
  %tbody
@@ -34,8 +34,6 @@
34
34
  = link_to link, target: '_blank' do
35
35
  Search in Google Maps
36
36
  %span.fa.fa-external-link.icon-space-l-half
37
- %dt.col-md-4 Bus List
38
- %dd.col-md-8= @school.bus_list ? link_to(@school.bus_list.name, manage_bus_list_path(@school.bus_list)) : '(not assigned)'
39
37
 
40
38
  .col-md-6
41
39
  %h4.pb-0 Duplicate Names
@@ -1,65 +1,72 @@
1
1
  - title "RSVP"
2
- .form-container
3
- #disclaimer
4
- %h1.section-title
5
- RSVP
6
- %span.emphasized Preferences
7
- - if @questionnaire.acc_status == "rsvp_confirmed" || @questionnaire.checked_in?
8
- %strong
9
- - if @questionnaire.riding_bus
10
- ALL SET TO ATTEND & RIDE THE BUS!
2
+ = simple_form_for @questionnaire, url: url_for(controller: "rsvps", action: "update"), html: { "data-validate" => "form" } do |f|
3
+ .form-container
4
+ #disclaimer
5
+ %h1.section-title
6
+ RSVP
7
+ %span.emphasized Preferences
8
+ - if @questionnaire.acc_status == "rsvp_confirmed" || @questionnaire.checked_in?
9
+ %strong ALL SET TO ATTEND!
10
+ - if Rails.configuration.hackathon['thanks_for_rsvp']
11
+ %br
12
+ = markdown(Rails.configuration.hackathon['thanks_for_rsvp'])
11
13
  - else
12
- ALL SET TO ATTEND!
13
- - if Rails.configuration.hackathon['thanks_for_rsvp']
14
- %br
15
- = markdown(Rails.configuration.hackathon['thanks_for_rsvp'])
16
- - else
17
- %strong= current_user.questionnaire.verbal_status.upcase
18
- - if @questionnaire.acc_status == "rsvp_denied"
19
- %p Sorry to hear you won't be with us this year.
14
+ %br
15
+ %br
20
16
  - else
21
- %p You've been accepted to #{Rails.configuration.hackathon['name']}!
22
- %p Will you be attending?
23
-
24
- %hr
17
+ %strong= current_user.questionnaire.verbal_status.upcase
18
+ - if @questionnaire.acc_status == "rsvp_denied"
19
+ %p Sorry to hear you won't be with us this year.
20
+ - else
21
+ %p You've been accepted to #{Rails.configuration.hackathon['name']}!
22
+ %p Will you be attending?
25
23
 
26
- = simple_form_for @questionnaire, url: url_for(controller: "rsvps", action: "update"), html: { "data-validate" => "form" } do |f|
27
24
  .form-inputs
28
25
  = f.input :acc_status, as: :radio_buttons, collection: { " Attending!" => "rsvp_confirmed", " Not Attending." => "rsvp_denied" }, label: "Attendance:", required: true
29
26
 
30
27
  .hide-if-not-attending{ style: @questionnaire.acc_status == "rsvp_denied" ? "display: none;" : "" }
31
28
  = f.input :phone, input_html: { "data-validate" => "presence" }, label: "Please verify your phone number:"
32
29
 
33
- .hide-if-not-attending{ style: @questionnaire.acc_status == "rsvp_denied" ? "display: none;" : "" }
34
- - if @questionnaire.eligible_for_a_bus?
35
- - if !@questionnaire.riding_bus && @questionnaire.bus_list.full?
36
- #disclaimer
37
- Aw, shucks. Your school is eligible for a bus, but all the seats are currently taken.
38
- - else
39
- %p
40
- - if @questionnaire.riding_bus && @questionnaire.acc_status != "rsvp_denied"
41
- .fa.fa-check
42
- You're all set to ride the bus.
43
- - if @questionnaire.bus_list.full?
44
- %br
45
- %br
46
- .fa.fa-warning
47
- Your bus is currently full. If you are no longer riding, please update your status so someone else may use it.
48
- - else
49
- Good news: your school is eligible for a bus! Will you be riding?
50
- .form-inputs
51
- = f.input :riding_bus, as: :radio_buttons, collection: { " Yes!" => true, " No thank you." => false }, label: "Riding the bus:", hint: "You MUST sign up here if you wish to ride the bus! IDs will be checked at boarding."
52
- - if @questionnaire.bus_list.needs_bus_captain
53
- = f.input :bus_captain_interest, as: :radio_buttons, collection: { " Yes!" => true, " No thank you." => false }, label: "We're also looking for bus captains from your school. Are you interested?"
30
+ = f.button :submit, value: "Update"
54
31
 
55
- - else
56
- = f.input :riding_bus, as: :hidden, value: false
32
+ - if BusList.any?
33
+ .form-container.hide-if-not-attending{ style: @questionnaire.acc_status == "rsvp_denied" ? "display: none;" : "" }
34
+ #disclaimer
35
+ %h1.section-title
36
+ Bus
37
+ %span.emphasized Sign-up
38
+ - if @questionnaire.acc_status == "rsvp_confirmed" || @questionnaire.checked_in?
39
+ %strong
40
+ - if @questionnaire.bus_list_id
41
+ ALL SET TO RIDE THE BUS!
42
+ - else
43
+ NOT RIDING BUS
44
+
45
+ %br
46
+ %br
47
+
48
+ %p
49
+ We are providing free, sponsored busses. Will you be riding?
50
+ %br
51
+ %em
52
+ %strong You must sign up here if you want to ride.
53
+
54
+ .form-inputs
55
+ - bus_list_options = ([OpenStruct.new({ name: 'Not riding a sponsored bus', id: '' })] + BusList.all.to_a)
56
+ = f.association :bus_list, as: :radio_buttons, collection: bus_list_options, label_method: :name, value_method: :id, label: false, wrapper_html: { class: 'radio_buttons_vertical' }
57
+ - if BusList.where(needs_bus_captain: true).any?
58
+ = f.input :bus_captain_interest, as: :radio_buttons, collection: { " Yes!" => true, " No thank you." => false }, label: "Would you be interested in being a bus captain?"
59
+ %p
60
+ %small Busses will pick up the morning of, arriving in time for opening ceremony. They will depart shortly after closing ceremony, dropping off to the same pick-up locations.
61
+ %p
62
+ %small If you sign up for a bus not stopping at your school, you are responsible for transportation to & from a pick-up location.
57
63
 
58
- .right
59
64
  = f.button :submit, value: "Update"
60
65
  %br
61
- - if @questionnaire.eligible_for_a_bus? && @questionnaire.is_bus_captain?
62
- %p= link_to "Manage Bus List &raquo;".html_safe, bus_list_path
66
+ - if @questionnaire.bus_list_id && @questionnaire.is_bus_captain?
67
+ %p= link_to "Bus Captain Dashboard &raquo;".html_safe, bus_list_path
63
68
 
64
- - if @questionnaire.eligible_for_a_bus?
65
- = render partial: 'bus_list_info', locals: { bus_list: @questionnaire.bus_list }
69
+ - if @questionnaire.bus_list_id
70
+ = render partial: 'bus_list_info', locals: { bus_list: @questionnaire.bus_list }
71
+ - else
72
+ = f.input :bus_list_id, as: :hidden, value: ''
@@ -68,10 +68,6 @@ class BulkMessageWorker
68
68
  case recipient_query.type
69
69
  when "bus-list"
70
70
  model.passengers.pluck(:user_id)
71
- when "bus-list--eligible"
72
- Questionnaire.joins(:school).where("schools.bus_list_id = ? AND riding_bus != 1 AND (acc_status = 'accepted' OR acc_status = 'rsvp_confirmed')", model.id).pluck(:user_id)
73
- when "bus-list--applied"
74
- Questionnaire.joins(:school).where("schools.bus_list_id = ? AND (acc_status != 'accepted' AND acc_status != 'rsvp_confirmed' AND acc_status != 'rsvp_denied')", model.id).pluck(:user_id)
75
71
  when "school"
76
72
  Questionnaire.where("school_id = ? AND (acc_status = 'rsvp_confirmed' OR acc_status = 'accepted')", model.id).pluck(:user_id)
77
73
  when "blazer"
@@ -0,0 +1,35 @@
1
+ class RefactorBusLists < ActiveRecord::Migration[5.2]
2
+ def up
3
+ make_new_change
4
+ BusList.all.each do |bus_list|
5
+ Questionnaire.joins(
6
+ :school
7
+ ).where(
8
+ "schools.bus_list_id = ? AND riding_bus = 1 AND (acc_status = 'accepted' OR acc_status = 'rsvp_confirmed')", bus_list.id
9
+ ).all.each do |q|
10
+ q.update_attribute(:bus_list_id, bus_list.id)
11
+ end
12
+ end
13
+ cleanup_old
14
+ end
15
+
16
+ def down
17
+ revert { cleanup_old }
18
+ BusList.all.each do |bus_list|
19
+ bus_list.passengers.each do |passengers|
20
+ passengers.update_attribute(:riding_bus, true)
21
+ end
22
+ end
23
+ revert { make_new_change }
24
+ end
25
+
26
+ private
27
+
28
+ def make_new_change
29
+ add_reference :questionnaires, :bus_list, type: :integer, foreign_key: true
30
+ end
31
+
32
+ def cleanup_old
33
+ remove_column :schools, :bus_list_id
34
+ end
35
+ end
@@ -1,3 +1,3 @@
1
1
  module HackathonManager
2
- VERSION = '0.11.2'.freeze
2
+ VERSION = '0.12.0'.freeze
3
3
  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.11.2
4
+ version: 0.12.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-15 00:00:00.000000000 Z
11
+ date: 2019-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -706,6 +706,7 @@ files:
706
706
  - db/migrate/20181221195241_enable_pkce.rb
707
707
  - db/migrate/20190107232955_create_trackable_tags.rb
708
708
  - db/migrate/20190107233210_create_trackable_events.rb
709
+ - db/migrate/20190113231044_refactor_bus_lists.rb
709
710
  - db/schools.csv
710
711
  - db/seed_messages/questionnaire--accepted.md
711
712
  - db/seed_messages/questionnaire--denied.md