diff --git a/app/controllers/activity_notifys_controller.rb b/app/controllers/activity_notifys_controller.rb
index c696836b2..01e4260ea 100644
--- a/app/controllers/activity_notifys_controller.rb
+++ b/app/controllers/activity_notifys_controller.rb
@@ -15,11 +15,10 @@ class ActivityNotifysController < ApplicationController
end
if( query != nil )
- logger.info('xxoo')
limit = 10;
@obj_count = query.count();
@obj_pages = Paginator.new @obj_count,limit,params['page']
- list = query.order('id desc').limit(limit).offset(@obj_pages.offset).all();
+ list = query.order('is_read,id desc').limit(limit).offset(@obj_pages.offset).all();
events=[];
for item in list
event = item.activity;
@@ -29,7 +28,6 @@ class ActivityNotifysController < ApplicationController
end
@events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
@controller_name = 'ActivityNotifys'
- logger.info('aavv')
end
respond_to do |format|
format.html {render :template => 'courses/show', :layout => 'base_courses'}
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index c310087f7..353108dc7 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -62,6 +62,16 @@ class AttachmentsController < ApplicationController
render :action => 'file'
end
+ def pdf?(file)
+ file.downcase.end_with?(".pdf")
+ end
+
+ def direct_download
+ send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
+ :type => detect_content_type(@attachment),
+ :disposition => 'attachment' #inline can open in browser
+ end
+
def download
# modify by nwb
# 下载添加权限设置
@@ -69,20 +79,30 @@ class AttachmentsController < ApplicationController
if candown || User.current.admin? || User.current.id == @attachment.author_id
@attachment.increment_download
if stale?(:etag => @attachment.digest)
- convered_file = File.join(Rails.root, "files", "convered_office", @attachment.disk_filename + ".html")
- if File.exist?(convered_file)
- send_file convered_file, :type => 'text/html; charset=utf-8', :disposition => 'inline'
+ if params[:force] == 'true'
+ direct_download
else
- send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
- :type => detect_content_type(@attachment),
- :disposition => 'attachment' #inline can open in browser
+ convered_file = @attachment.diskfile
+ #如果本身不是pdf文件,则先寻找是不是已转换化,如果没有则转化
+ unless pdf?(convered_file)
+ convered_file = File.join(Rails.root, "files", "convered_office", @attachment.disk_filename + ".pdf")
+ unless File.exist?(convered_file)
+ office = Trustie::Utils::Office.new(@attachment.diskfile)
+ office.conver(convered_file)
+ end
+ end
+ if File.exist?(convered_file) && pdf?(convered_file)
+ send_file convered_file, :type => 'application/pdf; charset=utf-8', :disposition => 'inline'
+ else
+ direct_download
+ end
end
end
else
render_403 :message => :notice_not_authorized
end
rescue => e
- redirect_to "http: //" + (Setting.host_name.to_s) +"/file_not_found.html"
+ redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html"
end
#更新资源文件类型
@@ -196,13 +216,13 @@ class AttachmentsController < ApplicationController
if @attachment.container.is_a?(News)
format.html { redirect_to_referer_or news_path(@attachment.container) }
elsif @attachment.container.is_a?(StudentWorksScore)
- @is_destroy = true #根据ID删除页面对应的数据,js刷新页面
+ @is_destroy = true unless params[:attachment_id] #根据ID删除页面对应的数据,js刷新页面
format.js
elsif @attachment.container.is_a?(HomeworkCommon)
- @is_destroy = true #根据ID删除页面对应的数据,js刷新页面
+ @is_destroy = true unless params[:attachment_id] #根据ID删除页面对应的数据,js刷新页面
format.js
elsif @attachment.container.is_a?(StudentWork)
- @is_destroy = true #根据ID删除页面对应的数据,js刷新页面
+ @is_destroy = true unless params[:attachment_id] #根据ID删除页面对应的数据,js刷新页面
format.js
elsif @attachment.container.is_a?(Message)
format.html { redirect_to_referer_or new_board_message_path(@attachment.container) }
@@ -226,7 +246,7 @@ class AttachmentsController < ApplicationController
end
format.js
- end
+ end
end
def delete_homework
diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb
index 35236414f..aa1c369a0 100644
--- a/app/controllers/bids_controller.rb
+++ b/app/controllers/bids_controller.rb
@@ -1,1096 +1,1097 @@
-# fq
-class BidsController < ApplicationController
- #Added by young
- menu_item l(:label_homework), :only => [:edit, :udpate]
- menu_item :respond
- menu_item :course, :only => :show_courseEx
- menu_item :project, :only => [:show_project,:show_results, :new_submit_homework]
- menu_item :homework_respond, :only => :homework_respond
- menu_item :homework_statistics, :only => :homework_statistics
- menu_item :edit, :only => :edit
-
- before_filter :auth_login1, :only => [:show_courseEx]
-
- before_filter :can_show_course,only: []
- before_filter :can_show_contest,only: []
- #Ended by young
- before_filter :find_bid, :only => [:show, :show_project, :create,:destroy,:more,:back,:add,:delete,:new,:show_results,:set_reward, :add_homework, :fork, :create_fork,
- :show_course, :show_courseEx,:show_bid_project, :show_bid_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings]
- # added by fq
- before_filter :require_login, :only => [:join_in_contest, :unjoin_in_contest]
- # end
- before_filter :require_login,:only => [:set_reward, :destroy, :add, :new, ]
-
- #before_filter :memberAccess, only: :show_project
-
- helper :watchers
- helper :attachments
- include AttachmentsHelper
- include ApplicationHelper
- include BidsHelper
-
- helper :projects
- helper :words
- helper :welcome
- helper :project_score
-
- def find_project_by_bid_id
- @bid = Bid.find(params[:id])
- @project = @bid.courses[0]
- rescue ActiveRecord::RecordNotFound
- render_404
- end
-
- def homework_ajax_modal
- @bid = Bid.find_by_id(params[:id])
- # find_bid
- respond_to do |format|
- format.js
- end
- end
-
-
- def index
- @project_type = params[:project_type]
- # Modified by nie
- # @requirement_title = "4"
- @offset, @limit = api_offset_and_limit({:limit => 10})
- if @project_type == '1'
- @bids = Bid.visible.where('reward_type = ?', 3)
- # elsif
- # @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4)
- else
- @bids = Bid.visible.where('reward_type = ?', 1)
- end
-
- @bids = @bids.like(params[:name]) if params[:name].present?
- @bid_count = @bids.count
- @bid_pages = Paginator.new @bid_count, @limit, params['page']
-
- @offset ||= @bid_pages.reverse_offset
- #added by nie
- if params[:bid_sort_type].present?
- case params[:bid_sort_type]
- when '0'
- unless @offset == 0
- @bids = @bids.offset(@offset).limit(@limit).all.reverse
- else
- limit = @bid_count % @limit
- limit = @limit if limit == 0
- @bids = @bids.offset(@offset).limit(limit).all.reverse
- end
- @s_state = 0
- when '1'
- unless @offset == 0
- @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
- else
- limit = @bid_count % @limit
- limit = @limit if limit == 0
- @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
- end
- @s_state = 1
- when '2'
- unless @offset == 0
- @bids = @bids.offset(@offset).limit(@limit).all.reverse
- else
- limit = @bid_count % @limit
- limit = @limit if limit == 0
- @bids = @bids.offset(@offset).limit(@limit).all.reverse
- end
- @s_state = 0
- end
- else
- unless @offset == 0
- @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
- else
- limit = @bid_count % @limit
- limit = @limit if limit == 0
- @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
- end
- @s_state = 1
- end
- #end
- end
- #huang
- def contest
-
- # Modified by nie
- # @requirement_title = "4"
- @offset, @limit = api_offset_and_limit({:limit => 10})
-
- @bids = Bid.visible.where('reward_type = ?', 2)
-
- # elsif
- # @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4)
- @bids = @bids.like(params[:name]) if params[:name].present?
- @bid_count = @bids.count
- @bid_pages = Paginator.new @bid_count, @limit, params['page']
-
- @offset ||= @bid_pages.reverse_offset
- #added by nie
- if params[:contest_sort_type].present?
- case params[:contest_sort_type]
- when '0'
- unless @offset == 0
- @bids = @bids.offset(@offset).limit(@limit).all.reverse
- else
- limit = @bid_count % @limit
- limit = @limit if limit == 0
- @bids = @bids.offset(@offset).limit(limit).all.reverse
- end
- @s_state = 0
- when '1'
- unless @offset == 0
- @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
- else
- limit = @bid_count % @limit
- limit = @limit if limit == 0
- @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
- end
- @s_state = 1
- when '2'
- unless @offset == 0
- @bids = @bids.offset(@offset).limit(@limit).all.reverse
- else
- limit = @bid_count % @limit
- limit = @limit if limit == 0
- @bids = @bids.offset(@offset).limit(@limit).all.reverse
- end
- @s_state = 0
- end
- else
- unless @offset == 0
- @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
- else
- limit = @bid_count % @limit
- limit = @limit if limit == 0
- @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
- end
- @s_state = 1
- end
- #end
- end
-
- def fork
- @courses = []
- @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
- @membership.each do |membership|
- if membership.project.project_type == 1
- @courses << membership.project
- end
- end
- end
-
- #将某个企业外包需求选为作业,目前此功能已放弃
- def create_fork
- @homework = Bid.new
- @homework.name = params[:bid][:name]
- @homework.description = params[:bid][:description]
- @homework.reward_type = 3
- # @bid.budget = params[:bid][:budget]
- @homework.deadline = params[:bid][:deadline]
- @homework.budget = 0
- @homework.author_id = User.current.id
- @homework.commit = 0
- @homework.homework_type = 1
- @homework.is_evaluation = params[:bid][:is_evaluation]
- @homework.parent_id = @bid.id
- @homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
- # @bid.
- if @homework.save
- HomeworkForCourse.create(:course_id => params[:course], :bid_id => @homework.id)
- unless @bid.watched_by?(User.current)
- if @bid.add_watcher(User.current)
- flash[:notice] = l(:label_bid_succeed)
- end
- end
- redirect_to course_for_bid_path(@homework)
- else
- @bid.safe_attributes = params[:bid]
- @courses = []
- @membership = User.current.coursememberships.all#(:conditions => Project.visible_condition(User.current))
- @membership.each do |membership|
- @courses << membership.course
- end
- render :action => 'fork'
- end
- end
-
- #有两个路由链接到此方法:/bids/:id /calls/:id但是貌似这两个路由都不能访问。。方法作用有待确认
- def show
- @user = @bid.author
- @jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
- @limit = 10
- @feedback_count = @jours.count
- @feedback_pages = Paginator.new @feedback_count, @limit, params['page']
- @offset ||= @feedback_pages.offset
- @jour = @jours[@offset, @limit]
- @state = false
-
- respond_to do |format|
- layout_file = ''
- case @bid.reward_type
- when 3
- html_title(l(:label_question_student))
- layout_file = 'base_homework'
- when 1
- layout_file = 'base_bids'
- else
- layout_file = 'base_contest'
- end
- format.html {
- render :layout => layout_file
- }
- format.api
- end
- end
-
- def join_in_contest
- if @bid.reward_type == 2 && params[:course_password] == @bid.password
- JoinInContest.create(:user_id => User.current.id, :bid_id => @bid.id)
- @state = 0
- else
- @state = 1
- end
- respond_to do |format|
- format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} }
- end
- end
-
- def unjoin_in_contest
- joined = JoinInContest.where('bid_id = ? and user_id = ?', @bid.id, User.current.id)
- joined.each do |join|
- join.delete
- end
- respond_to do |format|
- format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} }
- end
- end
-
- def new_join
-
- end
-
- # added by bai 增加了参与者和竞赛设置
- def show_participator
- render :layout => 'base_contest'
- end
-
- #配置竞赛
- def settings
- if @bid.author.id == User.current.id
- if @bid.reward_type == 2
- @contest = Bid.find_by_reward_type(@bid.reward_type)
- render :layout => 'base_contest'
- end
- else
- render_403 :message => :notice_not_contest_setting_authorized
- end
- end
- #end
-
- # 显示课程作业,但是好像已经废弃
- def show_course
- bids = Bid.where('parent_id = ?', @bid.id)
- @courses = []
- for bid in bids
- @courses << bid.courses.first
- end
-
- respond_to do |format|
- if @bid.reward_type == 3
- format.html {
- render :layout => 'base_homework'
- }
- elsif @bid.reward_type == 1
- format.html {
- render :layout => 'base_bids'
- }
- else
- format.html {
- render :layout => 'base_contest'
- }
- end
- format.api
-
- end
- end
-
- def show_bid_project
- bids = Bid.where('parent_id = ?', @bid.id)
- @projects = []
- for bid in bids
- @projects += bid.biding_projects
- end
-
- respond_to do |format|
- if @bid.reward_type == 3
- format.html {
- render :layout => 'base_homework'
- }
- elsif @bid.reward_type == 1
- format.html {
- render :layout => 'base_bids'
- }
- else
- format.html {
- render :layout => 'base_contest'
- }
- end
- format.api
-
- end
- end
-
- def show_bid_user
- bids = Bid.where('parent_id = ?', @bid.id)
- @users = []
- for bid in bids
- for project in bid.projects
- @users += project.users
- end
- end
-
- respond_to do |format|
- if @bid.reward_type == 3
- format.html {
- render :layout => 'base_homework'
- }
- elsif @bid.reward_type == 1
- format.html {
- render :layout => 'base_bids'
- }
- else
- format.html {
- render :layout => 'base_contest'
- }
- end
- format.api
-
- end
- end
-
- def show_project
- # flash[:notice] = ""
- @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
- @option = []
- @membership.each do |membership|
- unless(membership.project.project_type==1)
- if membership.user.allowed_to?(:quote_project,membership.project)
- @option << membership.project
- end
- end
- end
-
- # a = [1]
- # @project = Project.where("id in []", a)
- @user = @bid.author
- @bidding_project = @bid.biding_projects.all
- if params[:student_id].present?
- @temp = []
- @bidding_project.each do |pro|
- if pro.project && pro.project.project_status
- if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
- @temp << pro
- end
- end
- @temp
- end
- @bidding_project = @temp
- else
- #added by nie
- @temp = []
- @bidding_project.each do |pro|
- if pro.project && pro.project.project_status
- @temp << pro
- end
- @temp
- end
- if @temp.size > 0
- @bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
- end
- #ended
- end
-
- if @bid.homework_type == 1
- @homework = HomeworkAttach.new
- #@homework_list = @bid.homeworks
- #增加作业按评分排序,
- @homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC').order("#{HomeworkAttach.table_name}.created_at ASC")
- if params[:student_id].present?
- @temp = []
- @homework_list.each do |pro|
- if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
- @temp << pro
- end
- @temp
- end
- @homework_list = @temp
- end
- end
-
- respond_to do |format|
- if @bid.reward_type == 3
- format.html {
- render :layout => 'base_homework'
- }
- elsif @bid.reward_type == 1
- format.html {
- render :layout => 'base_bids'
- }
- else
- format.html {
- render :layout => 'base_contest'
- }
- end
- format.api
- end
- end
-
- # 显示作业课程
- # add by nwb
- def show_courseEx
-
- if (User.current.logged? && (User.current.member_of_course?(@bid.courses.first) || User.current.admin?))
- @membership = User.current.coursememberships.all(:conditions => Course.visible_condition(User.current))
- @user = @bid.author
- @bidding_project = @bid.biding_projects.all
-
- if params[:student_id].present?
- @temp = []
- @bidding_project.each do |pro|
- if pro.project && pro.project.project_status
- if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
- @temp << pro
- end
- end
- @temp
- end
- @bidding_project = @temp
- else
- #added by nie
- @temp = []
- @bidding_project.each do |pro|
- if pro.project && pro.project.project_status
- @temp << pro
- end
- @temp
- end
- if @temp.size > 0
- @bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
- end
- #ended
- end
-
- if @bid.homework_type
- @homework = HomeworkAttach.new
- @is_teacher = is_course_teacher(User.current,@bid.courses.first)
- if @is_teacher
- all_homework_list = HomeworkAttach.find_by_sql("SELECT * FROM (SELECT homework_attaches.*,
- (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score,
- (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score
- FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY s_score DESC,created_at ASC) AS table1
- WHERE table1.t_score IS NULL")
- @not_batch_homework = true
- @cur_type = 1
- else
- all_homework_list = HomeworkAttach.find_by_sql("SELECT homework_attaches.*,
- (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score,
- (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score,
- (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id} AND is_teacher_score = #{@is_teacher ? 1 : 0}) AS m_score
- FROM homework_attaches
- INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id
- WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY s_score DESC")
- @is_student_batch_homework = true
- @cur_type = 4
- end
-
- @cur_page = params[:page] || 1
- # @homework_list = paginateHelper all_homework_list,10
- @homework_list = all_homework_list
- @jours_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count
- if params[:student_id].present?
- @temp = []
- @homework_list.each do |pro|
- if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
- @temp << pro
- end
- @temp
- end
- @homework_list = @temp
- end
- end
-
- respond_to do |format|
- if @bid.reward_type == 3
- format.html {
- html_title(l(:label_homework_info))
- render :layout => 'base_homework'
- }
- elsif @bid.reward_type == 1
- format.html {
- render :layout => 'base_bids'
- }
- else
- format.html {
- render :layout => 'base_contest'
- }
- end
- format.api
- end
- else
- render_403 :message => :notice_not_authorized
- end
- end
-
- ##### by huang
- def show_project_homework
- # flash[:notice] = ""
- @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
- @option = []
- @membership.each do |membership|
- end
- # a = [1]
- # @project = Project.where("id in []", a)
- @user = @bid.author
- @bidding_project = @bid.biding_projects
- respond_to do |format|
- if @bid.reward_type == 3
- format.html {
- render :layout => 'base_homework'
- }
- elsif @bid.reward_type == 1
- format.html {
- render :layout => 'base_bids'
- }
- else
- format.html {
- render :layout => 'base_contest'
- }
- end
- format.api
- end
- end
-
- ###添加应标项目
- def add
- project = Project.find(params[:bid])
- bid_message = params[:bid_for_save][:bid_message]
- if BidingProject.where("project_id = ? and bid_id = ?", project.id, @bid.id).size == 0
- if BidingProject.cerate_bidding(@bid.id, project.id, bid_message)
-
- # added by bai type ==1 需求,type==2 竞赛, type==3 作业
- if @bid.reward_type == 1
- flash.now[:notice] = l(:label_bidding_succeed)
-
- elsif @bid.reward_type == 2
- flash.now[:notice] = l(:label_bidding_contest_succeed)
-
- else @bid.reward_type == 3
- flash.now[:notice] = l(:label_bidding_homework_succeed)
- end
- # end
-
- end
- else
- if @bid.reward_type == 3
- flash.now[:error] = l(:label_bidding_homework_fail)
- else
- flash.now[:error] = l(:label_bidding_fail)
- end
- end
- @bidding_project = @bid.biding_projects
- respond_to do |format|
- # format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}}
- # format.html
- format.html { redirect_to :back }
- format.js
- #format.api { render_api_ok }
- end
- end
-
- #删除已提交的项目作业(不删项目)
- def delete
- binding_project = params[:binding_project]
- if can_delete_project_homework(BidingProject.find(binding_project),User.current)
- if BidingProject.delete(binding_project)
- redirect_to project_for_bid_url
- else
- render_403;
- end
- end
- end
- ## 新建留言
- def create
-
- if params[:bid_message][:message].size>0
- if params[:reference_content]
- message = params[:bid_message][:message] + "\n" + params[:reference_content]
- else
- message = params[:bid_message][:message]
- @m = message
- end
- refer_user_id = params[:bid_message][:reference_user_id].to_i
- @bid.add_jour(User.current, message, refer_user_id)
- end
- @user = @bid.author
- @jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
- @jour = paginateHelper @jours,10
- @bid.set_commit(@feedback_count)
- respond_to do |format|
- format.js
- #format.api { render_api_ok }
- end
-
- end
-
- ##删除留言
- def destroy
- @user = @bid.author
- if User.current.admin? || User.current.id == @user.id
- JournalsForMessage.delete_message(params[:object_id])
- end
- @jours = @bid.journals_for_messages.reverse
- @limit = 10
- @feedback_count = @jours.count
- @feedback_pages = Paginator.new @feedback_count, @limit, params['page']
- @offset ||= @feedback_pages.offset
- @jour = @jours[@offset, @limit]
-
- @bid.set_commit(@feedback_count)
- # if a_message.size > 5
- # @message = a_message[-5, 5]
- # else
- # @message = a_message
- # end
- # @message_count = a_message.count
-
- respond_to do |format|
- # format.html
- format.js
- #format.api { render_api_ok }
- end
- end
-
- #删除作业
- #by xianbo
- def homework_destroy
- @bid_to_destroy = Bid.find params[:id]
- course_url = course_homework_path(@bid_to_destroy.courses.first)
- (render_403; return false) unless User.current.admin?||User.current.id==@bid_to_destroy.author_id
- @bid_to_destroy.destroy
- respond_to do |format|
- format.html { redirect_to course_url }
- format.js
- #format.api { render_api_ok }
- end
- end
-
- #end by xianbo
- ##引用
- def new
- @jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id]
- if @jour
- user = @jour.user
- text = @jour.notes
- else
- user = @bid.author
- text = @bid.description
- end
- # Replaces pre blocks with [...]
- text = text.to_s.strip.gsub(%r{
((.|\s)*?)
}m, '[...]')
- @content = "> #{ll(User.current.language, :text_user_wrote, user)}\n> "
- @content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
- @id = user.id
- rescue ActiveRecord::RecordNotFound
- render_404
- end
-
- ##新建需求
- def new_bid
- @bid = Bid.new
- @bid.safe_attributes = params[:bid]
- end
-
- #huang
- def create_contest
- @bid = Bid.new
- @bid.name = params[:bid][:name]
- @bid.description = params[:bid][:description]
- @bid.reward_type = 2
- @bid.budget = params[:bid][:budget]
- @bid.deadline = params[:bid][:deadline]
- @bid.password = params[:bid][:password] #added by bai
- @bid.author_id = User.current.id
- @bid.commit = 0
- if @bid.save
- unless @bid.watched_by?(User.current)
- if @bid.add_watcher(User.current)
- flash[:notice] = l(:label_bid_succeed)
- end
- end
- redirect_to respond_url(@bid)
- else
- @bid.safe_attributes = params[:bid]
- render :action => 'new_bid'
- end
- end
-
- # added by bai
- def update_contest
- @bid = Bid.find(params[:id])
- @bid.name = params[:bid][:name]
- @bid.description = params[:bid][:description]
- @bid.reward_type = 2
- @bid.budget = params[:bid][:budget]
- @bid.deadline = params[:bid][:deadline]
- @bid.password = params[:bid][:password]
- @bid.author_id = User.current.id
- @bid.commit = 0
- if @bid.save
- unless @bid.watched_by?(User.current)
- if @bid.add_watcher(User.current)
- flash[:notice] = l(:label_bid_succeed)
- end
- end
- redirect_to respond_url(@bid)
- else
- @bid.safe_attributes = params[:bid]
- render :action => 'new_bid'
- end
- end
- #huang
- def new_contest
- @bid = Bid.new
- @bid.safe_attributes = params[:bid]
- end
-
- def create_bid
- @bid = Bid.new
- @bid.name = params[:bid][:name]
- @bid.description = params[:bid][:description]
- @bid.reward_type = 1
- @bid.budget = params[:bid][:budget]
- @bid.deadline = params[:bid][:deadline]
- @bid.author_id = User.current.id
- @bid.commit = 0
- if @bid.save
- unless @bid.watched_by?(User.current)
- if @bid.add_watcher(User.current)
- flash[:notice] = l(:label_bid_succeed)
- end
- end
- redirect_to respond_url(@bid)
- else
- @bid.safe_attributes = params[:bid]
- render :action => 'new_bid'
- end
- end
-
- def create_homework
- @bid = Bid.new
- @bid.name = params[:bid][:name]
- @bid.description = params[:bid][:description]
- @bid.is_evaluation = params[:bid][:is_evaluation]
- @bid.proportion = params[:bid][:proportion]
- @bid.evaluation_num = params[:bid][:evaluation_num]
- params[:bid][:open_anonymous_evaluation] ? @bid.open_anonymous_evaluation = 1 : @bid.open_anonymous_evaluation = 0
- @bid.reward_type = 3
- # @bid.budget = params[:bid][:budget]
- @bid.deadline = params[:bid][:deadline]
- @bid.budget = 0
- @bid.author_id = User.current.id
- @bid.commit = 0
- @bid.homework_type = 1
- @bid.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
- # @bid.
- if @bid.save
- HomeworkForCourse.create(:course_id => params[:course_id], :bid_id => @bid.id)
- unless @bid.watched_by?(User.current)
- if @bid.add_watcher(User.current)
- flash[:notice] = l(:label_bid_succeed)
- end
- end
- redirect_to course_homework_url(params[:course_id])
- else
- @bid.safe_attributes = params[:bid]
- @homework = @bid
- @course = Course.find_by_id(params[:course_id])
- @course_id = @course.id
- #respond_to do |format|
- # format.html { redirect_to new_homework_course_path(params[:course_id]),:layout => 'base_courses'}
- # format.api { render_validation_errors(@bid) }
- #end
- render file: 'courses/new_homework', layout: 'base_courses'
- end
- end
-
- # modify by nwb\
- # 编辑作业
- def edit
- @bid = Bid.find(params[:bid_id])
- if (User.current.admin?||User.current.allowed_to?(:as_teacher,@bid.courses.first))
- @course_id = params[:course_id]
- respond_to do |format|
- format.html {
- @course = Course.find(params[:course_id])
- @user= User.find(User.current.id)
- render :layout => 'base_courses'
- }
- end
- else
- render_403
- end
- end
-
- def update
- @bid = Bid.find(params[:id])
- @course = @bid.courses.first#Project.find(params[:course_id])
- @bid.name = params[:bid][:name]
- @bid.description = params[:bid][:description]
- @bid.is_evaluation = params[:bid][:is_evaluation]
- @bid.proportion = params[:bid][:proportion]
- @bid.evaluation_num = params[:bid][:evaluation_num]
- params[:bid][:open_anonymous_evaluation] ? @bid.open_anonymous_evaluation = 1 : @bid.open_anonymous_evaluation = 0
- @bid.reward_type = 3
- @bid.deadline = params[:bid][:deadline]
- @bid.budget = 0
- #@bid.author_id = User.current.id
- @bid.commit = 0
- @bid.homework_type = 1
- @bid.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
- if @bid.save
- flash[:notice] = l(:label_update_homework_succeed)
- redirect_to course_homework_url(@course)
- else
- @bid.safe_attributes = params[:bid]
- render :action => 'edit', :layout =>'base_courses'
- end
- end
-
- def new_submit_homework
- #render html to prepare create submit homework
- find_bid
- find_bid
- render :layout => 'base_homework'
- end
-
- def add_homework
- if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0)
- # homework = HomeworkAttach.create(:bid_id => @bid.id, :user_id => User.current.id)
- # homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
-
- if hadcommittedhomework(User.current.id, @bid.id) == true
- @homework_flag = l(:label_bidding_homework_committed)
- else
- @homework = HomeworkAttach.new
- @homework.safe_attributes = params[:homeworkattach]
- @homework.bid_id = @bid.id
- @homework.user_id = User.current.id
- @homework.save_attachments(params[:attachments])
-
- render_attachment_warning_if_needed(@homework)
-
- @homework_flag = if @homework.save
- l(:label_bidding_homework_succeed)
- else
- l(:label_bidding_homework_failed)
- end
-
- if @homework.attachments.empty?
- @homework.delete
- #flash[:error] = l(:no_attachmens_allowed)
- @homework_flag = l(:no_attachmens_allowed)
- # else
- end
- end
- end
-
- @homework_list = @bid.homeworks
- respond_to do |format|
- format.html{
- #redirect_to project_for_bid_path, notice: @homework_flag.to_s
- flash[:notice] = @homework_flag.to_s
- redirect_back_or_default(project_for_bid_path)
- }
- format.js
- end
-
- end
-
- # 作业统计
- def homework_statistics
- @course = @bid.courses.first
- @member = []
- @course.memberships.each do |member|
- unless (member.roles && Role.where('id = ? ', 3)).empty?
- @member.push member
- end
- end
- if @bid.homework_type = 1
- @student = User.where("id in (select DISTINCT user_id from #{HomeworkAttach.table_name} where bid_id = ? )", @bid.id)
- @homework_type = true
- else
-
- @homework_type = false
- end
- @user = @bid.author
- render :layout => 'base_homework'
- end
-
- def homework_respond
- @user = @bid.author
- render :layout => 'base_homework'
- end
-
- def more
- @jour = @bid.journals_for_messages
- @jour.each_with_index {|j,i| j.indice = i+1}
- @state = true
-
- respond_to do |format|
- format.html { redirect_to :back }
- format.js
- #format.api { render_api_ok }
- end
- end
-
- def back
- @jour = @bid.journals_for_messages
- @jour.each_with_index {|j,i| j.indice = i+1}
- @state = false
-
- respond_to do |format|
- format.html { redirect_to :back }
- format.js
- #format.api { render_api_ok }
- end
- end
-
- #added by william
- #used to set the bidding project reward
- def set_reward
- @b_p = nil
- @biding_project_id = nil
-
- if params[:set_reward][:reward]&&((User.current.id==@bid.author_id)||User.current.admin)
- # @bid_id = params[:id]
- @biding_project_id = params[:set_reward][:b_id]
- @b_p = BidingProject.find_by_id(@biding_project_id)
-
- # 把字段存进表中
- @b_p.update_reward(params[:set_reward][:reward].to_s)
- end
-
- respond_to do |format|
- format.js
- end
- end
-
- # added by william
- # used to manage the bid and end the bid
- def manage
-
- end
-
- # 启动匿评
- def start_anonymous_comment
- @bid = Bid.find(params[:id])
- @course = @bid.courses.first
- if(@bid.comment_status == 0)
- homeworks = @bid.homeworks
- if(homeworks && homeworks.size >= 2)
- homeworks.each_with_index do |homework, index|
- user = homework.user
- n = @bid.evaluation_num
- n = n < homeworks.size ? n : homeworks.size - 1
- assigned_homeworks = get_assigned_homeworks(homeworks, n, index)
- assigned_homeworks.each do |h|
- @homework_evaluation = HomeworkEvaluation.new(user_id: user.id, homework_attach_id: h.id)
- @homework_evaluation.save
- end
- end
- @bid.update_column('comment_status', 1)
- @statue = 1
- else
- @statue = 2
- end
- else
- @statue = 3
- end
-
- respond_to do |format|
- format.js
- end
- end
-
- def stop_anonymous_comment
- @bid = Bid.find(params[:id])
-
- @bid.update_column('comment_status', 2)
-
- respond_to do |format|
- format.js
- end
- end
-
- def alert_anonymous_comment
- @bid = Bid.find params[:id]
- @course = @bid.courses.first
- @cur_size = 0
- @totle_size = 0
- if @bid.comment_status == 0
- @totle_size = searchStudent(@course).size
- @cur_size = @bid.homeworks.size
- elsif @bid.comment_status == 1
- @bid.homeworks.map { |homework| @totle_size += homework.homework_evaluations.count}
- @cur_size = 0
- @bid.homeworks.map { |homework| @cur_size += homework.rates(:quality).where("seems_rateable_rates.is_teacher_score = 0").count}
- end
- @percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100)
- respond_to do |format|
- format.js
- end
- end
-
- private
-
- def get_assigned_homeworks(homeworks, n, index)
- homeworks += homeworks
- homeworks[index + 1 .. index + n]
- end
-
- def find_bid
- if params[:id]
- @bid = Bid.find(params[:id], :include => [{:homeworks => :user}])
- @user = @bid.author
- end
- rescue
- render_404
- end
-
- def memberAccess
- # 是课程,则判断当前用户是否参加了课程
- return true if current_user.admin?
- #return 0 if @bid.courses.first.project_type == Project::ProjectType_project
- currentUser = User.current
- render_403 unless currentUser.member_of_course?(@bid.courses.first)
- end
-
- #验证是否显示课程
- def can_show_course
- @first_page = FirstPage.find_by_page_type('project')
- if @first_page.show_course == 2
- render_404
- end
- end
-
- #验证是否显示竞赛
- def can_show_contest
- @first_page = FirstPage.find_by_page_type('project')
- if @first_page.show_contest == 2
- render_404
- end
- end
-end
-
+# # fq
+#Bid功能已经废弃,代码参考用
+# class BidsController < ApplicationController
+# #Added by young
+# menu_item l(:label_homework), :only => [:edit, :udpate]
+# menu_item :respond
+# menu_item :course, :only => :show_courseEx
+# menu_item :project, :only => [:show_project,:show_results, :new_submit_homework]
+# menu_item :homework_respond, :only => :homework_respond
+# menu_item :homework_statistics, :only => :homework_statistics
+# menu_item :edit, :only => :edit
+#
+# before_filter :auth_login1, :only => [:show_courseEx]
+#
+# before_filter :can_show_course,only: []
+# before_filter :can_show_contest,only: []
+# #Ended by young
+# before_filter :find_bid, :only => [:show, :show_project, :create,:destroy,:more,:back,:add,:delete,:new,:show_results,:set_reward, :add_homework, :fork, :create_fork,
+# :show_course, :show_courseEx,:show_bid_project, :show_bid_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings]
+# # added by fq
+# before_filter :require_login, :only => [:join_in_contest, :unjoin_in_contest]
+# # end
+# before_filter :require_login,:only => [:set_reward, :destroy, :add, :new, ]
+#
+# #before_filter :memberAccess, only: :show_project
+#
+# helper :watchers
+# helper :attachments
+# include AttachmentsHelper
+# include ApplicationHelper
+# include BidsHelper
+#
+# helper :projects
+# helper :words
+# helper :welcome
+# helper :project_score
+#
+# def find_project_by_bid_id
+# @bid = Bid.find(params[:id])
+# @project = @bid.courses[0]
+# rescue ActiveRecord::RecordNotFound
+# render_404
+# end
+#
+# def homework_ajax_modal
+# @bid = Bid.find_by_id(params[:id])
+# # find_bid
+# respond_to do |format|
+# format.js
+# end
+# end
+#
+#
+# def index
+# @project_type = params[:project_type]
+# # Modified by nie
+# # @requirement_title = "4"
+# @offset, @limit = api_offset_and_limit({:limit => 10})
+# if @project_type == '1'
+# @bids = Bid.visible.where('reward_type = ?', 3)
+# # elsif
+# # @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4)
+# else
+# @bids = Bid.visible.where('reward_type = ?', 1)
+# end
+#
+# @bids = @bids.like(params[:name]) if params[:name].present?
+# @bid_count = @bids.count
+# @bid_pages = Paginator.new @bid_count, @limit, params['page']
+#
+# @offset ||= @bid_pages.reverse_offset
+# #added by nie
+# if params[:bid_sort_type].present?
+# case params[:bid_sort_type]
+# when '0'
+# unless @offset == 0
+# @bids = @bids.offset(@offset).limit(@limit).all.reverse
+# else
+# limit = @bid_count % @limit
+# limit = @limit if limit == 0
+# @bids = @bids.offset(@offset).limit(limit).all.reverse
+# end
+# @s_state = 0
+# when '1'
+# unless @offset == 0
+# @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
+# else
+# limit = @bid_count % @limit
+# limit = @limit if limit == 0
+# @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
+# end
+# @s_state = 1
+# when '2'
+# unless @offset == 0
+# @bids = @bids.offset(@offset).limit(@limit).all.reverse
+# else
+# limit = @bid_count % @limit
+# limit = @limit if limit == 0
+# @bids = @bids.offset(@offset).limit(@limit).all.reverse
+# end
+# @s_state = 0
+# end
+# else
+# unless @offset == 0
+# @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
+# else
+# limit = @bid_count % @limit
+# limit = @limit if limit == 0
+# @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
+# end
+# @s_state = 1
+# end
+# #end
+# end
+# #huang
+# def contest
+#
+# # Modified by nie
+# # @requirement_title = "4"
+# @offset, @limit = api_offset_and_limit({:limit => 10})
+#
+# @bids = Bid.visible.where('reward_type = ?', 2)
+#
+# # elsif
+# # @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4)
+# @bids = @bids.like(params[:name]) if params[:name].present?
+# @bid_count = @bids.count
+# @bid_pages = Paginator.new @bid_count, @limit, params['page']
+#
+# @offset ||= @bid_pages.reverse_offset
+# #added by nie
+# if params[:contest_sort_type].present?
+# case params[:contest_sort_type]
+# when '0'
+# unless @offset == 0
+# @bids = @bids.offset(@offset).limit(@limit).all.reverse
+# else
+# limit = @bid_count % @limit
+# limit = @limit if limit == 0
+# @bids = @bids.offset(@offset).limit(limit).all.reverse
+# end
+# @s_state = 0
+# when '1'
+# unless @offset == 0
+# @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
+# else
+# limit = @bid_count % @limit
+# limit = @limit if limit == 0
+# @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
+# end
+# @s_state = 1
+# when '2'
+# unless @offset == 0
+# @bids = @bids.offset(@offset).limit(@limit).all.reverse
+# else
+# limit = @bid_count % @limit
+# limit = @limit if limit == 0
+# @bids = @bids.offset(@offset).limit(@limit).all.reverse
+# end
+# @s_state = 0
+# end
+# else
+# unless @offset == 0
+# @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
+# else
+# limit = @bid_count % @limit
+# limit = @limit if limit == 0
+# @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
+# end
+# @s_state = 1
+# end
+# #end
+# end
+#
+# def fork
+# @courses = []
+# @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
+# @membership.each do |membership|
+# if membership.project.project_type == 1
+# @courses << membership.project
+# end
+# end
+# end
+#
+# #将某个企业外包需求选为作业,目前此功能已放弃
+# def create_fork
+# @homework = Bid.new
+# @homework.name = params[:bid][:name]
+# @homework.description = params[:bid][:description]
+# @homework.reward_type = 3
+# # @bid.budget = params[:bid][:budget]
+# @homework.deadline = params[:bid][:deadline]
+# @homework.budget = 0
+# @homework.author_id = User.current.id
+# @homework.commit = 0
+# @homework.homework_type = 1
+# @homework.is_evaluation = params[:bid][:is_evaluation]
+# @homework.parent_id = @bid.id
+# @homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
+# # @bid.
+# if @homework.save
+# HomeworkForCourse.create(:course_id => params[:course], :bid_id => @homework.id)
+# unless @bid.watched_by?(User.current)
+# if @bid.add_watcher(User.current)
+# flash[:notice] = l(:label_bid_succeed)
+# end
+# end
+# redirect_to course_for_bid_path(@homework)
+# else
+# @bid.safe_attributes = params[:bid]
+# @courses = []
+# @membership = User.current.coursememberships.all#(:conditions => Project.visible_condition(User.current))
+# @membership.each do |membership|
+# @courses << membership.course
+# end
+# render :action => 'fork'
+# end
+# end
+#
+# #有两个路由链接到此方法:/bids/:id /calls/:id但是貌似这两个路由都不能访问。。方法作用有待确认
+# def show
+# @user = @bid.author
+# @jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
+# @limit = 10
+# @feedback_count = @jours.count
+# @feedback_pages = Paginator.new @feedback_count, @limit, params['page']
+# @offset ||= @feedback_pages.offset
+# @jour = @jours[@offset, @limit]
+# @state = false
+#
+# respond_to do |format|
+# layout_file = ''
+# case @bid.reward_type
+# when 3
+# html_title(l(:label_question_student))
+# layout_file = 'base_homework'
+# when 1
+# layout_file = 'base_bids'
+# else
+# layout_file = 'base_contest'
+# end
+# format.html {
+# render :layout => layout_file
+# }
+# format.api
+# end
+# end
+#
+# def join_in_contest
+# if @bid.reward_type == 2 && params[:course_password] == @bid.password
+# JoinInContest.create(:user_id => User.current.id, :bid_id => @bid.id)
+# @state = 0
+# else
+# @state = 1
+# end
+# respond_to do |format|
+# format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} }
+# end
+# end
+#
+# def unjoin_in_contest
+# joined = JoinInContest.where('bid_id = ? and user_id = ?', @bid.id, User.current.id)
+# joined.each do |join|
+# join.delete
+# end
+# respond_to do |format|
+# format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} }
+# end
+# end
+#
+# def new_join
+#
+# end
+#
+# # added by bai 增加了参与者和竞赛设置
+# def show_participator
+# render :layout => 'base_contest'
+# end
+#
+# #配置竞赛
+# def settings
+# if @bid.author.id == User.current.id
+# if @bid.reward_type == 2
+# @contest = Bid.find_by_reward_type(@bid.reward_type)
+# render :layout => 'base_contest'
+# end
+# else
+# render_403 :message => :notice_not_contest_setting_authorized
+# end
+# end
+# #end
+#
+# # 显示课程作业,但是好像已经废弃
+# def show_course
+# bids = Bid.where('parent_id = ?', @bid.id)
+# @courses = []
+# for bid in bids
+# @courses << bid.courses.first
+# end
+#
+# respond_to do |format|
+# if @bid.reward_type == 3
+# format.html {
+# render :layout => 'base_homework'
+# }
+# elsif @bid.reward_type == 1
+# format.html {
+# render :layout => 'base_bids'
+# }
+# else
+# format.html {
+# render :layout => 'base_contest'
+# }
+# end
+# format.api
+#
+# end
+# end
+#
+# def show_bid_project
+# bids = Bid.where('parent_id = ?', @bid.id)
+# @projects = []
+# for bid in bids
+# @projects += bid.biding_projects
+# end
+#
+# respond_to do |format|
+# if @bid.reward_type == 3
+# format.html {
+# render :layout => 'base_homework'
+# }
+# elsif @bid.reward_type == 1
+# format.html {
+# render :layout => 'base_bids'
+# }
+# else
+# format.html {
+# render :layout => 'base_contest'
+# }
+# end
+# format.api
+#
+# end
+# end
+#
+# def show_bid_user
+# bids = Bid.where('parent_id = ?', @bid.id)
+# @users = []
+# for bid in bids
+# for project in bid.projects
+# @users += project.users
+# end
+# end
+#
+# respond_to do |format|
+# if @bid.reward_type == 3
+# format.html {
+# render :layout => 'base_homework'
+# }
+# elsif @bid.reward_type == 1
+# format.html {
+# render :layout => 'base_bids'
+# }
+# else
+# format.html {
+# render :layout => 'base_contest'
+# }
+# end
+# format.api
+#
+# end
+# end
+#
+# def show_project
+# # flash[:notice] = ""
+# @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
+# @option = []
+# @membership.each do |membership|
+# unless(membership.project.project_type==1)
+# if membership.user.allowed_to?(:quote_project,membership.project)
+# @option << membership.project
+# end
+# end
+# end
+#
+# # a = [1]
+# # @project = Project.where("id in []", a)
+# @user = @bid.author
+# @bidding_project = @bid.biding_projects.all
+# if params[:student_id].present?
+# @temp = []
+# @bidding_project.each do |pro|
+# if pro.project && pro.project.project_status
+# if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
+# @temp << pro
+# end
+# end
+# @temp
+# end
+# @bidding_project = @temp
+# else
+# #added by nie
+# @temp = []
+# @bidding_project.each do |pro|
+# if pro.project && pro.project.project_status
+# @temp << pro
+# end
+# @temp
+# end
+# if @temp.size > 0
+# @bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
+# end
+# #ended
+# end
+#
+# if @bid.homework_type == 1
+# @homework = HomeworkAttach.new
+# #@homework_list = @bid.homeworks
+# #增加作业按评分排序,
+# @homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC').order("#{HomeworkAttach.table_name}.created_at ASC")
+# if params[:student_id].present?
+# @temp = []
+# @homework_list.each do |pro|
+# if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
+# @temp << pro
+# end
+# @temp
+# end
+# @homework_list = @temp
+# end
+# end
+#
+# respond_to do |format|
+# if @bid.reward_type == 3
+# format.html {
+# render :layout => 'base_homework'
+# }
+# elsif @bid.reward_type == 1
+# format.html {
+# render :layout => 'base_bids'
+# }
+# else
+# format.html {
+# render :layout => 'base_contest'
+# }
+# end
+# format.api
+# end
+# end
+#
+# # 显示作业课程
+# # add by nwb
+# def show_courseEx
+#
+# if (User.current.logged? && (User.current.member_of_course?(@bid.courses.first) || User.current.admin?))
+# @membership = User.current.coursememberships.all(:conditions => Course.visible_condition(User.current))
+# @user = @bid.author
+# @bidding_project = @bid.biding_projects.all
+#
+# if params[:student_id].present?
+# @temp = []
+# @bidding_project.each do |pro|
+# if pro.project && pro.project.project_status
+# if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
+# @temp << pro
+# end
+# end
+# @temp
+# end
+# @bidding_project = @temp
+# else
+# #added by nie
+# @temp = []
+# @bidding_project.each do |pro|
+# if pro.project && pro.project.project_status
+# @temp << pro
+# end
+# @temp
+# end
+# if @temp.size > 0
+# @bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
+# end
+# #ended
+# end
+#
+# if @bid.homework_type
+# @homework = HomeworkAttach.new
+# @is_teacher = is_course_teacher(User.current,@bid.courses.first)
+# if @is_teacher
+# all_homework_list = HomeworkAttach.find_by_sql("SELECT * FROM (SELECT homework_attaches.*,
+# (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score,
+# (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score
+# FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY s_score DESC,created_at ASC) AS table1
+# WHERE table1.t_score IS NULL")
+# @not_batch_homework = true
+# @cur_type = 1
+# else
+# all_homework_list = HomeworkAttach.find_by_sql("SELECT homework_attaches.*,
+# (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score,
+# (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score,
+# (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id} AND is_teacher_score = #{@is_teacher ? 1 : 0}) AS m_score
+# FROM homework_attaches
+# INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id
+# WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY s_score DESC")
+# @is_student_batch_homework = true
+# @cur_type = 4
+# end
+#
+# @cur_page = params[:page] || 1
+# # @homework_list = paginateHelper all_homework_list,10
+# @homework_list = all_homework_list
+# @jours_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count
+# if params[:student_id].present?
+# @temp = []
+# @homework_list.each do |pro|
+# if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
+# @temp << pro
+# end
+# @temp
+# end
+# @homework_list = @temp
+# end
+# end
+#
+# respond_to do |format|
+# if @bid.reward_type == 3
+# format.html {
+# html_title(l(:label_homework_info))
+# render :layout => 'base_homework'
+# }
+# elsif @bid.reward_type == 1
+# format.html {
+# render :layout => 'base_bids'
+# }
+# else
+# format.html {
+# render :layout => 'base_contest'
+# }
+# end
+# format.api
+# end
+# else
+# render_403 :message => :notice_not_authorized
+# end
+# end
+#
+# ##### by huang
+# def show_project_homework
+# # flash[:notice] = ""
+# @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
+# @option = []
+# @membership.each do |membership|
+# end
+# # a = [1]
+# # @project = Project.where("id in []", a)
+# @user = @bid.author
+# @bidding_project = @bid.biding_projects
+# respond_to do |format|
+# if @bid.reward_type == 3
+# format.html {
+# render :layout => 'base_homework'
+# }
+# elsif @bid.reward_type == 1
+# format.html {
+# render :layout => 'base_bids'
+# }
+# else
+# format.html {
+# render :layout => 'base_contest'
+# }
+# end
+# format.api
+# end
+# end
+#
+# ###添加应标项目
+# def add
+# project = Project.find(params[:bid])
+# bid_message = params[:bid_for_save][:bid_message]
+# if BidingProject.where("project_id = ? and bid_id = ?", project.id, @bid.id).size == 0
+# if BidingProject.cerate_bidding(@bid.id, project.id, bid_message)
+#
+# # added by bai type ==1 需求,type==2 竞赛, type==3 作业
+# if @bid.reward_type == 1
+# flash.now[:notice] = l(:label_bidding_succeed)
+#
+# elsif @bid.reward_type == 2
+# flash.now[:notice] = l(:label_bidding_contest_succeed)
+#
+# else @bid.reward_type == 3
+# flash.now[:notice] = l(:label_bidding_homework_succeed)
+# end
+# # end
+#
+# end
+# else
+# if @bid.reward_type == 3
+# flash.now[:error] = l(:label_bidding_homework_fail)
+# else
+# flash.now[:error] = l(:label_bidding_fail)
+# end
+# end
+# @bidding_project = @bid.biding_projects
+# respond_to do |format|
+# # format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}}
+# # format.html
+# format.html { redirect_to :back }
+# format.js
+# #format.api { render_api_ok }
+# end
+# end
+#
+# #删除已提交的项目作业(不删项目)
+# def delete
+# binding_project = params[:binding_project]
+# if can_delete_project_homework(BidingProject.find(binding_project),User.current)
+# if BidingProject.delete(binding_project)
+# redirect_to project_for_bid_url
+# else
+# render_403;
+# end
+# end
+# end
+# ## 新建留言
+# def create
+#
+# if params[:bid_message][:message].size>0
+# if params[:reference_content]
+# message = params[:bid_message][:message] + "\n" + params[:reference_content]
+# else
+# message = params[:bid_message][:message]
+# @m = message
+# end
+# refer_user_id = params[:bid_message][:reference_user_id].to_i
+# @bid.add_jour(User.current, message, refer_user_id)
+# end
+# @user = @bid.author
+# @jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
+# @jour = paginateHelper @jours,10
+# @bid.set_commit(@feedback_count)
+# respond_to do |format|
+# format.js
+# #format.api { render_api_ok }
+# end
+#
+# end
+#
+# ##删除留言
+# def destroy
+# @user = @bid.author
+# if User.current.admin? || User.current.id == @user.id
+# JournalsForMessage.delete_message(params[:object_id])
+# end
+# @jours = @bid.journals_for_messages.reverse
+# @limit = 10
+# @feedback_count = @jours.count
+# @feedback_pages = Paginator.new @feedback_count, @limit, params['page']
+# @offset ||= @feedback_pages.offset
+# @jour = @jours[@offset, @limit]
+#
+# @bid.set_commit(@feedback_count)
+# # if a_message.size > 5
+# # @message = a_message[-5, 5]
+# # else
+# # @message = a_message
+# # end
+# # @message_count = a_message.count
+#
+# respond_to do |format|
+# # format.html
+# format.js
+# #format.api { render_api_ok }
+# end
+# end
+#
+# #删除作业
+# #by xianbo
+# def homework_destroy
+# @bid_to_destroy = Bid.find params[:id]
+# course_url = course_homework_path(@bid_to_destroy.courses.first)
+# (render_403; return false) unless User.current.admin?||User.current.id==@bid_to_destroy.author_id
+# @bid_to_destroy.destroy
+# respond_to do |format|
+# format.html { redirect_to course_url }
+# format.js
+# #format.api { render_api_ok }
+# end
+# end
+#
+# #end by xianbo
+# ##引用
+# def new
+# @jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id]
+# if @jour
+# user = @jour.user
+# text = @jour.notes
+# else
+# user = @bid.author
+# text = @bid.description
+# end
+# # Replaces pre blocks with [...]
+# text = text.to_s.strip.gsub(%r{((.|\s)*?)
}m, '[...]')
+# @content = "> #{ll(User.current.language, :text_user_wrote, user)}\n> "
+# @content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
+# @id = user.id
+# rescue ActiveRecord::RecordNotFound
+# render_404
+# end
+#
+# ##新建需求
+# def new_bid
+# @bid = Bid.new
+# @bid.safe_attributes = params[:bid]
+# end
+#
+# #huang
+# def create_contest
+# @bid = Bid.new
+# @bid.name = params[:bid][:name]
+# @bid.description = params[:bid][:description]
+# @bid.reward_type = 2
+# @bid.budget = params[:bid][:budget]
+# @bid.deadline = params[:bid][:deadline]
+# @bid.password = params[:bid][:password] #added by bai
+# @bid.author_id = User.current.id
+# @bid.commit = 0
+# if @bid.save
+# unless @bid.watched_by?(User.current)
+# if @bid.add_watcher(User.current)
+# flash[:notice] = l(:label_bid_succeed)
+# end
+# end
+# redirect_to respond_url(@bid)
+# else
+# @bid.safe_attributes = params[:bid]
+# render :action => 'new_bid'
+# end
+# end
+#
+# # added by bai
+# def update_contest
+# @bid = Bid.find(params[:id])
+# @bid.name = params[:bid][:name]
+# @bid.description = params[:bid][:description]
+# @bid.reward_type = 2
+# @bid.budget = params[:bid][:budget]
+# @bid.deadline = params[:bid][:deadline]
+# @bid.password = params[:bid][:password]
+# @bid.author_id = User.current.id
+# @bid.commit = 0
+# if @bid.save
+# unless @bid.watched_by?(User.current)
+# if @bid.add_watcher(User.current)
+# flash[:notice] = l(:label_bid_succeed)
+# end
+# end
+# redirect_to respond_url(@bid)
+# else
+# @bid.safe_attributes = params[:bid]
+# render :action => 'new_bid'
+# end
+# end
+# #huang
+# def new_contest
+# @bid = Bid.new
+# @bid.safe_attributes = params[:bid]
+# end
+#
+# def create_bid
+# @bid = Bid.new
+# @bid.name = params[:bid][:name]
+# @bid.description = params[:bid][:description]
+# @bid.reward_type = 1
+# @bid.budget = params[:bid][:budget]
+# @bid.deadline = params[:bid][:deadline]
+# @bid.author_id = User.current.id
+# @bid.commit = 0
+# if @bid.save
+# unless @bid.watched_by?(User.current)
+# if @bid.add_watcher(User.current)
+# flash[:notice] = l(:label_bid_succeed)
+# end
+# end
+# redirect_to respond_url(@bid)
+# else
+# @bid.safe_attributes = params[:bid]
+# render :action => 'new_bid'
+# end
+# end
+#
+# def create_homework
+# @bid = Bid.new
+# @bid.name = params[:bid][:name]
+# @bid.description = params[:bid][:description]
+# @bid.is_evaluation = params[:bid][:is_evaluation]
+# @bid.proportion = params[:bid][:proportion]
+# @bid.evaluation_num = params[:bid][:evaluation_num]
+# params[:bid][:open_anonymous_evaluation] ? @bid.open_anonymous_evaluation = 1 : @bid.open_anonymous_evaluation = 0
+# @bid.reward_type = 3
+# # @bid.budget = params[:bid][:budget]
+# @bid.deadline = params[:bid][:deadline]
+# @bid.budget = 0
+# @bid.author_id = User.current.id
+# @bid.commit = 0
+# @bid.homework_type = 1
+# @bid.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
+# # @bid.
+# if @bid.save
+# HomeworkForCourse.create(:course_id => params[:course_id], :bid_id => @bid.id)
+# unless @bid.watched_by?(User.current)
+# if @bid.add_watcher(User.current)
+# flash[:notice] = l(:label_bid_succeed)
+# end
+# end
+# redirect_to course_homework_url(params[:course_id])
+# else
+# @bid.safe_attributes = params[:bid]
+# @homework = @bid
+# @course = Course.find_by_id(params[:course_id])
+# @course_id = @course.id
+# #respond_to do |format|
+# # format.html { redirect_to new_homework_course_path(params[:course_id]),:layout => 'base_courses'}
+# # format.api { render_validation_errors(@bid) }
+# #end
+# render file: 'courses/new_homework', layout: 'base_courses'
+# end
+# end
+#
+# # modify by nwb\
+# # 编辑作业
+# def edit
+# @bid = Bid.find(params[:bid_id])
+# if (User.current.admin?||User.current.allowed_to?(:as_teacher,@bid.courses.first))
+# @course_id = params[:course_id]
+# respond_to do |format|
+# format.html {
+# @course = Course.find(params[:course_id])
+# @user= User.find(User.current.id)
+# render :layout => 'base_courses'
+# }
+# end
+# else
+# render_403
+# end
+# end
+#
+# def update
+# @bid = Bid.find(params[:id])
+# @course = @bid.courses.first#Project.find(params[:course_id])
+# @bid.name = params[:bid][:name]
+# @bid.description = params[:bid][:description]
+# @bid.is_evaluation = params[:bid][:is_evaluation]
+# @bid.proportion = params[:bid][:proportion]
+# @bid.evaluation_num = params[:bid][:evaluation_num]
+# params[:bid][:open_anonymous_evaluation] ? @bid.open_anonymous_evaluation = 1 : @bid.open_anonymous_evaluation = 0
+# @bid.reward_type = 3
+# @bid.deadline = params[:bid][:deadline]
+# @bid.budget = 0
+# #@bid.author_id = User.current.id
+# @bid.commit = 0
+# @bid.homework_type = 1
+# @bid.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
+# if @bid.save
+# flash[:notice] = l(:label_update_homework_succeed)
+# redirect_to course_homework_url(@course)
+# else
+# @bid.safe_attributes = params[:bid]
+# render :action => 'edit', :layout =>'base_courses'
+# end
+# end
+#
+# def new_submit_homework
+# #render html to prepare create submit homework
+# find_bid
+# find_bid
+# render :layout => 'base_homework'
+# end
+#
+# def add_homework
+# if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0)
+# # homework = HomeworkAttach.create(:bid_id => @bid.id, :user_id => User.current.id)
+# # homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
+#
+# if hadcommittedhomework(User.current.id, @bid.id) == true
+# @homework_flag = l(:label_bidding_homework_committed)
+# else
+# @homework = HomeworkAttach.new
+# @homework.safe_attributes = params[:homeworkattach]
+# @homework.bid_id = @bid.id
+# @homework.user_id = User.current.id
+# @homework.save_attachments(params[:attachments])
+#
+# render_attachment_warning_if_needed(@homework)
+#
+# @homework_flag = if @homework.save
+# l(:label_bidding_homework_succeed)
+# else
+# l(:label_bidding_homework_failed)
+# end
+#
+# if @homework.attachments.empty?
+# @homework.delete
+# #flash[:error] = l(:no_attachmens_allowed)
+# @homework_flag = l(:no_attachmens_allowed)
+# # else
+# end
+# end
+# end
+#
+# @homework_list = @bid.homeworks
+# respond_to do |format|
+# format.html{
+# #redirect_to project_for_bid_path, notice: @homework_flag.to_s
+# flash[:notice] = @homework_flag.to_s
+# redirect_back_or_default(project_for_bid_path)
+# }
+# format.js
+# end
+#
+# end
+#
+# # 作业统计
+# def homework_statistics
+# @course = @bid.courses.first
+# @member = []
+# @course.memberships.each do |member|
+# unless (member.roles && Role.where('id = ? ', 3)).empty?
+# @member.push member
+# end
+# end
+# if @bid.homework_type = 1
+# @student = User.where("id in (select DISTINCT user_id from #{HomeworkAttach.table_name} where bid_id = ? )", @bid.id)
+# @homework_type = true
+# else
+#
+# @homework_type = false
+# end
+# @user = @bid.author
+# render :layout => 'base_homework'
+# end
+#
+# def homework_respond
+# @user = @bid.author
+# render :layout => 'base_homework'
+# end
+#
+# def more
+# @jour = @bid.journals_for_messages
+# @jour.each_with_index {|j,i| j.indice = i+1}
+# @state = true
+#
+# respond_to do |format|
+# format.html { redirect_to :back }
+# format.js
+# #format.api { render_api_ok }
+# end
+# end
+#
+# def back
+# @jour = @bid.journals_for_messages
+# @jour.each_with_index {|j,i| j.indice = i+1}
+# @state = false
+#
+# respond_to do |format|
+# format.html { redirect_to :back }
+# format.js
+# #format.api { render_api_ok }
+# end
+# end
+#
+# #added by william
+# #used to set the bidding project reward
+# def set_reward
+# @b_p = nil
+# @biding_project_id = nil
+#
+# if params[:set_reward][:reward]&&((User.current.id==@bid.author_id)||User.current.admin)
+# # @bid_id = params[:id]
+# @biding_project_id = params[:set_reward][:b_id]
+# @b_p = BidingProject.find_by_id(@biding_project_id)
+#
+# # 把字段存进表中
+# @b_p.update_reward(params[:set_reward][:reward].to_s)
+# end
+#
+# respond_to do |format|
+# format.js
+# end
+# end
+#
+# # added by william
+# # used to manage the bid and end the bid
+# def manage
+#
+# end
+#
+# # 启动匿评
+# def start_anonymous_comment
+# @bid = Bid.find(params[:id])
+# @course = @bid.courses.first
+# if(@bid.comment_status == 0)
+# homeworks = @bid.homeworks
+# if(homeworks && homeworks.size >= 2)
+# homeworks.each_with_index do |homework, index|
+# user = homework.user
+# n = @bid.evaluation_num
+# n = n < homeworks.size ? n : homeworks.size - 1
+# assigned_homeworks = get_assigned_homeworks(homeworks, n, index)
+# assigned_homeworks.each do |h|
+# @homework_evaluation = HomeworkEvaluation.new(user_id: user.id, homework_attach_id: h.id)
+# @homework_evaluation.save
+# end
+# end
+# @bid.update_column('comment_status', 1)
+# @statue = 1
+# else
+# @statue = 2
+# end
+# else
+# @statue = 3
+# end
+#
+# respond_to do |format|
+# format.js
+# end
+# end
+#
+# def stop_anonymous_comment
+# @bid = Bid.find(params[:id])
+#
+# @bid.update_column('comment_status', 2)
+#
+# respond_to do |format|
+# format.js
+# end
+# end
+#
+# def alert_anonymous_comment
+# @bid = Bid.find params[:id]
+# @course = @bid.courses.first
+# @cur_size = 0
+# @totle_size = 0
+# if @bid.comment_status == 0
+# @totle_size = searchStudent(@course).size
+# @cur_size = @bid.homeworks.size
+# elsif @bid.comment_status == 1
+# @bid.homeworks.map { |homework| @totle_size += homework.homework_evaluations.count}
+# @cur_size = 0
+# @bid.homeworks.map { |homework| @cur_size += homework.rates(:quality).where("seems_rateable_rates.is_teacher_score = 0").count}
+# end
+# @percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100)
+# respond_to do |format|
+# format.js
+# end
+# end
+#
+# private
+#
+# def get_assigned_homeworks(homeworks, n, index)
+# homeworks += homeworks
+# homeworks[index + 1 .. index + n]
+# end
+#
+# def find_bid
+# if params[:id]
+# @bid = Bid.find(params[:id], :include => [{:homeworks => :user}])
+# @user = @bid.author
+# end
+# rescue
+# render_404
+# end
+#
+# def memberAccess
+# # 是课程,则判断当前用户是否参加了课程
+# return true if current_user.admin?
+# #return 0 if @bid.courses.first.project_type == Project::ProjectType_project
+# currentUser = User.current
+# render_403 unless currentUser.member_of_course?(@bid.courses.first)
+# end
+#
+# #验证是否显示课程
+# def can_show_course
+# @first_page = FirstPage.find_by_page_type('project')
+# if @first_page.show_course == 2
+# render_404
+# end
+# end
+#
+# #验证是否显示竞赛
+# def can_show_contest
+# @first_page = FirstPage.find_by_page_type('project')
+# if @first_page.show_contest == 2
+# render_404
+# end
+# end
+# end
+#
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
index 9e36d15f4..b1da35cfc 100644
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/messages_controller.rb
@@ -94,12 +94,12 @@ class MessagesController < ApplicationController
update_kindeditor_assets_owner ids,@message.id,OwnerTypeHelper::MESSAGE
end
# 与我相关动态的记录add start
- if(@board.course_id>0) #项目的先不管
- teachers = searchTeacherAndAssistant(@board.course);
+ if(@board && @board.course) #项目的先不管
+ teachers = searchTeacherAndAssistant(@board.course)
for teacher in teachers
if(teacher.user_id != User.current.id)
notify = ActivityNotify.new()
- if(@board.course_id>0)
+ if(@board.course)
notify.activity_container_id = @board.course_id
notify.activity_container_type = 'Course'
else
@@ -178,7 +178,7 @@ class MessagesController < ApplicationController
end
# 与我相关动态的记录add start
- if(@board.course_id>0) #项目的先不管
+ if(@board && @board.course) #项目的先不管
notifyto_arr = {}
notifyto_arr[@topic.author_id] = @topic.author_id
if( params[:parent_topic] != nil && params[:parent_topic] != '')
@@ -188,7 +188,7 @@ class MessagesController < ApplicationController
notifyto_arr.each do |k,user_id|
if(user_id != User.current.id)
notify = ActivityNotify.new()
- if(@board.course_id>0)
+ if(@board.course)
notify.activity_container_id = @board.course_id
notify.activity_container_type = 'Course'
else
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index fbafd16e9..3c34aa549 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -363,7 +363,8 @@ class ProjectsController < ApplicationController
#发送邮件邀请新用户
def invite_members_by_mail
- if User.current.member_of?(@project) || User.current.admin?
+ if User.current.member_of?(@project) || User.current.admin?
+ @inviter_lists = InviteList.where(project_id:@project.id).all
@is_zhuce = false
respond_to do |format|
format.html
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 0382e7be0..23053a48e 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -25,7 +25,7 @@ class UsersController < ApplicationController
menu_item :user_course, :only => :user_courses
menu_item :user_homework, :only => :user_homeworks
menu_item :user_project, :only => [:user_projects, :watch_projects]
- menu_item :requirement_focus, :only => :watch_bids
+ # menu_item :requirement_focus, :only => :watch_bids
menu_item :requirement_focus, :only => :watch_contests
menu_item :user_newfeedback, :only => :user_newfeedback
@@ -36,14 +36,14 @@ class UsersController < ApplicationController
#
before_filter :can_show_course, :only => [:user_courses,:user_homeworks]
- before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_bids, :watch_contests, :info,
+ before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_contests, :info,
:user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index,
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
:activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities,:user_projects_index]
#edit has been deleted by huang, 2013-9-23
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses,
:user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
- :watch_bids, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index,
+ :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index,
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index]
before_filter :auth_user_extension, only: :show
@@ -141,25 +141,25 @@ class UsersController < ApplicationController
##added by fq
def watch_bids
- cond = 'bids.reward_type <> 1'
- @bids = Bid.watched_by(@user).where('reward_type = ?', 1) # added by huang
- @offset, @limit = api_offset_and_limit({:limit => 10})
- @bid_count = @bids.count
- @bid_pages = Paginator.new @bid_count, @limit, params['page']
- @offset ||= @bid_pages.reverse_offset
- unless @offset == 0
- @bid = @bids.offset(@offset).limit(@limit).all.reverse
- else
- limit = @bid_count % @limit
- @bid = @bids.offset(@offset).limit(limit).all.reverse
- end
-
- respond_to do |format|
- format.html {
- render :layout => 'base_users'
- }
- format.api
- end
+ # cond = 'bids.reward_type <> 1'
+ # @bids = Bid.watched_by(@user).where('reward_type = ?', 1) # added by huang
+ # @offset, @limit = api_offset_and_limit({:limit => 10})
+ # @bid_count = @bids.count
+ # @bid_pages = Paginator.new @bid_count, @limit, params['page']
+ # @offset ||= @bid_pages.reverse_offset
+ # unless @offset == 0
+ # @bid = @bids.offset(@offset).limit(@limit).all.reverse
+ # else
+ # limit = @bid_count % @limit
+ # @bid = @bids.offset(@offset).limit(limit).all.reverse
+ # end
+ #
+ # respond_to do |format|
+ # format.html {
+ # render :layout => 'base_users'
+ # }
+ # format.api
+ # end
end
#new add by linchun
@@ -215,24 +215,24 @@ class UsersController < ApplicationController
# added by huang
def user_homeworks
- @membership = @user.memberships.all(:conditions => Project.visible_condition(User.current))
- @memberships = []
- @membership.each do |membership|
- if membership.project.project_type == 1
- @memberships << membership
- end
- end
- @bid = []
- @memberships.each do |membership|
- @bid += membership.project.homeworks
- end
- @bid = @bid.group_by {|bid| bid.courses.first.id}
- unless User.current.admin?
- if !@user.active?
- render_404
- return
- end
- end
+ # @membership = @user.memberships.all(:conditions => Project.visible_condition(User.current))
+ # @memberships = []
+ # @membership.each do |membership|
+ # if membership.project.project_type == 1
+ # @memberships << membership
+ # end
+ # end
+ # @bid = []
+ # @memberships.each do |membership|
+ # @bid += membership.project.homeworks
+ # end
+ # @bid = @bid.group_by {|bid| bid.courses.first.id}
+ # unless User.current.admin?
+ # if !@user.active?
+ # render_404
+ # return
+ # end
+ # end
end
@@ -757,7 +757,7 @@ class UsersController < ApplicationController
when '3' then
@obj = Issue.find_by_id(@obj_id)
when '4' then
- @obj = Bid.find_by_id(@obj_id)
+ # @obj = Bid.find_by_id(@obj_id)
when '5' then
@obj = Forum.find_by_id(@obj_id)
when '6'
@@ -800,7 +800,7 @@ class UsersController < ApplicationController
when '3' then
@obj = Issue.find_by_id(@obj_id)
when '4' then
- @obj = Bid.find_by_id(@obj_id)
+ # @obj = Bid.find_by_id(@obj_id)
when '5' then
@obj = Forum.find_by_id(@obj_id)
when '6'
diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb
index 043552872..7eb06d270 100644
--- a/app/controllers/zipdown_controller.rb
+++ b/app/controllers/zipdown_controller.rb
@@ -30,8 +30,7 @@ class ZipdownController < ApplicationController
if file_count > 0
zipfile = zip_bid bid
else
- render file: 'public/no_file_found.html'
- return
+ zipfile = {:message => "no file"}
end
elsif params[:obj_class] == "HomeworkCommon"
homework = HomeworkCommon.find params[:obj_id]
@@ -41,8 +40,7 @@ class ZipdownController < ApplicationController
if file_count > 0
zipfile = zip_homework_common homework
else
- render file: 'public/no_file_found.html'
- return
+ zipfile = {:message => "no file"}
end
else
logger.error "[ZipDown#assort] ===> #{params[:obj_class]} unKown !!"
@@ -62,7 +60,7 @@ class ZipdownController < ApplicationController
unless homework.attachments.empty?
zipfile = zip_homework_by_user homework
send_file zipfile.file_path, :filename => ((homework.user.user_extensions.nil? || homework.user.user_extensions.student_id.nil?) ? "" : homework.user.user_extensions.student_id) +
- "_" + (homework.user.lastname.nil? ? "" : homework.user.lastname) + (homework.user.firstname.nil? ? "" : homework.user.firstname) +
+ "_" + homework.user.show_name +
"_" + homework.name + ".zip", :type => detect_content_type(zipfile.file_path) if(zipfile)
else
render file: 'public/no_file_found.html'
@@ -150,7 +148,7 @@ class ZipdownController < ApplicationController
end
end
out_file = find_or_pack(homework_attach.bid_id, homework_attach.user_id, digests.sort){
- zipping("#{homework_attach.user.lastname}#{homework_attach.user.firstname}_#{((homework_attach.user.user_extensions.nil? || homework_attach.user.user_extensions.student_id.nil?) ? "" : homework_attach.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip",
+ zipping("#{homework_attach.user.show_name}_#{((homework_attach.user.user_extensions.nil? || homework_attach.user.user_extensions.student_id.nil?) ? "" : homework_attach.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip",
homeworks_attach_path, OUTPUT_FOLDER, true, not_exist_file)
}
end
@@ -170,7 +168,7 @@ class ZipdownController < ApplicationController
end
end
out_file = find_or_pack(work.homework_common_id, work.user_id, digests.sort){
- zipping("#{work.user.lastname}#{work.user.firstname}_#{((work.user.user_extensions.nil? || work.user.user_extensions.student_id.nil?) ? "" : work.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip",
+ zipping("#{work.user.show_name}_#{((work.user.user_extensions.nil? || work.user.user_extensions.student_id.nil?) ? "" : work.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip",
homeworks_attach_path, OUTPUT_FOLDER, true, not_exist_file)
}
end
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index 1e477ed04..f999e27d6 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -72,8 +72,8 @@ class Attachment < ActiveRecord::Base
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
before_save :files_to_final_location
- after_create :office_conver, :be_user_score ,:act_as_forge_activity# user_score
- after_update :be_user_score
+ after_create :office_conver, :be_user_score,:act_as_forge_activity# user_score
+ after_update :office_conver, :be_user_score
after_destroy :delete_from_disk,:down_user_score
# add by nwb
@@ -259,12 +259,14 @@ class Attachment < ActiveRecord::Base
end
def office_conver
- saved_path = File.join(Rails.root, "files", "convered_office")
- unless Dir.exist?(saved_path)
- Dir.mkdir(saved_path)
- end
- convered_file = File.join(saved_path, self.disk_filename + ".html")
- OfficeConverTask.new.conver(self.diskfile, convered_file)
+ # 不在这里做后台转换,换为点击时做转换
+ # return unless %w(Project Course).include? (self.container_type)
+ # saved_path = File.join(Rails.root, "files", "convered_office")
+ # unless Dir.exist?(saved_path)
+ # Dir.mkdir(saved_path)
+ # end
+ # convered_file = File.join(saved_path, self.disk_filename + ".pdf")
+ # OfficeConverTask.new.conver(self.diskfile, convered_file)
end
# Copies the temporary file to its final location
diff --git a/app/models/invite_list.rb b/app/models/invite_list.rb
index f1ba8546f..4868fc3d7 100644
--- a/app/models/invite_list.rb
+++ b/app/models/invite_list.rb
@@ -1,5 +1,13 @@
class InviteList < ActiveRecord::Base
attr_accessible :project_id, :user_id
- # belongs_to :user
- # belongs_to :project
+ belongs_to :user
+ belongs_to :project
+
+ # 用户拒绝邀请后,删除记录
+ def self.delete_inviter(userid, projectid)
+ @inviters = AppliedProject.where("user_id = ? and project_id = ?", userid, projectid)
+ @inviters.each do |inviter|
+ inviter.destroy
+ end
+ end
end
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index dbc5d3cff..087fb6d73 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -58,6 +58,7 @@ class Mailer < ActionMailer::Base
us = UsersService.new
# 自动激活用户
user = us.register_auto(login, @email, @password)
+ InviteList.create(:user_id => user.id, :project_id => project.id)
User.current = user unless User.current.nil?
@user = user
@@ -73,6 +74,10 @@ class Mailer < ActionMailer::Base
@project_name = "#{project.name}"
@user = user
@project = project
+ inviter_lists = InviteList.where(project_id:@project.id, user_id:@user.id).all
+ if inviter_lists.blank?
+ InviteList.create(:user_id => user.id, :project_id => project.id)
+ end
@token = Token.get_token_from_user(user, 'autologin')
@project_url = url_for(:controller => 'projects', :action => 'member', :id => project.id, :user_id => user.id, :mail => true, :token => @token.value)
mail :to => email, :subject => @subject
@@ -83,13 +88,10 @@ class Mailer < ActionMailer::Base
# 发送内容: 项目【缺陷,讨论区,新闻】,课程【通知,留言,新闻】, 贴吧, 个人留言
def send_for_user_activities(user, date_to, days)
date_from = date_to - days.days
-
subject = "[ #{user.show_name}#{l(:label_day_mail)}]"
@subject = " #{user.show_name}#{l(:label_day_mail)}"
-
date_from = "#{date_from} 17:59:59"
date_to = "#{date_to} 17:59:59"
-
# 生成token用于直接点击登录
@user = user
@token = Token.get_token_from_user(user, 'autologin')
@@ -100,34 +102,32 @@ class Mailer < ActionMailer::Base
project_ids = projects.map{|project| project.id}.join(",")
course_ids = courses.map {|course| course.id}.join(",")
- # 查询user的缺陷,包括发布的,跟踪的以及被指派的缺陷
- sql = "select DISTINCT i.* from issues i, watchers w
- where (i.assigned_to_id = #{user.id} or i.author_id = #{user.id}
- or (w.watchable_type = 'Issue' and w.watchable_id = i.id and w.user_id = #{user.id}))
- and (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc"
+ # 查询user的缺陷,项目中成员都能收到
+ sql = "select * from members m, issues i where i.project_id = m.project_id and m.user_id='#{user.id}'
+ and (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc"
@issues = Issue.find_by_sql(sql)
# @bids 查询课程作业,包括老师发布的作业,以及user提交作业
# @attachments查询课程课件更新
@attachments ||= []
-
@bids ||= [] # 老师发布的作业
-
unless courses.first.nil?
count = courses.count
count = count - 1
for i in 0..count do
bids = courses[i].homeworks.where("bids.created_on between '#{date_from}' and '#{date_to}'").order("bids.created_on desc")
attachments = courses[i].attachments.where("attachments.created_on between '#{date_from}' and '#{date_to}'").order('attachments.created_on DESC')
- @bids += bids if bids.count > 0
- @attachments += attachments if attachments.count > 0
+ @bids += bids if bids.count > 0
+ @attachments += attachments if attachments.count > 0
end
end
# user 提交的作业
@homeworks = HomeworkAttach.where("user_id=#{user.id} and (created_at between '#{date_from}' and '#{date_to}')").order("created_at desc")
# 查询user在课程。项目中发布的讨论帖子
- messages = Message.find_by_sql("select DISTINCT * from messages where author_id = #{user.id} and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
+ messages = Message.find_by_sql("select me.* from messages me, boards b, members m where
+ b.id = me.board_id and b.project_id = m.project_id and m.user_id = '#{user.id}' and (me.created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
+ # messages = Message.find_by_sql("select DISTINCT * from messages where author_id = #{user.id} and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
@course_messages ||= []
@project_messages ||= []
unless messages.first.nil?
@@ -139,6 +139,7 @@ class Mailer < ActionMailer::Base
end
end
end
+
# 查询user在课程中发布的通知,项目中发的新闻
@course_news = (course_ids && !course_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n
where n.course_id in (#{course_ids})
@@ -151,18 +152,13 @@ class Mailer < ActionMailer::Base
jour_type='Course' and user_id = #{user.id}
and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
@user_journal_messages = user.journals_for_messages.where("m_parent_id IS NULL and (created_on between '#{date_from}' and '#{date_to}')").order('created_on DESC')
-
-
# 查询user新建贴吧或发布帖子
@forums = Forum.find_by_sql("select DISTINCT * from forums where creator_id = #{user.id} and (created_at between '#{date_from}' and '#{date_to}') order by created_at desc")
@memos = Memo.find_by_sql("select DISTINCT m.* from memos m, forums f where (m.author_id = #{user.id} or (m.forum_id = f.id and f.creator_id = #{user.id}))
and (m.created_at between '#{date_from}' and '#{date_to}') order by m.created_at desc")
-
has_content = [@issues,@homeworks,@course_messages,@project_messages,@course_news,@project_news,
- @course_journal_messages,@user_journal_messages,@forums,@memos,@attachments,@bids].any? {|o|
- !o.empty?
- }
+ @course_journal_messages,@user_journal_messages,@forums,@memos,@attachments,@bids].any? {|o| !o.empty?}
mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}"
#有内容才发,没有不发
mail :to => user.mail,:subject => subject if has_content
@@ -277,11 +273,11 @@ class Mailer < ActionMailer::Base
@token = Token.get_token_from_user(user, 'autologin')
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :token => @token.value)
- # edit
- @issue_author_url = url_for(user_activities_url(@author,:token => @token.value))
- @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id, :token => @token.value)
+ # edit
+ @issue_author_url = url_for(user_activities_url(@author,:token => @token.value))
+ @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id, :token => @token.value)
- @user_url = url_for(my_account_url(user,:token => @token.value))
+ @user_url = url_for(my_account_url(user,:token => @token.value))
subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}"
@@ -289,13 +285,13 @@ class Mailer < ActionMailer::Base
:subject => subject,
:filter => true
end
- # issue.attachments.each do |attach|
- # attachments["#{attach.filename}"] = File.read("#{attach.disk_filename}")
- # end
- # cc = issue.watcher_recipients - recipients
- #mail.attachments['test'] = File.read("#{RAILS.root}/files/2015/01/150114094010_libegl.dll")
+ # issue.attachments.each do |attach|
+ # attachments["#{attach.filename}"] = File.read("#{attach.disk_filename}")
+ # end
+ # cc = issue.watcher_recipients - recipients
+ #mail.attachments['test'] = File.read("#{RAILS.root}/files/2015/01/150114094010_libegl.dll")
+
-
# Builds a Mail::Message object used to email recipients of the edited issue.
@@ -324,13 +320,13 @@ class Mailer < ActionMailer::Base
@project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id, :token => @token.value)
@user_url = url_for(my_account_url(user,:token => @token.value))
- @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :anchor => "change-#{journal.id}", :token => @token.value)
+ @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :anchor => "change-#{journal.id}", :token => @token.value)
s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] "
s << "(#{issue.status.name}) " if journal.new_value_for('status_id')
s << issue.subject
@issue = issue
@journal = journal
- # @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}")
+ # @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}")
mail :to => recipients,
:subject => s,
:filter => true
@@ -360,10 +356,10 @@ class Mailer < ActionMailer::Base
@issues = issues
@days = days
@issues_url = url_for(:controller => 'issues', :action => 'index',
- :set_filter => 1, :assigned_to_id => user.id,
- :sort => 'due_date:asc')
+ :set_filter => 1, :assigned_to_id => user.id,
+ :sort => 'due_date:asc')
mail :to => user.mail,
- :subject => l(:mail_subject_reminder, :count => issues.size, :days => days)
+ :subject => l(:mail_subject_reminder, :count => issues.size, :days => days)
end
#缺陷到期邮件通知
@@ -494,8 +490,8 @@ class Mailer < ActionMailer::Base
@news = news
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
mail :to => news.recipients,
- :subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}",
- :filter => true
+ :subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}",
+ :filter => true
elsif news.course
redmine_headers 'Course' => news.course.id
@author = news.author
@@ -526,9 +522,9 @@ class Mailer < ActionMailer::Base
@comment = comment
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
mail :to => news.recipients,
- :cc => news.watcher_recipients,
- :subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}",
- :filter => true
+ :cc => news.watcher_recipients,
+ :subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}",
+ :filter => true
elsif news.course
redmine_headers 'Course' => news.course.id
@author = comment.author
@@ -563,9 +559,9 @@ class Mailer < ActionMailer::Base
@message = message
@message_url = url_for(message.event_url)
mail :to => recipients,
- :cc => cc,
- :subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}",
- :filter => true
+ :cc => cc,
+ :subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}",
+ :filter => true
elsif message.course
redmine_headers 'Course' => message.course.id,
'Topic-Id' => (message.parent_id || message.id)
@@ -598,12 +594,12 @@ class Mailer < ActionMailer::Base
cc = wiki_content.page.wiki.watcher_recipients - recipients
@wiki_content = wiki_content
@wiki_content_url = url_for(:controller => 'wiki', :action => 'show',
- :project_id => wiki_content.project,
- :id => wiki_content.page.title)
+ :project_id => wiki_content.project,
+ :id => wiki_content.page.title)
mail :to => recipients,
- :cc => cc,
- :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :id => wiki_content.page.pretty_title)}",
- :filter => true
+ :cc => cc,
+ :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :id => wiki_content.page.pretty_title)}",
+ :filter => true
end
# Builds a Mail::Message object used to email the recipients of a project of the specified wiki content was updated.
@@ -620,15 +616,15 @@ class Mailer < ActionMailer::Base
cc = wiki_content.page.wiki.watcher_recipients + wiki_content.page.watcher_recipients - recipients
@wiki_content = wiki_content
@wiki_content_url = url_for(:controller => 'wiki', :action => 'show',
- :project_id => wiki_content.project,
- :id => wiki_content.page.title)
+ :project_id => wiki_content.project,
+ :id => wiki_content.page.title)
@wiki_diff_url = url_for(:controller => 'wiki', :action => 'diff',
- :project_id => wiki_content.project, :id => wiki_content.page.title,
- :version => wiki_content.version)
+ :project_id => wiki_content.project, :id => wiki_content.page.title,
+ :version => wiki_content.version)
mail :to => recipients,
- :cc => cc,
- :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_updated, :id => wiki_content.page.pretty_title)}",
- :filter => true
+ :cc => cc,
+ :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_updated, :id => wiki_content.page.pretty_title)}",
+ :filter => true
end
# Builds a Mail::Message object used to email the specified user their account information.
@@ -642,7 +638,7 @@ class Mailer < ActionMailer::Base
@password = password
@login_url = url_for(:controller => 'account', :action => 'login')
mail :to => user.mail,
- :subject => l(:mail_subject_register, Setting.app_title)
+ :subject => l(:mail_subject_register, Setting.app_title)
end
# Builds a Mail::Message object used to email all active administrators of an account activation request.
@@ -655,10 +651,10 @@ class Mailer < ActionMailer::Base
recipients = User.active.where(:admin => true).all.collect { |u| u.mail }.compact
@user = user
@url = url_for(:controller => 'users', :action => 'index',
- :status => User::STATUS_REGISTERED,
- :sort_key => 'created_on', :sort_order => 'desc')
+ :status => User::STATUS_REGISTERED,
+ :sort_key => 'created_on', :sort_order => 'desc')
mail :to => recipients,
- :subject => l(:mail_subject_account_activation_request, Setting.app_title)
+ :subject => l(:mail_subject_account_activation_request, Setting.app_title)
end
# Builds a Mail::Message object used to email the specified user that their account was activated by an administrator.
@@ -671,7 +667,7 @@ class Mailer < ActionMailer::Base
@user = user
@login_url = url_for(:controller => 'account', :action => 'login')
mail :to => user.mail,
- :subject => l(:mail_subject_register, Setting.app_title)
+ :subject => l(:mail_subject_register, Setting.app_title)
end
def lost_password(token)
@@ -679,7 +675,7 @@ class Mailer < ActionMailer::Base
@token = token
@url = url_for(:controller => 'account', :action => 'lost_password', :token => token.value)
mail :to => token.user.mail,
- :subject => l(:mail_subject_lost_password, Setting.app_title)
+ :subject => l(:mail_subject_lost_password, Setting.app_title)
end
def register(token)
@@ -687,14 +683,14 @@ class Mailer < ActionMailer::Base
@token = token
@url = url_for(:controller => 'account', :action => 'activate', :token => token.value)
mail :to => token.user.mail,
- :subject => l(:mail_subject_register, Setting.app_title)
+ :subject => l(:mail_subject_register, Setting.app_title)
end
def test_email(user)
set_language_if_valid(user.language)
@url = url_for(:controller => 'welcome')
mail :to => user.mail,
- :subject => 'forge test'
+ :subject => 'forge test'
end
# Overrides default deliver! method to prevent from sending an email
@@ -702,8 +698,8 @@ class Mailer < ActionMailer::Base
def deliver!(mail = @mail)
set_language_if_valid @initial_language
return false if (recipients.nil? || recipients.empty?) &&
- (cc.nil? || cc.empty?) &&
- (bcc.nil? || bcc.empty?)
+ (cc.nil? || cc.empty?) &&
+ (bcc.nil? || bcc.empty?)
# Log errors when raise_delivery_errors is set to false, Rails does not
@@ -735,8 +731,8 @@ class Mailer < ActionMailer::Base
user_ids = options[:users]
scope = Issue.open.where("#{Issue.table_name}.assigned_to_id IS NOT NULL" +
- " AND #{Project.table_name}.status = #{Project::STATUS_ACTIVE}" +
- " AND #{Issue.table_name}.due_date <= ?", days.day.from_now.to_date
+ " AND #{Project.table_name}.status = #{Project::STATUS_ACTIVE}" +
+ " AND #{Issue.table_name}.due_date <= ?", days.day.from_now.to_date
)
scope = scope.where(:assigned_to_id => user_ids) if user_ids.present?
scope = scope.where(:project_id => project.id) if project
@@ -800,12 +796,12 @@ class Mailer < ActionMailer::Base
def mail(headers={})
headers.merge! 'X-Mailer' => 'Redmine',
- 'X-Redmine-Host' => Setting.host_name,
- 'X-Redmine-Site' => Setting.app_title,
- 'X-Auto-Response-Suppress' => 'OOF',
- 'Auto-Submitted' => 'auto-generated',
- 'From' => Setting.mail_from,
- 'List-Id' => "<#{Setting.mail_from.to_s.gsub('@', '.')}>"
+ 'X-Redmine-Host' => Setting.host_name,
+ 'X-Redmine-Site' => Setting.app_title,
+ 'X-Auto-Response-Suppress' => 'OOF',
+ 'Auto-Submitted' => 'auto-generated',
+ 'From' => Setting.mail_from,
+ 'List-Id' => "<#{Setting.mail_from.to_s.gsub('@', '.')}>"
# Removes the author from the recipients and cc
# if he doesn't want to receive notifications about what he does
@@ -851,7 +847,7 @@ class Mailer < ActionMailer::Base
set_language_if_valid Setting.default_language
super
end
-
+
def self.deliver_mail(mail)
return false if mail.to.blank? && mail.cc.blank? && mail.bcc.blank?
Thread.new do
@@ -898,7 +894,7 @@ class Mailer < ActionMailer::Base
end
def mylogger
- if Setting.delayjob_enabled?
+ if Setting.delayjob_enabled?
Delayed::Worker.logger
else
Rails.logger
diff --git a/app/models/project.rb b/app/models/project.rb
index 4a546a430..49ed2d0ee 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -67,7 +67,7 @@ class Project < ActiveRecord::Base
has_many :student, :through => :students_for_courses, :source => :user
has_one :course_extra, :class_name => 'Course', :foreign_key => :extra,:primary_key => :identifier, :dependent => :destroy
has_many :applied_projects
- # has_many :invite_lists
+ has_many :invite_lists
# end
#ADDED BY NIE
diff --git a/app/models/user.rb b/app/models/user.rb
index a1f00a234..b4723cceb 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -277,15 +277,18 @@ class User < Principal
end
def show_name
+ name = ""
unless self.user_extensions.nil?
if self.user_extensions.identity == 2
- firstname
+ name = firstname
else
- lastname+firstname
+ name = lastname+firstname
end
else
- lastname+firstname
+ name = lastname+firstname
end
+ name = name.empty? || name.nil? ? login : name
+ name
end
## end
diff --git a/app/services/users_service.rb b/app/services/users_service.rb
index aff0a975c..7e8e775ed 100644
--- a/app/services/users_service.rb
+++ b/app/services/users_service.rb
@@ -255,7 +255,9 @@ class UsersService
watcher.push(params[:user_id])
scope = scope.where("id not in (?)",watcher)
end
- scope = scope.like(params[:name],search_by)
+ #scope = scope.like(params[:name],search_by)
+ scope = scope.where("( LOWER(login) LIKE ? or LOWER(concat(lastname, firstname)) LIKE ? or LOWER(mail) LIKE ? )",
+ "%#{params[:name]}%","%#{params[:name]}%","%#{params[:name]}%")
end
#modify by yutao 2015/5/18 没有params[:user_id]参数时去掉"id not in (?)"条件 end
else
diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb
index 589a0f25d..bf276925a 100644
--- a/app/views/boards/show.html.erb
+++ b/app/views/boards/show.html.erb
@@ -1,11 +1,11 @@
-<%= javascript_include_tag "/assets/kindeditor/kindeditor-min" %>
+<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
+<%#= javascript_include_tag "/assets/kindeditor/kindeditor-min" %>
<% if @project %>
<%= render :partial => 'project_show', locals: {project: @project} %>
@@ -123,21 +124,20 @@ function nh_init_board(params){
if(params.textarea.data('init') == undefined){
//初始化编辑器
var editor = params.kindutil.create(params.textarea, {
- resizeType : 1,
- allowPreviewEmoticons : false,
- allowImageUpload : false,
- minWidth:"1px",
- width:"565px",
- items : ['emoticons'],
+// allowPreviewEmoticons : false,
+// allowImageUpload : false,
+ resizeType : 1,minWidth:"1px",width:"565px",height:"150px",
+ allowFileManager:true,uploadJson:"/kindeditor/upload",
+ fileManagerJson:"/kindeditor/filemanager",
afterChange:function(){//按键事件
nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea});
},
afterCreate:function(){
- var toolbar = $("div[class='ke-toolbar']",params.about_talk);
- $(".ke-outline>.ke-toolbar-icon",toolbar).append('表情');
- params.toolbar_container.append(toolbar);
+// var toolbar = $("div[class='ke-toolbar']",params.about_talk);
+// $(".ke-outline>.ke-toolbar-icon",toolbar).append('表情');
+// params.toolbar_container.append(toolbar);
}
- });
+ }).loadPlugin('paste');
//主题输入框按键事件
params.inputsubject.keyup(function(){
diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb
index 0feca0d1b..9bbe4ea5a 100644
--- a/app/views/courses/show.html.erb
+++ b/app/views/courses/show.html.erb
@@ -3,7 +3,9 @@
<%= l(:label_activity)%>
与我相关
<% else %>
<%= l(:label_activity)%>
@@ -35,7 +37,7 @@
:class => "problem_tit c_dblue fl fb",'data-type'=>e.event_type,
'data-notify-id'=>(e.respond_to?('get_notify_id') ? e.get_notify_id : ''),:nhname=>"nh_act_link",
'data-href'=>(course_activity_notifys_path(@course)+"/chang_read_flag?an_id="+(e.respond_to?('get_notify_id') ? e.get_notify_id : '').to_s)%>
- <%if @controller_name=='ActivityNotifys' && !e.get_notify_is_read%>
+ <%if @controller_name=='ActivityNotifys' && e.get_notify_is_read!=1%>
<%end%>
@@ -49,6 +51,8 @@
<% end%>
<% end%>
+<% elsif @controller_name=='ActivityNotifys' %>
+ <%= l(:label_no_data) %>
<% end%>
<% if @obj_pages.next_page.nil? && @controller_name!='ActivityNotifys' %>
diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb
index ebccfcaf4..8283e15b7 100644
--- a/app/views/files/_course_file.html.erb
+++ b/app/views/files/_course_file.html.erb
@@ -31,7 +31,7 @@
}
showModal('ajax-modal', '513px');
$('#ajax-modal').siblings().remove();
- $('#ajax-modal').before("

");
+ $('#ajax-modal').before("

");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("popbox_polls");
}
diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb
index 043aea489..1d5684d31 100644
--- a/app/views/files/_course_list.html.erb
+++ b/app/views/files/_course_list.html.erb
@@ -31,15 +31,16 @@
<%= link_to("选入我的其他课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select c_lorange",:remote => true) if has_course?(User.current,file) %>
<% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %>
-
- <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open c_blue",:method => :post %>
-
+
+ <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open c_blue",:method => :post %>
+
<% else %>
<% end %>
<% else %>
<%= link_to("选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select c_lorange",:remote => true) if has_course?(User.current,file) %>
<% end %>
+ <%= link_to '下载',download_named_attachment_path(file.id, file.filename, force: true),class: 'f_l re_open' %>
<% else %>
<% end %>
@@ -65,4 +66,4 @@
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
-
\ No newline at end of file
+
diff --git a/app/views/files/_project_file_list.html.erb b/app/views/files/_project_file_list.html.erb
index 35aa36195..a5152ecdc 100644
--- a/app/views/files/_project_file_list.html.erb
+++ b/app/views/files/_project_file_list.html.erb
@@ -30,6 +30,7 @@
<% else %>
<%= link_to(l(:label_slected_to_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %>
<% end %>
+ <%= link_to '下载',download_named_attachment_path(file.id, file.filename, force: true),class: 'f_l re_open' %>
<% end %>
@@ -37,7 +38,7 @@
文件大小:<%= number_to_human_size(file.filesize) %>
<%= link_to( l(:button_delete), attachment_path(file),
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if manage_allowed && file.container_id == project.id && file.container_type == "Project"%>
- <%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %> | 下载<%= file.downloads %> | 引用<%= file.quotes.nil? ? 0:file.quotes %>
+ <%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %> | 下载<%= file.downloads %> | 引用<%= file.quotes.nil? ? 0:file.quotes %>
@@ -51,4 +52,4 @@
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
-
\ No newline at end of file
+
diff --git a/app/views/files/_project_file_new.html.erb b/app/views/files/_project_file_new.html.erb
index 1e217f991..878e6a75e 100644
--- a/app/views/files/_project_file_new.html.erb
+++ b/app/views/files/_project_file_new.html.erb
@@ -5,7 +5,7 @@
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'upload_show_project',:locals => {:project => project}) %>');
showModal('ajax-modal', '513px');
$('#ajax-modal').siblings().remove();
- $('#ajax-modal').before("

");
+ $('#ajax-modal').before("

");
$('#ajax-modal').parent().css("top","40%").css("left","36%");
$('#ajax-modal').parent().addClass("popbox_polls");
}
diff --git a/app/views/files/quote_resource_show.js.erb b/app/views/files/quote_resource_show.js.erb
index fa1f8f4ca..76025fbd2 100644
--- a/app/views/files/quote_resource_show.js.erb
+++ b/app/views/files/quote_resource_show.js.erb
@@ -6,6 +6,6 @@
showModal('ajax-modal', '513px');
$('#ajax-modal').siblings().remove();
-$('#ajax-modal').before("

");
+$('#ajax-modal').before("

");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("popbox_polls");
\ No newline at end of file
diff --git a/app/views/files/quote_resource_show_project.js.erb b/app/views/files/quote_resource_show_project.js.erb
index d1a44e90f..41dc19fc5 100644
--- a/app/views/files/quote_resource_show_project.js.erb
+++ b/app/views/files/quote_resource_show_project.js.erb
@@ -6,6 +6,6 @@
showModal('ajax-modal', '513px');
$('#ajax-modal').siblings().remove();
-$('#ajax-modal').before("

");
+$('#ajax-modal').before("

");
$('#ajax-modal').parent().css("top","30%").css("left","35%");
$('#ajax-modal').parent().addClass("popbox_polls");
\ No newline at end of file
diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb
index 87bf37f04..1e8189ddb 100644
--- a/app/views/homework_common/index.html.erb
+++ b/app/views/homework_common/index.html.erb
@@ -16,9 +16,9 @@
<%= link_to(image_tag(url_to_avatar(homework.user), :width => "42", :height => "42"), user_path(homework.user), :class => "problem_pic fl") %>
- <%= link_to(homework.user.lastname+homework.user.firstname, user_path(homework.user),:class => 'problem_name fl') %>
+ <%= link_to(homework.user.lastname+homework.user.firstname, user_path(homework.user),:class => 'problem_name fl',:target => "_blank") %>
<%= l(:label_user_create_project_homework) %>:
- <%= link_to(homework.name, student_work_index_path(:homework => homework.id), :class => 'problem_tit fl fb c_dblue') %>
+ <%= link_to(homework.name, student_work_index_path(:homework => homework.id), :class => 'problem_tit fl fb c_dblue',:target => "_blank") %>
<%= l(:lebel_homework_commit)%>
diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb
index 269017eb8..5686c9a1b 100644
--- a/app/views/layouts/base_users.html.erb
+++ b/app/views/layouts/base_users.html.erb
@@ -218,9 +218,8 @@
<% end %>
- <% unless @user.user_extensions.nil?&&@user.user_extensions.location.empty?%>
+ <% if @user.user_extensions && @user.user_extensions.location && !@user.user_extensions.location.empty?%>
-
<%= l(:label_location) %>:
|
diff --git a/app/views/mailer/news_added.html.erb b/app/views/mailer/news_added.html.erb
index ca8f3c1b0..316ab9d2c 100644
--- a/app/views/mailer/news_added.html.erb
+++ b/app/views/mailer/news_added.html.erb
@@ -1,17 +1,15 @@
-
-
-
- <%= link_to(h("#{@news.author.login}(#{@news.author.show_name})"), @issue_author_url , :style=>'color:#1b55a7; font-weight:bold;') %>
-
- <%= l(:mail_issue_title_userin)%>
+
+ <%= link_to(h("#{@news.author.login}(#{@news.author.show_name})"), @issue_author_url , :style=>'color:#1b55a7; font-weight:bold;') %>
+ <%= l(:mail_issue_title_userin)%>
<% if @news.project %>
- <%=h @news.project.name %> : <%= link_to(h(@news.title), @news_url,:style=>'color:#1b55a7; font-weight:bold;') %>
+ <%=h @news.project.name %> : <%= link_to(h(@news.title), @news_url,:style=>'color:#1b55a7; font-weight:bold;') %>
<% elsif @news.course %>
- <%=h @news.course.name %> : <%= link_to(h(@news.title), @news_url,:style=>'color:#1b55a7; font-weight:bold;') %>
- <% end %>
- <%= l(:mail_issue_title_active)%>
+ <%=h @news.course.name %> : <%= link_to(h(@news.title), @news_url,:style=>'color:#1b55a7; font-weight:bold;') %>
+ <% end %>
+ <%= l(:mail_issue_title_active)%>
+
- <%= l(:mail_issue_subject)%>
@@ -25,7 +23,7 @@
- <%= l(:mail_issue_content)%>
- <%= @news.description %>
+ <%= @news.description.html_safe %>
diff --git a/app/views/mailer/send_for_user_activities.html.erb b/app/views/mailer/send_for_user_activities.html.erb
index 73a561ca3..81a65442f 100644
--- a/app/views/mailer/send_for_user_activities.html.erb
+++ b/app/views/mailer/send_for_user_activities.html.erb
@@ -1,341 +1,359 @@
+
+
+ <%= @subject %>
+
+<% if @attachments.first || @course_news.first || @bids.first ||
+ @homeworks.first || @course_journal_messages.first|| @course_messages.first %>
+
+
<%= l(:label_course_overview)%>
+ <% unless @course_news.first.nil? %>
+
+
+ <%= l(:label_course_news) %>
+ (<%= @course_news.count %>)
+
+ <% @course_news.each do |course_new|%>
+ -
+ ▪
+ [
+ <%= link_to truncate(course_new.course.name,length: 30,omission: '...'), course_url(course_new.course, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
+ <%= link_to course_new.author, user_activities_url(course_new.author,:token => @token.value), :class => "wmail_name",
+ :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
+ <%= l(:label_project_notice) %>
+ <%= link_to truncate(course_new.title,length: 30,omission: '...'), news_url(course_new,:token => @token.value),
+ :class => 'wmail_info',
+ :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
+ %>
+ <%= format_time(course_new.created_on) %>
+
+ <% end %>
+
+
+ <% end %>
+
+ <% if !@bids.first.nil? || !@homeworks.first.nil? %>
+
+ <%= l(:label_homework_overview) %>(<%= @bids.count %>)
+ <% unless @bids.first.nil?%>
+ <% @bids.each do |bid| %>
+ -
+ ▪
+ [
+
+ <%= link_to truncate(bid.courses.first.name,length: 30,omission: '...'), course_url(bid.courses.first, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
+
+ <%= link_to bid.author, user_activities_url(bid.author,:token => @token.value), :class => "wmail_name",
+ :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
+ <%= l(:label_course_homework) %>
+
+ <%= link_to truncate(bid.name,length: 30,omission: '...'), course_for_bid_url(:id => bid.id,:token => @token.value),
+ :class => 'wmail_info',
+ :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
+ %>
+ <%= format_time(bid.created_on) %>
+
+ <% end %>
+ <% end %>
+ <% unless @homeworks.first.nil? %>
+ <% @homeworks.each do |homework| %>
+ -
+ ▪
+ [
+
+ <%= link_to truncate(homework.bid.courses.first.name,length: 30,omission: '...'), course_url(homework.bid.courses.first, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
+
+ <%= link_to homework.user, user_activities_url(homework.user,:token => @token.value), :class => "wmail_name",
+ :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
+ <%= l(:label_course_submit_homework) %>
+
+ <%= link_to truncate(homework.name,length: 30,omission: '...'), course_for_bid_url(:id => homework.bid.id,:token => @token.value),
+ :class => 'wmail_info',
+ :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
+ %>
+ <%= format_time(homework.created_at) %>
+
+ <% end %>
+ <% end %>
+
+
+ <% end %>
-
-
-<%= @subject %>
-
-<% if @attachments.first || @course_news.first || @bids.first ||
- @homeworks.first || @course_journal_messages.first|| @course_messages.first %>
-
-
<%= l(:label_course_overview)%>
- <% unless @course_news.first.nil? %>
-
-
-
- <%= l(:label_course_news) %>
- (<%= @course_news.count %>)
-
-
- <% @course_news.each do |course_new|%>
- -
- ▪
- [
-
- <%= link_to truncate(course_new.course.name,length: 30,omission: '...'), course_url(course_new.course, :token => @token.value),
- :class=> "wmail_column",
- :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
- ]
-
- <%= link_to course_new.author, user_activities_url(course_new.author,:token => @token.value), :class => "wmail_name",
- :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
- <%= l(:label_project_notice) %>
-
- <%= link_to truncate(course_new.title,length: 30,omission: '...'), news_url(course_new,:token => @token.value),
- :class => 'wmail_info',
- :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
- %>
- <%= format_time(course_new.created_on) %>
-
+
+ <% unless @course_journal_messages.first.nil? %>
+
+
+ <%= l(:view_course_journals_for_messages) %>
+ (<%= @course_journal_messages.count %>)
+
+
+ <% @course_journal_messages.each do |course_journal_message|%>
+ -
+ ▪
+ [
+
+ <%= link_to truncate(course_journal_message.course.name,length: 30,omission: '...'), course_url(course_journal_message.course, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
+
+ <%= link_to course_journal_message.user, user_activities_url(course_journal_message.user,:token => @token.value), :class => "wmail_name",
+ :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
+ <%= l(:label_send_course_journals_for_messages) %>
+
+ <%= link_to truncate(course_journal_message.notes,length: 30,omission: '...'), course_feedback_url(course_journal_message.course,:token => @token.value),
+ :class => 'wmail_info',
+ :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
+ %>
+ <%= format_time(course_journal_message.created_on) %>
+
+ <% end %>
+
+
<% end %>
-
-
- <% end %>
- <% if !@bids.first.nil? || !@homeworks.first.nil? %>
-
-
- <%= l(:label_homework_overview) %>(<%= @bids.count %>)
- <% unless @bids.first.nil?%>
- <% @bids.each do |bid| %>
- -
- ▪
- [
-
- <%= link_to truncate(bid.courses.first.name,length: 30,omission: '...'), course_url(bid.courses.first, :token => @token.value),
- :class=> "wmail_column",
- :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
- ]
-
- <%= link_to bid.author, user_activities_url(bid.author,:token => @token.value), :class => "wmail_name",
- :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
- <%= l(:label_course_homework) %>
-
- <%= link_to truncate(bid.name,length: 30,omission: '...'), course_for_bid_url(:id => bid.id,:token => @token.value),
- :class => 'wmail_info',
- :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
- %>
- <%= format_time(bid.created_on) %>
-
+
+ <% unless @course_messages.first.nil? %>
+
+
+ <%= l(:view_borad_course) %>
+ (<%= @course_journal_messages.count %>)
+
+ <% @course_messages.each do |course_message|%>
+ -
+ ▪
+ [
+ <%= link_to truncate(course_message.course.name,length: 30,omission: '...'), course_url(course_message.course.id, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
+ <%= link_to course_message.author, user_activities_url(course_message.author,:token => @token.value), :class => "wmail_name",
+ :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
+ <%= l(:label_send_course_messages) %>
+ <%= link_to truncate(course_message.subject,length: 30,omission: '...'),board_message_url(course_message, :board_id => course_message.board_id,:token => @token.value),
+ :class => 'wmail_info',
+ :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ <%= format_time(course_message.created_on) %>
+
+ <% end %>
+
+
<% end %>
+
+
+ <% unless @attachments.first.nil? %>
+
+
+ <%= l(:label_course_attendingcontestwork_download) %>
+ (<%= @attachments.count %>)
+
+
+ <% @attachments.each do |attachment|%>
+ -
+ ▪
+ [
+
+ <%= link_to truncate(attachment.course.name,length: 30,omission: '...'), course_url(attachment.course, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
+
+ <%= link_to attachment.author, user_activities_url(attachment.author,:token => @token.value), :class => "wmail_name",
+ :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
+ <%= l(:label_course_file_upload) %>
+
+ <%= link_to truncate(attachment.filename,length: 30,omission: '...'),course_files_url(attachment.course,:token => @token.value),
+ :class => 'wmail_info',
+ :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
+ %>
+ <%= format_time(attachment.created_on) %>
+
+ <% end %>
+
+
<% end %>
- <% unless @homeworks.first.nil? %>
- <% @homeworks.each do |homework| %>
- -
- ▪
- [
-
- <%= link_to truncate(homework.bid.courses.first.name,length: 30,omission: '...'), course_url(homework.bid.courses.first, :token => @token.value),
- :class=> "wmail_column",
- :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
- ]
-
- <%= link_to homework.user, user_activities_url(homework.user,:token => @token.value), :class => "wmail_name",
- :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
- <%= l(:label_course_submit_homework) %>
-
- <%= link_to truncate(homework.name,length: 30,omission: '...'), course_for_bid_url(:id => homework.bid.id,:token => @token.value),
- :class => 'wmail_info',
- :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
- %>
- <%= format_time(homework.created_at) %>
-
+
+<% end %>
+
+
+
+
+<% if @issues.first || @project_messages.first %>
+
+
<%= l(:label_project_overview_new)%>
+ <% unless @issues.first.nil? %>
+
+
+ <%= l(:label_issue_tracking) %>
+ (<%= @issues.count %>)
+
+ <% @issues.each do |issue|%>
+ -
+ ▪
+ [
+ <%= link_to truncate(issue.project.name,length: 30,omission: '...'), project_url(issue.project, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
+ <%= link_to issue.author, user_activities_url(issue.author,:token => @token.value), :class => "wmail_name",
+ :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
+ <%= l(:label_project_issue) %>
+ <%= link_to truncate(issue.subject,length: 30,omission: '...'),issue_url(issue, :token => @token.value),
+ :class => 'wmail_info',
+ :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
+ %>
+ <%= format_time(issue.created_on) %>
+
+ <% end %>
+
+
+
<% end %>
+
+
+ <% unless @project_messages.first.nil? %>
+
+
+ <%= l(:project_moule_boards_show) %>
+ (<%= @project_messages.count %>)
+
+
+ <% @project_messages.each do |project_message|%>
+ -
+ ▪
+ [
+
+ <%= link_to truncate(project_message.project.name,length: 30,omission: '...'), project_url(project_message.project, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
+
+ <%= link_to project_message.author, user_activities_url(project_message.author,:token => @token.value), :class => "wmail_name",
+ :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
+ <%= l(:label_send_course_messages) %>
+
+ <%= link_to truncate(project_message.subject,length: 30,omission: '...'),board_message_url(project_message, :board_id => project_message.board_id,:token => @token.value),
+ :class => 'wmail_info',
+ :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
+ %>
+ <%= format_time(project_message.created_on) %>
+
+ <% end %>
+
+
+
<% end %>
-
-
- <% end %>
-
- <% unless @course_journal_messages.first.nil? %>
-
-
-
- <%= l(:view_course_journals_for_messages) %>
- (<%= @course_journal_messages.count %>)
-
-
- <% @course_journal_messages.each do |course_journal_message|%>
- -
- ▪
- [
-
- <%= link_to truncate(course_journal_message.course.name,length: 30,omission: '...'), course_url(course_journal_message.course, :token => @token.value),
- :class=> "wmail_column",
- :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
- ]
-
- <%= link_to course_journal_message.user, user_activities_url(course_journal_message.user,:token => @token.value), :class => "wmail_name",
- :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
- <%= l(:label_send_course_journals_for_messages) %>
-
- <%= link_to truncate(course_journal_message.notes,length: 30,omission: '...'), course_feedback_url(course_journal_message.course,:token => @token.value),
- :class => 'wmail_info',
- :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
- %>
- <%= format_time(course_journal_message.created_on) %>
-
- <% end %>
-
-
-
- <% end %>
-
- <% unless @course_messages.first.nil? %>
-
-
-
- <%= l(:view_borad_course) %>
- (<%= @course_journal_messages.count %>)
-
-
- <% @course_messages.each do |course_message|%>
- -
- ▪
- [
-
- <%= link_to truncate(course_message.course.name,length: 30,omission: '...'), course_url(course_message.course.id, :token => @token.value),
- :class=> "wmail_column",
- :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
- ]
-
- <%= link_to course_message.author, user_activities_url(course_message.author,:token => @token.value), :class => "wmail_name",
- :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
- <%= l(:label_send_course_messages) %>
-
- <%= link_to truncate(course_message.subject,length: 30,omission: '...'),board_message_url(course_message, :board_id => course_message.board_id,:token => @token.value),
- :class => 'wmail_info',
- :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
- %>
- <%= format_time(course_message.created_on) %>
-
- <% end %>
-
-
-
- <% end %>
-
- <% unless @attachments.first.nil? %>
-
-
- <%= l(:label_course_attendingcontestwork_download) %>
- (<%= @attachments.count %>)
-
-
- <% @attachments.each do |attachment|%>
- -
- ▪
- [
-
- <%= link_to truncate(attachment.course.name,length: 30,omission: '...'), course_url(attachment.course, :token => @token.value),
- :class=> "wmail_column",
- :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
- ]
-
- <%= link_to attachment.author, user_activities_url(attachment.author,:token => @token.value), :class => "wmail_name",
- :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
- <%= l(:label_course_file_upload) %>
-
- <%= link_to truncate(attachment.filename,length: 30,omission: '...'),course_files_url(attachment.course,:token => @token.value),
- :class => 'wmail_info',
- :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
- %>
- <%= format_time(attachment.created_on) %>
-
- <% end %>
-
-
- <% end %>
-
- <% end %>
- <% if @issues.first || @project_messages.first %>
-
-
<%= l(:label_project_overview_new)%>
- <% unless @issues.first.nil? %>
-
-
- <%= l(:label_issue_tracking) %>
- (<%= @issues.count %>)
-
-
- <% @issues.each do |issue|%>
- -
- ▪
- [
-
- <%= link_to truncate(issue.project.name,length: 30,omission: '...'), project_url(issue.project, :token => @token.value),
- :class=> "wmail_column",
- :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
- ]
-
- <%= link_to issue.author, user_activities_url(issue.author,:token => @token.value), :class => "wmail_name",
- :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
- <%= l(:label_project_issue) %>
-
- <%= link_to truncate(issue.subject,length: 30,omission: '...'),issue_url(issue, :token => @token.value),
- :class => 'wmail_info',
- :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
- %>
- <%= format_time(issue.created_on) %>
-
- <% end %>
-
-
-
- <% end %>
-
- <% unless @project_messages.first.nil? %>
-
-
- <%= l(:project_moule_boards_show) %>
- (<%= @project_messages.count %>)
-
-
- <% @project_messages.each do |project_message|%>
- -
- ▪
- [
-
- <%= link_to truncate(project_message.project.name,length: 30,omission: '...'), project_url(project_message.project, :token => @token.value),
- :class=> "wmail_column",
- :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
- ]
-
- <%= link_to project_message.author, user_activities_url(project_message.author,:token => @token.value), :class => "wmail_name",
- :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
- <%= l(:label_send_course_messages) %>
-
- <%= link_to truncate(project_message.subject,length: 30,omission: '...'),board_message_url(project_message, :board_id => project_message.board_id,:token => @token.value),
- :class => 'wmail_info',
- :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
- %>
- <%= format_time(project_message.created_on) %>
-
- <% end %>
-
-
-
- <% end %>
-
-
-
-
- <% end %>
- <% unless @user_journal_messages.first.nil? %>
-
-
<%= l(:label_activities) %>
-
-
-
- <%= l(:label_user_message) %>
- (<%= @user_journal_messages.count %>)
-
-
- <% @user_journal_messages.each do |user_journal_message|%>
- -
- ▪
-
- <%= link_to user_journal_message.user, user_activities_url(user_journal_message.user,:token => @token.value),
- :class => "wmail_name",
- :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
- <%= l(:label_show_your_message) %>
-
- <%= link_to truncate(user_journal_message.notes,length: 30,omission: '...'),feedback_url(@user,:token => @token.value),
- :class => 'wmail_info',
- :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
- %>
- <%= format_time(user_journal_message.created_on) %>
+
+ <% unless @project_news.first.nil? %>
+
+
+ <%= l(:label_course_news) %>
+ (<%= @project_news.count %>)
+
+ <% @project_news.each do |project_new|%>
+ -
+ ▪
+ [
- <% end %>
+ <%= link_to truncate(project_new.project.name,length: 30,omission: '...'), project_url(project_new.project, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
+ <%= link_to project_new.author, user_activities_url(project_new.author,:token => @token.value), :class => "wmail_name",
+ :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
+ <%= l(:label_project_notice) %>
-
-
+ <%= link_to truncate(project_new.title,length: 30,omission: '...'), news_url(project_new,:token => @token.value),
+ :class => 'wmail_info',
+ :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
+ %>
+ <%= format_time(project_new.created_on) %>
+
+ <% end %>
+
+
+ <% end %>
-
- <% end %>
- <% if @forums.first || @memos.first %>
+
+<% end %>
+
+
+<% unless @user_journal_messages.first.nil? %>
-
<%= l(:lable_bar_active) %>
- <% unless @forums.first.nil? %>
+
<%= l(:label_activities) %>
+
- <%= l(:label_user_forum) %>
- (<%= @forums.count %>)
+ <%= l(:label_user_message) %>
+ (<%= @user_journal_messages.count %>)
- <% @forums.each do |forum|%>
+ <% @user_journal_messages.each do |user_journal_message|%>
-
▪
- <%= link_to forum.creator, user_activities_url(forum.creator,:token => @token.value),
+ <%= link_to user_journal_message.user, user_activities_url(user_journal_message.user,:token => @token.value),
:class => "wmail_name",
:style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
- <%= l(:label_forum_new) %>
+ <%= l(:label_show_your_message) %>
- <%= link_to truncate(forum.name,length: 30,omission: '...'),forum_url(forum,:token => @token.value),
+ <%= link_to truncate(user_journal_message.notes,length: 30,omission: '...'),feedback_url(@user,:token => @token.value),
:class => 'wmail_info',
:style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
%>
- <%= format_time(forum.created_at) %>
+ <%= format_time(user_journal_message.created_on) %>
<% end %>
-
+
+
+
+<% end %>
+<% if @forums.first || @memos.first %>
+
+
<%= l(:lable_bar_active) %>
+ <% unless @forums.first.nil? %>
+
+
+ <%= l(:label_user_forum) %>
+ (<%= @forums.count %>)
+
+
+ <% @forums.each do |forum|%>
+ -
+ ▪
+
+ <%= link_to forum.creator, user_activities_url(forum.creator,:token => @token.value),
+ :class => "wmail_name",
+ :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ <%= l(:label_forum_new) %>
+
+ <%= link_to truncate(forum.name,length: 30,omission: '...'),forum_url(forum,:token => @token.value),
+ :class => 'wmail_info',
+ :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
+ %>
+ <%= format_time(forum.created_at) %>
+
+ <% end %>
+
+
+
<% end %>
<% unless @memos.first.nil? %>
@@ -366,14 +384,14 @@
<% end %>
<% end %>
-
+
diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb
index 5452aa893..05358c32a 100644
--- a/app/views/memos/show.html.erb
+++ b/app/views/memos/show.html.erb
@@ -131,9 +131,9 @@
<%= link_to image_tag(url_to_avatar(reply.author), :class => "avatar"), user_path(reply.author) %>