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

This commit is contained in:
Linda 2017-02-23 17:14:32 +08:00
commit 2fb75fdb4d
17 changed files with 158 additions and 50 deletions

View File

@ -770,10 +770,14 @@ class ProjectsController < ApplicationController
end
def add_script
if @project.update_attribute(:script, params[:project_script])
@notice = "脚本添加成功"
if User.current.admin? || User.current.member_of?(@project)
if @project.update_attribute(:script, params[:project_script])
@notice = "脚本添加成功"
else
@notice = "脚本添加失败"
end
else
@notice = "脚本添加失败"
return render_403
end
end
@ -830,16 +834,17 @@ class ProjectsController < ApplicationController
# training_status: 默认为0 1代表实训项目 2代表实训子项目
def training_project_execute
if @project.training_tasks.count == 0
@notice = "实训开启失败:请先发布实训任务"
return
end
jobName = "#{@project.id}"
pipeLine = "#{Base64.encode64(@project.script)}"
uri = URI("http://123.59.135.74:9999/jenkins-exec/api/createJob")
res = Net::HTTP.post_form(uri, {jobName: jobName, pipeLine: pipeLine}).body
# if res.code == 0
@project.update_attribute(:training_status, 1)
@notice = "实训开启成功"
# else
# flash[:notice] = "启动失败"
# end
end
def training_project_update

View File

@ -310,6 +310,11 @@ class UsersController < ApplicationController
@user_activity_id = params[:user_activity_id]
@activity_id = params[:activity_id]
@type = 'Issue'
when 'Training_task'
@reply = Journal.find params[:reply_id]
@user_activity_id = params[:user_activity_id]
@activity_id = params[:activity_id]
@type = 'Training_task'
when 'Syllabus'
@reply = JournalsForMessage.find params[:reply_id]
@type = 'Syllabus'
@ -4348,6 +4353,11 @@ class UsersController < ApplicationController
@journals = @activity.journals.reorder("created_on desc")
@user_activity_id = params[:div_id].to_i if params[:div_id]
@user_activity = ForgeActivity.where(params[:div_id].to_i).first if params[:div_id]
when 'is_project_training_task'
@activity = TrainingTask.where('id = ?', params[:id].to_i).first
@journals = @activity.journals.reorder("created_on desc")
@user_activity_id = params[:div_id].to_i if params[:div_id]
@user_activity = ForgeActivity.where(params[:div_id].to_i).first if params[:div_id]
when 'BlogComment'
obj = BlogComment.where('id = ?', params[:id].to_i).first
@user_activity_id = params[:div_id].to_i if params[:div_id]

View File

@ -225,7 +225,7 @@ class Project < ActiveRecord::Base
# 判断项目是否为实训项目
def is_training_project?
(self.enabled_modules.where("name = 'training_tasks'").empty? && self.training_status == 1) ? false : true
(!self.enabled_modules.where("name = 'training_tasks'").empty? && self.training_status == 1) ? true : false
end
# 判断项目是否为开启实训的项目eg学生开启实训

View File

@ -36,7 +36,7 @@
<!--项目fork-->
<li class="mr5 fl">
<!--实训项目条件1、modules中选中了实训任务 2、不是fork的项目-->
<% if @project.is_training_project? %>
<% if @project.is_training_project? && User.current.id != @project.user_id %>
<%= link_to "开始实训", training_chiled_project_exec_project_path(@project), :class => "sy_btn_green fr", :remote => true %>
<% else %>
<%= link_to "<span class='vl_fork'></span>".html_safe+"Fork", forked_pop_project_path(@project),

View File

