Merge branch 'develop' into 'develop'

本周上线任务



See merge request !176
This commit is contained in:
陈晓婷 2017-03-17 14:32:20 +08:00
commit 4337a9d1fd
19 changed files with 149 additions and 81 deletions

View File

@ -310,7 +310,8 @@ class AttachmentsController < ApplicationController
@history.version = @old_history.nil? ? 1 : @old_history.version + 1
@history.save #历史记录保存完毕
#将最新保存的记录 数据替换到 需要修改的文件记录
@old_attachment.attributes = @attachment.attributes.dup.except("id","container_id","container_type","is_public","downloads", "quotes")
@old_attachment.attributes = @attachment.attributes.dup.except("id","container_id","container_type","is_public","downloads", "quotes",'is_publish','publish_time')
@status = @old_attachment.is_publish
# 如果附件描述被修改,则保存附件
unless params[:description] == @attachment.description
@old_attachment.description = params[:description]
@ -327,6 +328,14 @@ class AttachmentsController < ApplicationController
end
end
def update_attachment_publish_time
@attachment = Attachment.find params[:id]
@status = params[:status].to_i
if @status == 0
@attachment.update_attributes(:is_publish => 1, :publish_time => Time.now)
end
end
# prams[:type] => history 历史版本
def destroy
if params[:type] == "history"

View File

@ -627,13 +627,14 @@ class CoursesController < ApplicationController
member = @course.members.find params[:member_id]
student_role = member.member_roles.where("role_id = 10").first
teacher_role = member.member_roles.where("role_id = 7 || role_id = 9").first
joined = StudentsForCourse.where('student_id = ? and course_id = ?', member.user_id,@course.id)
joined.destroy_all
if member && member.deletable? && student_role
user_admin = CourseInfos.where("user_id = ? and course_id = ?", member.user_id, @course.id)
if user_admin.size > 0
user_admin.destroy_all
end
joined = StudentsForCourse.where('student_id = ? and course_id = ?', member.user_id,@course.id)
joined.destroy_all
if member.member_roles.count > 1&& student_role && teacher_role
student_role.destroy

View File

@ -636,7 +636,7 @@ class OrganizationsController < ApplicationController
end
def apply_subdomain
organization = Organization.find(params[:id])
@applied_message_count = AppliedMessage.where(:applied_id => organization.id, :name => params[:domain].downcase, :status => 1).count
@applied_message_count = AppliedMessage.where(:applied_id => organization.id, :name => params[:domain].downcase, :status => 0).count
# 如果申请过该名字,怎不能重复申请
if @applied_message_count > 0
@flag = 1
@ -670,7 +670,7 @@ class OrganizationsController < ApplicationController
end
# 自己处理自己的消息则不需要另外发送消息
if User.current.id != @applied_message.applied_user_id
AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_id => organization_id, :applied_type => 'Organization', :viewed => 0, :satus => 2, :applied_user_id => User.current.id, :name => org_domain.downcase)
OrgMessage.create(:user_id => params[:user_id], :organization_id => organization_id, :message_type => 'AgreeApplySubdomain', :message_id => organization_id, :sender_id => User.current.id, :viewed => 0, :content => params[:org_domain])
end
@applied_message.status = 2
@applied_message.updated_at = Time.now
@ -696,7 +696,7 @@ class OrganizationsController < ApplicationController
applied_messages.update_all(:status => 4, :viewed => true, :updated_at => Time.now)
# 自己处理自己的消息则不需要另外发送消息
if User.current.id != @applied_message.applied_user_id
AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_id => organization_id, :applied_type => 'Organization', :viewed => 0, :satus => 4, :applied_user_id => User.current.id, :name => org_domain.downcase)
OrgMessage.create(:user_id => params[:user_id], :organization_id => organization_id, :message_type => 'DisagreeApplySubdomain', :message_id => organization_id, :sender_id => User.current.id, :viewed => 0, :content => params[:org_domain])
end
@applied_message.status = 4
@applied_message.updated_at = Time.now

View File

@ -0,0 +1,17 @@
<div id="muban_popup_box" style="width:470px;">
<div class="muban_popup_top">
<h3 class="fl">更新成功</h3>
<a href="javascript:void(0);" class="muban_icons_close fr"></a>
<div class="cl"></div>
</div>
<div style='text-align:center;font-family: "微软雅黑","宋体"' class="mt20 f14">
是否保留您设置的延期发布时间:<%= format_time @old_attachment.publish_time %>
</div>
<div style='width:164px; margin:0 auto; margin-top: 15px; text-align:center; font-family: "微软雅黑","宋体"'>
<%=link_to '取消', update_attachment_publish_time_path(@old_attachment, :status => 0),:style => 'margin-left: 25px;', :class => 'sy_btn_grey fl mr5', :remote => true%>
<%=link_to '确认', update_attachment_publish_time_path(@old_attachment, :status => 1), :class => 'sy_btn_blue fl', :remote => true%>
<div class="cl"></div>
</div>
</div>

