hackathon_manager 0.6.5 → 0.6.6

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
  SHA1:
3
- metadata.gz: a51352083b4efe91bc92f29569313d4cae2411f1
4
- data.tar.gz: 67421b84d0631aa2df21a2bf15dc83f7ba60c43c
3
+ metadata.gz: a1312a0a0c5155bb9132a067c2623c6676895220
4
+ data.tar.gz: f7f4e0060ed5bba8aafd8aa791da7ebdcc2c077c
5
5
  SHA512:
6
- metadata.gz: 7c63629d0dd82b8c317f929e320b73884fe947a3ca517a36f9d68b4e817b490225ad8cbe170056633b75b867bf03da186478c15b834ee6ee58c571d90fe9b925
7
- data.tar.gz: 4725f0733645437c9eaf9496f95de77ecbcd87cec56f880620fae19d49a187e9fd99d6d5f297dbd30242849e5694b6b94f7c53a64c718d98e247b61dce17e13e
6
+ metadata.gz: 86e4b003525db2df0e8a8856223b93981ce18e1436b57818e15b4c28626d6550dba5591b88b1aefbfd5bad412c9cd0f88e7bb3db69a8249ea9c32d75835806ea
7
+ data.tar.gz: dc52ba638ec4902a8cf658571be4857c6d026a4a11e0544eed07ecffb85977502867b719e5a033631286ef32dbed065f245018a754bab0615889066f030c28a1
@@ -41,4 +41,8 @@ module HackathonManagerHelper
41
41
  Rails.application.assets_manifest.assets[logical_path].present?
42
42
  end
43
43
  end
44
+
45
+ def collection_or_text(model_value, collection)
46
+ model_value.blank? || collection.include?(model_value) ? collection : nil
47
+ end
44
48
  end
@@ -101,11 +101,17 @@ class Message < ApplicationRecord
101
101
  end
102
102
  # No flatten needed here since each map returns a single option
103
103
 
104
+ blazer_recipients = Blazer::Query.select(:id, :name).map do |query|
105
+ option.call("blazer::#{query.id}", query)
106
+ end
107
+ # No flatten needed here since each map returns a single option
108
+
104
109
  # Combine all recipients. push(*recipients) is the most efficient,
105
110
  # as it doesn't create a new array each time (concat() does)
106
111
  recipients = POSSIBLE_SIMPLE_RECIPIENTS.invert.to_a
107
112
  recipients.push(*bus_list_recipients)
108
113
  recipients.push(*school_recipients)
114
+ recipients.push(*blazer_recipients)
109
115
 
110
116
  # Add current recipients if not included
111
117
  self.recipients.each do |recipient|
@@ -31,6 +31,9 @@ class MessageRecipientQuery
31
31
  when "school"
32
32
  model ||= School.find_by_id(id)
33
33
  model_name = "School"
34
+ when "blazer"
35
+ model ||= Blazer::Query.find_by_id(id)
36
+ model_name = "Blazer Query"
34
37
  else
35
38
  raise "Unknown recipient query type: #{type.inspect} (in message recipient query: #{query.inspect}"
36
39
  end
@@ -61,6 +64,8 @@ class MessageRecipientQuery
61
64
  "Bus List: #{model.name} (applied/not accepted)"
62
65
  when "school"
63
66
  "Confirmed or Accepted: #{model.name}"
67
+ when "blazer"
68
+ "Blazer Query: #{model.name}"
64
69
  else
65
70
  raise "Unknown recipient query type: #{recipient_query.type.inspect} (in message recipient query: #{r.inspect}"
66
71
  end
@@ -67,6 +67,30 @@ class Questionnaire < ApplicationRecord
67
67
  "rsvp_denied" => "RSVP Denied"
68
68
  }.freeze
69
69
 
