Merge 18433a6776 into 749115e507
This commit is contained in:
commit
a0cdc60ca5
8 changed files with 28 additions and 13 deletions
|
|
@ -29,6 +29,7 @@ module Admin
|
||||||
:send_on_accepted, :send_on_rejected, :send_on_confirmed_without_registration,
|
:send_on_accepted, :send_on_rejected, :send_on_confirmed_without_registration,
|
||||||
:send_on_submitted_proposal,
|
:send_on_submitted_proposal,
|
||||||
:submitted_proposal_subject, :submitted_proposal_body,
|
:submitted_proposal_subject, :submitted_proposal_body,
|
||||||
|
:send_on_event_comment,
|
||||||
:registration_subject, :accepted_subject, :rejected_subject, :confirmed_without_registration_subject,
|
:registration_subject, :accepted_subject, :rejected_subject, :confirmed_without_registration_subject,
|
||||||
:registration_body, :accepted_body, :rejected_body, :confirmed_without_registration_body,
|
:registration_body, :accepted_body, :rejected_body, :confirmed_without_registration_body,
|
||||||
:send_on_conference_dates_updated, :conference_dates_updated_subject, :conference_dates_updated_body,
|
:send_on_conference_dates_updated, :conference_dates_updated_subject, :conference_dates_updated_body,
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,7 @@ class EventCommentMailJob < ApplicationJob
|
||||||
queue_as :default
|
queue_as :default
|
||||||
|
|
||||||
def perform(comment)
|
def perform(comment)
|
||||||
conference = comment.commentable.program.conference
|
User.comment_notifiable(comment.conference_id).each do |user|
|
||||||
|
|
||||||
User.comment_notifiable(conference).each do |user|
|
|
||||||
Mailbot.event_comment_mail(comment, user).deliver_now
|
Mailbot.event_comment_mail(comment, user).deliver_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -57,13 +57,19 @@ class Comment < ApplicationRecord
|
||||||
commentable_str.constantize.find(commentable_id)
|
commentable_str.constantize.find(commentable_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def send_notification
|
|
||||||
EventCommentMailJob.perform_later(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
def conference_id
|
def conference_id
|
||||||
commentable.program.conference_id
|
commentable.program.conference_id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def conference
|
||||||
|
commentable.program.conference
|
||||||
|
end
|
||||||
|
|
||||||
|
def send_notification
|
||||||
|
return unless conference.email_settings.send_on_event_comment?
|
||||||
|
|
||||||
|
EventCommentMailJob.perform_later(self)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class User < ApplicationRecord
|
||||||
after_save :touch_events
|
after_save :touch_events
|
||||||
|
|
||||||
# add scope
|
# add scope
|
||||||
scope :comment_notifiable, ->(conference) {joins(:roles).where('roles.name IN (?)', [:organizer, :cfp]).where('roles.resource_type = ? AND roles.resource_id = ?', 'Conference', conference.id)}
|
scope :comment_notifiable, ->(conference_id) {joins(:roles).where('roles.name IN (?)', [:organizer, :cfp]).where('roles.resource_type = ? AND roles.resource_id = ?', 'Conference', conference_id)}
|
||||||
|
|
||||||
# scopes for user distributions
|
# scopes for user distributions
|
||||||
scope :recent, lambda {
|
scope :recent, lambda {
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,10 @@
|
||||||
%a.btn.btn-link.control_label.template_help_link{ 'data-name' => 'registration_help' } Show Help
|
%a.btn.btn-link.control_label.template_help_link{ 'data-name' => 'registration_help' } Show Help
|
||||||
= render partial: 'help', locals: { id: 'registration_help', show_event_variables: false }
|
= render partial: 'help', locals: { id: 'registration_help', show_event_variables: false }
|
||||||
#proposal.tab-pane{ role: 'tabpanel' }
|
#proposal.tab-pane{ role: 'tabpanel' }
|
||||||
|
.checkbox
|
||||||
|
%label
|
||||||
|
= f.check_box :send_on_event_comment
|
||||||
|
Send an email to all organizers and CfP team members when a comment is added?
|
||||||
.checkbox
|
.checkbox
|
||||||
%label
|
%label
|
||||||
= f.check_box :send_on_submitted_proposal, data: { name: 'email_settings_proposal_submited_subject'}, class: 'send_on_radio'
|
= f.check_box :send_on_submitted_proposal, data: { name: 'email_settings_proposal_submited_subject'}, class: 'send_on_radio'
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddSendOnEventCommentToEmailSettings < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
add_column :email_settings, :send_on_event_comment, :boolean, default: true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20181229233811) do
|
ActiveRecord::Schema.define(version: 2022_04_01_000955) do
|
||||||
|
|
||||||
create_table "answers", force: :cascade do |t|
|
create_table "answers", force: :cascade do |t|
|
||||||
t.string "title"
|
t.string "title"
|
||||||
|
|
@ -192,6 +192,7 @@ ActiveRecord::Schema.define(version: 20181229233811) do
|
||||||
t.boolean "send_on_submitted_proposal", default: false
|
t.boolean "send_on_submitted_proposal", default: false
|
||||||
t.string "submitted_proposal_subject"
|
t.string "submitted_proposal_subject"
|
||||||
t.text "submitted_proposal_body"
|
t.text "submitted_proposal_body"
|
||||||
|
t.boolean "send_on_event_comment", default: true
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "event_schedules", force: :cascade do |t|
|
create_table "event_schedules", force: :cascade do |t|
|
||||||
|
|
|
||||||
|
|
@ -88,11 +88,11 @@ describe User do
|
||||||
let(:cfp_user) { create(:user, role_ids: [cfp_role.id]) }
|
let(:cfp_user) { create(:user, role_ids: [cfp_role.id]) }
|
||||||
|
|
||||||
it 'includes organizer and cfp user' do
|
it 'includes organizer and cfp user' do
|
||||||
expect(User.comment_notifiable(conference)).to include(organizer, cfp_user)
|
expect(User.comment_notifiable(conference.id)).to include(organizer, cfp_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'excludes ordinary user' do
|
it 'excludes ordinary user' do
|
||||||
expect(User.comment_notifiable(conference)).not_to include(user)
|
expect(User.comment_notifiable(conference.id)).not_to include(user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue