hackathon_manager 0.6.0 → 0.6.1

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: 7b2b4e0940990bd9d79779dc11df2261481e953a
4
- data.tar.gz: 231e89a71e42dd25ed692d41c2bf285dbee54962
3
+ metadata.gz: 4cc3f7d2686f6f8c6ef43edde9822405515135d4
4
+ data.tar.gz: d56facacbfd9b47a5982219314d21ea0df5911ae
5
5
  SHA512:
6
- metadata.gz: eeb9342f9cd545f46932c0330154888d8cc549f26199b19d5c96f31a47d4503ba801aadf4913d6e2908ff947841ddb39158306aa0eda9b3dca2bdb572774542a
7
- data.tar.gz: c17ae7672d988fe083cce647d3c1e4e0edb4005961a433ab803d0d7f9af8f6adfdca2a260a7390a2b432e19a9f6b7d8d6243cc81666180c35425acd999f40bea
6
+ metadata.gz: b5279168bef47676d692e045c9e3ff9ea17cf343efc3cb6bf264dd87816ee60b149f81447be866399b5f63f3179a50e0c60c5493c553b5e2ea817509b8b7f843
7
+ data.tar.gz: 94b98a0f6d13a0100ab5eb53064646091792230626b00bd8d6dcbfce5dc2e868473f343efeef69df129b2ac43e10978260483475b85e45164f969d6f9f905975
@@ -38,11 +38,12 @@ var setupDataTables = function() {
38
38
  };
39
39
 
40
40
  window.questionnairesDataTable = setupDataTable($('.datatable.questionnaires'), {
41
- order : [2, 'desc'],
41
+ order : [3, 'desc'],
42
42
  scrollX : false,
43
43
  columns : [
44
44
  { orderable : false, data: 'bulk' },
45
45
  { orderable : false, data: 'link' },
46
+ { orderable : false, data: 'note' },
46
47
  { orderable: true, data: 'id' },
47
48
  { orderable: true, data: 'first_name' },
48
49
  { orderable: true, data: 'last_name' },
@@ -21,6 +21,7 @@ class QuestionnaireDatatable < AjaxDatatablesRails::Base
21
21
  {
22
22
  bulk: current_user.admin_limited_access ? '' : "<input type=\"checkbox\" data-bulk-row-edit=\"#{record.id}\">".html_safe,
23
23
  link: link_to('<i class="fa fa-search"></i>'.html_safe, manage_questionnaire_path(record)),
24
+ note: record.minor? ? '<div class="center"><i class="fa fa-exclamation-triangle icon-space-r"></i> Minor</div>'.html_safe : '',
24
25
  id: record.id,
25
26
  first_name: record.first_name,
26
27
  last_name: record.last_name,
@@ -0,0 +1,7 @@
1
+ module QuestionnaireHelper
2
+ def format_age(age)
3
+ parts = ActiveSupport::Duration.build(age).parts
4
+
5
+ "#{pluralize(parts[:years], 'year')}, #{pluralize(parts[:months], 'month')}, and #{pluralize(parts[:days], 'day')}"
6
+ end
7
+ end
@@ -75,11 +75,15 @@ class Message < ApplicationRecord
75
75
  status == "drafted" || trigger.present?
76
76
  end
77
77
 
78
+ def can_queue?
79
+ status == "drafted" && recipients_list.present?
80
+ end
81
+
78
82
  def using_default_template?
79
83
  template == "default"
80
84
  end
81
85
 
82
- def self.possible_recipients
86
+ def possible_recipients
83
87
  # Produce an array like:
84
88
  # ["School: My University", "school::123"]
85
89
  option = ->(query, model) { [MessageRecipientQuery.friendly_name(query, model), query] }
@@ -102,6 +106,14 @@ class Message < ApplicationRecord
102
106
  recipients = POSSIBLE_SIMPLE_RECIPIENTS.invert.to_a
103
107
  recipients.push(*bus_list_recipients)
104
108
  recipients.push(*school_recipients)
109
+
110
+ # Add current recipients if not included
111
+ self.recipients.each do |recipient|
112
+ if recipients.none? { |recipient_pair| recipient_pair[1] == recipient }
113
+ recipients.push([recipient, recipient])
114
+ end
115
+ end
116
+
105
117
  recipients
106
118
  end
107
119
 
@@ -1,4 +1,7 @@
1
1
  class MessageRecipientQuery
2
+ class ModelIdNotFound < StandardError
3
+ end
4
+
2
5
  attr_accessor :query
3
6
  attr_accessor :type
4
7
  attr_accessor :id
@@ -31,7 +34,7 @@ class MessageRecipientQuery
31
34
  else
32
35
  raise "Unknown recipient query type: #{type.inspect} (in message recipient query: #{query.inspect}"
33
36
  end
34
- raise "Could not find #{model_name} with ID #{id.inspect} (in message recipient query: #{query.inspect}" if model.blank?
37
+ raise MessageRecipientQuery::ModelIdNotFound, "Could not find #{model_name} with ID #{id.inspect} (in message recipient query: #{query.inspect})" if model.blank?
35
38
 
36
39
  MessageRecipientQuery.new(
37
40
  query,
@@ -42,8 +45,12 @@ class MessageRecipientQuery
42
45
  end
43
46
 
44
47
  def self.friendly_name(query, model = nil)
45
- recipient_query = parse(query, model)
46
- model = recipient_query.model
48
+ begin
49
+ recipient_query = parse(query, model)
50
+ model = recipient_query.model
51
+ rescue MessageRecipientQuery::ModelIdNotFound
52
+ return "[invalid recipient]"
53
+ end
47
54
 
48
55
  case recipient_query.type
49
56
  when "bus-list"
@@ -123,6 +123,14 @@ class Questionnaire < ApplicationRecord
123
123
  Fips.where(city: school.city, state: school.state).first
124
124
  end
125
125
 
126
+ def age_at_time_of_event
127
+ (Rails.configuration.hackathon['event_start_date'] - date_of_birth).to_i * 1.day
128
+ end
129
+
130
+ def minor?
131
+ age_at_time_of_event < 18.years
132
+ end
133
+
126
134
  def can_rsvp?
127
135
  ["accepted", "rsvp_confirmed", "rsvp_denied"].include? acc_status
128
136
  end
@@ -7,9 +7,9 @@
7
7
  = f.input :subject, hint: "All emails are from <pre>#{html_escape(Rails.configuration.hackathon['email_from'])}</pre>".html_safe
8
8
  = f.input :template, as: :select, collection: Message::POSSIBLE_TEMPLATES.map { |x| [x.titleize, x] }, include_blank: false
9
9
  - if @message.status == "drafted"
10
- = f.input :recipients, as: :select, collection: Message.possible_recipients, input_html: { class: "selectize", multiple: true, }, hint: "Sent manually, in bulk", placeholder: "Type to search by school or type..."
10
+ = f.input :recipients, as: :select, collection: @message.possible_recipients, input_html: { class: "selectize", multiple: true, }, hint: "Sent manually, in bulk", placeholder: "Type to search by school or type..."
11
11
  - else
12
- = f.input :recipients, as: :select, collection: Message.possible_recipients, input_html: { class: "selectize", multiple: true }, hint: "Cannot be edited once a message has been delivered", disabled: true
12
+ = f.input :recipients, as: :select, collection: @message.possible_recipients, input_html: { class: "selectize", multiple: true }, hint: "Cannot be edited once a message has been delivered", disabled: true
13
13
  = f.input :trigger, as: :select, collection: Message::POSSIBLE_TRIGGERS.invert, include_blank: "(no automatic trigger)", hint: "Sent automatically, to an individual applicant"
14
14
  = f.input :body, input_html: { rows: 10 }, hint: "Supports markdown and HTML"
15
15
 
@@ -1,7 +1,11 @@
1
1
  %section.section.manage
2
2
  %h1.section-title= title "Message"
3
3
 
4
- - recipient_count = pluralize(BulkMessageWorker.build_recipients(@message.recipients).count, "recipient")
4
+ :ruby
5
+ begin
6
+ recipient_count = pluralize(BulkMessageWorker.build_recipients(@message.recipients).count, "recipient")
7
+ rescue => recipient_error
8
+ end
5
9
 
6
10
  %p
7
11
  %b Name:
@@ -21,7 +25,12 @@
21
25
  - if @message.recipients.present?
22
26
  %br
23
27
  %small
24
- %em #{recipient_count} currently match this query
28
+ - if recipient_error.present?
29
+ %strong{style: 'color: red;'} Error parsing recipients:
30
+ = recipient_error
31
+ %br To resolve this, edit & remove the offending recipient.
32
+ - else
33
+ %em #{recipient_count} currently match this query
25
34
  %p
26
35
  %b Trigger:
27
36
  = Message::POSSIBLE_TRIGGERS[@message.trigger] || "(no automatic trigger)"
@@ -54,9 +63,15 @@
54
63
  %hr
55
64
 
56
65
  - unless current_user.admin_limited_access
57
- - if @message.status == "drafted" && @message.recipients_list.present?
58
- = btn_link_to 'Deliver', deliver_manage_message_path(@message), method: :patch, data: { confirm: "Are you sure? The message \"#{@message.name}\" will be sent to #{recipient_count}." }
59
- \|
66
+ - if @message.can_queue?
67
+ - if recipient_error.present?
68
+ %button.button{disabled: 'disabled'} Deliver
69
+ %small Cannot deliver when there is a recipient error; see error above.
70
+ %br
71
+ %br
72
+ - else
73
+ = btn_link_to 'Deliver', deliver_manage_message_path(@message), method: :patch, data: { confirm: "Are you sure? The message \"#{@message.name}\" will be sent to #{recipient_count}." }
74
+ \|
60
75
  - if @message.can_edit?
61
76
  = link_to 'Edit', edit_manage_message_path(@message)
62
77
  \|
@@ -14,6 +14,7 @@
14
14
  - unless current_user.admin_limited_access?
15
15
  %input{ type: "checkbox", name: "select_allc", value: "1", data: { bulk_row_select: "" } }
16
16
  %th
17
+ %th
17
18
  %th ID
18
19
  %th First name
19
20
  %th Last name
@@ -1,5 +1,16 @@
1
1
  %section.section.manage
2
2
  .container.container-half
3
+ - if @questionnaire.minor?
4
+ #disclaimer
5
+ %p
6
+ %strong
7
+ %span.fa.fa-exclamation-triangle.icon-space-r
8
+ Applicant is a minor
9
+ %p
10
+ Will be
11
+ = format_age(@questionnaire.age_at_time_of_event)
12
+ old.
13
+
3
14
  = render partial: 'questionnaire_summary'
4
15
 
5
16
  %p
@@ -13,7 +13,7 @@
13
13
  = f.input :first_name, input_html: { "data-validate" => "presence" }, autofocus: true, wrapper_html: { class: 'input--half' }
14
14
  = f.input :last_name, input_html: { "data-validate" => "presence" }, wrapper_html: { class: 'input--half' }
15
15
  = f.input :phone, label: "Phone number", input_html: { "data-validate" => "presence" }
16
- = f.input :date_of_birth, start_year: Date.today.year - 18, end_year: Date.today.year - 90, order: [:month, :day, :year], input_html: { "data-validate" => "presence" }
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
19
  = f.input :level_of_study, input_html: { "data-validate" => "presence" }, wrapper_html: { class: 'input--half' }
@@ -1,3 +1,3 @@
1
1
  module HackathonManager
2
- VERSION = '0.6.0'.freeze
2
+ VERSION = '0.6.1'.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.0
4
+ version: 0.6.1
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-01-18 00:00:00.000000000 Z
11
+ date: 2018-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -507,6 +507,7 @@ files:
507
507
  - app/datatables/school_datatable.rb
508
508
  - app/helpers/hackathon_manager_helper.rb
509
509
  - app/helpers/manage/dashboard_helper.rb
510
+ - app/helpers/questionnaire_helper.rb
510
511
  - app/inputs/deletable_attachment_input.rb
511
512
  - app/inputs/formatted_boolean_input.rb
512
513
  - app/inputs/school_selection_input.rb