竞赛增加讨论区模块

This commit is contained in:
cxt 2016-12-30 16:37:20 +08:00
parent 6ba5f124e3
commit 986fe7db86
33 changed files with 934 additions and 14 deletions

View File

@ -67,6 +67,30 @@ class BoardsController < ApplicationController
else
render_403
end
elsif @contest
if (User.current.admin? || @contest.is_public || (!@contest.is_public && User.current.member_of_contest?(@contest)))
@boards = @contest.boards.includes(:last_message => :author).all
if @contest.boards.empty?
@board = @contest.boards.build
@board.name = " #{l(:label_board_contest) }"
@board.description = @contest.name.to_s
@board.project_id = -1
@board.course_id = -1
if @board.save
@boards = @contest.boards.includes(:last_message => :author).all
end
end
if params[:board_id]
@board = Board.find params[:board_id].to_i
else
unless @contest.boards.where("parent_id is NULL").empty?
@board = @contest.boards.where("parent_id is NULL").first
end
end
show and return
else
render_403
end
end
end
@ -116,6 +140,25 @@ class BoardsController < ApplicationController
else
@topics = [];
end
elsif @contest
if (@board)
@topic_count = @board.topics.count();
@topic_pages = 0 #(params[:page] ? params[:page].to_i + 1 : 0) *10
@topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on) #{sort_type}").offset(@topic_pages).includes(:last_reply).preload(:author, {:last_reply => :author}).all();
else
@board = @contest.boards.build
@board.name = " #{l(:label_board_contest) }"#self.name
@board.description = @contest.name.to_s
@board.project_id = -1
@board.course_id = -1
if @board.save
@topic_count = @board.topics.count();
@topic_pages = 0 #(params[:page] ? params[:page].to_i + 1 : 0) *10
@topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on) #{sort_type}").offset(@topic_pages).includes(:last_reply).preload(:author, {:last_reply => :author}).all();
else
@topics = []
end
end
end
#根据 赞+回复数排序
@ -162,6 +205,10 @@ class BoardsController < ApplicationController
@left_nav_type = 2
@params=params
render :action => 'show', :layout => 'base_courses'
elsif @contest
@left_nav_type = 4
@params=params
render :action => 'show', :layout => 'base_contests'
end
}
format.atom {
@ -296,6 +343,8 @@ private
@board = @project.boards.find(params[:id]) if params[:id]
elsif @course
@board = @course.boards.find(params[:id]) if params[:id]
elsif @contest
@board = @contest.boards.find(params[:id]) if params[:id]
end
rescue ActiveRecord::RecordNotFound
render_404

View File

@ -82,6 +82,13 @@ class MessagesController < ApplicationController
format.js
format.html {render :layout => 'base_projects'}
end
elsif @contest
@left_nav_type = 4
respond_to do |format|
format.js
format.html { render :layout => 'base_contests' }
end
#render :action => "show", :layout => "base_courses"#by young
else
# @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page
# @replies = @topic.children.
@ -94,7 +101,7 @@ class MessagesController < ApplicationController
@organization = @org_subfield.organization
respond_to do |format|
format.js
format.html {render :layout => 'base_org'}
format.html { render :layout => 'base_org' }
end
end
end
@ -111,6 +118,8 @@ class MessagesController < ApplicationController
is_public = @project.is_public
elsif @course
is_public = @course.is_public
elsif @contest
is_public = @contest.is_public
end
# 公开项目/课程上传的资源是公开的,私有项目上传的是私有的
@message.save_attachments_containers(params[:attachments], User.current, is_public)
@ -128,6 +137,8 @@ class MessagesController < ApplicationController
redirect_to project_boards_path(@project)
elsif @course
redirect_to course_boards_path(@course, :board_id => @board.id)
elsif @contest
redirect_to contest_boards_path(@contest, :board_id => @board.id)
end
else
redirect_to board_message_url(@board, @message)
@ -138,9 +149,11 @@ class MessagesController < ApplicationController
redirect_to project_boards_path(@project, :flag => true)
elsif @course
redirect_to course_boards_path(@course, :board_id => @board.id, :flag => true)
elsif @contest
redirect_to contest_boards_path(@contest, :board_id => @board.id, :flag => true)
end
else
layout_file = @project ? 'base_projects' : 'base_courses'
layout_file = @project ? 'base_projects' : (@course ? 'base_courses' : 'base_contests')
render :action => 'new', :layout => layout_file
end
@ -149,7 +162,7 @@ class MessagesController < ApplicationController
@left_nav_type = 2
respond_to do |format|
format.html {
layout_file = @project ? 'base_projects' : 'base_courses'
layout_file = @project ? 'base_projects' : (@course ? 'base_courses' : 'base_contests')
render :layout => layout_file
}
end
@ -187,6 +200,7 @@ class MessagesController < ApplicationController
end
update_course_activity(@topic.class,@topic.id)
update_contest_activity(@topic.class,@topic.id)
update_user_activity(@topic.class,@topic.id)
update_forge_activity(@topic.class,@topic.id)
update_org_activity(@topic.class,@topic.id)
@ -226,6 +240,8 @@ class MessagesController < ApplicationController
(render_403; return false) unless @message.editable_by?(User.current)
elsif @course
(render_403; return false) unless @message.course_editable_by?(User.current)
elsif @contest
(render_403; return false) unless @message.contest_editable_by?(User.current)
else
(render_403; return false) unless @message.org_subfield_editable_by?(User.current)
end
@ -243,12 +259,16 @@ class MessagesController < ApplicationController
redirect_to project_path(@project)
elsif @course
redirect_to course_activity_path(@course)
elsif @contest
redirect_to contest_activities_contest_path(@contest)
end
elsif params[:is_course] && params[:is_course].to_i == 1 && params[:is_board] && params[:is_board].to_i == 1
if @project
redirect_to project_boards_path(@project)
elsif @course
redirect_to course_boards_path(@course)
elsif @contest
redirect_to contest_boards_path(@contest)
end
else
redirect_to board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id))
@ -265,6 +285,9 @@ class MessagesController < ApplicationController
elsif @course
@left_nav_type = 2
layout_file = 'base_courses'
elsif @contest
@left_nav_type = 4
layout_file = 'base_contests'
elsif @org_subfield
@organization = @org_subfield.organization
layout_file = 'base_org'
@ -292,6 +315,8 @@ class MessagesController < ApplicationController
(render_403; return false) unless @message.destroyable_by?(User.current)
elsif @course
(render_403; return false) unless @message.course_destroyable_by?(User.current)
elsif @contest
(render_403; return false) unless @message.contest_destroyable_by?(User.current)
else
(render_403; return false) unless @message.org_subfield_editable_by?(User.current)
end
@ -322,6 +347,18 @@ class MessagesController < ApplicationController
else
redirect_to course_boards_path(@course)
end
elsif @contest
if params[:is_course] && params[:is_course].to_i == 0
redirect_to user_contest_community_path(User.current.id)
elsif params[:is_course] && params[:is_course].to_i == 1 && params[:is_board] && params[:is_board].to_i == 0
redirect_to contest_activities_contest_path(@contest)
elsif params[:is_course] && params[:is_course].to_i == 1 && params[:is_board] && params[:is_board].to_i == 1
redirect_to contest_boards_path(@contest)
elsif @message.parent
redirect_to board_message_url(@board, @message.parent, :r => r)
else
redirect_to contest_boards_path(@contest)
end
elsif @org_subfield
if params[:is_board]
redirect_to organization_path(:id => @org_subfield.organization_id, :org_subfield_id => @org_subfield.id)
@ -400,8 +437,10 @@ class MessagesController < ApplicationController
@board = Board.find(params[:board_id])
if @board.project_id != -1 && @board.project_id != nil
@project = @board.project
elsif @board.course_id
elsif @board.course_id && @board.course_id != -1
@course = @board.course
elsif @board.contest_id
@contest = @board.contest
else
@org_subfield = @board.org_subfield
@organization = @org_subfield

View File

@ -20,6 +20,7 @@ class Board < ActiveRecord::Base
belongs_to :project,:touch => true
belongs_to :course,:touch=>true
belongs_to :org_subfield, :touch => true
belongs_to :contest, :touch => true
has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC"
has_many :messages, :dependent => :destroy, :order => "#{Message.table_name}.created_on DESC"
belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id
@ -55,6 +56,8 @@ class Board < ActiveRecord::Base
@valid_parents ||= project.boards - self_and_descendants
elsif course
@valid_parents ||= course.boards - self_and_descendants
elsif contest
@valid_parents ||= contest.boards - self_and_descendants
end
end

View File

@ -14,6 +14,8 @@ class Contest < ActiveRecord::Base
has_many :contestants, :class_name => 'ContestantForContest', :source => :user
has_many :works
has_many :contestant_work_projects, :dependent => :destroy
has_many :boards, :dependent => :destroy, :order => "position ASC"
has_many :news, :dependent => :destroy, :include => :author
@ -25,7 +27,7 @@ class Contest < ActiveRecord::Base
validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]*$/
before_destroy :delete_all_members
#after_create :act_as_contest_activity
after_create :create_board_sync
scope :visible, lambda {|*args| where(Contest.where("is_delete =?", 0).visible_condition(args.shift || User.current, *args)) }
@ -109,4 +111,19 @@ class Contest < ActiveRecord::Base
end
code
end
# 创建竞赛讨论区
def create_board_sync
@board = self.boards.build
#self.name=" #{l(:label_borad_course) }"
@board.name = " #{l(:label_board_contest) }"#self.name
@board.description = self.name.to_s
@board.project_id = -1
@board.course_id = -1
if @board.save
logger.debug "[Contest Model] ===> #{@board.to_json}"
else
logger.error "[Contest Model] ===> Auto create board when contest saved, because #{@board.full_messages}"
end
end
end

View File

@ -86,7 +86,7 @@ class Message < ActiveRecord::Base
# after_create :add_author_as_watcher, :reset_counters!, :add_boards_count
after_update :update_messages_board, :update_activity
after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count, :down_course_score
after_create :act_as_course_activity, :act_as_forge_activity, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count, :act_as_system_message, :delay_message_send
after_create :act_as_course_activity, :act_as_forge_activity, :act_as_contest_activity, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count, :act_as_system_message, :delay_message_send
#before_save :be_user_score
scope :visible, lambda {|*args|
@ -188,6 +188,18 @@ class Message < ActiveRecord::Base
board.course
end
def contest
board.contest
end
def contest_editable_by?(usr)
usr && usr.logged? && (usr.admin_of_contest?(contest) || self.author == usr || usr.admin?)
end
def contest_destroyable_by?(usr)
usr && usr.logged? && (usr.admin_of_contest?(contest) || self.author == usr || usr.admin?)
end
def course_editable_by?(usr)
usr && usr.logged? && (usr.allowed_to?(:edit_messages, course) || (self.author == usr && usr.allowed_to?(:edit_own_messages, course)))
end
@ -223,6 +235,7 @@ class Message < ActiveRecord::Base
#动态的更新
def update_activity
update_course_activity(self.class, self.id)
update_contest_activity(self.class, self.id)
update_user_activity(self.class, self.id)
update_forge_activity(self.class, self.id)
update_org_activity(self.class, self.id)
@ -269,6 +282,13 @@ class Message < ActiveRecord::Base
end
end
#竞赛动态公共表记录
def act_as_contest_activity
if self.contest && self.parent_id.nil?
self.contest_acts << ContestActivity.new(:user_id => self.author_id,:contest_id => self.board.contest_id)
end
end
# 课程讨论区添加消息:
# 老师发帖所有人都能收到消息
# 学生发帖,有人回复则给该学生消息,没回复则不给其它人发送消息
@ -324,6 +344,29 @@ class Message < ActiveRecord::Base
# end
end
end
elsif self.contest
if self.parent_id.nil? # 主贴
self.contest.contest_members.includes(:user).each do |m|
if self.author.admin_of_contest?(self.contest) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息
#self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
# count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course.id}").count
# if count == 0
# content = strip_html self.subject, 200
# ws.topic_publish_template m.user_id, "course_discussion", self.id, "#{l(:label_course_topic_template)}", content, self.author.try(:realname), format_time(self.created_on)
# end
end
end
else # 回帖
parent_author_id = Message.find(self.parent_id).author_id
if parent_author_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息
self.contest_messages << ContestMessage.new(:user_id => parent_author_id, :contest_id => self.board.contest_id, :viewed => false)
# count = ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Course' and shield_id=#{self.board.course_id}").count
# if count == 0
# content = strip_html self.content.html_safe, 200
# ws.comment_template parent_author_id, "course_discussion", self.parent_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content
# end
end
end
end
end
@ -346,6 +389,25 @@ class Message < ActiveRecord::Base
self.delay.contain_messages_message(dm)
end
end
elsif self.contest
if self.parent_id.nil? # 发帖
dm = []
self.contest.contest_members.includes(:user).each do |m|
if self.author.admin_of_contest?(self.contest) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息
dm << {contest_message_type:'Message',contest_message_id:self.id, :user_id => m.user_id,
:contest_id => self.board.contest_id, :viewed => false}
if dm.size >= 30
self.delay.contain_contest_messages_message(dm)
dm.clear
end
end
end
unless dm.empty?
self.delay.contain_contest_messages_message(dm)
end
end
end
end
@ -354,6 +416,10 @@ class Message < ActiveRecord::Base
CourseMessage.create(vs)
end
def contain_contest_messages_message vs
ContestMessage.create(vs)
end
#更新用户分数 -by zjc
def be_user_score
#新建message且无parent的为发帖

View File

@ -0,0 +1,80 @@
<div class = "cl"> </div>
<div id="course-boardlist">
<div class="listbox mt10" >
<p class="list-h2">讨论区列表</p>
<div class="category">
<span class="grayTxt ">排序:</span>
<%= link_to "时间", {:controller => 'boards', :action => 'index', :board_id =>@board.id, :type => @type, :sort => @b_sort, :order => 1 }, :class => "sortTxt", :remote => true %>
<% if @type.to_i == 1 %>
<%= link_to "", {:controller => 'boards', :action => 'index', :board_id =>@board.id, :type => @type, :sort => @b_sort, :order => 1 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
<% end %>
<%= link_to "人气", {:controller => 'boards', :action => 'index', :board_id =>@board.id, :type => @type, :sort => @b_sort, :order => 2 }, :class => "sortTxt", :remote => true %>
<% if @type.to_i == 2 %>
<%= link_to "", {:controller => 'boards', :action => 'index', :board_id =>@board.id, :type => @type, :sort => @b_sort, :order => 2 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
<% end %>
<div class="cl"></div>
</div>
<div class="bloglistbox">
<% if topics.any? %>
<% topics.each do |activity| %>
<div class="list-file">
<div><span class="item_list fl"></span>
<% if activity.parent_id.nil? %> <!--+"(帖子标题)"-->
<%= link_to activity.subject.to_s.html_safe, User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :class => "list-title-normal fl" %>
<% else %>
<%= link_to activity.parent.subject.to_s.html_safe, User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :class => "list-title-normal f1" %>
<% end %>
<% if activity.sticky == 1 %>
<span class="fl ml10 red-cir-btn">顶</span>
<% end%>
<% if activity.locked %>
<span class="fl ml10 green-cir-btn" title="已锁定">锁</span>
<% end %>
<%# u = User.where("id=?",activity.author_id).first%>
<div class="cl"></div>
</div>
<!--<div class="massages-content ml15">-->
<!--<%# if activity.parent_id.nil? %>-->
<!--<% content = activity.content %>-->
<!--<%# else %>-->
<!--<%# content = activity.parent.content %>-->
<!--<%# end %>-->
<!--<p><%#=render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id =>activity.id, :content=>content, :maxheight=>54, :maxwordsnum=>75, :maxwidth=>563} %></p>-->
<!--</div>-->
<div class="ml15 mt10">
<span class="grayTxt mr15">
发帖人:<%= link_to activity.author.show_name, user_path(activity.author), :class => "link-blue" %>
</span>
<span class="grayTxt">更新:<%= format_time(activity.children.any? ? activity.children.last[:created_on] : activity[:created_on] ) %></span>
<% all_comments = []%>
<% count=Message.where("root_id = #{activity.id}").count %>
<p class="list-info fr grayTxt"><span><%= count>0 ? "#{count}" : "0" %></span><span>回复</span><span>|</span><span><%= get_praise_num(activity) > 0 ? "#{get_praise_num(activity)}" : "0" %></span><span>赞</span></p>
</div>
<div class="cl"></div>
</div>
<% end %>
<div>
<ul class="wlist" id="pages" >
<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>
</ul>
<div class="cl"></div>
</div>
<% else %>
<div class="icons_tishi"><img src="/images/sy/icons_smile.png" width="110" height="110" alt="" ></div>
<p class="sy_tab_con_p">没有数据可以显示!</p>
<% end %>
</div>
</div>
</div>
<script type="text/javascript">
//如果右边的博客列表比左边的高度低则将右边的高度设为与左边对齐
$(function(){
var leftHeight = $("#LSide").height()-$(".fontGrey5").height()-20;
var rightHeight = $(".homepageRight").height();
if (rightHeight < leftHeight){
var diffHeight = leftHeight - rightHeight;
var tmpHeight = $(".listbox").height()+diffHeight;
$(".listbox").css("height",tmpHeight);
}
});
</script>

View File

@ -0,0 +1,16 @@
<script type="text/javascript">
$(function(){
$("#RSide").removeAttr("id");
$("#Container").css("width","1000px");
$("#message_subject").focus();
});
</script>
<div class="homepageRight mt0 ml10">
<div class="homepageRightBanner">
<div class="NewsBannerName">
编辑帖子
</div>
</div>
<%= render :partial => 'boards/contest_new',
:locals => {:f => f, :edit_mode => edit_mode, :topic => topic, :contest => contest} %>
</div>

View File

@ -0,0 +1,194 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: true, prettify: false, init_activity: false) %>
<% end %>
<script type="text/javascript">
var first_click = true;
function nh_check_field(params){
var result=true;
if(!regexTopicSubject()) {
result=false;
return result;
}
if(params.content!=undefined){
if(params.content.isEmpty()){
result=false;
}
if(params.content.html()!=params.textarea.html() || params.issubmit==true){
params.textarea.html(params.content.html());
params.content.sync();
if(params.content.isEmpty())
{
params.contentmsg.text("描述不能为空");
params.contentmsg.css('color','#ff0000');
result=false;
}
else
{
params.contentmsg.text("填写正确");
params.contentmsg.css('color','#008000');
}
}
}
return result;
}
function init_homework_form(params){
params.form.submit(function(){
params.textarea.html(params.editor.html());
params.editor.sync();
var flag = false;
if(params.form.attr('data-remote') != undefined ){
flag = true
}
var is_checked = false;
is_checked = nh_check_field({
issubmit:true,
content:params.editor,
contentmsg:params.contentmsg,
textarea:params.textarea
});
if(first_click && is_checked){
if(flag){
first_click = false;
return true;
}else{
first_click = false;
$(this)[0].submit();
return false;
}
}
return false;
});
}
function init_homework_editor(params){
params.textarea.removeAttr('placeholder');
var editor = params.kindutil.create(params.textarea, {
resizeType : 1,minWidth:"1px",width:"100%",minHeight:"30px",height:"30px",
items : ['code','emoticons','fontname',
'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|',
'formatblock', 'fontsize', '|','indent', 'outdent',
'|','imagedirectupload','table', 'media', 'preview',"more"
],
afterChange:function(){//按键事件
var edit = this.edit;
var body = edit.doc.body;
//paramsHeight = params.kindutil.removeUnit(this.height);
edit.iframe.height(150);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + 33, 150));
},
afterCreate:function(){
//init
var edit = this.edit;
var body = edit.doc.body;
edit.iframe[0].scroll = 'no';
body.style.overflowY = 'hidden';
//reset height
var edit = this.edit;
var body = edit.doc.body;
edit.html(params.textarea.innerHTML);
//paramsHeight = params.kindutil.removeUnit(this.height);
edit.iframe.height(150);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150));
elocalStorage(message_content_editor,'topic_contest_<%=contest.id %>');
}
}).loadPlugin('paste');
return editor;
}
KindEditor.ready(function(K){
$("div[nhname='topic_form']").each(function(){
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.form = $("form",params.div_form);
if(params.form==undefined || params.form.length==0){
return;
}
params.textarea = $("textarea[nhname='topic_textarea']",params.div_form);
params.contentmsg = $("#message_content_span");
params.submit_btn = $("#new_message_submit_btn");
if(params.textarea.data('init') == undefined) {
params.editor = init_homework_editor(params);
message_content_editor = params.editor;
init_homework_form(params);
params.submit_btn.click(function () {
params.form.submit();
});
params.textarea.data('init', 1);
}
});
});
</script>
<%= error_messages_for 'message' %>
<div class="resources mt10">
<div id="new_course_topic">
<div class="homepagePostBrief c_grey">
<div>
<input type="text" name="message[subject]" id="message_subject" class="InputBox w713" maxlength="128" onfocus="$('#topic_editor').show()" onkeyup="regexTopicSubject();" placeholder="发布帖子,请先输入帖子标题" value="<%= topic.subject%>" >
<p id="subjectmsg"></p>
</div>
<div id="topic_editor" style="display: none;">
<%if User.current.member_of_contest?(contest) %>
<div class="mt10">
<% if User.current.id == contest.user_id %>
<%= f.check_box :sticky, :value => topic.sticky %>
<%= label_tag 'message_sticky', l(:label_board_sticky) %>
<%= f.check_box :locked, :value => topic.locked %>
<%= label_tag 'message_locked', l(:label_board_locked) %>
<% end %>
<div class="cl"></div>
</div>
<% end %>
<div class="mt10">
<div id="message_quote" class="wiki" style="width: 92%;word-break: break-all;word-wrap: break-word;margin-left: 40px;"></div>
<%= text_area :quote,:quote,:style => 'display:none' %>
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<%#= f.kindeditor :content, :editor_id => 'message_content_editor',
:owner_id => topic.nil? ? 0: topic.id,
:owner_type => OwnerTypeHelper::MESSAGE,
:width => '100%',
:height => 300,
:minHeight=>300,
:class => 'talk_text fl',
:input_html => { :id => 'message_content',
:class => 'talk_text fl',
:maxlength => 5000 },
at_id: topic.id, at_type: topic.class.to_s
%>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='topic_textarea' name="message[content]"><%=topic.content %></textarea>
<div class="cl"></div>
<p id="message_content_span"></p>
<p id="e_tip" class="c_grey"></p>
<p id="e_tips" class="c_grey"></p>
</div>
<div class="cl"></div>
<div class="mt10">
<div class="fl" id="topic_attachments">
<%= render :partial => 'attachments/form_course', :locals => {:container => topic, :isReply => @isReply} %>
</div>
</div>
<div class="cl"></div>
<div class="mt5">
<%if !edit_mode %>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_message_submit_btn">确定</a>
<span class="fr mr10 mt3">或</span>
<a href="javascript:void(0);" class="fr mr10 mt3" onclick="reset_topic();">取消</a>
<% else %>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_message_submit_btn">确定</a>
<span class="fr mr10 mt3">或</span>
<%= link_to "取消",board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "fr mr10 mt3"%>
<% end %>
</div>
<div class="cl"></div>
</div>
</div>
<%#= render :partial => 'course_new_topic', :locals => {:f => f, :topic => @message} %>
<!--<li>
<div class="ml55 fl" nhname="toolbar_container"></div>
<a href="javascript:void(0);" nhname="cancelbtn" class="grey_btn fr ml10"><%#= l(:button_cancel) %></a>
<a href="javascript:void(0);" nhname="submitbtn" class="blue_btn fr " style="margin-left: 55px">
<%#= l(:button_submit)%>
</a>
<div class="cl"></div>
</li>-->
</div>
</div>

View File

@ -0,0 +1,43 @@
<script type="text/javascript">
$(function(){
$("#RSide").removeAttr("id");
$("#Container").css("width","1000px");
});
function reset_topic(){
$("#message_subject").val("");
$("#subjectmsg").text("");
document.getElementById("message_sticky").checked=false;
document.getElementById("message_locked").checked=false;
$("#topic_attachments").html("<%= escape_javascript(render :partial => 'attachments/form_course', :locals => {:container => Message.new, :isReply => @isReply})%>");
message_content_editor.html("");
$("#topic_editor").toggle();
}
<% if @is_new%>
$(function(){
$("#message_subject").focus();
});
<%end%>
</script>
<div class="homepageRight mt0 ml10">
<div class="homepageRightBanner">
<div class="NewsBannerName break_word" style="width: 600px;">
<%= @board.parent_id.nil? ? "竞赛讨论区" : "#{@board.name}" %>
</div>
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.admin_of_contest?(@board.contest)) %>
<%# if is_teacher %>
<%#= link_to "添加子栏目", settings_course_path(@board.course.id,'boards'), :class => "link-blue fr mt5" %>
<%# end %>
</div>
<div nhname="topic_form">
<% if User.current.logged? %>
<%= labelled_form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'},
:html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'contest_new', :locals => {:f => f, :topic => @message, :edit_mode => false, :contest => @board.contest} %>
<% end %>
<% end %>
</div>
<%= render :partial=> 'contest_show_detail',:locals =>{:topics => @topics, :page => 0} %>
</div>

View File

@ -0,0 +1,8 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: false, prettify: false) %>
<%= javascript_include_tag "create_kindeditor" %>
<% end %>
<% if @topics || topics %>
<%= render :partial => 'boards/contest_boardlist', :locals => {:topics => @topics ? @topics: topics , :is_course => 1, :is_board=>1} %>
<% end %>

View File

@ -36,6 +36,8 @@
<%= render :partial => 'project_show', locals: {:topics => @topics, :page => 0, project: @project} %>
<% elsif @course %>
<%= render :partial => 'course_show', :locals => {:topics => @topics, :page => 0, :course => @course} %>
<% elsif @contest %>
<%= render :partial => 'contest_show', :locals => {:topics => @topics, :page => 0, :contest => @contest} %>
<% end %>

View File

@ -43,7 +43,7 @@
<% when 'News' %>
<%= render :partial => 'users/contest_news', :locals => {:activity => act, :user_activity_id => activity.id, :is_contest => 1} %>
<% when 'Message' %>
<%#= render :partial => 'users/contest_message', :locals => {:activity => act, :user_activity_id => activity.id,:is_course=>1,:is_board=>0} %>
<%= render :partial => 'users/contest_message', :locals => {:activity => act, :user_activity_id => activity.id,:is_course=>1,:is_board=>0} %>
<% when 'Poll' %>
<%#= render :partial => 'users/contest_poll', :locals => {:activity => act, :user_activity_id => activity.id, :is_course => 1} %>
<% when 'JournalsForMessage' %>

View File

@ -11,7 +11,7 @@
<li><%= link_to "作品动态", contest_activities_contest_path(@contest, :type => 'work'), :class => "homepagePostTypeAssignment postTypeGrey"%></li>
<li><%= link_to "通知动态", contest_activities_contest_path(@contest, :type => 'news'), :class => "homepagePostTypeNotice postTypeGrey"%></li>
<!--<li><%#= link_to "资源库动态", {:controller => "courses", :action => "show", :type => "attachment"}, :class => "homepagePostTypeResource resourcesGrey"%></li>-->
<!--<li><%#= link_to "论坛动态", {:controller => "courses", :action => "show", :type => "message"}, :class => "homepagePostTypeForum postTypeGrey"%></li>-->
<li><%= link_to "论坛动态", contest_activities_contest_path(@contest, :type => 'message'), :class => "homepagePostTypeForum postTypeGrey"%></li>
<!--<li><%#= link_to "留言动态", {:controller => "courses", :action => "show", :type => "journalsForMessage"}, :class => "homepagePostTypeMessage postTypeGrey"%></li>-->
<!--<li><%#= link_to "问卷动态", {:controller => "courses", :action => "show", :type => "poll"}, :class => "homepagePostTypeQuiz postTypeGrey"%></li>-->
</ul>

View File

@ -21,6 +21,10 @@
<%= link_to "通知", contest_news_index_path(contest), :class => 'user_navmore_li fl',:target => '_blank' %>
<%= link_to "+", new_contest_news_path(contest,:is_new=>1), :class => 'user_navmore_add fl', :title => '发布通知',:target => '_blank' %>
</li>
<li class="clear">
<%= link_to "论坛", contest_boards_path(contest), :class => 'user_navmore_li fl',:target => '_blank' %>
<%= link_to "+", contest_boards_path(contest, :flag => true, :is_new => 1), :class => 'user_navmore_add fl', :title => '发布帖子',:target => '_blank' %>
</li>
<% else %>
<li>
<%= link_to "提交",works_path(:contest => contest.id), :class => 'user_navmore_li', :target => '_blank' %>
@ -30,6 +34,10 @@
<%= link_to "通知", contest_news_index_path(contest), :class => 'user_navmore_li',:target => '_blank' %>
<div class="cl"></div>
</li>
<li class="clear">
<%= link_to "论坛", contest_boards_path(contest), :class => 'user_navmore_li fl',:target => '_blank' %>
<div class="cl"></div>
</li>
<% end %>
<!--<li class="clear">-->
<!--<%#= link_to "论坛",contest_boards_path(contest), :class => 'user_navmore_li fl',:target => '_blank' %>-->

View File

@ -45,6 +45,11 @@
<a href="<%= works_path(:contest => @contest.id,:is_new => 1) %>" class="sy_class_add"></a>
<% end %>
</li>
<li id="sy_04" class="sy_icons_boards">
<% count = @contest.boards.first ? (@contest.boards.first.topics.count + Message.where("board_id =? and parent_id is not ?", @contest.boards.first.id, nil).count) : 0 %>
<a href="<%=contest_boards_path(@contest) %>">讨论区<span><%=count %></span></a>
<%= link_to( "",contest_boards_path(@contest, :flag => true, :is_new => 1), :class => 'sy_class_add', :title =>"#{l(:label_message_new)}") if is_admin %>
</li>
<li id="sy_05" class="sy_icons_news">
<%= link_to "通知<span>#{@contest.news.count}</span>".html_safe, contest_news_index_path(@contest), :class => "sy_icons_feedback" %>
<% if is_admin %>

View File

@ -0,0 +1,131 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: false, prettify: false, init_activity: true) %>
<% end %>
<script type="text/javascript">
$(function(){
$("#RSide").removeAttr("id");
$("#Container").css("width","1000px");
});
</script>
<script>
function expand_reply(container,btnid){
var target = $(container).children();
var btn = $(btnid);
if(btn.data('init')=='0'){
btn.data('init',1);
btn.html('收起回复');
target.show();
}else{
btn.data('init',0);
btn.html('展开更多');
target.hide();
target.eq(0).show();
target.eq(1).show();
target.eq(2).show();
}
}
$(function() {
sd_create_editor_from_data(<%= @topic.id%>,null,"100%", "<%=@topic.class.to_s%>");
showNormalImage('message_description_<%= @topic.id %>');
});
</script>
<div class="postRightContainer ml10" onmouseover="$('#message_setting_<%= @topic.id%>').show();" onmouseout="$('#message_setting_<%= @topic.id%>').hide();">
<div class="postThemeContainer">
<div class="postDetailPortrait">
<%= link_to image_tag(url_to_avatar(@topic.author), :width => 50, :height => 50,:alt=>'图像' ), user_path(@topic.author) %>
</div>
<div class="postThemeWrap">
<% if User.current.logged? %>
<div class="homepagePostSetting" id="message_setting_<%= @topic.id%>" style="display: none">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li>
<%= link_to(
l(:button_edit),
{:action => 'edit', :id => @topic},
:class => 'postOptionLink'
) if @message.contest_editable_by?(User.current) %>
</li>
<li>
<%= link_to(
l(:button_delete),
{:action => 'destroy', :id => @topic},
:method => :post,
:data => {:confirm => l(:text_are_you_sure)},
:class => 'postOptionLink'
) if @message.contest_destroyable_by?(User.current) %>
</li>
<li><%= link_to "发送", "javascript:void(0);", :onclick => "show_send(#{@message.id}, #{User.current.id}, 'message');", :class => "postOptionLink" %></li>
</ul>
</li>
</ul>
</div>
<%end%>
<div class="postDetailTitle fl break_full_word">
<a href="javascript:void(0);" class="f14 linkGrey4 fb" style="overflow:hidden;">主题: <%= @topic.subject%></a>
</div>
<div class="cl"></div>
<div class="postDetailCreater">
<%= link_to @topic.author.show_name, user_path(@topic.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
</div>
<div class="postDetailDate mb5"><%= format_time( @topic.created_on)%></div>
<div class="cl"></div>
<div class="homepagePostIntro memo-content upload_img break_full_word ke-block" id="message_description_<%= @topic.id %>" >
<%= @topic.content.html_safe%>
</div>
<div class="cl"></div>
<div class="mt10" style="font-weight:normal;">
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @topic} %>
</div>
</div>
<div class="cl"></div>
</div>
<div class="cl"></div>
<div class="homepagePostReply">
<div class="homepagePostReplyBanner">
<div class="homepagePostReplyBannerCount">回复
<sapn class="mr15"><%= @reply_count>0 ? "#{@reply_count}" : "" %></sapn><span style="color: #cecece;">▪</span>
<span id="praise_count_<%=@topic.id %>">
<%=render :partial=> "praise_tread/praise", :locals => {:activity=>@topic, :user_activity_id=>@topic.id,:type=>"activity"}%>
</span>
</div>
</div>
<%# all_comments = []%>
<%# comments = get_all_children(all_comments, @topic) %>
<div class="" id="reply_div_<%= @topic.id %>">
<%= render :partial => "messages/contest_show_replies" %>
</div>
<div class="cl"></div>
<% if !@topic.locked? && User.current.logged? %>
<div class="talkWrapMsg" nhname="about_talk_reply">
<em class="talkWrapArrow"></em>
<div class="cl"></div>
<div class="talkConIpt ml5 mb10" id="reply<%= @topic.id %>">
<%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message_form'} do |f| %>
<%= render :partial => 'form_course', :locals => {:f => f, :replying => true} %>
<%= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'course_board_canel_message_replay();', :class => "grey_btn fr c_white mt10 mr5 ml10" %>
<%= link_to l(:button_submit), "javascript:void(0)", :onclick => 'course_board_submit_message_replay();', :class => "blue_btn fr c_white mt10", :style => "margin-left: 50px;" %>
<% end %>
<div class="cl"></div>
</div>
</div>
<% end %>
</div>
</div>
<script type="text/javascript">
$(function(){
$("#message_description_<%= @topic.id %> p,#message_description_<%= @topic.id %> span,#message_description_<%= @topic.id %> em").each(function(){
var postContent = $(this).html();
postContent = postContent.replace(/&nbsp;/g," ");
postContent= postContent.replace(/ {2}/g,"&nbsp; ");
postContent=postContent.replace(/&nbsp; &nbsp;/g,"&nbsp;&nbsp;&nbsp;");
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
$(this).html(postContent);
});
autoUrl('message_description_<%= @topic.id %>');
});
</script>

View File

@ -0,0 +1,60 @@
<% @replies.each do |reply| %>
<script type="text/javascript">
$(function(){
showNormalImage('reply_message_description_<%= reply.id %>');
autoUrl('reply_message_description_<%= reply.id %>');
});
</script>
<div class="homepagePostReplyContainer" onmouseover="$('#reply_edit_menu_<%= reply.id%>').show();" onmouseout="$('#reply_edit_menu_<%= reply.id%>').hide();">
<div class="homepagePostReplyPortrait">
<%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %>
</div>
<div class="homepagePostReplyDes" onmouseover="$('#delete_reply_<%=reply.id %>').show();" onmouseout="$('#delete_reply_<%=reply.id %>').hide();">
<%= render :partial => 'users/message_contents', :locals => {:comment => reply, :type => 'Message', :user_activity_id => @topic.id}%>
<div class="homepagePostReplyContent upload_img break_word table_maxWidth" id="reply_message_description_<%= reply.id %>">
<%= reply.content.html_safe%>
</div>
<div class="orig_reply mb10 mt-10">
<div class="reply">
<span class="reply-right">
<span class="reply_praise_count_<%= reply.id %>">
<%= render :partial => "praise_tread/praise", :locals => {:activity => reply, :user_activity_id => reply.id, :type => "reply"} %>
</span>
<span style="position: relative" class="fr mr20">
<%= link_to(
l(:button_reply),
{:action => 'quote', :id => reply},
:remote => true,
:method => 'get',
:title => l(:button_reply)) if !@topic.locked? && authorize_for('messages', 'reply') %>
<span id="reply_iconup_<%= reply.id %>" class="reply_iconup02" style="display: none"> ︿</span>
</span>
<%= link_to(
l(:button_delete),
{:action => 'destroy', :id => reply},
:method => :post,
:id => "delete_reply_#{reply.id}",
:class => 'fr mr20 undis',
:data => {:confirm => l(:text_are_you_sure)},
:title => l(:button_delete)
) if reply.contest_destroyable_by?(User.current) %>
</span>
<div class="cl"></div>
</div>
</div>
<p id="reply_message_<%= reply.id%>"></p>
</div>
<div class="cl"></div>
</div>
<% end %>
<% if @limit_count > @page * @limit + 10 %>
<div id="more_message_replies">
<div class="detail_cont_hide clearfix">
<span class="orig_icon" >&darr; </span>
<span class="orig_icon" style="display:none;" > &uarr;</span>
<%= link_to '点击展开更多回复', board_message_path(@topic.board_id, @topic, :page => @page),:remote=>true %>
</div>
</div>
<% end %>

