2014-06-05 10:28:36 +08:00
|
|
|
class NotificationcommentsController < ApplicationController
|
|
|
|
default_search_scope :contestnotifications
|
|
|
|
model_object Contestnotifications
|
|
|
|
before_filter :find_model_object
|
|
|
|
before_filter :find_contest_from_association
|
|
|
|
before_filter :authorize
|
|
|
|
|
|
|
|
def create
|
2014-06-05 11:02:32 +08:00
|
|
|
raise Unauthorized unless @contestnotifications.notificationcommentable?
|
2014-06-05 10:28:36 +08:00
|
|
|
|
|
|
|
@notificaioncomment = Notificaioncomment.new
|
|
|
|
@notificaioncomment.safe_attributes = params[:notificaioncomment]
|
|
|
|
@notificaioncomment.author = User.current
|
|
|
|
if @contestnotifications.notificaioncomments << @notificaioncomment
|
|
|
|
flash[:notice] = l(:label_comment_added)
|
|
|
|
end
|
|
|
|
|
|
|
|
redirect_to contest_contestnotification_path(@contestnotifications)
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@contestnotifications.notificaioncomments.find(params[:notificaioncomment_id]).destroy
|
|
|
|
redirect_to contest_contestnotification_path(@contestnotifications)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def find_model_object
|
|
|
|
super
|
|
|
|
@contestnotifications = @object
|
|
|
|
@notificaioncomment = nil
|
|
|
|
@contestnotifications
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|