diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb
index 91ea92629..eb51ea56a 100644
--- a/app/controllers/contests_controller.rb
+++ b/app/controllers/contests_controller.rb
@@ -9,7 +9,7 @@ class ContestsController < ApplicationController
include AvatarHelper
before_filter :find_contest, :only => [:show, :settings, :update, :destroy, :contest_activities, :search_member, :private_or_public, :switch_role, :set_invite_code_halt, :renew,
- :member, :export_all_members]
+ :member, :export_all_members, :feedback]
before_filter :is_logged, :only => [:index, :new, :create]
before_filter :is_admin?, :only => [:settings, :set_invite_code_halt, :destroy]
before_filter :is_member?, :only => [:show, :contest_activities]
@@ -115,6 +115,30 @@ class ContestsController < ApplicationController
@contest.update_attributes(:is_delete => true)
end
+ def feedback
+ if (User.current.admin? || @contest.is_public || (!@contest.is_public && User.current.member_of_contest?(@contest)))
+ ContestMessage.where(:user_id => User.current.id, :contest_id => @contest.id, :contest_message_type => 'JournalsForMessage', :contest_message_id => @contest.journals_for_messages.map{|jour|jour.id}).update_all(:viewed => true)
+ page = params[:page]
+ # Find the page of the requested reply
+ @jours = @contest.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
+ @jour_count = @jours.count
+ @limit = 10
+ if params[:r] && page.nil?
+ offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i])
+ page = 1 + offset / @limit
+ end
+ @jour = paginateHelper @jours,10
+ @state = false
+ @left_nav_type = 6
+ respond_to do |format|
+ format.html{render :layout => 'base_contests'}
+ format.api
+ end
+ else
+ render_403
+ end
+ end
+
def private_or_public
@contest.update_attributes(:is_public => !@contest.is_public)
diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb
index a3f1de6f9..587d14c9c 100644
--- a/app/controllers/words_controller.rb
+++ b/app/controllers/words_controller.rb
@@ -109,6 +109,19 @@ class WordsController < ApplicationController
end
return
end
+ elsif @journal_destroyed.jour_type == "Contest"
+ @contest = Contest.find(@journal_destroyed.jour_id)
+ @jours_count = @contest.journals_for_messages.where('m_parent_id IS NULL').count
+ @user_activity_id = params[:user_activity_id] if params[:user_activity_id]
+ @activity = JournalsForMessage.where("id = #{params[:activity_id].to_i}").first if params[:activity_id]
+ unless @activity
+ if params[:user_activity_id] == params[:activity_id]
+ redirect_to feedback_contest_path(@contest)
+ else
+ redirect_to contest_activities_contest_path(@contest)
+ end
+ return
+ end
elsif @journal_destroyed.jour_type == 'HomeworkCommon'
@homework = HomeworkCommon.find @journal_destroyed.jour_id
if params[:user_activity_id]
@@ -305,6 +318,18 @@ class WordsController < ApplicationController
end
end
+ def leave_contest_message
+ if User.current.logged?
+ @contest = Contest.find params[:id]
+ if params[:new_form][:content].size>0 && User.current.logged?
+ @contest.journals_for_messages << JournalsForMessage.new(:user_id => User.current.id, :notes => params[:new_form][:content], :reply_id => 0, :status => true, :is_readed => false)
+ end
+ redirect_to feedback_contest_path(@contest)
+ else
+ render_403
+ end
+ end
+
#作业的回复
def leave_homework_message
if User.current.logged?
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index a40254b97..8a3e7846f 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -4138,6 +4138,8 @@ def add_reply_adapter obj, options
Project.add_new_jour(nil, nil, obj.jour_id, options)
when 'Course'
Course.add_new_jour(nil, nil, obj.jour_id, options)
+ when 'Contest'
+ Contest.add_new_jour(nil, nil, obj.jour_id, options)
#when 'Bid'
# obj.jour.add_jour(nil, nil, nil, options)
#when 'Contest'
diff --git a/app/helpers/contests_helper.rb b/app/helpers/contests_helper.rb
index a16c75f24..e4dec9651 100644
--- a/app/helpers/contests_helper.rb
+++ b/app/helpers/contests_helper.rb
@@ -93,4 +93,8 @@ module ContestsHelper
end
mems
end
+
+ def contest_feedback_count
+ @contest.journals_for_messages.where('m_parent_id IS NULL').count
+ end
end
diff --git a/app/models/contest.rb b/app/models/contest.rb
index 4aa4803bf..bced1785d 100644
--- a/app/models/contest.rb
+++ b/app/models/contest.rb
@@ -16,7 +16,7 @@ class Contest < ActiveRecord::Base
has_many :contestant_work_projects, :dependent => :destroy
has_many :boards, :dependent => :destroy, :order => "position ASC"
has_many :files
-
+ has_many :journals_for_messages, :as => :jour, :dependent => :destroy
has_many :news, :dependent => :destroy, :include => :author
@@ -131,4 +131,16 @@ class Contest < ActiveRecord::Base
logger.error "[Contest Model] ===> Auto create board when contest saved, because #{@board.full_messages}"
end
end
+
+ # 新增竞赛留言
+ def self.add_new_jour(user, notes, id, options={})
+ contest = Contest.find(id)
+ if options.count == 0
+ pjfm = contest.journals_for_messages.build(:user_id => user.id, :notes => notes, :reply_id => 0)
+ else
+ pjfm = contest.journals_for_messages.build(options)
+ end
+ pjfm.save
+ pjfm
+ end
end
diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb
index a80d9b425..38c323798 100644
--- a/app/models/journals_for_message.rb
+++ b/app/models/journals_for_message.rb
@@ -76,7 +76,7 @@ class JournalsForMessage < ActiveRecord::Base
has_one :praise_tread_cache, as: :object, dependent: :destroy
validates :notes, presence: true, if: :is_homework_jour?
- after_create :act_as_course_activity, :act_as_course_message,
+ after_create :act_as_course_activity, :act_as_course_message, :act_as_contest_activity,
act_as_at_message(:notes, :user_id), :act_as_user_feedback_message,
:act_as_principal_activity
# after_create :reset_counters!
@@ -222,6 +222,13 @@ class JournalsForMessage < ActiveRecord::Base
end
end
+ #竞赛动态公共表记录
+ def act_as_contest_activity
+ if self.jour_type == 'Contest' && self.m_parent_id.nil?
+ self.contest_acts << ContestActivity.new(:user_id => self.user_id,:contest_id => self.jour_id)
+ end
+ end
+
# 课程/作品回复 留言消息通知
def act_as_course_message
if self.jour_type == 'StudentWorksScore'
diff --git a/app/views/contests/_contest_activity.html.erb b/app/views/contests/_contest_activity.html.erb
index 8a29f6262..e5215abda 100644
--- a/app/views/contests/_contest_activity.html.erb
+++ b/app/views/contests/_contest_activity.html.erb
@@ -47,7 +47,7 @@
<% when 'Poll' %>
<%#= render :partial => 'users/contest_poll', :locals => {:activity => act, :user_activity_id => activity.id, :is_course => 1} %>
<% when 'JournalsForMessage' %>
- <%#= render :partial => 'users/contest_journalsformessage', :locals => {:activity => act, :user_activity_id => activity.id, :is_course => 1} %>
+ <%= render :partial => 'users/contest_journalsformessage', :locals => {:activity => act, :user_activity_id => activity.id, :is_contest => 1} %>
<% when 'Attachment' %>
<%#= render :partial => 'users/contest_attachment', :locals => {:activity => act, :user_activity_id => activity.id} %>
<% when 'Contest' %>
diff --git a/app/views/contests/_contest_jours_list.html.erb b/app/views/contests/_contest_jours_list.html.erb
new file mode 100644
index 000000000..ce76c61fe
--- /dev/null
+++ b/app/views/contests/_contest_jours_list.html.erb
@@ -0,0 +1,19 @@
+<%= content_for(:header_tags) do %>
+ <%= import_ke(enable_at: true, prettify: false, init_activity: true) %>
+ <%#= javascript_include_tag "init_KindEditor","user" %>
+<% end %>
+
+<%if jours %>
+ <% jours.each do |jour|%>
+
+ <%= render :partial => 'users/contest_journalsformessage', :locals => {:activity => jour,:user_activity_id =>jour.id, :is_contest => 1} %>
+ <%#= render :partial => 'user_jours_new', :locals => {:jour => jour} %>
+ <%end%>
+<% end%>
+<% if (jours.count + page * 10) < count %>
+ <%= link_to "点击展开更多",feedback_contest_path(@contest.id, :page => page),:id => "show_more_jours",:remote => "true",:class => "loadMore mt10 f_grey"%>
+<% end %>
\ No newline at end of file
diff --git a/app/views/contests/contest_activities.html.erb b/app/views/contests/contest_activities.html.erb
index ee0155af7..ab2e1059a 100644
--- a/app/views/contests/contest_activities.html.erb
+++ b/app/views/contests/contest_activities.html.erb
@@ -12,7 +12,7 @@
<%= link_to "通知动态", contest_activities_contest_path(@contest, :type => 'news'), :class => "homepagePostTypeNotice postTypeGrey"%>
<%= link_to "论坛动态", contest_activities_contest_path(@contest, :type => 'message'), :class => "homepagePostTypeForum postTypeGrey"%>
-
+ <%= link_to "留言动态", contest_activities_contest_path(@contest, :type => 'journalsForMessage'), :class => "homepagePostTypeMessage postTypeGrey"%>
diff --git a/app/views/contests/feedback.html.erb b/app/views/contests/feedback.html.erb
new file mode 100644
index 000000000..120ec1365
--- /dev/null
+++ b/app/views/contests/feedback.html.erb
@@ -0,0 +1,28 @@
+
+
\ No newline at end of file
diff --git a/app/views/contests/feedback.js.erb b/app/views/contests/feedback.js.erb
new file mode 100644
index 000000000..485ec3326
--- /dev/null
+++ b/app/views/contests/feedback.js.erb
@@ -0,0 +1 @@
+$("#show_more_jours").replaceWith("<%= escape_javascript( render :partial => 'contests/contest_jours_list',:locals => {:jours => @jours, :page => @page, :count => @jour_count} )%>");
diff --git a/app/views/layouts/base_contests.html.erb b/app/views/layouts/base_contests.html.erb
index e10b221a1..0c52f8596 100644
--- a/app/views/layouts/base_contests.html.erb
+++ b/app/views/layouts/base_contests.html.erb
@@ -71,7 +71,10 @@
<%= link_to "", contest_news_index_path(@contest,:is_new => 1), :class => "sy_class_add" %>
<% end %>
-
+
+ 留言<%=contest_feedback_count %>
+ <%= link_to( "", feedback_contest_path(@contest), :class => 'sy_class_add', :title =>"#{l(:label_course_feedback)}") if User.current.member_of_contest?(@contest) %>
+
diff --git a/app/views/users/_contest_journalsformessage.html.erb b/app/views/users/_contest_journalsformessage.html.erb
new file mode 100644
index 000000000..da96c7935
--- /dev/null
+++ b/app/views/users/_contest_journalsformessage.html.erb
@@ -0,0 +1,65 @@
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user), :alt => "用户头像" %>
+ <%#= render :partial => 'users/show_detail_info', :locals => {:user => activity.user} %>
+
+
+
+ <%= link_to activity.user.show_name, user_path(activity.user), :class => "newsBlue mr15" %>
+ TO
+ <% contest=Contest.find(activity.jour_id) %>
+ <% str = defined?(is_contest) && is_contest == 1 ? "竞赛留言" : "#{contest.name.to_s} | 竞赛留言" %>
+ <%= link_to str, feedback_contest_path(contest), :class => "newsBlue ml15" %>
+
+ <% if activity.parent %>
+ <% content = activity.parent.notes %>
+ <% else %>
+ <% content = activity.notes %>
+ <% end %>
+ <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
+
+
+
+
+
+ 留言时间:<%= format_time(activity.created_on) %>
+
+
+ 更新时间:<%= format_time(ContestActivity.where("contest_act_type='#{activity.class}' and contest_act_id =#{activity.id}").first.updated_at) %>
+
+
+ <% if defined?(is_contest) && is_contest == 1 && (activity.user == User.current || User.current.admin? || User.current.admin_of_contest?(contest))%>
+
+
+ -
+
+ -
+ 删除
+ <%#= link_to(l(:label_bid_respond_delete),
+ {:controller => 'words', :action => 'destroy', :object_id => activity, :user_id => activity.user.id,:user_activity_id => user_activity_id, :activity_id => activity.id},
+ :confirm => l(:text_are_you_sure), :method => 'delete',
+ :class => "postOptionLink", :title => l(:button_delete)) %>
+
+
+
+
+
+ <% end%>
+
+
+
+
+
+
+ <%=render :partial => 'users/user_journal_post_reply', :locals => {:activity => activity, :user_activity_id => user_activity_id} %>
+
+
+
+
+
diff --git a/app/views/users/_jour_form.html.erb b/app/views/users/_jour_form.html.erb
index e9e549c40..a883b770e 100644
--- a/app/views/users/_jour_form.html.erb
+++ b/app/views/users/_jour_form.html.erb
@@ -23,7 +23,7 @@
diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb
index 85a2c09c5..d6ecffd98 100644
--- a/app/views/users/_user_activities.html.erb
+++ b/app/views/users/_user_activities.html.erb
@@ -94,7 +94,7 @@
<% when 'Contest' %>
<%= render :partial => 'users/contest_create', :locals => {:activity => act, :user_activity_id => act.id} %>
<% when 'JournalsForMessage' %>
- <%#= render :partial => 'users/contest_journalsformessage', :locals => {:activity => act, :user_activity_id => user_activity.id} %>
+ <%= render :partial => 'users/contest_journalsformessage', :locals => {:activity => act, :user_activity_id => user_activity.id} %>
<% end %>
<% when 'Principal' %>
<% case user_activity.act_type.to_s %>
diff --git a/app/views/users/contest_community.html.erb b/app/views/users/contest_community.html.erb
index adac07d6d..26cad6c32 100644
--- a/app/views/users/contest_community.html.erb
+++ b/app/views/users/contest_community.html.erb
@@ -13,7 +13,7 @@
<%= link_to "作品动态", {:controller => "users", :action => "contest_community", :type => "contest_work"}, :class => "homepagePostTypeAssignment postTypeGrey" %>
<%= link_to "通知动态", {:controller => "users", :action => "contest_community", :type => "contest_news"}, :class => "homepagePostTypeNotice postTypeGrey" %>
<%= link_to "论坛动态", {:controller => "users", :action => "contest_community", :type => "contest_message"}, :class => "homepagePostTypeForum postTypeGrey" %>
-
+ <%= link_to "竞赛留言", {:controller => "users", :action => "contest_community", :type => "contest_journals"}, :class => "homepagePostTypeMessage postTypeGrey" %>
<% end %>
diff --git a/app/views/users/user_newfeedback.html.erb b/app/views/users/user_newfeedback.html.erb
index 81e2fe399..7a3328bf4 100644
--- a/app/views/users/user_newfeedback.html.erb
+++ b/app/views/users/user_newfeedback.html.erb
@@ -18,7 +18,7 @@
<%= link_to image_tag(url_to_avatar(User.current),:class=>"fl mr10", :width => "50", :height => "50"), :alt => "用户头像" %>
<%= form_for('new_form',:url => leave_user_message_path(@user.id), :html =>{:id => "user_feedback_new"}, :method => "post") do |f|%>
- <%= render :partial => "jour_form", :locals => {:f => f} %>
+ <%= render :partial => "jour_form", :locals => {:f => f, :object => @user} %>
留言
私信
diff --git a/app/views/words/create_reply.js.erb b/app/views/words/create_reply.js.erb
index 0edea0588..2ed2aaa86 100644
--- a/app/views/words/create_reply.js.erb
+++ b/app/views/words/create_reply.js.erb
@@ -1,8 +1,6 @@
<% if @save_succ %>
<% if @user_activity_id %>
- <% if @activity.jour_type == 'Principal' %>
- $("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/user_journal_post_reply', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>");
- <% elsif @activity.jour_type == 'Course' %>
+ <% if @activity.jour_type == 'Principal' || @activity.jour_type == 'Course' || @activity.jour_type == 'Contest' %>
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/user_journal_post_reply', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>");
<% end %>
//init_activity_KindEditor_data('<%#= @user_activity_id%>', "", "87%", "UserActivity");
diff --git a/app/views/words/destroy.js.erb b/app/views/words/destroy.js.erb
index 9680b5c68..f53a21935 100644
--- a/app/views/words/destroy.js.erb
+++ b/app/views/words/destroy.js.erb
@@ -28,7 +28,12 @@
<% else %>
$('#course_jour_count').html("<%= @jours_count %>");
<% end %>
- <% elsif @user && @jours_count%>
+ <% elsif @contest && @jours_count%>
+ <% if @user_activity_id %>
+ $("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/user_journal_post_reply', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>");
+ sd_create_editor_from_data('<%= @user_activity_id%>', "", "100%", "UserActivity");
+ <% end %>
+ <% elsif @user && @jours_count%>
$('#jour_count').html("<%= @jours_count %>");
<% elsif @homework%>
$("#homework_post_reply_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/homework_post_reply', :locals => {:activity => @homework, :user_activity_id => @user_activity_id, :is_teacher => @is_teacher}) %>");
diff --git a/config/routes.rb b/config/routes.rb
index d95d04d68..64792bee0 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -638,6 +638,7 @@ RedmineApp::Application.routes.draw do
get 'renew'
get 'member'
get 'export_all_members'
+ get 'feedback'
end
resources :boards
@@ -1438,6 +1439,7 @@ RedmineApp::Application.routes.draw do
match 'projects/:id/feedback', :to => 'projects#feedback', :via => :get, :as => 'project_feedback'
match 'project/:id/share', :to => 'projects#share', :as => 'share_show' #share
post 'words/:id/leave_user_message', :to => 'words#leave_user_message', :as => "leave_user_message"
+ post 'words/:id/leave_contest_message', :to => 'words#leave_contest_message', :as => "leave_contest_message"
post 'words/:id/leave_syllabus_message', :to => 'words#leave_syllabus_message', :as => "leave_syllabus_message"
post 'words/:id/leave_homework_message', :to => 'words#leave_homework_message', :as => "leave_homework_message"
post 'words/:id/reply_to_homework', :to => 'words#reply_to_homework', :as => "reply_to_homework"
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 6c00676cb..a60fa2581 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -1749,7 +1749,7 @@ function delete_confirm_box(url, str){
pop_box_new(htmlvalue, 300, 140);
}
-//点击删除时的确认弹框: 走destroy方法
+//点击删除时的确认弹框: 走destroy方法,remote为true
function delete_confirm_box_2(url, str){
var htmlvalue = '