mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
recipient lists for somerville data
This commit is contained in:
parent
1db61cd3e5
commit
fa02cee295
5 changed files with 10 additions and 11 deletions
|
|
@ -4,7 +4,6 @@ class RecipientList < ApplicationRecord
|
|||
|
||||
validates_associated :school
|
||||
validates :name, presence: true
|
||||
validates :recipient_ids, presence: true
|
||||
|
||||
attr_accessor :recipient_id_array
|
||||
before_validation :convert_recipient_id_array
|
||||
|
|
@ -24,8 +23,8 @@ class RecipientList < ApplicationRecord
|
|||
end
|
||||
|
||||
def set_recipient_id_array
|
||||
return if recipient_ids.blank?
|
||||
self.recipient_id_array = recipient_ids.split(',').map(&:to_i)
|
||||
return if recipient_id_array.present?
|
||||
self.recipient_id_array = (recipient_ids || '').split(',').map(&:to_i)
|
||||
end
|
||||
|
||||
def sync_recipient_schedules
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
%p
|
||||
%b Recipients:
|
||||
- @recipient_list.recipients.each do |recipient|
|
||||
%p= recipient.name
|
||||
%p= link_to recipient.name, [@school, recipient]
|
||||
|
||||
= link_to 'Edit', edit_school_recipient_list_path(@recipient_list.school, @recipient_list)
|
||||
|
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class CreateRecipients < ActiveRecord::Migration[5.0]
|
|||
t.string :ethnicity
|
||||
t.integer :home_language_id
|
||||
t.string :income
|
||||
t.boolean :opted_out
|
||||
t.boolean :opted_out, default: false
|
||||
t.integer :school_id
|
||||
|
||||
t.timestamps
|
||||
|
|
|
|||
|
|
@ -159,11 +159,6 @@ namespace :data do
|
|||
next
|
||||
end
|
||||
|
||||
recipient_list = school.recipient_lists.find_by_name("#{recipients.titleize} List")
|
||||
if recipient_list.nil?
|
||||
school.recipient_lists.create(name: "#{recipients.titleize} List")
|
||||
end
|
||||
|
||||
respondent_id = row['RespondentID']
|
||||
recipient_id = respondent_map[respondent_id]
|
||||
if recipient_id.present?
|
||||
|
|
@ -174,6 +169,11 @@ namespace :data do
|
|||
)
|
||||
respondent_map[respondent_id] = recipient.id
|
||||
end
|
||||
|
||||
recipient_list = school.recipient_lists.find_by_name("#{recipients.titleize} List")
|
||||
if recipient_list.nil?
|
||||
recipient_list = school.recipient_lists.create(name: "#{recipients.titleize} List")
|
||||
end
|
||||
recipient_list.recipient_id_array << recipient.id
|
||||
recipient_list.save!
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ RSpec.describe RecipientListsController, type: :controller do
|
|||
}
|
||||
|
||||
let(:invalid_attributes) {
|
||||
{school_id: school.id, name: 'Empty List', recipient_id_array: ['']}
|
||||
{school_id: school.id, name: ''}
|
||||
}
|
||||
|
||||
# This should return the minimal set of values that should be in the session
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue