mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-02-01 21:21:02 -05:00
DRY for the notifications controller
This commit is contained in:
@@ -2,14 +2,11 @@ class NotificationsController < ApplicationController
|
||||
include NotificationsHelper
|
||||
before_action :authenticate_member!
|
||||
load_and_authorize_resource
|
||||
respond_to :html
|
||||
|
||||
# GET /notifications
|
||||
def index
|
||||
@notifications = Notification.by_recipient(current_member).page(params[:page])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
end
|
||||
end
|
||||
|
||||
# GET /notifications/1
|
||||
@@ -17,10 +14,6 @@ class NotificationsController < ApplicationController
|
||||
@notification.read = true
|
||||
@notification.save
|
||||
@reply_link = reply_link(@notification)
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
end
|
||||
end
|
||||
|
||||
# GET /notifications/new
|
||||
@@ -29,10 +22,6 @@ class NotificationsController < ApplicationController
|
||||
@notification = Notification.new
|
||||
@recipient = Member.find_by(id: params[:recipient_id])
|
||||
@subject = params[:subject] || ""
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
end
|
||||
end
|
||||
|
||||
# GET /notifications/1/reply
|
||||
@@ -45,19 +34,12 @@ class NotificationsController < ApplicationController
|
||||
@subject = @sender_notification.subject =~ /^Re: / ?
|
||||
@sender_notification.subject :
|
||||
"Re: " + @sender_notification.subject
|
||||
|
||||
respond_to do |format|
|
||||
format.html # reply.html.haml
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /notifications/1
|
||||
def destroy
|
||||
@notification.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to notifications_url }
|
||||
end
|
||||
redirect_to notifications_url
|
||||
end
|
||||
|
||||
# POST /notifications
|
||||
@@ -66,12 +48,10 @@ class NotificationsController < ApplicationController
|
||||
@notification = Notification.new(notification_params)
|
||||
@recipient = Member.find_by(id: params[:notification][:recipient_id])
|
||||
|
||||
respond_to do |format|
|
||||
if @notification.save
|
||||
format.html { redirect_to notifications_path, notice: 'Message was successfully sent.' }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
end
|
||||
if @notification.save
|
||||
redirect_to notifications_path, notice: 'Message was successfully sent.'
|
||||
else
|
||||
render action: "new"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user