Merge remote-tracking branch 'origin/szzh' into szzh

This commit is contained in:
lizanle 2015-10-09 14:25:50 +08:00
commit 98ba28ab3d
4 changed files with 68 additions and 41 deletions

View File

@ -244,13 +244,18 @@ class TagsController < ApplicationController
@taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,@taggable_id,@taggable_type) unless @taggable_id.blank? @taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,@taggable_id,@taggable_type) unless @taggable_id.blank?
@obj = get_object(@taggable_id,params[:taggableType]) unless @taggable_id.blank? @obj = get_object(@taggable_id,params[:taggableType]) unless @taggable_id.blank?
if @taggable_id.blank? #如果没有传tag_id那么直接更新tag_name就好了。但是要防止 重命名后的tag存在。 if @taggable_id.blank? #如果没有传tag_id那么直接更新tag_name就好了。但是要防止 重命名后的tag存在。
#看重命名后的tag是否存在。如果存在的话只需要更改taggings里边的id, if @course_id
if @rename_tag course = Course.find @course_id
@taggings = ActsAsTaggableOn::Tagging.where(" `taggings`.`tag_id` = #{ @tag_id} AND `taggings`.`taggable_type` = 'Attachment' ")#find_by_tag_id_and_taggable_type(@tag_id,@taggable_type) if course
@taggings.each { |t| t.update_attributes({:tag_id=> @rename_tag.id}) if t.tag_id != @rename_tag.id } course.attachments.each do |attachment|
ActsAsTaggableOn::Tag.find(@tag_id).update_attributes(:name=>@rename_tag_name)#并且将该tag改名 taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,attachment.id,attachment.class)
else #如果不存在那么就直接更新该tag名称为新的名称 if taggings
(ActsAsTaggableOn::Tag.find_by_name(@tag_name)).update_attributes(:name=>@rename_tag_name) taggings.delete
attachment.tag_list.add(@rename_tag_name.split(","))
attachment.save
end
end
end
end end
else else
if(@rename_tag.nil?) #这次命名的是新的tag if(@rename_tag.nil?) #这次命名的是新的tag

View File

@ -112,17 +112,10 @@ class UsersController < ApplicationController
case params[:type] case params[:type]
when nil when nil
@message_alls = [] @message_alls = []
system_message_types = MessageAll.where("message_type =?", "SystemMessage").order("created_at desc") messages = MessageAll.where("(user_id =? and message_type !=?) or message_type =?" ,@user, "SystemMessage", "SystemMessage").order("created_at desc")
messages = MessageAll.where("user_id =? and message_type !=?" ,@user, "SystemMessage").order("created_at desc")
messages.each do |message_all| messages.each do |message_all|
@message_alls << message_all.message @message_alls << message_all.message
end end
# 系统消息需要给每个人发送,之所以这样做,可以避免遍历系统所有用户
system_message_types.each do |system_message_type|
@message_alls << system_message_type.message
end
# 取出所有符合条件的按照创建时间排序
@message_alls = @message_alls.sort {|a,b| b.created_at <=> a.created_at}
when 'unviewed' when 'unviewed'
@message_alls = [] @message_alls = []
messages = MessageAll.where("user_id =?", @user).order("created_at desc") messages = MessageAll.where("user_id =?", @user).order("created_at desc")

View File

@ -246,36 +246,63 @@
tagId = id; tagId = id;
taggableType = type; taggableType = type;
width = parseInt(domEle.css('width').replace('px','')) >=100 ? parseInt(domEle.css('width').replace('px','')) : 100 width = parseInt(domEle.css('width').replace('px','')) >=100 ? parseInt(domEle.css('width').replace('px','')) : 100
domEle.html('<input name="" id="renameTagName" maxlength="<%=Setting.tags_max_length%>" minlength="<%= Setting.tags_min_length%>" style="width:'+width +'px;" value="'+name+'"/>'); domEle.html('<input name="" id="renameTagName" maxlength="<%=Setting.tags_max_length%>" minlength="<%= Setting.tags_min_length%>" style="width:'+width +'px;" value="'+name+'"/>');
domEle.parent().css("border","1px solid #ffffff"); domEle.parent().css("border","1px solid #ffffff");
$("#renameTagName").focus(); $("#renameTagName").focus();
} }
//监听所有的单击事件 //监听所有的单击事件
$(document.body).click(function(e){ $(function(){
isdb = false; //这是单击 $("#renameTagName").live("blur",function(){
node = document.elementFromPoint(e.clientX, e.clientY); updateTagName();
if(node.tagName == "INPUT"){ //如果是输入框的聚焦,那么就不要进行下去了 }).live("keypress",function(e){
isdb = true; //为了防止在编辑的时候又去单击其他tag去过滤。导致tag过滤不可用 if (e.keyCode == '13') {
return; updateTagName();
} }
if($("#renameTagName")[0] != undefined ){//存在renameTagName,则处于编辑状态 });
if($("#renameTagName").val().trim() == tagName){ //如果值一样,则恢复原来的状态 });
ele.parent().css("border","");
ele.parent().html(tagNameHtml);
}else{ //否则就要更新tag名称了 //执行修改TAGName方法
// if(confirm("是否将标签改为 "+ $("#renameTagName").val().trim())){ 去掉询问 function updateTagName(){
$.post( if(isdb){
'<%= update_tag_name_path %>', isdb = false;
{"taggableId": tagId, "taggableType": taggableType, "tagName": tagName, "renameName": $("#renameTagName").val().trim(),"courseId":<%= @course.id%>} if($("#renameTagName").val() == tagName){ //如果值一样,则恢复原来的状态
) ele.parent().css("border","");
// }else{ ele.parent().html(tagNameHtml);
// ele.parent().css("border","");
// ele.parent().html(tagNameHtml); }
// } else{
} $.post(
} '<%= update_tag_name_path %>',
}); {"taggableId": tagId, "taggableType": taggableType, "tagName": tagName, "renameName": $("#renameTagName").val().trim(),"courseId":<%= @course.id%>}
);
}
}
}
// $(document.body).click(function(e){
// isdb = false; //这是单击
// node = document.elementFromPoint(e.clientX, e.clientY);
// if(node.tagName == "INPUT"){ //如果是输入框的聚焦,那么就不要进行下去了
// isdb = true; //为了防止在编辑的时候又去单击其他tag去过滤。导致tag过滤不可用
// return;
// }
// if($("#renameTagName")[0] != undefined ){//存在renameTagName,则处于编辑状态
// if($("#renameTagName").val().trim() == tagName){ //如果值一样,则恢复原来的状态
// ele.parent().css("border","");
// ele.parent().html(tagNameHtml);
//
// }else{ //否则就要更新tag名称了
//// if(confirm("是否将标签改为 "+ $("#renameTagName").val().trim())){ 去掉询问
// $.post(
// '<%= update_tag_name_path %>',
// {"taggableId": tagId, "taggableType": taggableType, "tagName": tagName, "renameName": $("#renameTagName").val().trim(),"courseId":<%= @course.id%>}
// )
//// }else{
//// ele.parent().css("border","");
//// ele.parent().html(tagNameHtml);
//// }
// }
// }
// });
<%end %> <%end %>
</script> </script>

View File

@ -191,8 +191,10 @@
<div style="display: none" class="message_title_red system_message_style"> <div style="display: none" class="message_title_red system_message_style">
<p> <p>
<%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher, ma.course_message.course) ? '老师':'同学'%>您好! <%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher, ma.course_message.course) ? '老师':'同学'%>您好!
<%= User.current.eql?(ma.course_message.user) ?"您":(ma.course_message.user.lastname + ma.course_message.user.firstname + "老师") %>启动作业匿评失败,作业详情如下: <%= User.current.eql?(ma.course_message.user) ?"您":(ma.course_message.user.lastname + ma.course_message.user.firstname + "老师") %>启动作业匿评失败,
失败原因提交作品的人数低于2人
</p> </p>
<p>作业详情如下:</p>
<p>课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.term %>)</p> <p>课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.term %>)</p>
<p>作业标题:<span style="color:Red;"><%= ma.course_message.name %></span></p> <p>作业标题:<span style="color:Red;"><%= ma.course_message.name %></span></p>
</div> </div>