View File

@ -7,6 +7,8 @@ $("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(re
<%elsif @course%>
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/course_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>");
<%elsif @contest%>
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/contest_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>");
<% elsif @org_subfield %>
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'organizations/org_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>");
<%end%>

View File

@ -24,6 +24,19 @@
:locals => {:f => f, :edit_mode => true, :topic => @message, :course => @message.course} %>
<% end %>
</div>
<% elsif @message.contest %>
<div nhname="topic_form">
<%= form_for @message, {
:as => :message,
:url => {:action => 'edit',:is_course=>@is_course,:is_board=>@is_board},
:html => {:multipart => true,
:id => 'message-form',
:method => :post}
} do |f| %>
<%= render :partial => 'boards/contest_message_edit',
:locals => {:f => f, :edit_mode => true, :topic => @message, :contest => @message.contest} %>
<% end %>
</div>
<% elsif @message.board.org_subfield %>
<%= form_for @message, {
:as => :message,

View File

@ -7,6 +7,8 @@ $("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(re
<%elsif @course%>
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/course_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>");
<%elsif @contest%>
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/contest_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>");
<% elsif @org_subfield %>
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'organizations/org_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>");
<%end%>

View File

@ -2,6 +2,8 @@
<%= render :partial => 'project_show', locals: {project: @project} %>
<% elsif @course %>
<%= render :partial => 'course_show', locals: {course: @course} %>
<% elsif @contest %>
<%= render :partial => 'contest_show', locals: {contest: @contest} %>
<% else %>
<%= render :partial => 'org_subfield_show', :locals => {:org_subfield => @org_subfield} %>
<% end %>

View File

@ -0,0 +1,92 @@
<div class="resources mt10" id="user_activity_<%= user_activity_id%>" onmouseover="$('#message_setting_<%= user_activity_id%>').show();" onmouseout="$('#message_setting_<%= user_activity_id%>').hide();">
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author, :host => Setting.host_user), :alt => "用户头像" %>
<%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
</div>
<div class="homepagePostDes">
<div class="homepagePostTo break_word">
<%= link_to activity.author.show_name, user_path(activity.author, :host=>Setting.host_user), :class => "newsBlue mr15" %>
TO
<% str = is_course == 1 ? "#{activity.board.parent.nil? ? '竞赛讨论区' : activity.board.name}" : activity.contest.name.to_s+" | #{activity.board.parent.nil? ? '竞赛讨论区' : activity.board.name}" %>
<%= link_to str, contest_boards_path(activity.contest), :class => "newsBlue ml15"%>
</div>
<div class="homepagePostTitle hidden m_w530 fl">
<% if activity.parent_id.nil? %> <!--+"(帖子标题)"-->
<%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey" %>
<% else %>
<%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey" %>
<% end %>
</div>
<% if activity.sticky == 1 %>
<span class="sticky_btn_cir ml10">置顶</span>
<% end%>
<% if activity.locked %>
<span class="locked_btn_cir ml10 fl" title="已锁定">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
<% end %>
<div class="cl"></div>
<div class="homepagePostDate fl">
发帖时间:<%= format_time(activity.created_on) %>
</div>
<div class="homepagePostDate fl ml15">
更新时间:<%= format_time(ContestActivity.where("contest_act_type='#{activity.class}' and contest_act_id =#{activity.id}").first.updated_at) %>
</div>
<div class="cl"></div>
<% if activity.parent_id.nil? %>
<% content = activity.content %>
<% else %>
<% content = activity.parent.content %>
<% end %>
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
<div class="cl"></div>
<div id="intro_content_show_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[展开]</a></div>
<div id="intro_content_hide_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[收起]</a></div>
<div class="cl"></div>
<div class="mt10" style="font-weight:normal;">
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
</div>
<% if User.current.logged? %>
<div class="homepagePostSetting" id="message_setting_<%= user_activity_id%>" style="display: none">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<% if activity.author.id == User.current.id%>
<li>
<%= link_to(
l(:button_edit),
edit_board_message_path(activity.id,:board_id=>activity.board_id,:is_course=>is_course,:is_board=>is_board),
:class => 'postOptionLink'
) if activity.contest_editable_by?(User.current) %>
</li>
<li>
<%= link_to(
l(:button_delete),
delete_board_message_path(activity.id,:board_id=>activity.board_id,:is_course=>is_course,:is_board=>is_board),
:method => :post,
:data => {:confirm => l(:text_are_you_sure)},
:class => 'postOptionLink'
) if activity.contest_destroyable_by?(User.current) %>
</li>
<% end %>
<li><%= link_to "发送", "javascript:void(0);", :onclick => "show_send(#{activity.id}, #{User.current.id}, 'message');", :class => "postOptionLink" %></li>
</ul>
</li>
</ul>
</div>
<% end %>
</div>
<div class="cl"></div>
</div>
<div class="homepagePostReply">
<div id="activity_post_reply_<%=user_activity_id %>">
<%=render :partial => 'users/contest_message_post_reply', :locals => {:activity => activity, :user_activity_id => user_activity_id} %>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -0,0 +1,35 @@
<% all_replies = Message.where("root_id = #{activity.id}").reorder("created_on desc") %>
<% count = all_replies.count %>
<% no_children_comments = get_no_children_comments all_replies %>
<%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :expand_more =>no_children_comments[:three_more]} %>
<% if count > 0 %>
<div class="" id="reply_div_<%= user_activity_id %>">
<%= render :partial => 'users/message_replies', :locals => {:comments => no_children_comments[:no_children_comments], :user_activity_id => user_activity_id, :type => 'Message', :activity_id =>activity.id}%>
</div>
<% end %>
<% if !activity.locked? %>
<div class="homepagePostReplyContainer borderBottomNone minHeight48">
<div class="homepagePostReplyPortrait mr15 imageFuzzy" id="reply_image_<%= user_activity_id%>"><%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %></div>
<div class="homepagePostReplyInputContainer mb10">
<% if User.current.logged? %>
<div nhname='new_message_<%= user_activity_id%>' style="display:none;">
<%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id},:method => "post", :remote => true) do |f|%>
<input type="hidden" name="quote[quote]" value="">
<input type="hidden" name="user_activity_id" value="<%=user_activity_id%>">
<div nhname='toolbar_container_<%= user_activity_id%>'></div>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= user_activity_id%>' name="reply[content]"></textarea>
<a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" onclick="this.style.display='none'" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a>
<div class="cl"></div>
<p nhname='contentmsg_<%= user_activity_id%>'></p>
<% end%>
<div class="cl"></div>
</div>
<% else %>
<%= render :partial => "users/show_unlogged" %>
<% end %>
<div class="cl"></div>
</div>
<div class="cl"></div>
</div>
<% end %>

