竞赛通知新建
This commit is contained in:
parent
345d8b5045
commit
c98a8b5113
|
@ -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
|
||||
|
|
|
@ -334,6 +334,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
|
||||
|
||||
|
|
|
@ -21,13 +21,13 @@
|
|||
<div class="homepageRight mt0 ml10">
|
||||
<div class="homepageRightBanner">
|
||||
<div class="NewsBannerName">
|
||||
班级通知
|
||||
竞赛通知
|
||||
</div>
|
||||
</div>
|
||||
<% if @course && User.current.allowed_to?(:manage_news, @course) %>
|
||||
<%= labelled_form_for @news, :url =>{:controller=>'news',:action => 'new', :course_id => @course.id},
|
||||
:html => {:nhname=>'form',:multipart => true, :id => 'news-form'} do |f| %>
|
||||
<%= render :partial => 'course_news_new', :locals => {:f => f, :news => @news, :edit_mode => false, :course => @course} %>
|
||||
<% if contest && User.current.allowed_to?(:manage_news, @contest) %>
|
||||
<%= labelled_form_for @news, :url => new_contest_news_path(:contest_id => @contest),
|
||||
:html => {:id => 'contest_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=> 'course_news_detail',:locals =>{:newss => @newss, :page => 0} %>
|
||||
|
|
|
@ -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%>
|
||||
|
|
@ -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();
|
||||
$("#contest_news_form").submit();
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -3,7 +3,7 @@
|
|||
<% elsif @course %>
|
||||
<%= render :partial => 'course_news', locals: {course: @course} %>
|
||||
<% elsif @contest %>
|
||||
<%= render :partial => 'contest_news', locals: {course: @contest} %>
|
||||
<%= render :partial => 'contest_news', locals: {contest: @contest} %>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<% if @project %>
|
||||
$("#show_more_project_news").replaceWith("<%= escape_javascript(render :partial => 'project_news_detail', :locals=>{ :all_news=>@newss,:page => @page})%>");
|
||||
<% elsif @course %>
|
||||
$("#course-newslist").replaceWith('<%= escape_javascript( render :partial => 'users/course_newslist', :locals => {:topics => @newss}) %>');
|
||||
<% else %>
|
||||
$("#course-newslist").replaceWith('<%= escape_javascript( render :partial => 'users/course_newslist', :locals => {:topics => @newss}) %>');
|
||||
<% end %>
|
Loading…
Reference in New Issue