Issue#15: Added Comment Notifications: notification_emails and comments view
This commit is contained in:
parent
a73ca335a9
commit
38e8be8793
16 changed files with 155 additions and 13 deletions
|
|
@ -137,6 +137,7 @@ class Ability
|
|||
can :manage, Sponsor, conference_id: conf_ids_for_organizer
|
||||
can :manage, SponsorshipLevel, conference_id: conf_ids_for_organizer
|
||||
can :manage, Ticket, conference_id: conf_ids_for_organizer
|
||||
can :manage, Comment, conference_id: conf_ids_for_organizer
|
||||
end
|
||||
|
||||
def signed_in_with_cfp_role(user)
|
||||
|
|
@ -155,6 +156,7 @@ class Ability
|
|||
can :manage, CallForPaper, conference_id: conf_ids_for_cfp
|
||||
can :manage, Commercial, commercialable_type: 'Event',
|
||||
commercialable_id: Event.where(conference_id: conf_ids_for_cfp).pluck(:id)
|
||||
can :manage, Comment, conference_id: conf_ids_for_cfp
|
||||
end
|
||||
|
||||
def signed_in_with_info_desk_role(user)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ class Comment < ActiveRecord::Base
|
|||
attr_accessible :commentable, :body, :user_id
|
||||
validates_presence_of :body
|
||||
validates_presence_of :user
|
||||
after_create :send_notification
|
||||
|
||||
# NOTE: install the acts_as_votable plugin if you
|
||||
# want user to vote on the quality of comments.
|
||||
|
|
@ -40,9 +41,18 @@ class Comment < ActiveRecord::Base
|
|||
where(commentable_type: commentable_str.to_s, commentable_id: commentable_id).order('created_at DESC')
|
||||
}
|
||||
|
||||
scope :find_since_last_login, lambda { |user|
|
||||
where(created_at: (user.last_sign_in_at..Time.now)).order(created_at: :desc)
|
||||
}
|
||||
# Helper class method to look up a commentable object
|
||||
# given the commentable class name and id
|
||||
def self.find_commentable(commentable_str, commentable_id)
|
||||
commentable_str.constantize.find(commentable_id)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def send_notification
|
||||
Mailbot.delay.send_notification_email_for_comment(self)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class EmailSettings < ActiveRecord::Base
|
|||
h['registration_end_date'] = conference.registration_period.end_date
|
||||
end
|
||||
|
||||
if !event.nil?
|
||||
if event
|
||||
h['eventtitle'] = event.title
|
||||
h['proposalslink'] = Rails.application.routes.url_helpers.conference_proposal_index_url(
|
||||
conference.short_title, host: CONFIG['url_for_emails'])
|
||||
|
|
@ -67,6 +67,8 @@ class EmailSettings < ActiveRecord::Base
|
|||
parse_template(conf_update_template, values)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def parse_template(text, values)
|
||||
values.each do |key, value|
|
||||
if value.kind_of?(Date)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ class User < ActiveRecord::Base
|
|||
|
||||
before_create :setup_role
|
||||
|
||||
# add scope
|
||||
scope :comment_notifiable, ->(conference) {joins(:roles).where('roles.name IN (?)', [:organizer, :cfp]).where('roles.resource_id = ?', conference.id)}
|
||||
|
||||
# Include default devise modules. Others available are:
|
||||
# :token_authenticatable, :confirmable,
|
||||
# :lockable, :timeoutable and :omniauthable
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue