Merge branch 'develop' into 'develop'

新建/编辑里程碑,名字相同时提示更改;课程的资源库动态无法被筛选;待审批消息旧数据依旧存在的问题

新建/编辑里程碑,名字相同时提示更改;课程的资源库动态无法被筛选;待审批消息旧数据依旧存在的问题

See merge request !88
This commit is contained in:
黄井泉 2016-12-27 16:27:19 +08:00
commit 8e2353d61e
12 changed files with 165 additions and 94 deletions

View File

@ -1888,7 +1888,7 @@ class UsersController < ApplicationController
@applied_message_alls << mess @applied_message_alls << mess
end end
elsif (message_all.message_type == "AppliedMessage" ) elsif (message_all.message_type == "AppliedMessage" )
if (mess.applied_type == "AppliedContest" && mess.status == 0) || (mess.applied_type == "StudentWorksScoresAppeal" && mess.status == 0) || (mess.applied_type == "AppliedProject" && mess.status == 1) || ( mess.applied_type == "ApplyAddSchools" && ApplyAddSchools.where(:school_id => mess.applied_id, :status => 0).count != 0 ) if (mess.applied_type == "AppliedContest" && mess.status == 0) || (mess.applied_type == "StudentWorksScoresAppeal" && mess.status == 0) || (mess.applied_type == "AppliedProject" && mess.status == 1 && AppliedMessage.where("applied_id = #{mess.applied_id} and status != 1").count == 0) || ( mess.applied_type == "ApplyAddSchools" && ApplyAddSchools.where(:school_id => mess.applied_id, :status => 0).count != 0 )
@applied_message_alls << mess @applied_message_alls << mess
end end
elsif message_all.message_type == "CourseMessage" elsif message_all.message_type == "CourseMessage"
@ -2099,7 +2099,7 @@ class UsersController < ApplicationController
@message_alls << mess @message_alls << mess
end end
elsif (message_all.message_type == "AppliedMessage" ) elsif (message_all.message_type == "AppliedMessage" )
if (mess.applied_type == "AppliedContest" && mess.status == 0) || (mess.applied_type == "StudentWorksScoresAppeal" && mess.status == 0) || (mess.applied_type == "AppliedProject" && mess.status == 1) || ( mess.applied_type == "ApplyAddSchools" && ApplyAddSchools.where(:school_id => mess.applied_id, :status => 0).count != 0 ) if (mess.applied_type == "AppliedContest" && mess.status == 0) || (mess.applied_type == "StudentWorksScoresAppeal" && mess.status == 0) || (mess.applied_type == "AppliedProject" && mess.status == 1 && AppliedMessage.where("applied_id = #{mess.applied_id} and status != 1").count == 0) || ( mess.applied_type == "ApplyAddSchools" && ApplyAddSchools.where(:school_id => mess.applied_id, :status => 0).count != 0 )
@message_alls << mess @message_alls << mess
end end
elsif message_all.message_type == "CourseMessage" elsif message_all.message_type == "CourseMessage"

View File

@ -19,11 +19,11 @@ class VersionsController < ApplicationController
layout "base_projects" layout "base_projects"
menu_item :roadmap menu_item :roadmap
model_object Version model_object Version
before_filter :find_model_object, :except => [:index, :new, :create, :close_completed] before_filter :find_model_object, :except => [:index, :new, :create, :close_completed,:judge_version_title]
#before_filter :find_model_object_contest, :except => [:index, :new, :create] #before_filter :find_model_object_contest, :except => [:index, :new, :create]
before_filter :find_project_from_association, :except => [:index, :new, :create, :close_completed] before_filter :find_project_from_association, :except => [:index, :new, :create, :close_completed, :judge_version_title]
before_filter :find_project_by_project_id, :only => [:index, :new, :create, :close_completed] before_filter :find_project_by_project_id, :only => [:index, :new, :create, :close_completed,:judge_version_title]
before_filter :authorize before_filter :authorize, :except => [:judge_version_title]
accept_api_auth :index, :show, :create, :update, :destroy accept_api_auth :index, :show, :create, :update, :destroy
@ -189,9 +189,9 @@ class VersionsController < ApplicationController
end end
else else
respond_to do |format| respond_to do |format|
format.html { flash[:error] = @version.errors.full_messages.flatten.to_s # format.html { flash[:error] = @version.errors.full_messages.flatten.to_s
redirect_to settings_project_url(@project, :tab => 'versions') } # redirect_to settings_project_url(@project, :tab => 'versions') }
format.js { render :action => 'new' } format.js { @error = @version.errors.full_messages.flatten.to_s }
format.api { render_validation_errors(@version) } format.api { render_validation_errors(@version) }
end end
end end
@ -275,6 +275,21 @@ class VersionsController < ApplicationController
redirect_to settings_contest_url(@contest, :tab => 'versions') redirect_to settings_contest_url(@contest, :tab => 'versions')
end end
# 判断里程碑是否重名
def judge_version_title
begin
version = Version.where(:name => params[:version_name]).first
if version.blank?
result = {:result => true}
else
result = {:result => false}
end
rescue Exception => e
puts e
end
render :json => result
end
def destroy def destroy
begin begin
project = @version.project project = @version.project

View File

@ -42,8 +42,7 @@
<h4 style="font-size: 18px;margin-top: 10px; padding-bottom: 10px;"><%= l(:notice_email_register_time) %></h4> <h4 style="font-size: 18px;margin-top: 10px; padding-bottom: 10px;"><%= l(:notice_email_register_time) %></h4>
<div class="to-email mb10" style="padding-bottom: 8px; font-size: 14px"> <div class="to-email mb10" style="padding-bottom: 8px; font-size: 14px">
<div class="to-email" style="padding-bottom:15px; font-size:14px; padding-top:10px;"> <div class="to-email" style="padding-bottom:15px; font-size:14px; padding-top:10px;">
<span ><%= l(:notice_email_arrival)%></span> <span ><%= l(:notice_email_arrival)%> <%= @user.mail %></span>
<a href="#" class="f-blue"><%= @user.mail %></a>
</div> </div>
<p> <p>
<a href="http://mail.<%= email %>" class="btn btn-blue" target="_blank"><%= l(:label_check_email)%></a> <a href="http://mail.<%= email %>" class="btn btn-blue" target="_blank"><%= l(:label_check_email)%></a>

View File