70
+ # From My MLH's dropdown list.
71
+ # Should *not* validate against this list in case My MLH changes their options,
72
+ # as this would cause errors until a manual gem update
73
+ POSSIBLE_GENDERS = [
74
+ "Female",
75
+ "Male",
76
+ "Non-Binary",
77
+ "I prefer not to say",
78
+ "Other"
79
+ ].freeze
80
+
81
+ # From My MLH's dropdown list.
82
+ # Should *not* validate against this list in case My MLH changes their options,
83
+ # as this would cause errors until a manual gem update
84
+ POSSIBLE_LEVELS_OF_STUDY = [
85
+ "Elementary / Middle School / Primary School",
86
+ "High School / Secondary School",
87
+ "University (Undergraduate)",
88
+ "University (Master's / Doctoral)",
89
+ "Vocational / Code School",
90
+ "Not Currently a Student",
91
+ "Other"
92
+ ].freeze
93
+
70
94
  validates_inclusion_of :experience, in: POSSIBLE_EXPERIENCES
71
95
  validates_inclusion_of :interest, in: POSSIBLE_INTERESTS
72
96
  # validates_inclusion_of :school_id, :in => School.select(:id)
@@ -16,9 +16,9 @@
16
16
  = f.input :date_of_birth, start_year: Date.today.year - 5, end_year: Date.today.year - 90, order: [:month, :day, :year], input_html: { "data-validate" => "presence" }
17
17
 
18
18
  = f.input :school_id, as: :school_selection, input_html: { "data-validate" => "presence" }
19
- = f.input :level_of_study, input_html: { "data-validate" => "presence" }, wrapper_html: { class: 'input--half' }
19
+ = f.input :level_of_study, collection: collection_or_text(@questionnaire.level_of_study, Questionnaire::POSSIBLE_LEVELS_OF_STUDY), include_blank: "(select one...)", input_html: { "data-validate" => "presence" }, wrapper_html: { class: 'input--half' }
20
20
  = f.input :major, input_html: { "data-validate" => "presence" }, wrapper_html: { class: 'input--half' }
21
- = f.input :gender, input_html: { "data-validate" => "presence" }, wrapper_html: { class: 'input--half' }
21
+ = f.input :gender, collection: collection_or_text(@questionnaire.gender, Questionnaire::POSSIBLE_GENDERS), include_blank: "(select one...)", input_html: { "data-validate" => "presence" }, wrapper_html: { class: 'input--half' }
22
22
  = f.input :shirt_size, as: :select, collection: Questionnaire::POSSIBLE_SHIRT_SIZES, include_blank: "(select one...)", input_html: { "data-validate" => "presence" }, wrapper_html: { class: 'input--half' }
23
23
  = f.input :dietary_restrictions, as: :text, placeholder: "Allergies, medical assistance, etc.", label: "Health restrictions", wrapper_html: { class: 'input--half' }
24
24
  = f.input :special_needs, as: :text, placeholder: "Any special needs or requests", label: "Special needs", wrapper_html: { class: 'input--half' }
@@ -74,6 +74,11 @@ class BulkMessageWorker
74
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
75
  when "school"
76
76
  Questionnaire.where("school_id = ? AND (acc_status = 'rsvp_confirmed' OR acc_status = 'accepted')", model.id).pluck(:user_id)
77
+ when "blazer"
78
+ result = Blazer::RunStatement.new.perform(Blazer.data_sources[model.data_source], model.statement)
79
+ user_id_column = result.columns.index("user_id")
80
+ raise "Blazer query is missing required \"user_id\" column" unless user_id_column.present?
81
+ result.rows.map { |row| row[user_id_column] }
77
82
  else
78
83
  raise "Unknown recipient query type: #{recipient_query.type.inspect} (in message recipient query: #{type.inspect}"
79
84
  end
@@ -1,3 +1,3 @@
1
1
  module HackathonManager
2
- VERSION = '0.6.5'.freeze
2
+ VERSION = '0.6.6'.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.6.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Olivera
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-01 00:00:00.000000000 Z
11
+ date: 2018-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails