修改了竞赛通知及评论相关文件代码
This commit is contained in:
parent
0255a61d2f
commit
00b1a40345
|
@ -65,7 +65,7 @@ class ContestnotificationsController < ApplicationController
|
||||||
# GET /contestnotifications/1
|
# GET /contestnotifications/1
|
||||||
# GET /contestnotifications/1.json
|
# GET /contestnotifications/1.json
|
||||||
def show
|
def show
|
||||||
# @contestnotification = Contestnotification.find(params[:id])
|
@contestnotification = Contestnotification.find(params[:id])
|
||||||
#
|
#
|
||||||
# respond_to do |format|
|
# respond_to do |format|
|
||||||
# format.html # show.html.erb
|
# format.html # show.html.erb
|
||||||
|
@ -136,12 +136,12 @@ class ContestnotificationsController < ApplicationController
|
||||||
# format.json { render json: @contestnotification.errors, status: :unprocessable_entity }
|
# format.json { render json: @contestnotification.errors, status: :unprocessable_entity }
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
@contestnotifications.safe_attributes = params[:contestnotifications]
|
@contestnotification.safe_attributes = params[:contestnotification]
|
||||||
@contestnotifications.save_attachments(params[:attachments])
|
@contestnotification.save_attachments(params[:attachments])
|
||||||
if @contestnotifications.save
|
if @contestnotification.save
|
||||||
render_attachment_warning_if_needed(@contestnotifications)
|
render_attachment_warning_if_needed(@contestnotification)
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to contestnotification_path(@contestnotifications)
|
redirect_to contest_contestnotification_path(@contestnotification)
|
||||||
else
|
else
|
||||||
render :action => 'edit'
|
render :action => 'edit'
|
||||||
end
|
end
|
||||||
|
@ -158,7 +158,7 @@ class ContestnotificationsController < ApplicationController
|
||||||
# format.json { head :no_content }
|
# format.json { head :no_content }
|
||||||
# end
|
# end
|
||||||
@contestnotifications.destroy
|
@contestnotifications.destroy
|
||||||
redirect_to contest_contestnotification_index_path(@contest)
|
redirect_to contest_contestnotifications_path(@contest)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -41,18 +41,18 @@ class Contestnotification < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def recipients
|
def recipients
|
||||||
contest.users.select {|user| user.notify_about?(self)}.map(&:mail)
|
#contest.users.select {|user| user.notify_about?(self)}.map(&:mail)
|
||||||
end
|
end
|
||||||
|
|
||||||
# returns latest news for contests visible by user
|
# returns latest news for contests visible by user
|
||||||
def self.latest(user = User.current, count = 5)
|
def self.latest(user = User.current, count = 5)
|
||||||
visible(user).includes([:author, :contest]).order("#{Contestnotifications.table_name}.created_at DESC").limit(count).all
|
visible(user).includes([:author, :contest]).order("#{Contestnotification.table_name}.created_at DESC").limit(count).all
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def add_author_as_watcher
|
def add_author_as_watcher
|
||||||
Watcher.create(:watchable => self, :user => author)
|
#Watcher.create(:watchable => self, :user => author)
|
||||||
end
|
end
|
||||||
## fq
|
## fq
|
||||||
def act_as_activity
|
def act_as_activity
|
||||||
|
|
Loading…
Reference in New Issue