hackathon_manager 0.6.0 → 0.6.1
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.
- checksums.yaml +4 -4
 - data/app/assets/javascripts/hackathon_manager/manage/lib/setupDataTables.js +2 -1
 - data/app/datatables/questionnaire_datatable.rb +1 -0
 - data/app/helpers/questionnaire_helper.rb +7 -0
 - data/app/models/message.rb +13 -1
 - data/app/models/message_recipient_query.rb +10 -3
 - data/app/models/questionnaire.rb +8 -0
 - data/app/views/manage/messages/_form.html.haml +2 -2
 - data/app/views/manage/messages/show.html.haml +20 -5
 - data/app/views/manage/questionnaires/index.html.haml +1 -0
 - data/app/views/manage/questionnaires/show.html.haml +11 -0
 - data/app/views/questionnaires/_form.html.haml +1 -1
 - data/lib/hackathon_manager/version.rb +1 -1
 - metadata +3 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 4cc3f7d2686f6f8c6ef43edde9822405515135d4
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: d56facacbfd9b47a5982219314d21ea0df5911ae
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 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      : [ 
     | 
| 
      
 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,
         
     | 
    
        data/app/models/message.rb
    CHANGED
    
    | 
         @@ -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  
     | 
| 
      
 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 
     | 
    
         
            -
                 
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
      
 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"
         
     | 
    
        data/app/models/questionnaire.rb
    CHANGED
    
    | 
         @@ -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:  
     | 
| 
      
 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:  
     | 
| 
      
 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 
     | 
    
         
            -
               
     | 
| 
      
 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 
     | 
    
         
            -
                     
     | 
| 
      
 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. 
     | 
| 
       58 
     | 
    
         
            -
                   
     | 
| 
       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 
     | 
    
         
             
                  \|
         
     | 
| 
         @@ -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 -  
     | 
| 
      
 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' }
         
     | 
    
        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. 
     | 
| 
      
 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- 
     | 
| 
      
 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
         
     |