@ -34,23 +34,32 @@
</span>
<span style="position: relative" class="fr mr20">
<%= link_to(
l(:button_reply),
{:controller => 'users', :action => 'reply_to', :reply_id => comment.id, :type => 'Issue', :user_activity_id => user_activity_id, :activity_id => activity.id, :is_project => true},
:remote => true,
:method => 'get',
:title => l(:button_reply)) %>
<%= link_to(l(:button_reply),
{:controller => 'users',
:action => 'reply_to',
:reply_id => comment.id,
:type => 'Training_task',
:user_activity_id => user_activity_id,
:activity_id => activity.id,
:is_project => true},
:remote => true,
:method => 'get',
:title => l(:button_reply)) %>
<span id="reply_iconup_<%= comment.id %>" class="reply_iconup02" style="display: none"> ︿</span>
</span>
<%= link_to(
l(:button_delete),
{:controller => 'issues',:action => 'delete_journal', :id => activity.id,:journal_id=>comment.id, :user_activity_id => user_activity_id, :is_project => true},
:method => 'get',
:confirm => l(:text_are_you_sure),
:remote=>true,
:id => "delete_reply_#{activity.id}_#{comment.id}",
:class => 'fr mr20 undis',
:title => l(:button_delete)
<%= link_to(l(:button_delete),
{:controller => 'training_tasks',
:action => 'delete_journal',
:id => activity.id,
:journal_id=>comment.id,
:user_activity_id => user_activity_id,
:is_project => true},
:method => 'get',
:confirm => l(:text_are_you_sure),
:remote=>true,
:id => "delete_reply_#{activity.id}_#{comment.id}",
:class => 'fr mr20 undis',
:title => l(:button_delete)
) if comment.user_id == User.current.id %>
</span>
@ -70,13 +79,13 @@
<div class="reply-content mb10">
<% if User.current.logged? %>
<div nhname='new_message_<%= user_activity_id %>' style="display:none;">
<%= form_for('new_form',:url => add_journal_issue_path(activity.id, :user_activity_id => user_activity_id, :is_project => true),:method => "post", :remote => true) do |f| %>
<input type="hidden" name="user_activity_id" value="<%=user_activity_id%>">
<div nhname='toolbar_container_<%= user_activity_id%>'></div>
<%= form_for('new_form', :url => add_journal_training_task_path(activity.id, :user_activity_id => user_activity_id, :is_project => true), :method => "post", :remote => true) do |f| %>
<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="notes"></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>
<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>
<p nhname='contentmsg_<%= user_activity_id %>'></p>
<% end%>
</div>
<% else %>

View File

@ -4,6 +4,6 @@
<div class="container-big-grey">
<%= render :partial => 'projects/project_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :expand_more =>no_children_comments[:three_more]} %>
<div class="" id="reply_div_<%= user_activity_id %>">
<%= render :partial => "projects/project_issue_expand_show", :locals => {:comments => no_children_comments[:no_children_comments], :activity => activity, :user_activity_id => user_activity_id} %>
<%= render :partial => "projects/project_issue_expand_show", :locals => { :comments => no_children_comments[:no_children_comments], :activity => activity, :user_activity_id => user_activity_id} %>
</div>
</div>

View File

@ -3,7 +3,7 @@
<span>回复</span>
<span class="reply_iconup" > ︿</span>
<span class="mr15"><%= count>0 ? "#{count}" : "" %></span><span style="color: #cecece;">▪</span>
<span id="praise_count_<%=user_activity_id %>">
<span id="praise_count_<%= user_activity_id %>">
<%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
</span>
</div>
@ -11,15 +11,19 @@
<% if expand_more %>
<div class="homepagePostReplyBannerMore">
<% if activity.class.to_s == 'Issue' %>
<a id="reply_btn_<%=user_activity_id%>" onclick="expand_reply_homework('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>',<%= activity.id %>,'is_project_issue',<%=user_activity_id %>)" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >
<a id="reply_btn_<%= user_activity_id %>" onclick="expand_reply_homework('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>',<%= activity.id %>,'is_project_issue',<%= user_activity_id %>)" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >
展开更多
</a>
<% elsif activity.class.to_s == 'Message' %>
<a id="reply_btn_<%=user_activity_id%>" onclick="expand_reply_homework('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>',<%= activity.id %>,'is_project_message',<%=user_activity_id %>)" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >
<a id="reply_btn_<%= user_activity_id %>" onclick="expand_reply_homework('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>',<%= activity.id %>,'is_project_message',<%= user_activity_id %>)" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >
展开更多
</a>
<% elsif activity.class.to_s == 'TrainingTask' %>
<a id="reply_btn_<%= user_activity_id %>" onclick="expand_reply_homework('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>',<%= activity.id %>,'is_project_training_task',<%= user_activity_id %>)" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >
展开更多
</a>
<% else %>
<a id="reply_btn_<%=user_activity_id%>" onclick="expand_reply_homework('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>',<%= activity.id %>,'<%=activity.class %>',<%=user_activity_id %>)" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >
<a id="reply_btn_<%= user_activity_id %>" onclick="expand_reply_homework('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>',<%= activity.id %>,'<%=activity.class %>',<%= user_activity_id %>)" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >
展开更多
</a>
<% end %>

View File

@ -26,6 +26,16 @@
<div class="cl"></div>
<p nhname='contentmsg_<%= reply.id%>' class="fl"></p>
<% end %>
<% elsif @type == 'Training_task' %>
<%= form_for('new_form', :url => add_reply_training_task_path(reply.training_task.id, :is_project => true),:method => "post", :remote => true) do |f|%>
<%= hidden_field_tag 'journal_id',params[:journal_id],:value =>reply.id %>
<%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>@user_activity_id %>
<div nhname='toolbar_container_<%= reply.id %>' ></div>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= reply.id%>' name="content"></textarea>
<a id="new_message_submit_btn_<%= reply.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_<%= reply.id%>' class="fl"></p>
<% end %>
<% end %>
</div>

View File

@ -19,7 +19,7 @@
<% if User.current.allowed_to?(:manage_repository, @project) %>
<li><a href="javascript:void(0)" id="pro_st_tb_6" class="<%= show_memu == 'manage_repository' ? 'active' : ''%>" onclick="project_setting(6);">版本库</a></li>
<% end %>
<% if @project.is_training_project? %>
<% if !@project.enabled_modules.where("name = 'training_tasks'").empty? %>
<li><a href="javascript:void(0)" id="pro_st_tb_7" class="<%= show_memu == 'trainig_task' ? 'active' : ''%>" onclick="project_setting(7);">实训任务</a></li>
<% end %>
<!--<li id="pro_st_tb_7" class="pro_st_normaltab" onclick="project_setting(7);">活动(时间跟踪)</li>-->

View File

@ -5,9 +5,6 @@
<div class=" sy_new_tchbox clear ">
<div id="training_project_filter_tip">
<%= render :partial => "projects/settings/training_projects_filter_tip" %>
</div>
<div id="training_project_filter_tip">
</div>
<div class="cl"></div>
<div class="clear">

View File

@ -24,7 +24,7 @@
<!--<li><%#= link_to "作业动态", {:controller => "courses", :action => "show", :type => "homework"}, :class => "homepagePostTypeAssignment postTypeGrey" %></li>-->
<li><%= link_to "资源库动态", {:controller => "projects", :action => "show", :type => "attachment"}, :class => "homepagePostTypeResource resourcesGrey" %></li>
<li><%= link_to "讨论区动态", {:controller => "projects", :action => "show", :type => "message"}, :class => "homepagePostTypeForum postTypeGrey" %></li>
<li><%= link_to "讨论区动态", {:controller => "projects", :action => "show", :type => "training_task"}, :class => "homepagePostTypeForum postTypeGrey" %></li>
<li><%= link_to "实训任务动态", {:controller => "projects", :action => "show", :type => "training_task"}, :class => "homepagePostTypeForum postTypeGrey" %></li>
<!--<li><%#= link_to "问卷动态", {:controller => "courses", :action => "show", :type => "poll"}, :class => "homepagePostTypeQuiz postTypeGrey" %></li>-->
</ul>
</li>

View File

@ -1 +1,6 @@
<% if params[:is_project] %>
$("#div_user_issue_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'projects/project_issue_reply', :locals => {:activity => @training_task, :user_activity_id => @user_activity_id}) %>");
<% else %>
$("#div_user_issue_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'users/project_issue_reply', :locals => {:activity => @training_task, :user_activity_id => @user_activity_id}) %>");
<% end %>
sd_create_editor_from_data(<%= @user_activity_id %>, null, "100%", "UserActivity");

View File

@ -0,0 +1,13 @@
<% if @user_activity_id %>
<%# 动态中 %>
<% if params[:is_project] %>
$("#div_user_issue_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'projects/project_issue_reply', :locals => {:activity => @training_task, :user_activity_id => @user_activity_id}) %>");
<% else %>
$("#div_user_issue_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'users/project_issue_reply', :locals => {:activity => @training_task, :user_activity_id => @user_activity_id}) %>");
<% end %>
sd_create_editor_from_data(<%= @user_activity_id %>, null, "100%","<%= @training_task.class.name %>");
<% else %>
<%# issue详情 %>
<%= render "jounal_refresh" %>
<% end %>

View File

@ -0,0 +1,14 @@
<% if @user_activity_id %>
<% if @is_project %>
$("#div_user_issue_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'projects/project_issue_reply',
:locals => {:activity => @training_task,
:user_activity_id => @user_activity_id}) %>");
<% else %>
$("#div_user_issue_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'users/project_issue_reply',
:locals => {:activity => @training_task,
:user_activity_id => @user_activity_id}) %>");
<% end %>
sd_create_editor_from_data(<%= @user_activity_id %>, null, "100%","<%= @training_task.class.name %>");
<% else %>
<%= render "jounal_refresh" %>
<% end %>

View File

@ -1,3 +1,6 @@
<% if params[:is_project]%>
$("#reply_message_<%= @jour.id %>").
<% else %>
if($("#reply_message_<%= @jour.id %>").length > 0) {
$("#reply_message_<%= @jour.id %>").replaceWith("<%= escape_javascript(render :partial => 'training_tasks/training_tasks_reply_ke_form') %>");
$(function(){
@ -5,4 +8,5 @@ if($("#reply_message_<%= @jour.id %>").length > 0) {
});
}else if($("#reply_to_message_<%= @jour.id %>").length >0) {
$("#reply_to_message_<%= @jour.id %>").replaceWith("<p id='reply_message_<%= @jour.id %>'></p>");
}
}
<% end %>

View File

@ -6,7 +6,7 @@ issue_desc_editor = KindEditor.create('#issue_description',
{"width":"85%",
"resizeType":0,
"no_label":true,
"at_id":<%= @training_task.project_id%>,
"at_id":<%= @training_task.project_id %>,
"at_type":"Project",
"autoHeightMode":true,
"afterCreate":"eval(function(){ if(typeof enablePasteImg ==='function'){enablePasteImg(self);};if(typeof enableAt ==='function'){enableAt(self, \"<%= @training_task.project_id %>\", 'Project');}; this.loadPlugin('autoheight')})",

View File

@ -1,17 +1,54 @@
<% if params[:type] == 'HomeworkCommon' || params[:type] == 'Work' %>
$('#reply_div_<%= @user_activity_id %>').html('<%=escape_javascript(render :partial => 'users/news_replies', :locals => {:comments => @journals, :type => @type, :is_teacher => @is_teacher, :user_activity_id => @user_activity_id, :activity_id => params[:id].to_i}) %>');
$('#reply_div_<%= @user_activity_id %>').html('<%= escape_javascript(render :partial => 'users/news_replies',
:locals => {:comments => @journals,
:type => @type,
:is_teacher => @is_teacher,
:user_activity_id => @user_activity_id,
:activity_id => params[:id].to_i}) %>');
<% elsif params[:type] == 'JournalsForMessage' %>
$('#reply_div_<%= @user_activity_id %>').html('<%=escape_javascript(render :partial => 'users/message_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :activity_id =>params[:id].to_i}) %>');
$('#reply_div_<%= @user_activity_id %>').html('<%= escape_javascript(render :partial => 'users/message_replies',
:locals => {:comments => @journals,
:user_activity_id => @user_activity_id,
:type => @type,
:activity_id =>params[:id].to_i}) %>');
<% elsif params[:type] == 'Message' %>
$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/message_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :activity_id => params[:id].to_i}) %>');
$('#reply_div_<%= params[:div_id].to_i %>').html('<%= escape_javascript(render :partial => 'users/message_replies',
:locals => {:comments => @journals,
:user_activity_id => @user_activity_id,
:type => @type,
:activity_id => params[:id].to_i}) %>');
<% elsif params[:type] == 'BlogComment' %>
$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/message_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :activity_id => params[:id].to_i}) %>');
$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/message_replies',
:locals => {:comments => @journals,
:user_activity_id => @user_activity_id,
:type => @type,
:activity_id => params[:id].to_i}) %>');
<% elsif params[:type] == 'OrgDocumentComment' %>
$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/message_replies', :locals => {:comments => @journals, :user_activity_id => @user_activity_id, :type => @type, :activity_id => params[:id].to_i}) %>');
$('#reply_div_<%= params[:div_id].to_i %>').html('<%= escape_javascript(render :partial => 'users/message_replies',
:locals => {:comments => @journals,
:user_activity_id => @user_activity_id,
:type => @type,
:activity_id => params[:id].to_i}) %>');
<% elsif params[:type] == 'News' || params[:type] == 'Issue' || params[:type] == 'Syllabus' %>
$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/news_replies', :locals => {:comments => @journals, :user_activity_id => @user_activity_id, :type => @type, :activity_id => params[:id].to_i}) %>');
$('#reply_div_<%= params[:div_id].to_i %>').html('<%= escape_javascript(render :partial => 'users/news_replies',
:locals => {:comments => @journals,
:user_activity_id => @user_activity_id,
:type => @type,
:activity_id => params[:id].to_i}) %>');
<% elsif params[:type] == 'is_project_issue' %>
$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'projects/project_issue_expand_show', :locals => {:comments => @journals, :user_activity_id => @user_activity_id, :activity => @activity}) %>');
$('#reply_div_<%= params[:div_id].to_i %>').html('<%= escape_javascript(render :partial => 'projects/project_issue_expand_show',
:locals => {:comments => @journals,
:user_activity_id => @user_activity_id,
:activity => @activity}) %>');
<% elsif params[:type] == 'is_project_training_task' %>
$('#reply_div_<%= params[:div_id].to_i %>').html('<%= escape_javascript(render :partial => 'projects/project_issue_expand_show',
:locals => {:comments => @journals,
:user_activity_id => @user_activity_id,
:activity => @activity}) %>');
<% elsif params[:type] == 'is_project_message' %>
$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'projects/project_message_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :activity_id => params[:id].to_i}) %>');
$('#reply_div_<%= params[:div_id].to_i %>').html('<%= escape_javascript(render :partial => 'projects/project_message_replies',
:locals => {:comments => @journals,
:user_activity_id => @user_activity_id,
:type => @type,
:activity_id => params[:id].to_i}) %>');
<% end %>