Merge branch 'cxt_course' of https://git.trustie.net/jacknudt/trustieforge into develop

This commit is contained in:
cxt 2016-12-23 21:44:20 +08:00
commit 44b3f6019c
25 changed files with 638 additions and 55 deletions

View File

@ -430,6 +430,8 @@ class ApplicationController < ActionController::Base
@course = Course.find(params[:course_id])
elsif params[:org_subfield_id]
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
elsif params[:contest_id]
@contest = Contest.find(params[:contest_id])
end
rescue ActiveRecord::RecordNotFound
render_404

View File

@ -28,6 +28,7 @@ class CommentsController < ApplicationController
if !@news.org_subfield_id.nil?
@org_subfield = OrgSubfield.find(@news.org_subfield_id)
end
@contest = Contest.find(@news.contest_id) if @news.contest_id
@comment = Comment.new
#@project ? @comment.comments = params[:comment][:comments] : @comment.comments = params[:comment]
if params[:user_activity_id]

View File

@ -37,6 +37,8 @@ class ContestsController < ApplicationController
@contest_activities = contest_activities.where("contest_act_type = 'Attachment'").order('updated_at desc')
when "journalsForMessage"
@contest_activities = contest_activities.where("contest_act_type = 'JournalsForMessage'").order('updated_at desc')
when "news"
@contest_activities = contest_activities.where("contest_act_type = 'News'").order('updated_at desc')
else
@contest_activities = contest_activities.order('updated_at desc')
end

View File

@ -42,6 +42,8 @@ class NewsController < ApplicationController
@limit = 10
end
@contest = Contest.find(params[:contest_id]) if params[:contest_id]
# modify by nwb
if params[:course_id] && @course==nil
@course = Course.find(params[:course_id])
@ -69,6 +71,83 @@ class NewsController < ApplicationController
format.api
format.atom { render_feed(@newss, :title => (@project ? @project.name : Setting.app_title) + ": #{l(:label_news_plural)}") }
end
elsif @contest
if (User.current.admin? || @contest.is_public == 1 || (@contest.is_public == 0 && User.current.member_of_contest?(@contest)))
@order, @b_sort,@type = params[:order] || 1, params[:sort] || 1, params[:type] || 1
#确定 sort_type 1升序 2 降序
if @order.to_i == @type.to_i
@b_sort = @b_sort.to_i == 1 ? 2 : 1
else
@b_sort = 2
end
sort_name = "updated_at"
sort_type = @b_sort == 1 ? "asc" : "desc"
#scope = News.find_by_sql("select a.*,b.updated_at from news a, course_activities b where a.course_id = 532 and a.course_id = b.course_id and b.course_act_id = a.id ) ")
scope = @contest.news if @contest
# @newss = scope.all(:include => [:author, :contest], :order => "#{News.table_name}.created_on DESC")
#
# @page = params[:page] ? params[:page].to_i + 1 : 0
news_page = 0 #@page *10
# @news_count = @newss.count
# @is_new = params[:is_new]
@q = params[:subject]
if params[:subject].nil? || params[:subject].blank?
scope_order = scope.reorder("#{News.table_name}.sticky DESC, #{News.table_name}.created_on #{sort_type}").offset(news_page).includes(:author,:course).all()
else
scope_order = scope.where("#{News.table_name}.title like '#{'%' << params[:subject].to_s << '%'}'").reorder("#{News.table_name}.sticky DESC, #{News.table_name}.#{sort_name} #{sort_type}").offset(news_page).includes(:author,:contest).all()
end
scope_order.each do |topic|
topic[:updated_at] = topic.contest_acts.first.updated_at
#topic[:updated_at] = CourseActivity.where("course_act_type='#{topic.class}' and course_act_id =#{topic.id}").first.updated_at
end
#根据 赞+回复数排序
if @order.to_i == 2
@type = 2
scope_order.each do |topic|
topic[:infocount] = get_praise_num(topic) + topic.comments.count
if topic[:infocount] < 0
topic[:infocount] = 0
end
end
@b_sort == 1 ? scope_order = scope_order.sort{|x,y| x[:infocount] <=> y[:infocount] } : scope_order = scope_order.sort{|x,y| y[:infocount] <=> x[:infocount] }
scope_order = sort_by_sticky scope_order
scope_order = sortby_time_countcommon_hassticky scope_order,sort_name
else
@type = 1
@b_sort == 1 ? scope_order = scope_order.sort{|x,y| x[:updated_at] <=> y[:updated_at] } : scope_order = scope_order.sort{|x,y| y[:updated_at] <=> x[:updated_at] }
scope_order = sort_by_sticky scope_order
end
@newss = scope_order
#分页
@limit = 15
@is_remote = true
@atta_count = @newss.count
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
@offset ||= @atta_pages.offset
@newss = paginateHelper @newss,@limit
#@newss = paginateHelper scope_order,10
@left_nav_type = 4
respond_to do |format|
format.html {
@news = News.new
render :layout => 'base_contests'
}
format.js
format.api
end
else
render_403
end
elsif @course
if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course)))
@order, @b_sort,@type = params[:order] || 1, params[:sort] || 1, params[:type] || 1
@ -190,6 +269,15 @@ class NewsController < ApplicationController
format.html {render :layout => 'base_courses'}
end
end
elsif @news.contest_id
@contest = Contest.find(@news.contest_id)
if @contest
@left_nav_type = 4
respond_to do |format|
format.js
format.html {render :layout => 'base_contests'}
end
end
elsif @project
respond_to do |format|
format.js
@ -255,6 +343,22 @@ class NewsController < ApplicationController
#layout_file = 'base_courses'
#render :action => 'new', :layout => layout_file
end
elsif @contest
@news = News.new(:contest => @contest, :author => User.current)
#render :layout => 'base_courses'
@news.safe_attributes = params[:news]
@news.save_attachments(params[:attachments])
if @news.save
if params[:asset_id]
ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids,@news.id,OwnerTypeHelper::NEWS
end
render_attachment_warning_if_needed(@news)
else
end
respond_to do |format|
format.html{redirect_to contest_news_index_path(@contest)}
end
end
end
@ -310,10 +414,15 @@ class NewsController < ApplicationController
if @news.org_subfield_id
@org_subfield = OrgSubfield.find(@news.org_subfield_id)
@organization = @org_subfield.organization
elsif @news.contest_id
@contest = Contest.find(@news.contest_id)
end
if @course
@left_nav_type = 4
render :layout => "base_courses"
elsif @contest
@left_nav_type = 4
render :layout => "base_contests"
elsif @org_subfield
render :layout => 'base_org'
end
@ -335,6 +444,8 @@ class NewsController < ApplicationController
def destroy
if @news.org_subfield_id
@org_subfield = OrgSubfield.find(@news.org_subfield_id)
elsif @news.contest_id
@contest = Contest.find(@news.contest_id)
end
@news.destroy
# modify by nwb
@ -342,6 +453,8 @@ class NewsController < ApplicationController
redirect_to project_news_index_url(@project)
elsif @course
redirect_to course_news_index_url(@course)
elsif @contest
redirect_to contest_news_index_url(@contest)
elsif @org_subfield
redirect_to organization_path(@org_subfield.organization, :org_subfield_id => @org_subfield.id)
end

View File

@ -14,6 +14,8 @@ class Contest < ActiveRecord::Base
has_many :contestants, :class_name => 'ContestantForContest', :source => :user
has_many :works
has_many :news, :dependent => :destroy, :include => :author
has_many :contest_acts, :class_name => 'ContestActivity',:as =>:contest_act ,:dependent => :destroy
has_many :contest_activities
has_many :contest_messages, :class_name =>'ContestMessage', :as => :contest_message, :dependent => :destroy

View File

@ -25,6 +25,7 @@ class News < ActiveRecord::Base
has_many_kindeditor_assets :assets, :dependent => :destroy
#added by nwb
belongs_to :course,:touch => true
belongs_to :contest,:touch => true
belongs_to :org_subfield, :touch => true
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
has_many :comments, :as => :commented, :dependent => :destroy, :order => "created_on"
@ -79,6 +80,10 @@ class News < ActiveRecord::Base
scope :course_visible, lambda {|*args|
includes(:course).where(Course.allowed_to_condition(args.shift || User.current, :view_course_news, *args))
}
scope :contest_visible, lambda {|*args|
includes(:contest).where(Contest.allowed_to_condition(args.shift || User.current, :view_contest_news, *args))
}
safe_attributes 'title', 'summary', 'description', 'sticky'
#动态的更新
@ -160,6 +165,8 @@ class News < ActiveRecord::Base
def act_as_course_activity
if self.course
self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.course_id)
elsif self.contest
self.contest_acts << ContestActivity.new(:user_id => self.author_id,:contest_id => self.contest_id)
end
end
@ -229,6 +236,23 @@ class News < ActiveRecord::Base
self.delay.contain_news_message(vs)
end
elsif self.contest_id
vs = []
self.contest.contest_members.each do | m|
if m.user_id != self.author_id
vs << {course_message_type:'Contest',course_message_id:self.id, :user_id => m.user_id,
:contest_id => self.contest_id, :viewed => false}
if vs.size >= 30
self.delay.contain_contst_news_message(vs)
vs.clear
end
end
end
unless vs.empty?
self.delay.contain_contst_news_message(vs)
end
end
end
@ -236,6 +260,10 @@ class News < ActiveRecord::Base
CourseMessage.create(vs)
end
def contain_contst_news_message(vs)
ContestMessage.create(vs)
end
# Time 2015-03-31 13:50:54
# Author lizanle
# Description 删除news后删除对应的资源

View File

@ -2,6 +2,8 @@
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/course_news_post_reply', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>");
<% elsif @project %>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'projects/project_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>");
<% elsif @contest %>
$("#activity_post_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'users/course_news_post_reply', :locals => {:activity => @news,:user_activity_id => @user_activity_id}) %>");
<% else %>
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'organizations/course_news_post_reply', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>");
<% end %>

View File

@ -3,6 +3,8 @@
$("#user_activity_<%= @user_activity_id %>").replaceWith("<%= escape_javascript(render :partial => 'projects/project_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>");
<% elsif @news.course_id %>
$("#activity_post_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'users/course_news_post_reply', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>");
<% elsif @news.contest_id %>
$("#activity_post_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'users/course_news_post_reply', :locals => {:activity => @news,:user_activity_id => @user_activity_id}) %>");
<% elsif @news.org_subfield_id %>
$("#user_activity_<%= @user_activity_id %>").replaceWith("<%= escape_javascript(render :partial => 'organizations/org_subfield_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>");
<% end %>

View File

@ -3,6 +3,8 @@
$("#user_activity_<%= @user_activity_id %>").replaceWith("<%= escape_javascript(render :partial => 'projects/project_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>");
<% elsif @news.course_id %>
$("#activity_post_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'users/course_news_post_reply', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>");
<% elsif @news.contest_id %>
$("#activity_post_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'users/course_news_post_reply', :locals => {:activity => @news,:user_activity_id => @user_activity_id}) %>");
<% elsif @news.org_subfield_id %>
$("#user_activity_<%= @user_activity_id %>").replaceWith("<%= escape_javascript(render :partial => 'organizations/org_subfield_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>");
<% end %>

View File

@ -41,7 +41,7 @@
<% when 'Work' %>
<%= render :partial => 'users/contest_work', :locals => {:activity => act, :user_activity_id => activity.id, :hw_status => 2} %>
<% when 'News' %>
<%#= render :partial => 'users/contest_news', :locals => {:activity => act, :user_activity_id => activity.id, :is_course => 1} %>
<%= render :partial => 'users/contest_news', :locals => {:activity => act, :user_activity_id => activity.id, :is_course => 1} %>
<% when 'Message' %>
<%#= render :partial => 'users/contest_message', :locals => {:activity => act, :user_activity_id => activity.id,:is_course=>1,:is_board=>0} %>
<% when 'Poll' %>

View File

@ -9,7 +9,7 @@
<ul class="homepagePostTypeHomework fl">
<li><%= link_to "全部动态", contest_activities_contest_path(@contest), :class =>"homepagePostTypeAll postTypeGrey"%></li>
<li><%= link_to "作品动态", contest_activities_contest_path(@contest, :type => 'work'), :class => "homepagePostTypeAssignment postTypeGrey"%></li>
<!--<li><%#= link_to "通知动态", {:controller => "courses", :action => "show", :type => "news"}, :class => "homepagePostTypeNotice 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 "留言动态", {:controller => "courses", :action => "show", :type => "journalsForMessage"}, :class => "homepagePostTypeMessage postTypeGrey"%></li>-->

View File

@ -45,7 +45,10 @@
<a href="<%= works_path(:contest => @contest.id,:is_new => 1) %>" class="sy_class_add"></a>
<% end %>
</li>
<!--<li id="sy_05" class="sy_icons_news"> <a href="">通知<span>26</span></a><a href="javascript:void(0);" class="sy_class_add"></a></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" %>
<%= link_to "", contest_news_index_path(@contest), :class => "sy_class_add" %>
</li>
<!--<li id="sy_06" class="sy_icons_feedback"> <a href="">留言<span>26</span></a> <a href="javascript:void(0);" class="sy_class_add"></a></li>-->
</ul>
</div><!--sy_class_leftnav end-->

View File

@ -0,0 +1,34 @@
<script type="text/javascript">
$(function(){
$("#RSide").removeAttr("id");
$("#Container").css("width","1000px");
});
function reset_news(){
$("#news_title").val("");
$("#title_notice_span").text("");
$("#description_notice_span").text("");
document.getElementById("news_sticky").checked=false;
$("#news_attachments").html("<%= escape_javascript(render :partial => 'attachments/new_form', :locals => {:container => News.new})%>");
news_description_editor.html("");
$("#news_editor").toggle();
}
<% if @is_new%>
$(function(){
$("#news_title").focus();
});
<%end%>
</script>
<div class="homepageRight mt0 ml10">
<div class="homepageRightBanner">
<div class="NewsBannerName">
竞赛通知
</div>
</div>
<% if contest && User.current.allowed_to?(:manage_news, @contest) %>
<%= labelled_form_for @news, :url => new_contest_news_path(:contest_id => @contest),
:html => {:id => 'news-form', :nhname => 'form', :multipart => true, :method => "get"} do |f| %>
<%= render :partial => 'contest_news_new', :locals => {:f => f, :news => @news, :edit_mode => false, :contest => @contest} %>
<% end %>
<% end %>
<%= render :partial=> 'contest_news_detail', :locals =>{:newss => @newss, :page => 0} %>
</div>

View File

@ -0,0 +1,9 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: false, prettify: false) %>
<%= javascript_include_tag "create_kindeditor" %>
<% end %>
<% if newss%>
<%= render :partial => 'users/course_newslist', :locals => {:topics => newss} %>
<% end%>

View File

@ -0,0 +1,114 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: true, prettify: false) %>
<% end %>
<div class="resources mt10">
<div id="new_course_news">
<div class="homepagePostBrief c_grey">
<div>
<input type="text" name="news[title]" id="news_title" class="InputBox w713" maxlength="60" onfocus="$('#news_editor').show()" onkeyup="regexTitle();" placeholder="发布通知,请先输入通知标题" value="<%= news.title%>" >
<p id="title_notice_span"></p>
</div>
<div id="news_editor" style="display: none;">
<div class="mt10">
<%= f.check_box :sticky, :value => edit_mode ? news.sticky : 0 %>
<%= label_tag 'news_sticky', l(:label_board_sticky) %>
<div class="cl"></div>
</div>
<div class="mt10">
<div id="news_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 :description, :editor_id => 'news_description_editor',
:owner_id => news.nil? ? 0: news.id,
:owner_type => OwnerTypeHelper::NEWS,
:width => '100%',
:height => 300,
:minHeight=>300,
:class => 'talk_text fl',
:input_html => { :id => 'news_content',
:class => 'talk_text fl',
:maxlength => 5000 },
at_id: news.id, at_type: news.class.to_s
%>
<div class="cl"></div>
<p id="description_notice_span"></p>
</div>
<div class="cl"></div>
<div class="mt10">
<div class="fl" id="news_attachments">
<%= render :partial => 'attachments/form_course', :locals => {:container => news, :isReply => false} %>
</div>
</div>
<div class="cl"></div>
<div class="mt5">
<%if !edit_mode %>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="submit_contest_news();">确定</a>
<span class="fr mr10 mt3">或</span>
<a href="javascript:void(0);" class="fr mr10 mt3" onclick="reset_news();">取消</a>
<% else %>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="submit_contest_news();">确定</a>
<span class="fr mr10 mt3">或</span>
<%= link_to "取消",news_path(news), :class => "fr mr10 mt3"%>
<% end %>
</div>
<div class="cl"></div>
</div>
</div>
</div>
</div>
<script>
function regexcontestTitle()
{
var name = $("#news_title").val();
if(name.length ==0)
{
$("#title_notice_span").text("标题不能为空");
$("#title_notice_span").css('color','#ff0000');
$("#news_title").focus();
return false;
}
else if(name.length <= 60)
{
$("#title_notice_span").text("填写正确");
$("#title_notice_span").css('color','#008000');
return true;
}
else
{
$("#title_notice_span").text("标题超过60个字符");
$("#title_notice_span").css('color','#ff0000');
$("#news_title").focus();
return false;
}
}
function regexcontestDescription()
{
var name = news_description_editor.html();
if(news_description_editor.isEmpty())
{
$("#description_notice_span").text("描述不能为空");
$("#description_notice_span").css('color','#ff0000');
$("#description_notice_span").focus();
return false;
}
else
{
$("#description_notice_span").text("填写正确");
$("#description_notice_span").css('color','#008000');
return true;
}
}
function submit_contest_news()
{
if(regexcontestTitle() && regexcontestDescription())
{
news_description_editor.sync();
$("#news-form").submit();
}
}
</script>

View File

@ -0,0 +1,103 @@
<%= 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() {
sd_create_editor_from_data(<%= @news.id%>,null,"100%", "<%=@news.class.to_s%>");
showNormalImage('message_description_<%= @news.id %>');
});
</script>
<div class="postRightContainer ml10" onmouseover="$('#message_setting_<%= @news.id%>').show();" onmouseout="$('#message_setting_<%= @news.id%>').hide();">
<div class="postThemeContainer">
<div class="postDetailPortrait">
<%= link_to image_tag(url_to_avatar(@news.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@news.author) %>
</div>
<div class="postThemeWrap">
<% if User.current.allowed_to?(:manage_news, @contest)%>
<div class="homepagePostSetting" id="message_setting_<%= @news.id%>" style="display: none">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li><%= link_to("发送", 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{@news.id}','#{User.current.id}','news')") %></li>
<li>
<%= link_to(
l(:button_edit),
{:action => 'edit', :id => @news},
:class => 'postOptionLink'
) if User.current.allowed_to?(:manage_news, @contest) %>
</li>
<li>
<%= delete_link(
news_path(@news),
:data => {:confirm => l(:text_are_you_sure)},
:class => 'postOptionLink'
) if User.current.allowed_to?(:manage_news, @contest) %>
</li>
</ul>
</li>
</ul>
</div>
<% elsif User.current.logged? %>
<div class="homepagePostSetting" id="message_setting_<%= @news.id %>" style="display: none">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li><%= link_to("发送", 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{@news.id}','#{User.current.id}','news')") %></li>
</ul>
</li>
</ul>
</div>
<%end%>
<div class="postDetailTitle fl">
<a href="javascript:void(0);" class="f14 linkGrey4 fb" style="overflow:hidden;">通知: <%= @news.title%></a>
</div>
<div class="cl"></div>
<div class="postDetailCreater">
<% if @news.try(:author).try(:realname) == ' ' %>
<%= link_to @news.try(:author), user_path(@news.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
<% else %>
<%= link_to @news.try(:author).try(:realname), user_path(@news.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
<% end %>
</div>
<div class="postDetailDate mb5"><%= format_time( @news.created_on)%></div>
<div class="cl"></div>
<div class="homepagePostIntro memo-content upload_img break_word ke-block" id="message_description_<%= @news.id %>" style="word-break: break-all; word-wrap:break-word;margin-bottom: 0px !important;" >
<%= @news.description.html_safe%>
</div>
<div class="cl"></div>
<div class="mt10" style="font-weight:normal;">
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @news} %>
</div>
</div>
<div class="cl"></div>
</div>
<div class="cl"></div>
<div class="homepagePostReply">
<%= render :partial => 'news/news_all_replies', :locals => {:object => @contest} %>
</div>
</div>
<script type="text/javascript">
$(function(){
$("#news_submit_comment").one('click',function(){
submitComment();
});
$("#message_description_<%= @news.id %> p,#message_description_<%= @news.id %> span,#message_description_<%= @news.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_<%= @news.id %>');
});
</script>

View File

@ -20,8 +20,10 @@
<%= render :partial => 'edit_for_org_subfield', :locals => {:f => f, :news => @news} %>
<% elsif @course %>
<%= render :partial => 'course_news_new', :locals => {:f => f, :news => @news, :edit_mode => true, :course => @course} %>
<% elsif @contest %>
<%= render :partial => 'contest_news_new', :locals => {:f => f, :news => @news, :edit_mode => true, :contest => @contest} %>
<% elsif @project %>
<%= render :partial => 'project_news_new', :locals => {:f => f, :news => @news, :edit_mode => true} %>
<%= render :partial => 'project_news_new', :locals => {:f => f, :news => @news, :edit_mode => true} %>
<% end %>
<% end %>
</div>

View File

@ -2,6 +2,8 @@
<%= render :partial => 'project_news', locals: {project: @project} %>
<% elsif @course %>
<%= render :partial => 'course_news', locals: {course: @course} %>
<% elsif @contest %>
<%= render :partial => 'contest_news', locals: {contest: @contest} %>
<% 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} %>
<% elsif @organization %>
<%= render :partial => 'organization_show', :locals => {:org_subfield => @org_subfield} %>
<% end %>

View File

@ -0,0 +1,77 @@
<div class="resources mt10" id="user_activity_<%= user_activity_id %>">
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author), :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), :class => "newsBlue mr15" %>
TO <!--+"(课程名称)"-->
<% str = defined?(is_course) && is_course == 1 ? "竞赛通知" : "#{activity.contest.name.to_s} | 竞赛通知" %>
<%= link_to str, contest_news_index_path(activity.contest), :class => "newsBlue ml15" %>
</div>
<div class="homepagePostTitle break_word hidden fl m_w600"> <!--+"(通知标题)"-->
<%= link_to activity.title.to_s, news_path(activity), :class => "postGrey" %>
</div>
<% if activity.sticky == 1 %>
<span class="sticky_btn_cir ml10">置顶</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>
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %>
<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">
<ul>
<li class="homepagePostSettingIcon">
<% if User.current.logged? %>
<ul class="homepagePostSettiongText">
<li><%= link_to("发送", 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{activity.id}',#{User.current.id},'news')") %></li>
<li>
<%= link_to(
l(:button_edit),
{controller:'news', :action => 'edit', :id => activity.id},
:class => 'postOptionLink'
) if User.current.allowed_to?(:manage_news, activity.course) %>
</li>
<li>
<%= delete_link(
news_path(activity),
:data => {:confirm => l(:text_are_you_sure)},
:class => 'postOptionLink'
) if User.current.allowed_to?(:manage_news, activity.course) %>
</li>
</ul>
<% end %>
</li>
</ul>
</div>
<% end %>
</div>
<div class="cl"></div>
</div>
<div class="homepagePostReply">
<div id="activity_post_reply_<%=user_activity_id %>">
<%=render :partial => 'users/course_news_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,67 @@
<div class = "cl"> </div>
<div id="course-newslist">
<div class="listbox mt10" >
<p class="list-h2">通知列表</p>
<div class="category">
<span class="grayTxt ">排序:</span>
<%= link_to "时间", {:controller => 'news', :action => 'index', :type => @type, :sort => @b_sort, :order => 1 }, :class => "sortTxt", :remote => true %>
<% if @type.to_i == 1 %>
<%= link_to "", {:controller => 'news', :action => 'index', :type => @type, :sort => @b_sort, :order => 1 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
<% end %>
<%= link_to "人气", {:controller => 'news', :action => 'index', :type => @type, :sort => @b_sort, :order => 2 }, :class => "sortTxt", :remote => true %>
<% if @type.to_i == 2 %>
<%= link_to "", {:controller => 'news', :action => 'index', :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>
<%= link_to activity.title.to_s, User.current.logged? ? news_path(activity) : signin_url_without_domain, :class => "list-title-normal fl" %>
<% if activity.sticky == 1 %>
<span class="fl ml10 red-cir-btn">顶</span>
<% end%>
<% u = User.where("id=?",activity.author_id).first%>
<div class="cl"></div>
</div>
<!--<div class="massages-content ml15">-->
<!--<p><%#=render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id =>activity.id, :content=>activity.description, :maxheight=>54, :maxwordsnum=>100, :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.course_acts.first.try(:updated_at)) %></span>
<% count=0 %>
<% count=activity.comments.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 %>
<p class="nodata"><%= l(:label_no_data) %></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

@ -33,7 +33,7 @@
<span class="grayTxt mr15">
发布者:<%= link_to activity.author.show_name, user_path(activity.author), :class => "link-blue" %>
</span>
<span class="grayTxt">更新:<%= format_time(activity.course_acts.first.try(:updated_at)) %></span>
<span class="grayTxt">更新:<%= format_time(@course ? activity.course_acts.first.try(:updated_at) : activity.contest_acts.first.try(:updated_at)) %></span>
<% count=0 %>
<% count=activity.comments.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>

View File

@ -0,0 +1,5 @@
class AddContestIdToNews < ActiveRecord::Migration
def change
add_column :news, :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 => 20161222063638) do
ActiveRecord::Schema.define(:version => 20161223083022) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -337,14 +337,16 @@ ActiveRecord::Schema.define(:version => 20161222063638) do
add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids"
create_table "changesets", :force => true do |t|
t.integer "repository_id", :null => false
t.string "revision", :null => false
t.integer "repository_id", :null => false
t.string "revision", :null => false
t.string "committer"
t.datetime "committed_on", :null => false
t.datetime "committed_on", :null => false
t.text "comments"
t.date "commit_date"
t.string "scmid"
t.integer "user_id"
t.integer "project_id"
t.integer "type", :default => 0
end
add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on"
@ -495,12 +497,12 @@ ActiveRecord::Schema.define(:version => 20161222063638) do
t.integer "user_id"
t.integer "contest_id"
t.integer "contest_message_id"
t.string "contest_message_type"
t.boolean "viewed", :default => false
t.string "course_message_type"
t.boolean "viewed", :default => false
t.text "content"
t.integer "status"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "contest_messages", ["contest_id"], :name => "index_contest_messages_on_contest_id"
@ -605,20 +607,6 @@ ActiveRecord::Schema.define(:version => 20161222063638) do
t.integer "container_id", :default => 0
end
create_table "course_class_post", :id => false, :force => true do |t|
t.integer "班级id", :default => 0, :null => false
t.string "班级名"
t.integer "帖子id", :default => 0, :null => false
t.integer "主贴id"
t.string "帖子标题", :default => "", :null => false
t.text "帖子内容"
t.integer "帖子用户id"
t.integer "帖子回复数", :default => 0, :null => false
t.integer "最后回帖id"
t.datetime "发帖时间", :null => false
t.datetime "帖子更新时间", :null => false
end
create_table "course_contributor_scores", :force => true do |t|
t.integer "course_id"
t.integer "user_id"
@ -687,8 +675,8 @@ ActiveRecord::Schema.define(:version => 20161222063638) do
t.string "code"
t.integer "time"
t.string "extra"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "location"
t.string "term"
t.string "string"
@ -698,27 +686,28 @@ ActiveRecord::Schema.define(:version => 20161222063638) do
t.string "class_period"
t.integer "school_id"
t.text "description"
t.integer "status", :default => 1
t.integer "attachmenttype", :default => 2
t.integer "status", :default => 1
t.integer "attachmenttype", :default => 2
t.integer "lft"
t.integer "rgt"
t.integer "is_public", :limit => 1, :default => 1
t.integer "inherit_members", :limit => 1, :default => 1
t.integer "open_student", :default => 0
t.integer "outline", :default => 0
t.integer "publish_resource", :default => 0
t.integer "is_delete", :default => 0
t.integer "is_public", :limit => 1, :default => 1
t.integer "inherit_members", :limit => 1, :default => 1
t.integer "open_student", :default => 0
t.integer "outline", :default => 0
t.integer "publish_resource", :default => 0
t.integer "is_delete", :default => 0
t.integer "end_time"
t.string "end_term"
t.integer "is_excellent", :default => 0
t.integer "excellent_option", :default => 0
t.integer "is_copy", :default => 0
t.integer "visits", :default => 0
t.integer "is_excellent", :default => 0
t.integer "excellent_option", :default => 0
t.integer "is_copy", :default => 0
t.integer "visits", :default => 0
t.integer "syllabus_id"
t.string "invite_code"
t.string "qrcode"
t.integer "qrcode_expiretime", :default => 0
t.integer "invite_code_halt", :limit => 1, :default => 0
t.integer "qrcode_expiretime", :default => 0
t.integer "professional_level_id", :limit => 1
t.integer "invite_code_halt", :limit => 1, :default => 0
end
add_index "courses", ["invite_code"], :name => "index_courses_on_invite_code", :unique => true
@ -793,6 +782,11 @@ ActiveRecord::Schema.define(:version => 20161222063638) do
add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority"
create_table "disciplines", :force => true do |t|
t.string "name"
t.integer "professional_level_id", :limit => 1
end
create_table "discuss_demos", :force => true do |t|
t.string "title"
t.text "body"
@ -918,13 +912,11 @@ ActiveRecord::Schema.define(:version => 20161222063638) do
t.integer "exercise_status"
t.integer "user_id"
t.integer "time"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "publish_time"
t.datetime "end_time"
t.integer "show_result"
t.integer "question_random", :default => 0
t.integer "choice_random", :default => 0
end
create_table "first_pages", :force => true do |t|
@ -1113,6 +1105,10 @@ ActiveRecord::Schema.define(:version => 20161222063638) do
t.datetime "updated_at", :null => false
end
create_table "innodb_monitor", :id => false, :force => true do |t|
t.integer "a"
end
create_table "invite_lists", :force => true do |t|
t.integer "project_id"
t.integer "user_id"
@ -1376,6 +1372,7 @@ ActiveRecord::Schema.define(:version => 20161222063638) do
t.integer "course_id"
t.integer "sticky", :default => 0
t.integer "org_subfield_id"
t.integer "contest_id"
end
add_index "news", ["author_id"], :name => "index_news_on_author_id"
@ -1644,9 +1641,12 @@ ActiveRecord::Schema.define(:version => 20161222063638) do
end
create_table "professional_levels", :force => true do |t|
t.string "level"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "level"
end
create_table "professions", :force => true do |t|
t.string "name"
t.integer "discipline_id", :limit => 1
end
create_table "project_infos", :force => true do |t|
@ -1709,7 +1709,6 @@ ActiveRecord::Schema.define(:version => 20161222063638) do
t.boolean "hidden_repo", :default => false, :null => false
t.integer "attachmenttype", :default => 1
t.integer "user_id"
t.integer "dts_test", :default => 0
t.string "enterprise_name"
t.integer "organization_id"
t.integer "project_new_type"
@ -1717,6 +1716,11 @@ ActiveRecord::Schema.define(:version => 20161222063638) do
t.integer "forked_from_project_id"
t.integer "forked_count"
t.integer "publish_resource", :default => 0
t.integer "boards_count", :default => 0
t.integer "news_count", :default => 0
t.integer "acts_count", :default => 0
t.integer "journals_count", :default => 0
t.integer "boards_reply_count", :default => 0
t.integer "visits", :default => 0
t.integer "hot", :default => 0
t.string "invite_code"
@ -2114,8 +2118,8 @@ ActiveRecord::Schema.define(:version => 20161222063638) do
t.string "title"
t.text "description"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "eng_name"
t.integer "syllabus_type"
t.integer "credit"
@ -2124,8 +2128,9 @@ ActiveRecord::Schema.define(:version => 20161222063638) do
t.integer "practice_hours"
t.string "applicable_major"
t.string "pre_course"
t.integer "visits", :default => 0
t.integer "des_status", :default => 0
t.integer "visits", :default => 0
t.integer "des_status", :default => 0
t.integer "professional_level_id", :limit => 1
end
add_index "syllabuses", ["user_id"], :name => "index_syllabuses_on_user_id"

View File

@ -132,6 +132,12 @@ Redmine::AccessControl.map do |map|
map.permission :comment_news, {:comments => :create}
end
map.contest_module :news do |map|
map.permission :manage_news, {:news => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member
map.permission :view_contest_news, {:news => [:index, :show]}, :public => true, :read => true
map.permission :comment_news, {:comments => :create}
end
map.course_module :bids do |map|
map.permission :view_homework_attaches, {:bids => [:show, :show_project, :revision]}, :read => true,:belong_to_course => true
map.permission :paret_in_homework,{},:require => :member ,:belong_to_course => true