metamaps--metamaps/app/models/access_request.rb
Devin Howard d16709e8e7 fix codeclimate style issues (#1046)
* bunch of code climate fixes

* more
2017-01-23 19:30:13 -05:00

37 lines
842 B
Ruby

# frozen_string_literal: true
class AccessRequest < ApplicationRecord
belongs_to :user
belongs_to :map
def approve
self.approved = true
self.answered = true
save
Mailboxer::Notification.where(notified_object: self).find_each do |notification|
Mailboxer::Receipt.where(notification: notification).update_all(is_read: true)
end
UserMap.create(user: user, map: map)
NotificationService.access_approved(self)
end
def deny
self.approved = false
self.answered = true
save
Mailboxer::Notification.where(notified_object: self).find_each do |notification|
Mailboxer::Receipt.where(notification: notification).update_all(is_read: true)
end
end
def requested_text
map.name + ' - request to edit'
end
def approved_text
map.name + ' - access approved'
end
end