@ -1,5 +1,5 @@
<% if @project.shared_versions.empty? %> <% if @project.shared_versions.empty? %>
<div class="pro_new_prompt ml15 mr15 mb10"><p><%= l(:milestone_no_data) %></p></div> <div class="pro_new_prompt ml15 mr15 mb10"><p><%= l(:milestone_no_data) %></p></div>
<% end %> <% end %>
<div class=" sy_new_tchbox clear " > <div class=" sy_new_tchbox clear " >
<a href="javascript:void(0);" class=" sy_btn_green mb10 fr" onclick="pro_st_show_ban1();">新建里程碑</a> <a href="javascript:void(0);" class=" sy_btn_green mb10 fr" onclick="pro_st_show_ban1();">新建里程碑</a>
@ -8,73 +8,45 @@
</div> </div>
<% if @project.shared_versions.any? %> <% if @project.shared_versions.any? %>
<div class=" clear ml15 mr15" > <div class=" clear ml15 mr15" >
<table class="sy_new_table clear mb15" cellpadding="0" cellspacing="0"> <table class="sy_new_table clear mb15" cellpadding="0" cellspacing="0">
<thead> <thead>
<tr>
<th class="fl" style="width:156px;">名称</th>
<th class="w80 fl">结束日期</th>
<th class="w350 fl">描述</th>
<th class="w50 fl">状态</th>
<th class="w150 fl">操作</th>
</tr>
</thead>
<tbody>
<% @project.shared_versions.reverse.each do |version| %>
<tr> <tr>
<th class="fl hidden" style="width:156px;" title="<%= version.name %>" > <th class="fl" style="width:156px;">名称</th>
<%= link_to version.name, version_path(version), :class => "c_blue02" %> <th class="w80 fl">结束日期</th>
</th> <th class="w350 fl">描述</th>
<th class="fl w80"><%= format_date(version.effective_date) %></th> <th class="w50 fl">状态</th>
<th class="fl w350 hidden"><%=h version.description %></th> <th class="w150 fl">操作</th>
<th class="fl w50"><%= l("version_status_#{version.status}") %></th>
<th class="fl w150">
<% if version.project == @project && User.current.allowed_to?(:manage_versions, @project) %>
<%= link_to l(:button_edit), edit_version_path(version, :is_setting => true), :class => 'sy_btn_blue mr5', :remote => true %>
<%= delete_link_version version_path(version, :is_setting => true), :class=>"sy_btn_grey mr5", :remote => true %>
<% end %>
</th>
</tr> </tr>
<% end %> </thead>
</tbody> <tbody>
</table> <% @project.shared_versions.reverse.each do |version| %>
</div> <tr>
<th class="fl hidden" style="width:156px;" title="<%= version.name %>" >
<%= link_to version.name, version_path(version), :class => "c_blue02" %>
</th>
<th class="fl w80"><%= format_date(version.effective_date) %></th>
<th class="fl w350 hidden"><%=h version.description %></th>
<th class="fl w50"><%= l("version_status_#{version.status}") %></th>
<th class="fl w150">
<% if version.project == @project && User.current.allowed_to?(:manage_versions, @project) %>
<%= link_to l(:button_edit), edit_version_path(version, :is_setting => true), :class => 'sy_btn_blue mr5', :remote => true %>
<%= delete_link_version version_path(version, :is_setting => true), :class=>"sy_btn_grey mr5", :remote => true %>
<% end %>
</th>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %> <% end %>
<script> <script>
// 新建版本
function project_version_commit()
{
if(regex_version_name())
{
$("#new_project_version_form").submit();
}
}
function regex_version_name()
{
var name = $.trim($("#setting_version_name").val());
if(name.length == 0)
{
$("#project_setting_version_title").show();
return false;
}
else
{
$("#project_setting_version_title").hide();
return true;
}
}
function pro_st_show_ban1() function pro_st_show_ban1()
{ {
$("#pro_st_edit_ban1").toggle(); $("#pro_st_edit_ban1").toggle();
$("#setting_version_name").val(""); $("#project_setting_create_version_title").val("");
$("#setting_version_description").val(""); $("#setting_version_description").val("");
$("#setting_version_effective_date").val(""); $("#setting_version_effective_date").val("");
} }
function pro_st_show_ban()
{
$("#pro_st_edit_ban").toggle();
}
</script> </script>

View File

@ -1,10 +1,10 @@
<%= form_for :version, :url => project_versions_path(@project, :is_setting => true),:html=>{:id=>"new_project_version_form", :remote => true} do |f| %> <%= form_for :version, :url => project_versions_path(@project, :is_setting => true),:html=>{:id => "setting_new_project_version_form", :remote => true} do |f| %>
<div id="pro_st_edit_ban1" style="display:none;"> <div id="pro_st_edit_ban1" style="display:none;">
<ul class="pro_newsetting_con mb15"> <ul class="pro_newsetting_con mb15">
<li class="mb10 clear"> <li class="mb10 clear">
<label class="label02"><span class="c_red f12">*</span>&nbsp;<%= l(:field_name) %>&nbsp;&nbsp;:&nbsp;</label> <label class="label02"><span class="c_red f12">*</span>&nbsp;<%= l(:field_name) %>&nbsp;&nbsp;:&nbsp;</label>
<%= f.text_field :name, :maxlength => 60, :class=>"w650 fl", :style=>"height: 28px;", :id => "setting_version_name" %> <%= f.text_field :name, :maxlength => 60, :class=>"w650 fl", :style=>"height: 28px;", :id => "project_setting_create_version_title" %>
<p class="c_orange ml100" style="display: none" id="project_setting_version_title">标题不能为空</p> <p class="c_orange ml100" style="display: none" id="project_setting_version_name">标题不能为空</p>
</li> </li>
<li class="mb10 clear"> <li class="mb10 clear">
<label class="fl">&nbsp;<%= l(:label_version_description) %>&nbsp;&nbsp;:&nbsp;</label> <label class="fl">&nbsp;<%= l(:label_version_description) %>&nbsp;&nbsp;:&nbsp;</label>
@ -24,11 +24,30 @@
<div class="cl mb10"></div> <div class="cl mb10"></div>
</ul> </ul>
<a href="javascript:void(0);" class="fr sy_btn_grey " onclick="pro_st_show_ban1();">取消</a> <a href="javascript:void(0);" class="fr sy_btn_grey " onclick="pro_st_show_ban1();">取消</a>
<a href="javascript:void(0);" onclick="project_version_commit();" class="fr sy_btn_blue mr5">保存</a> <a href="javascript:void(0);" onclick="project_setting_version_commit();" class="fr sy_btn_blue mr5">保存</a>
</div> </div>
<% end %> <% end %>
<script> <script>
function project_version_commit(){ // 新建版本
$("#new_project_version_form").submit(); function project_setting_version_commit()
} {
if(regex_setting_version_name())
{
$("#setting_new_project_version_form").submit();
}
}
function regex_setting_version_name()
{
var name = $.trim($("#project_setting_create_version_title").val());
if(name.length == 0)
{
$("#project_setting_version_name").show();
return false;
}
else
{
$("#project_setting_version_name").hide();
return true;
}
}
</script> </script>

