president
parent
545e5c5941
commit
45e12c4bef
@ -1,35 +1,27 @@
|
||||
class NotificationcommentsController < ApplicationController
|
||||
default_search_scope :contestnotifications
|
||||
model_object Contestnotifications
|
||||
before_filter :find_model_object
|
||||
before_filter :find_contest_from_association
|
||||
before_filter :authorize
|
||||
# default_search_scope :contestnotifications
|
||||
# model_object Contestnotifications
|
||||
# before_filter :authorize
|
||||
|
||||
def create
|
||||
#raise Unauthorized unless @contestnotifications.notificationcommentable?
|
||||
@contest = Contest.find(params[:contest_id])
|
||||
@contestnotification = Contestnotification.find(params[:contestnotification_id])
|
||||
|
||||
@notificationcomment = Notificationcomment.new
|
||||
@notificationcomment.safe_attributes = params[:notificationcomment]
|
||||
@notificationcomment.author = User.current
|
||||
if @contestnotifications.notificationcomments << @notificationcomment
|
||||
@notificaioncomment = Notificationcomment.new
|
||||
@notificaioncomment.safe_attributes = params[:notificaioncomment]
|
||||
@notificaioncomment.author = User.current
|
||||
if @contestnotification.notificationcomments << @notificaioncomment
|
||||
flash[:notice] = l(:label_comment_added)
|
||||
end
|
||||
|
||||
redirect_to contest_contestnotification_path(@contestnotifications)
|
||||
#redirect_to contest_contestnotification_notificationcomment_path(@contest, @contestnotification, @notificaioncomment)
|
||||
redirect_to contest_contestnotification_path(@contest, @contestnotification)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@contestnotifications.notificationcomments.find(params[:notificationcomment_id]).destroy
|
||||
@contestnotifications.notificaioncomments.find(params[:notificaioncomment_id]).destroy
|
||||
redirect_to contest_contestnotification_path(@contestnotifications)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_model_object
|
||||
super
|
||||
@contestnotifications = @object
|
||||
@notificationcomment = nil
|
||||
@contestnotifications
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in new issue