metamaps--metamaps/app/models/access_request.rb

29 lines
813 B
Ruby
Raw Normal View History

class AccessRequest < ApplicationRecord
belongs_to :user
belongs_to :map
def approve
self.approved = true
self.answered = true
self.save
Mailboxer::Notification.where(notified_object: self).each do |notification|
Mailboxer::Receipt.where(notification: notification).update_all(is_read: true)
end
2016-12-09 16:55:53 +00:00
user_map = UserMap.create(user: user, map: map)
mail = MapMailer.invite_to_edit_email(map, map.user, user)
2016-12-09 16:55:53 +00:00
user.notify(mail.subject, 'invite to edit', user_map, true, MAILBOXER_CODE_INVITED_TO_EDIT)
end
def deny
self.approved = false
self.answered = true
self.save
Mailboxer::Notification.where(notified_object: self).each do |notification|
Mailboxer::Receipt.where(notification: notification).update_all(is_read: true)
end
end
end