View File

@ -48,13 +48,11 @@
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
console.log("2222222222");
$.ajax({ $.ajax({
url:"<%= repository_tree_changes_project_path(@project, :rev => @rev, :ent_path => ent_path, :gpid => @project.gpid) %>", url:"<%= repository_tree_changes_project_path(@project, :rev => @rev, :ent_path => ent_path, :gpid => @project.gpid) %>",
type: "GET", type: "GET",
data: "text", data: "text",
success:function(data){ success:function(data){
console.log(data);
$('#changes_message_<%=tr_id %>').html(data.message) $('#changes_message_<%=tr_id %>').html(data.message)
$('#changes_author_<%=tr_id %>').html(data.author_name) $('#changes_author_<%=tr_id %>').html(data.author_name)
$('#changes_time_<%=tr_id %>').html(data.time) $('#changes_time_<%=tr_id %>').html(data.time)

View File

@ -57,6 +57,8 @@
<%# cache [act, act.comments.count] do %> <%# cache [act, act.comments.count] do %>
<%= render :partial => 'course_news', :locals => {:activity => act, :user_activity_id => user_activity.id} %> <%= render :partial => 'course_news', :locals => {:activity => act, :user_activity_id => user_activity.id} %>
<%# end %> <%# end %>
<% when 'Attachment'%>
<%= render :partial => 'users/course_attachment', :locals => {:activity => act, :user_activity_id => user_activity.id} %>
<% when 'Message' %> <% when 'Message' %>
<%= render :partial => 'course_message', :locals => {:activity => act, :user_activity_id => user_activity.id, :is_course => 0, :is_board => 0} %> <%= render :partial => 'course_message', :locals => {:activity => act, :user_activity_id => user_activity.id, :is_course => 0, :is_board => 0} %>
<% when 'Poll' %> <% when 'Poll' %>

View File

@ -12,9 +12,11 @@
<%= labelled_form_for @version, :html => {:id => "popub_new_project_version_form", :remote => @is_setting ? true :false}, :is_setting => @is_setting, :is_index => @is_index, :is_create => @is_create do |f| %> <%= labelled_form_for @version, :html => {:id => "popub_new_project_version_form", :remote => @is_setting ? true :false}, :is_setting => @is_setting, :is_index => @is_index, :is_create => @is_create do |f| %>
<ul class="pro_newsetting_con mb15 "> <ul class="pro_newsetting_con mb15 ">
<li class="mb10 clear"> <li class="mb10 clear">
<label class=" fl"><span class="c_red f12">*</span>&nbsp;名称&nbsp;&nbsp;:&nbsp;</label> <label class="fl"><span class="c_red f12">*</span>&nbsp;名称&nbsp;&nbsp;:&nbsp;</label>
<%= f.text_field :name, :maxlength => 60, :class=>"w650 fl", :style=>"height: 28px;", :id => "popub_setting_version_name", :no_label => true %> <%= f.text_field :name, :maxlength => 60, :class => "w650 fl", :style=>"height: 28px;", :id => "popub_setting_version_name", :no_label => true %>
<p class="c_orange ml100" style="display: none" id="pupub_project_setting_version_title">标题不能为空</p> <div class="clear"></div>
<p class="c_orange ml50" style="display: none" id="pupub_project_setting_version_title">名称不能为空</p>
<p class="c_orange ml50" style="display: none" id="version_name_repetition_tip">名称已经被使用</p>
</li> </li>
<li class="mb10 clear"> <li class="mb10 clear">
<label class="fl ml5">&nbsp;描述&nbsp;&nbsp;:&nbsp;</label> <label class="fl ml5">&nbsp;描述&nbsp;&nbsp;:&nbsp;</label>
@ -63,13 +65,32 @@
var name = $.trim($("#popub_setting_version_name").val()); var name = $.trim($("#popub_setting_version_name").val());
if(name.length == 0) if(name.length == 0)
{ {
$("#version_name_repetition_tip").hide();
$("#pupub_project_setting_version_title").show(); $("#pupub_project_setting_version_title").show();
return false; return false;
} }
else else
{ {
$("#pupub_project_setting_version_title").hide(); $.ajax({
return true; url:"<%= judge_version_title_project_versions_path(:project_id => @project) %>",
type: "GET",
data: {
version_name: $.trim($("#popub_setting_version_name").val())
},
success:function(data){
if(data.result == true) {
$("#pupub_project_setting_version_title").hide();
$("#popub_new_project_version_form").submit();
hideModal();
return true;
}
else{
$("#pupub_project_setting_version_title").hide();
$("#version_name_repetition_tip").show();
return false;
}
}
});
} }
} }
</script> </script>

View File

@ -8,13 +8,15 @@
<div class="muban_popup_con " > <div class="muban_popup_con " >
<div class="clear mt30 ml20 " > <div class="clear mt30 ml20 " >
<%#= form_tag( url_for(:controller => 'versions', :action => 'update', :is_setting => true, :is_index => @is_index), :remote => true, :id => 'project_applied_form') do %> <%#= form_tag( url_for(:controller => 'versions', :action => 'update', :is_setting => true, :is_index => @is_index), :remote => true, :id => 'project_applied_form') do %>
<%= form_for :version, :url => project_versions_path(@project, :is_setting => @is_setting, :is_issue => @is_issue, :is_create => @is_create, :issue_project_id => @issue_project_id),:html => {:id=>"popub_new_project_version_form", :remote => @is_setting ? true : false} do |f| %> <%= form_for :version, :url => project_versions_path(@project, :is_setting => @is_setting, :is_issue => @is_issue, :is_create => @is_create, :issue_project_id => @issue_project_id),
:html => {:id => "popub_new_project_version_form", :remote => @is_setting ? true : false} do |f| %>
<%#= labelled_form_for @version, :html => {:id => "popub_new_project_version_form", :remote => true, :is_setting => true, :is_index => params[:is_index] } do |f| %> <%#= labelled_form_for @version, :html => {:id => "popub_new_project_version_form", :remote => true, :is_setting => true, :is_index => params[:is_index] } do |f| %>
<ul class="pro_newsetting_con mb15 "> <ul class="pro_newsetting_con mb15 ">
<li class="mb10 clear"> <li class="mb10 clear">
<label><span class="c_red f12">*</span>&nbsp;名称&nbsp;&nbsp;:&nbsp;</label> <label><span class="c_red f12">*</span>&nbsp;名称&nbsp;&nbsp;:&nbsp;</label>
<%= f.text_field :name, :maxlength => 60, :class=>"w650", :style=>"height: 28px;", :id => "popub_setting_version_name", :no_label => true %> <%= f.text_field :name, :maxlength => 60, :class=>"w650", :style=>"height: 28px;", :id => "popub_setting_version_name", :no_label => true %>
<p class="c_orange ml100" style=" margin-left:50px;display: none" id="pupub_project_setting_version_title">标题不能为空</p> <p class="c_orange ml100" style=" margin-left:50px;display: none" id="pupub_project_setting_version_title">名称不能为空</p>
<p class="c_orange ml100" style=" margin-left:50px;display: none" id="version_name_repetition_tip">名称已经被使用</p>
</li> </li>
<li class="mb10 clear"> <li class="mb10 clear">
<label class="ml5">&nbsp;描述&nbsp;&nbsp;:&nbsp;</label> <label class="ml5">&nbsp;描述&nbsp;&nbsp;:&nbsp;</label>
@ -44,11 +46,7 @@
// 新建版本 // 新建版本
function popub_project_version_commit() function popub_project_version_commit()
{ {
if(popub_regex_version_name()) popub_regex_version_name();
{
$("#popub_new_project_version_form").submit();
hideModal();
}
} }
function popub_regex_version_name() function popub_regex_version_name()
@ -56,13 +54,32 @@
var name = $.trim($("#popub_setting_version_name").val()); var name = $.trim($("#popub_setting_version_name").val());
if(name.length == 0) if(name.length == 0)
{ {
$("#version_name_repetition_tip").hide();
$("#pupub_project_setting_version_title").show(); $("#pupub_project_setting_version_title").show();
return false; return false;
} }
else else
{ {
$("#pupub_project_setting_version_title").hide(); $.ajax({
return true; url:"<%= judge_version_title_project_versions_path(:project_id => @project) %>",
type: "GET",
data: {
version_name: $.trim($("#popub_setting_version_name").val())
},
success:function(data){
if(data.result == true) {
$("#pupub_project_setting_version_title").hide();
$("#popub_new_project_version_form").submit();
hideModal();
return true;
}
else{
$("#pupub_project_setting_version_title").hide();
$("#version_name_repetition_tip").show();
return false;
}
}
});
} }
} }
</script> </script>

View File

@ -0,0 +1,22 @@
<div style="width:460px;">
<div class="sy_popup_top">
<h3 class="fl">提示</h3>
<a href="javascript:void(0);" class="sy_icons_close fr" onclick="hideModal()"></a>
<div class="cl"></div>
</div>
<div class="sy_popup_con" style="width:380px;">
<ul class="sy_popup_add" >
<li class="center mb5" style="line-height:20px;text-align: center;">
名称已经被使用
</li>
<li class="mt10">
<label class="mr27">&nbsp;</label>
<a href="javascript:void(0);" class="sy_btn_grey fl" onclick="hideModal()">取&nbsp;&nbsp;消</a>
<%#= link_to "确 定", {:controller => 'repositories', :action => 'forked'}, :class => "sy_btn_blue fl ml20", :onclick => "hideModal();", :target => "_blank" %>
<a href="javascript:void(0);" class="sy_btn_blue fl ml20" onclick="hideModal()">确&nbsp;&nbsp;定</a>
<div class="cl"></div>
</li>
</ul>
</div>
</div>

View File

@ -1 +1,6 @@
$("#pro_st_tbc_04").html('<%= escape_javascript( render :partial => 'projects/settings/new_versions') %>'); <% if @error %>
var htmlvalue = "<%= escape_javascript(render :partial => 'versions/version_name_repetition_tip') %>";
pop_box_new(htmlvalue,300,316);
<% else %>
$("#pro_st_tbc_04").html('<%= escape_javascript( render :partial => 'projects/settings/new_versions') %>');
<% end %>

View File

@ -985,6 +985,7 @@ RedmineApp::Application.routes.draw do
resources :versions, :except => [:index, :show, :edit, :update, :destroy] do resources :versions, :except => [:index, :show, :edit, :update, :destroy] do
collection do collection do
put 'close_completed' put 'close_completed'
get 'judge_version_title'
end end
end end
get 'versions.:format', :to => 'versions#index' get 'versions.:format', :to => 'versions#index'