View File

@ -60,7 +60,8 @@
<div class="cl"></div>
</div>
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<div class="icons_tishi"><img src="/images/sy/icons_smile.png" width="110" height="110" alt="" ></div>
<p class="sy_tab_con_p">没有数据可以显示!</p>
<% end %>
</div>
</div>

View File

@ -36,7 +36,7 @@
<span id="reply_iconup_<%=comment.id %>" class="reply_iconup02" style="display: none"> ︿</span>
</span>
<% end %>
<% if comment.course_destroyable_by?(User.current) || comment.destroyable_by?(User.current) %>
<% if comment.course_destroyable_by?(User.current) || comment.destroyable_by?(User.current) || comment.contest_destroyable_by?(User.current) %>
<%= link_to(
l(:button_delete),
delete_board_message_path(comment,:board_id =>comment.board.id, :user_activity_id => user_activity_id, :activity_id => activity_id),

View File

@ -88,7 +88,7 @@
<% when 'News' %>
<%= render :partial => 'contest_news', :locals => {:activity => act, :user_activity_id => user_activity.id} %>
<% when 'Message' %>
<%#= render :partial => 'contest_message', :locals => {:activity => act, :user_activity_id => user_activity.id, :is_contest => 0, :is_board => 0} %>
<%= render :partial => 'contest_message', :locals => {:activity => act, :user_activity_id => user_activity.id, :is_course => 0, :is_board => 0} %>
<% when 'Contest' %>
<%= render :partial => 'users/contest_create', :locals => {:activity => act, :user_activity_id => act.id} %>
<% when 'JournalsForMessage' %>

View File

@ -188,5 +188,35 @@
</div>
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<!--发布/回复了竞赛帖子-->
<% elsif ma.contest_message_type == "Message" && !ma.nil? && !ma.contest_message.nil? %>
<ul class="homepageNewsList fl">
<div class="longMessageWidth">
<li class="homepageNewsPortrait fl">
<%=link_to image_tag(url_to_avatar(ma.contest_message.author), :width => "30", :height => "30"), user_path(ma.contest_message.author), :target => '_blank' %>
</li>
<li class="homepageNewsPubType fl">
<%=link_to ma.contest_message.author.try(:show_name), user_path(ma.contest_message.author), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
<span class="homepageNewsType fl">
<%= ma.contest_message.parent_id.nil? ? "发布了竞赛帖子:" : "回复了竞赛帖子:" %></span></li>
<% if ma.contest_message.parent_id.nil? %>
<li class="messageInformationContents">
<%= link_to ma.contest_message.subject, board_message_path(ma.contest_message.board_id, ma.contest_message.id),
:class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
:target => '_blank',
:title => "#{ma.contest_message.subject}"
%>
</li>
<% else %>
<li class="messageInformationContents">
<%= link_to message_content(ma.contest_message.content), board_message_path(ma.contest_message.board_id, ma.contest_message.parent_id),
:class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
</li>
<% end %>
</div>
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% end %>

View File

@ -12,7 +12,7 @@
<li><%= link_to @user == User.current ? "我的动态" : "他的动态", {:controller => "users", :action => "contest_community", :type => "current_user"}, :class => "homepagePostTypeMine postTypeGrey" %></li>
<li><%= link_to "作品动态", {:controller => "users", :action => "contest_community", :type => "contest_work"}, :class => "homepagePostTypeAssignment postTypeGrey" %></li>
<li><%= link_to "通知动态", {:controller => "users", :action => "contest_community", :type => "contest_news"}, :class => "homepagePostTypeNotice postTypeGrey" %></li>
<!--<li><%#= link_to "论坛动态", {:controller => "users", :action => "contest_community", :type => "contest_message"}, :class => "homepagePostTypeForum postTypeGrey" %></li>-->
<li><%= link_to "论坛动态", {:controller => "users", :action => "contest_community", :type => "contest_message"}, :class => "homepagePostTypeForum postTypeGrey" %></li>
<!--<li><%#= link_to "竞赛留言", {:controller => "users", :action => "contest_community", :type => "contest_journals"}, :class => "homepagePostTypeMessage postTypeGrey" %></li>-->
<% end %>
</ul>

View File

@ -0,0 +1,6 @@
$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'users/user_activities',
:locals => {:user_activities => @user_activities,
:page => @page,
:type => @type,
:user_id => (@user.type == "AnonymousUser" ? User.current.id : @user.id),
:action => "contest_community"} )%>");

View File

@ -1606,6 +1606,7 @@ zh:
label_CM: 管理员
label_judge: 评委
label_contestant: 参赛者
label_board_contest: 竞赛讨论区
#end

View File

@ -7,6 +7,5 @@ class CreateContestantWorkEvaluationDistributions < ActiveRecord::Migration
t.timestamps
end
add_index :contestant_work_evaluation_distributions, :user_id
add_index :contestant_work_evaluation_distributions, :contestant_work_id
end
end

View File

@ -0,0 +1,6 @@
#encoding=utf-8
class AddContestIdToBoards < ActiveRecord::Migration
def change
add_column :boards, :contest_id, :integer
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20161228091749) do
ActiveRecord::Schema.define(:version => 20161230061940) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -303,6 +303,7 @@ ActiveRecord::Schema.define(:version => 20161228091749) do
t.integer "parent_id"
t.integer "course_id"
t.integer "org_subfield_id"
t.integer "contest_id"
end
add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id"
@ -516,6 +517,15 @@ ActiveRecord::Schema.define(:version => 20161228091749) do
add_index "contestant_for_contests", ["contest_id"], :name => "index_contestant_for_contests_on_contest_id"
add_index "contestant_for_contests", ["student_id"], :name => "index_contestant_for_contests_on_student_id"
create_table "contestant_work_evaluation_distributions", :force => true do |t|
t.integer "user_id"
t.integer "contestant_work_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "contestant_work_evaluation_distributions", ["user_id"], :name => "index_contestant_work_evaluation_distributions_on_user_id"
create_table "contestant_work_projects", :force => true do |t|
t.integer "contest_id"
t.integer "work_id"