|
|
|
@ -4,8 +4,8 @@ class ContestnotificationsController < ApplicationController
|
|
|
|
|
layout 'base_newcontest'
|
|
|
|
|
default_search_scope :contestnotifications
|
|
|
|
|
model_object Contestnotification
|
|
|
|
|
before_filter :find_model_object, :except => [:new, :create, :index]
|
|
|
|
|
before_filter :find_contest_from_association, :except => [:new, :create, :index]
|
|
|
|
|
# before_filter :find_model_object, :except => [:new, :create, :index]
|
|
|
|
|
# before_filter :find_contest_from_association, :except => [:new, :create, :index]
|
|
|
|
|
before_filter :find_contest_by_contest_id, :only => [:new, :create]
|
|
|
|
|
before_filter :find_contest
|
|
|
|
|
before_filter :find_author
|
|
|
|
@ -14,6 +14,8 @@ class ContestnotificationsController < ApplicationController
|
|
|
|
|
accept_rss_auth :index
|
|
|
|
|
accept_api_auth :index
|
|
|
|
|
|
|
|
|
|
before_filter :access_edit_destroy, only: [:edit ,:update, :destroy]
|
|
|
|
|
|
|
|
|
|
def find_author
|
|
|
|
|
@user = @contest.author
|
|
|
|
|
render_404 if @user.nil?
|
|
|
|
@ -93,7 +95,7 @@ class ContestnotificationsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
# GET /contestnotifications/1/edit
|
|
|
|
|
def edit
|
|
|
|
|
# @contestnotification = Contestnotification.find(params[:id])
|
|
|
|
|
@contestnotification = Contestnotification.find(params[:id])
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# POST /contestnotifications
|
|
|
|
@ -137,12 +139,13 @@ class ContestnotificationsController < ApplicationController
|
|
|
|
|
# format.json { render json: @contestnotification.errors, status: :unprocessable_entity }
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
@contestnotification = Contestnotification.find(params[:id])
|
|
|
|
|
@contestnotification.safe_attributes = params[:contestnotification]
|
|
|
|
|
@contestnotification.save_attachments(params[:attachments])
|
|
|
|
|
if @contestnotification.save
|
|
|
|
|
render_attachment_warning_if_needed(@contestnotification)
|
|
|
|
|
flash[:notice] = l(:notice_successful_update)
|
|
|
|
|
redirect_to contest_contestnotification_path(@contestnotification)
|
|
|
|
|
redirect_to contest_contestnotification_path(@contestnotification.contest, @contestnotification)
|
|
|
|
|
else
|
|
|
|
|
render :action => 'edit'
|
|
|
|
|
end
|
|
|
|
@ -172,4 +175,12 @@ class ContestnotificationsController < ApplicationController
|
|
|
|
|
render_404
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def access_edit_destroy
|
|
|
|
|
if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?)
|
|
|
|
|
return true
|
|
|
|
|
else
|
|
|
|
|
render_403
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|