grant/deny buttons mark access request notifications as read
This commit is contained in:
parent
7aa19365a1
commit
8e74ec9a0b
2 changed files with 14 additions and 4 deletions
|
@ -50,7 +50,7 @@ class AccessController < ApplicationController
|
||||||
# GET maps/:id/approve_access/:request_id
|
# GET maps/:id/approve_access/:request_id
|
||||||
def approve_access
|
def approve_access
|
||||||
request = AccessRequest.find(params[:request_id])
|
request = AccessRequest.find(params[:request_id])
|
||||||
request.approve
|
request.approve # also marks mailboxer notification as read
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to map_path(@map), notice: 'Request was approved' }
|
format.html { redirect_to map_path(@map), notice: 'Request was approved' }
|
||||||
end
|
end
|
||||||
|
@ -59,7 +59,7 @@ class AccessController < ApplicationController
|
||||||
# GET maps/:id/deny_access/:request_id
|
# GET maps/:id/deny_access/:request_id
|
||||||
def deny_access
|
def deny_access
|
||||||
request = AccessRequest.find(params[:request_id])
|
request = AccessRequest.find(params[:request_id])
|
||||||
request.deny
|
request.deny # also marks mailboxer notification as read
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to map_path(@map), notice: 'Request was turned down' }
|
format.html { redirect_to map_path(@map), notice: 'Request was turned down' }
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,13 +6,23 @@ class AccessRequest < ApplicationRecord
|
||||||
self.approved = true
|
self.approved = true
|
||||||
self.answered = true
|
self.answered = true
|
||||||
self.save
|
self.save
|
||||||
UserMap.create(user: self.user, map: self.map)
|
|
||||||
MapMailer.invite_to_edit_email(self.map, self.map.user, self.user).deliver_later
|
Mailboxer::Notification.where(notified_object: self).each do |notification|
|
||||||
|
Mailboxer::Receipt.where(notification: notification).update_all(is_read: true)
|
||||||
|
end
|
||||||
|
|
||||||
|
UserMap.create(user: user, map: map)
|
||||||
|
mail = MapMailer.invite_to_edit_email(map, map.user, user)
|
||||||
|
user.notify(mail.subject, 'invite to edit', self, true, MAILBOXER_CODE_INVITED_TO_EDIT)
|
||||||
end
|
end
|
||||||
|
|
||||||
def deny
|
def deny
|
||||||
self.approved = false
|
self.approved = false
|
||||||
self.answered = true
|
self.answered = true
|
||||||
self.save
|
self.save
|
||||||
|
|
||||||
|
Mailboxer::Notification.where(notified_object: self).each do |notification|
|
||||||
|
Mailboxer::Receipt.where(notification: notification).update_all(is_read: true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue