修改了竞赛通知及评论相关文件代码

This commit is contained in:
wanglinchun 2014-06-05 15:45:17 +08:00
parent 0255a61d2f
commit 00b1a40345
2 changed files with 10 additions and 10 deletions

View File

@ -65,7 +65,7 @@ class ContestnotificationsController < ApplicationController
# GET /contestnotifications/1
# GET /contestnotifications/1.json
def show
# @contestnotification = Contestnotification.find(params[:id])
@contestnotification = Contestnotification.find(params[:id])
#
# respond_to do |format|
# format.html # show.html.erb
@ -136,12 +136,12 @@ class ContestnotificationsController < ApplicationController
# format.json { render json: @contestnotification.errors, status: :unprocessable_entity }
# end
# end
@contestnotifications.safe_attributes = params[:contestnotifications]
@contestnotifications.save_attachments(params[:attachments])
if @contestnotifications.save
render_attachment_warning_if_needed(@contestnotifications)
@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 contestnotification_path(@contestnotifications)
redirect_to contest_contestnotification_path(@contestnotification)
else
render :action => 'edit'
end
@ -158,7 +158,7 @@ class ContestnotificationsController < ApplicationController
# format.json { head :no_content }
# end
@contestnotifications.destroy
redirect_to contest_contestnotification_index_path(@contest)
redirect_to contest_contestnotifications_path(@contest)
end
private

View File

@ -41,18 +41,18 @@ class Contestnotification < ActiveRecord::Base
end
def recipients
contest.users.select {|user| user.notify_about?(self)}.map(&:mail)
#contest.users.select {|user| user.notify_about?(self)}.map(&:mail)
end
# returns latest news for contests visible by user
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
private
def add_author_as_watcher
Watcher.create(:watchable => self, :user => author)
#Watcher.create(:watchable => self, :user => author)
end
## fq
def act_as_activity