View File

@ -0,0 +1,2 @@
hideModal();
$(".re_search").submit(); // 为了刷新

View File

@ -1,7 +1,11 @@
<% if @flag %>
hideModal();
alert('更新成功');
$(".re_search").submit(); // 为了刷新
<% if @status == 1 %>
notice_box("更新成功");
$(".re_search").submit(); // 为了刷新
<% else %>
var htmlvalue = "<%=escape_javascript(render :partial => 'update_publish_time_box') %>";
pop_box_new(htmlvalue, 470, 140);
<% end %>
<%else%>
$("#upload_file_count").html('(更新失败)');
<%end %>

View File

@ -22,6 +22,7 @@
<div class="cl"></div>
<div class="courseSendCancel mr15" style="float:right;"><a href="javascript:void(0);" class="sendSourceText" onclick="clickCanel();">取消</a></div>
<div class="courseSendSubmit" style="float:right;"><a href="javascript:void(0);" class="sendSourceText" onclick="clickOK()">确定</a></div>
<span class="c_red fl" id="choose_member_notice"></span>
<div class="cl"></div>
</div>
<script type="text/javascript">
@ -82,10 +83,8 @@
}
function delete_student(id) {
$("#choose_member_notice").hide();
$("#choose_student_"+id).remove();
$("#student_"+id).one("click",function choose_student() {
$("#choose_students_list").append("<li id='choose_student_"+id+"' onclick='delete_student("+id+");'>"+$("#student_"+id).html()+"</li>");
});
}
$(document).ready(function(){

View File

@ -22,13 +22,19 @@ if(lists.length > 0) {
<%# if user.id.to_i != User.current.id.to_i && (@commit_student_ids.find{|e| e.to_i == user.id.to_i}).nil? && user.contestant_of_contest?(@contest) %>
<% if user.id.to_i != User.current.id.to_i && (@commit_student_ids.find{|e| e.to_i == user.id.to_i}).nil? %>
if (str.indexOf(<%=user.id.to_s %>) < 0 && choose_str.indexOf(<%=user.id.to_s %>) < 0) {
$("#student_<%=user.id %>").one("click",function choose_student() {
var li = "<li id='choose_student_<%=user.id %>'";
<% if user.id.to_i != User.current.id.to_i %>
li += " onclick='delete_student(<%=user.id %>);'";
<% end %>
li += ">" + $("#student_<%=user.id %>").html()+"<input name='member_id[]' value='<%=user.id %>' type='hidden'/></li>";
$("#choose_students_list").append(li);
$("#student_<%=user.id %>").on("click",function choose_student() {
if($("#choose_student_<%=user.id %>").length > 0){
$("#choose_member_notice").html("该成员已添加");
$("#choose_member_notice").show();
} else{
$("#choose_member_notice").hide();
var li = "<li id='choose_student_<%=user.id %>'";
<% if user.id.to_i != User.current.id.to_i %>
li += " onclick='delete_student(<%=user.id %>);'";
<% end %>
li += ">" + $("#student_<%=user.id %>").html()+"<input name='member_id[]' value='<%=user.id %>' type='hidden'/></li>";
$("#choose_students_list").append(li);
}
});
}
<%# elsif !user.contestant_of_contest?(@contest) %>
@ -37,7 +43,15 @@ if (str.indexOf(<%=user.id.to_s %>) < 0 && choose_str.indexOf(<%=user.id.to_s %>
//}
<% else %>
if (str.indexOf(<%=user.id.to_s %>) < 0) {
$("#student_<%=user.id %>").attr("title","该成员已加入其它分组");
$("#student_<%=user.id %>").on("click",function() {
$("#choose_member_notice").html("该成员已加入其它分组");
$("#choose_member_notice").show();
});
} else{
$("#student_<%=user.id %>").on("click",function() {
$("#choose_member_notice").html("该成员已添加");
$("#choose_member_notice").show();
});
}
<% end %>
<% end %>

View File

@ -12,7 +12,7 @@
<% elsif ma.course_message_type == "Comment" %>
<li><a href="<%=news_path(ma.course_message.commented.id) %>" target="_blank" title="<%=ma.course_message.author.show_name %> 评论了通知:<%=ma.course_message.commented.title%>"><span class="shadowbox_news_user"><%=ma.course_message.author.show_name %> </span>评论了通知:<%= ma.course_message.commented.title%></a></li>
<% elsif ma.course_message_type == "HomeworkCommon" && ma.status.nil? %>
<li><a href="<%= (!User.current.allowed_to?(:as_teacher, ma.course_message.course) && cur_user_works_for_homework(ma.course_message).nil?) ? new_student_work_path(:homework => ma.course_message.id) : student_work_index_path(:homework => ma.course_message.id) %>" target="_blank" title="<%=ma.course_message.user.show_name %>老师 发布了班级作业:作业标题:<%= ma.course_message.name%>"><span class="shadowbox_news_user"><%=ma.course_message.user.show_name %>老师 </span>发布了班级作业:作业标题:<%= ma.course_message.name%></a></li>
<li><a href="<%= student_work_index_path(:homework => ma.course_message.id) %>" target="_blank" title="<%=ma.course_message.user.show_name %>老师 发布了班级作业:作业标题:<%= ma.course_message.name%>"><span class="shadowbox_news_user"><%=ma.course_message.user.show_name %>老师 </span>发布了班级作业:作业标题:<%= ma.course_message.name%></a></li>
<% elsif ma.course_message_type == "HomeworkCommon" && ma.status == 1 %>
<li><a href="<%= student_work_index_path(:homework => ma.course_message.id) %>" target="_blank" title="<%=ma.course_message.user.show_name %>老师 发布的作业:作业标题:<%= ma.course_message.name%>的截止日期快到了"><span class="shadowbox_news_user"><%=ma.course_message.user.show_name %>老师 </span>发布的作业:作业标题:<%= ma.course_message.name%>的截止日期快到了</a></li>
<% elsif ma.course_message_type == "HomeworkCommon" && ma.status == 2 %>
@ -101,7 +101,7 @@
<% elsif ma.contest_message_type == "Comment" %>
<li><a href="<%=news_path(ma.contest_message.commented.id) %>" target="_blank" title="<%=ma.contest_message.author.show_name %> 回复了竞赛通知:<%=ma.contest_message.commented.title%>"><span class="shadowbox_news_user"><%=ma.contest_message.author.show_name %> </span>回复了竞赛通知:<%= ma.contest_message.commented.title%></a></li>
<% elsif ma.contest_message_type == "Work" && ma.status.nil? %>
<li><a href="<%= User.current.contestant_of_contest?(ma.contest_message.contest) && cur_user_works_for_work(ma.contest_message).nil? && ma.contest_message.work_status == 1 ? new_contestant_work_path(:work => ma.contest_message.id) : contestant_works_path(:work => ma.contest_message.id) %>" target="_blank" title="<%=ma.contest_message.user.show_name %> 发布了竞赛题:<%= ma.contest_message.name%>"><span class="shadowbox_news_user"><%=ma.contest_message.user.show_name %> </span>发布了竞赛题:<%= ma.contest_message.name%></a></li>
<li><a href="<%= contestant_works_path(:work => ma.contest_message.id) %>" target="_blank" title="<%=ma.contest_message.user.show_name %> 发布了竞赛题:<%= ma.contest_message.name%>"><span class="shadowbox_news_user"><%=ma.contest_message.user.show_name %> </span>发布了竞赛题:<%= ma.contest_message.name%></a></li>
<% elsif ma.contest_message_type == "Work" && ma.status == 1 %>
<li><a href="<%= contestant_works_path(:work => ma.contest_message.id) %>" target="_blank" title="<%=ma.contest_message.user.show_name %> 发布的竞赛题:<%= ma.contest_message.name%>的截止日期快到了"><span class="shadowbox_news_user"><%=ma.contest_message.user.show_name %> </span>发布的竞赛题:<%= ma.contest_message.name%>的截止时间快到啦</a></li>
<% elsif ma.contest_message_type == "Work" && ma.status == 2 %>

View File

@ -221,6 +221,7 @@
},
success:function(){
if(!$is_exist){
$("#apply_hint").text("");
$.ajax({
url:"<%= apply_subdomain_organization_path %>",
type:'post',

View File

@ -22,6 +22,7 @@
<div class="cl"></div>
<div class="courseSendCancel mr15" style="float:right;"><a href="javascript:void(0);" class="sendSourceText" onclick="clickCanel();">取消</a></div>
<div class="courseSendSubmit" style="float:right;"><a href="javascript:void(0);" class="sendSourceText" onclick="clickOK()">确定</a></div>
<span class="c_red fl" id="choose_member_notice"></span>
<div class="cl"></div>
</div>
<script type="text/javascript">
@ -82,10 +83,8 @@
}
function delete_student(id) {
$("#choose_member_notice").hide();
$("#choose_student_"+id).remove();
$("#student_"+id).one("click",function choose_student() {
$("#choose_students_list").append("<li id='choose_student_"+id+"' onclick='delete_student("+id+");'>"+$("#student_"+id).html()+"</li>");
});
}
$(document).ready(function(){

View File

@ -21,22 +21,39 @@ $("#all_students_list").empty();
}
<% if user.id.to_i != User.current.id.to_i && (@commit_student_ids.find{|e| e.to_i == user.id.to_i}).nil? && user.member_of_course?(@course) %>
if (str.indexOf(<%=user.id.to_s %>) < 0 && choose_str.indexOf(<%=user.id.to_s %>) < 0) {
$("#student_<%=user.id %>").one("click",function choose_student() {
var li = "<li id='choose_student_<%=user.id %>'";
<% if user.id.to_i != User.current.id.to_i %>
$("#student_<%=user.id %>").on("click",function choose_student() {
if($("#choose_student_<%=user.id %>").length > 0){
$("#choose_member_notice").html("该成员已添加");
$("#choose_member_notice").show();
} else{
$("#choose_member_notice").hide();
var li = "<li id='choose_student_<%=user.id %>'";
<% if user.id.to_i != User.current.id.to_i %>
li += " onclick='delete_student(<%=user.id %>);'";
<% end %>
li += ">" + $("#student_<%=user.id %>").html()+"<input name='member_id[]' value='<%=user.id %>' type='hidden'/></li>";
$("#choose_students_list").append(li);
<% end %>
li += ">" + $("#student_<%=user.id %>").html()+"<input name='member_id[]' value='<%=user.id %>' type='hidden'/></li>";
$("#choose_students_list").append(li);
}
});
}
<% elsif !user.member_of_course?(@course) %>
if (str.indexOf(<%=user.id.to_s %>) < 0) {
$("#student_<%=user.id %>").attr("title","该项目成员不是本课程的学生");
$("#student_<%=user.id %>").on("click",function() {
$("#choose_member_notice").html("该项目成员不是本班级的学生");
$("#choose_member_notice").show();
});
}
<% else %>
if (str.indexOf(<%=user.id.to_s %>) < 0) {
$("#student_<%=user.id %>").attr("title","该学生已加入其它分组");
$("#student_<%=user.id %>").on("click",function() {
$("#choose_member_notice").html("该学生已加入其它分组");
$("#choose_member_notice").show();
});
} else{
$("#student_<%=user.id %>").on("click",function() {
$("#choose_member_notice").html("该成员已添加");
$("#choose_member_notice").show();
});
}
<% end %>
<% end %>

View File

@ -1,17 +1,25 @@
<br>
<div style='width:470px;text-align:center;font-family: "微软雅黑","宋体"' class="f14">
<% if @syllabus.courses.not_deleted.empty? %>
确认删除该课程吗?
<% else %>
该课程下已经存在班级,不能删除。
<% end %>
</div>
</br>
<div style='width:164px; margin:0 auto; text-align:center; font-family: "微软雅黑","宋体"'>
<% if @syllabus.courses.not_deleted.empty? %>
<%=link_to '确认', syllabus_path(@syllabus), :class => 'Blue-btn fl', :method => 'delete'%>
<a href='javascript:void(0);' class='Blue-btn fl' onclick='hideModal()'>取消</a>
<% else %>
<a href='javascript:void(0);' class='Blue-btn' style="margin-left: 50px;" onclick='hideModal()'>取消</a>
<% end %>
<div id="muban_popup_box" style="width:470px;">
<div class="muban_popup_top">
<h3 class="fl">删除课程</h3>
<a href="javascript:void(0);" class="muban_icons_close fr"></a>
<div class="cl"></div>
</div>
<div style='text-align:center;font-family: "微软雅黑","宋体"' class="mt20 f14">
<% if @syllabus.courses.not_deleted.empty? %>
确认删除该课程吗?
<% else %>
该课程下已经存在班级,不能删除。
<% end %>
</div>
<div style='width:164px; margin:0 auto; margin-top: 15px; text-align:center; font-family: "微软雅黑","宋体"'>
<% if @syllabus.courses.not_deleted.empty? %>
<a href='javascript:void(0);' class='sy_btn_grey fl mr5' style="margin-left: 25px;" onclick='hideModal()'>取消</a>
<%=link_to '确认', syllabus_path(@syllabus), :class => 'sy_btn_blue fl', :method => 'delete'%>
<% else %>
<a href='javascript:void(0);' class='sy_btn_blue' onclick='hideModal()'>确定</a>
<% end %>
<div class="cl"></div>
</div>
</div>

View File

@ -1,2 +1,2 @@
var htmlvalue = "<%=escape_javascript(render :partial => 'delete_syllabus') %>";
pop_up_box(htmlvalue,500,30,50);
pop_box_new(htmlvalue, 470, 30);

View File

@ -46,7 +46,7 @@
<li>
<%=link_to '查看课程', syllabus_path(syllabus.id), :class => 'postOptionLink',:target =>'_blank', :title => '查看课程' %>
</li>
<% if User.current == syllabus.user %>
<% if User.current == syllabus.user || User.current.admin? %>
<li><%=link_to '删除课程', delete_syllabus_syllabus_path(syllabus), :class => 'postOptionLink', :remote => 'true'%></li>
<% end %>
</ul>

View File

@ -141,19 +141,11 @@
<span class="homepageNewsType fl">发布了竞赛题:</span>
</li>
<li class="messageInformationContents">
<% if User.current.contestant_of_contest?(ma.contest_message.contest) && cur_user_works_for_work(ma.contest_message).nil? && ma.contest_message.work_status == 1 %>
<%= link_to ma.contest_message.name, new_contestant_work_path(:work => ma.contest_message.id),
:class =>"#{!ma.viewed ? "newsBlack" : "newsGrey"}",
:target => '_blank',
:title => "竞赛题:#{ma.contest_message.name}"
%>
<% else %>
<%= link_to ma.contest_message.name, contestant_works_path(:work => ma.contest_message.id),
:class => "#{!ma.viewed ? "newsBlack" : "newsGrey"}",
:target => '_blank',
:title => "竞赛题:#{ma.contest_message.name}"
%>
<% end %>
<%= link_to ma.contest_message.name, contestant_works_path(:work => ma.contest_message.id),
:class => "#{!ma.viewed ? "newsBlack" : "newsGrey"}",
:target => '_blank',
:title => "竞赛题:#{ma.contest_message.name}"
%>
</li>
</div>
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>

View File

@ -66,23 +66,11 @@
<span class="homepageNewsType fl">发布了班级作业:</span>
</li>
<li class="messageInformationContents">
<% if !User.current.allowed_to?(:as_teacher, ma.course_message.course) && cur_user_works_for_homework(ma.course_message).nil? %>
<%= link_to "作业标题:" + ma.course_message.name, new_student_work_path(:homework => ma.course_message.id),
:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:target => '_blank',
:title => "作业标题:#{ma.course_message.name}"
%>
<!--:onmouseover =>"message_titile_show($(this),event)",-->
<!--:onmouseout => "message_titile_hide($(this))" %>-->
<% else %>
<%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id),
:class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:target => '_blank',
:title => "作业标题:#{ma.course_message.name}"
%>
<!--:onmouseover => "message_titile_show($(this),event)",-->
<!--:onmouseout => "message_titile_hide($(this))" %>-->
<% end %>
<%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id),
:class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:target => '_blank',
:title => "作业标题:#{ma.course_message.name}"
%>
</li>
</div>
<div style="display: none" class="message_title_red system_message_style">

View File

@ -41,3 +41,19 @@
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% if ma.message_type == 'DisagreeApplySubdomain'%>
<ul class="homepageNewsList fl">
<div class="longMessageWidth">
<li class="homepageNewsPortrait fl">
<div class="navHomepageLogo fl"><%= image_tag("/images/trustie_logo1.png", width: "30px", height: "30px", class: "mt3") %></div>
</li>
<li class="homepageNewsPubType fl">
<span class='homepageNewsType fl'>管理员拒绝了您的子域名申请:</span>
</li>
<li class="messageInformationContents">
<%= ma.content %>
</li>
</div>
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>

View File

@ -1222,6 +1222,7 @@ RedmineApp::Application.routes.draw do
get 'attachments/download/:id', :to => 'attachments#download', :id => /\d+/
get 'attachments/thumbnail/:id(/:size)', :to => 'attachments#thumbnail', :id => /\d+/, :size => /\d+/, :as => 'thumbnail'
get 'attachments/autocomplete'
get 'attachments/update_attachment_publish_time/:id',:to=>'attachments#update_attachment_publish_time',:as=>'update_attachment_publish_time'
match 'attachments/autocomplete', :to => 'attachments#autocomplete', :via => [:post]
post 'attachments/relationfile', to: 'attachments#add_exist_file_to_project', as: 'attach_relation'
post 'attachments/relationfiles', to: 'attachments#add_exist_file_to_projects', as: 'attach_relations'