Merge branch 'szzh' into develop

This commit is contained in:
cxt 2016-02-02 15:53:30 +08:00
commit 15c828197f
27 changed files with 2516 additions and 2123 deletions

View File

@ -770,6 +770,7 @@ class ApplicationController < ActionController::Base
end
def api_request?
return false if params[:controller] == 'at'
%w(xml json).include? params[:format]
end

View File

@ -442,10 +442,14 @@ class CoursesController < ApplicationController
@course = cs.create_course(params,User.current)[:course]
if params[:copy_course]
copy_course = Course.find params[:copy_course].to_i
@course.is_copy = 1
@course.is_copy = params[:copy_course].to_i
@course.open_student = copy_course.open_student
@course.publish_resource = copy_course.publish_resource
@course.save
#copy avatar
copy_avatar(@course, copy_course)
if params[:checkAll]
attachments = copy_course.attachments
attachments.each do |attachment|

View File

@ -458,9 +458,9 @@ class UsersController < ApplicationController
if(params[:type].blank? || params[:type] == "1") #全部
visible_course = Course.where("is_public = 1 && is_delete = 0")
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'} and (name like '%#{search}%')").order("created_at desc")
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%')").order("created_at desc")
elsif params[:type] == "2" #课程资源
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("created_at desc")
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%')").order("created_at desc")
end
@type = params[:type]
@limit = 15

View File

@ -67,7 +67,7 @@ module ApplicationHelper
# 获取项目/课程总分
# 发布缺陷 4分 回复缺陷 1分 提交一次 4分 讨论帖子 2分 回复帖子 1分 发布新闻 1分
def static_project_score obj
score = obj.issue_num * 4 + obj.issue_journal_num + obj.changeset_num * 4 + obj.board_num * 2 + obj.board_message_num + obj.news_num + obj.attach_num * 5
score = obj.issue_num * 4 + obj.issue_journal_num + (obj.changeset_num||0) * 4 + obj.board_num * 2 + obj.board_message_num + obj.news_num + obj.attach_num * 5
end
# 获取组织成员中文名字

View File

@ -1,9 +1,24 @@
module AvatarHelper
AVATAR_SIZE="50x50"
def copy_avatar(des, src)
src_file = disk_filename(src.class,src.id)
des_file = disk_filename(des.class,des.id)
FileUtils.cp(src_file, des_file) if File.exist?(src_file)
end
def avatar_image(source)
File.join(relative_path, avatar_directory(source.class), source.id.to_s)
def avatar_image(source, copyed=false)
source_type = source.class
source_id = source.id
course = Course.find(source_id) rescue nil
if course && copyed
source_id = course.is_copy
end
File.join(relative_path, avatar_directory(source_type), source_id.to_s)
end
def relative_path
@ -23,7 +38,18 @@ module AvatarHelper
end
def disk_filename(source_type,source_id,image_file=nil)
File.join(storage_path,avatar_directory(source_type),avatar_filename(source_id,image_file))
File.join(storage_path,avatar_directory(source_type),avatar_filename(source_id,image_file))
end
def copy_course?(source_type, source_id)
file= disk_filename(source_type, source_id)
if source_type == Course && !File.exist?(file)
course = Course.find(source_id) rescue nil
if course && course.is_copy>0
return true
end
end
false
end
def file_extension(filename=nil)
@ -35,7 +61,9 @@ module AvatarHelper
return File.join(relative_path,'AnonymousUser','0')
end
if source.class && source.id && File.exist?(disk_filename(source.class,source.id))
avatar_image(source)
avatar_image(source, false)
elsif copy_course?(source.class, source.id)
avatar_image(source, true)
else
File.join(relative_path,avatar_directory(source.class),'0')
end

View File

@ -72,7 +72,7 @@ class CourseActivity < ActiveRecord::Base
# message的status状态为0为正常为1表示创建课程时发送的message
message = Message.create(:subject => name, :content => content, :board_id => self.course.boards.first.id, :author_id => self.course.tea_id , :sticky => true, :status => true )
# 更新的目的是为了排序,因为该条动态的时间可能与课程创建的动态创建时间一直
message.course_acts.first.update_attribute(:updated_at, message.course_acts.first.updated_at + 1)
message.course_acts.first.update_attribute(:updated_at, message.course_acts.first.updated_at + 1) if message.course_acts.first
end
end
end

View File

@ -39,12 +39,13 @@
<input name="copy_course" value="<%=@course.id %>" style="display: none"/>
<li class="ml45 mb10">
<a href="javascript:void(0)" class="upimg fl">
<%= image_tag(url_to_avatar(@new_course), id: "avatar_image", :width =>"60", :height =>"60",:alt=>"上传图片")%>
<%= image_tag(url_to_avatar(@course), id: "avatar_image", :width =>"60", :height =>"60",:alt=>"上传图片")%>
</a> <!--<a href="javascript:void(0)" class="upbtn fl ml30" onclick="$('#upload_course_logo').click();">上传图片</a>-->
<!--</span>-->
<div class="cl"></div>
</li>
<li class="ml45">
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
<label><span class="c_red">*</span>&nbsp;<%= l(:label_tags_course_name)%>&nbsp;&nbsp;</label>

View File

@ -8,8 +8,13 @@
<div class="fl">
<p class="f12 mb5"><%=link_to e_course.name, course_path(e_course.id), :class => "hidden fl w170" %></p>
<p class="f12">
<span class="fl mr15 fontGrey4"><%= l(:project_module_attachments) %>(<%= link_to e_course.attachments.count, course_files_path(e_course), :class => "linkBlue2" %>)</span>
<span class="fl fontGrey4"><%= l(:label_homework_commont) %>(<%= link_to e_course.homework_commons.count, homework_common_index_path(:course=>e_course.id), :class => "linkBlue2" %>)</span></p>
<% if e_course.attachments.count > 0 %>
<span class="fl mr15 fontGrey4"><%= l(:project_module_attachments) %>(<%= link_to e_course.attachments.count, course_files_path(e_course), :class => "linkBlue2" %>)</span>
<% end %>
<% if e_course.homework_commons.count > 0 %>
<span class="fl fontGrey4"><%= l(:label_homework_commont) %>(<%= link_to e_course.homework_commons.count, homework_common_index_path(:course=>e_course.id), :class => "linkBlue2" %>)</span>
<% end %>
</p>
</div>
<div class="cl"></div>
</li>

View File

@ -5,7 +5,11 @@
$("#homework_end_time").val("");
$("#course_id").val($("#option_select").val());
$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new })%>");
homework_description_editor.html("");
//homework_description_editor.html("");
$("#homework_name_span").text("");
$("#homework_end_time_span").text("");
$("#homework_end_time_span").text("");
$("#homework_course_id_span").text("");
$("#homework_editor").toggle();
}
function cancel_edit(){
@ -26,7 +30,7 @@
<div class="cl"></div>
<!-- 老师身份才可以发布作业 -->
<div class="HomeWork mb10">
<div class="HomeWork mb10" nhname='homework_common_form'>
<%= form_for @homework do |f| %>
<input type="text" name="is_in_course" class="none" value="<%= @is_in_course%>"/>
<input type="text" name="course_activity" class="none" value="<%= @course_activity%>"/>

View File

@ -6,7 +6,11 @@
document.getElementById("anonymous_comment").checked = true;
$("#course_id").val($("#option_select").val());
$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new,:has_program => true,:has_group => true})%>");
homework_description_editor.html("");
//homework_description_editor.html("");
$("#homework_name_span").text("");
$("#homework_end_time_span").text("");
$("#homework_end_time_span").text("");
$("#homework_course_id_span").text("");
$("#homework_editor").toggle();
}
@ -44,7 +48,7 @@
<% if @is_teacher%>
<!-- 老师身份才可以发布作业 -->
<div class="HomeWork mb10">
<div class="HomeWork mb10" nhname='homework_common_form'>
<%= labelled_form_for @new_homework,:url => user_new_homework_users_path,:method => "post" do |f| %>
<div id="HomeWorkCon">
<%= render :partial => 'users/user_homework_form', :locals => { :homework => @new_homework,:f => f,:edit_mode => false,:select_course => false } %>

View File

@ -2,7 +2,7 @@
$("#reply_div_<%= @issue_id %>").html("<%= escape_javascript(render :partial => 'issues/issue_replies', :locals => {:issue => Issue.find( @issue_id),:replies_all_i=>0}) %>");
$("#div_issue_attachment_<%=@issue.id %>").html("<%= escape_javascript(render :partial => 'issues/issue_attachments', :locals => {:issue => Issue.find( @issue_id)}) %>");
$("#issue_edit").replaceWith('<%= escape_javascript(render :partial => 'issues/edit') %>')
sd_create_editor_from_data(<%= @issue.id%>, null, "100%");
sd_create_editor_from_data(<%= @issue.id%>, null, "100%", "<%=@issue.class.name%>");
issue_desc_editor = KindEditor.create('#issue_description',
{"width":"85%",
"resizeType":0,
@ -18,7 +18,7 @@
"fileManagerJson":"/kindeditor/filemanager"});
// $("#issue_test_<%#= @issue.id %>").html("<%#= escape_javascript(render :partial => 'issues/edit', :locals => {:issue => Issue.find( @issue_id)}) %>");
$(".homepagePostReplyBannerCount").html('回复(<%= Issue.find( @issue_id).journals.count %>)')
sd_create_editor_from_data(<%= @issue.id %>, null, "100%");
sd_create_editor_from_data(<%= @issue.id %>, null, "100%","<%=@issue.class.name%>");
<%else%>
$("#div_user_issue_reply_<%=@user_activity_id %>").html("<%= escape_javascript(render :partial => 'users/project_issue_reply', :locals => {:activity => @issue, :user_activity_id => @user_activity_id}) %>");
init_activity_KindEditor_data(<%= @user_activity_id %>,"","87%", 'UserActivity');

View File

@ -1,3 +1,3 @@
$("#reply_div_<%= @issue.id %>").html("<%= escape_javascript(render :partial => 'issues/issue_replies', :locals => {:issue => @issue,:replies_all_i=>0}) %>");
$(".homepagePostReplyBannerCount").html('回复(<%= Issue.find( @issue).journals.count %>)')
sd_create_editor_from_data(<%= @issue.id%>, null, "100%");
sd_create_editor_from_data(<%= @issue.id%>, null, "100%","<%=@issue.class.name%>");

View File

@ -1,3 +1,3 @@
$("#reply_div_<%= @issue.id %>").html("<%= escape_javascript(render :partial => 'issues/issue_replies', :locals => {:issue => @issue,:replies_all_i=>0}) %>");
$(".homepagePostReplyBannerCount").html('回复(<%= @issue.journals.count %>)')
sd_create_editor_from_data(<%= @issue.id%>, null, "100%");
sd_create_editor_from_data(<%= @issue.id%>, null, "100%","<%=@issue.class.name%>");

View File

@ -2,7 +2,7 @@ if($("#reply_message_<%= @jour.id%>").length > 0) {
$("#reply_message_<%= @jour.id%>").replaceWith("<%= escape_javascript(render :partial => 'issues/issue_reply_ke_form') %>");
$(function(){
$('input[name=quote]').val("<%= raw escape_javascript(@tempContent.html_safe) %>");
sd_create_editor_from_data(<%= @issue.id%>, null, "100%");
sd_create_editor_from_data(<%= @issue.id%>, null, "100%", "<%= @issue.class.name %>");
});
}else if($("#reply_to_message_<%= @issue.id%>").length >0) {
$("#reply_to_message_<%= @issue.id%>").replaceWith("<p id='reply_message_<%= @jour.id%>'></p>");

View File

@ -5,7 +5,7 @@ $("#issue_edit").replaceWith('<%= escape_javascript(render :partial => 'issues/e
$("#issue_detail").show();
$("#issue_edit").hide();
$("#reply_div_<%= @issue.id %>").html("<%= escape_javascript(render :partial => 'issues/issue_replies', :locals => {:issue => @issue,:replies_all_i=>0}) %>");
sd_create_editor_from_data(<%= @issue.id%>, null, "100%");
sd_create_editor_from_data(<%= @issue.id%>, null, "100%","<%=@issue.class.name%>");
$(".homepagePostReplyBannerCount").html('回复(<%= @issue.journals.count %>)')
//edit里的编辑器貌似显示不出来所以手动js生成。
issue_desc_editor = KindEditor.create('#issue_description',

View File

@ -1,9 +1,13 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: false, prettify: false, init_activity: false) %>
<%= javascript_include_tag "des_KindEditor" %>
<% end %>
<script>
function check_org_title(title)
$(function(){
init_des_data(150);
});
function check_org_title()
{
if($("#document_title").val().trim() == "")
{
@ -20,16 +24,17 @@
</div>
<div class="cl"></div>
<div>
<%= form_tag url_for(:controller => 'org_document_comments',:action => 'update', :id => @org_document.id, :flag => @flag, :org_subfield_id => params[:org_subfield_id]),:method => 'put', :id => 'new_org_document_form' do |f| %>
<div class="resources">
<div>
<div class="resources" nhname="new_topic_form">
<%= form_tag url_for(:controller => 'org_document_comments',:action => 'update', :id => @org_document.id, :flag => @flag, :org_subfield_id => params[:org_subfield_id]),:method => 'put', :id => 'new_org_document_form' do |f| %>
<div>
<input class="postDetailInput fl mr15" style="margin-bottom:15px;" name="org_document_comment[title]" id="document_title" style="resize:none;" onfocus = "$('#org_document_editor').show();" onblur="check_org_title();" value="<%= @org_document.title %>" />
</div>
<div id="doc_title_hint"></div>
<div class="cl"></div>
<div id="org_document_editor" >
<div class="mt10">
<%= kindeditor_tag 'org_document_comment[content]',@org_document.content, :editor_id => 'org_document_description_editor', :height => "150px" %>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='description_textarea' name="org_document_comment[content]"><%=@org_document.content.html_safe %></textarea>
<%#= kindeditor_tag 'org_document_comment[content]','', :editor_id => 'org_document_description_editor', :height => "150px" %>
</div>
<div class="cl"></div>
@ -43,13 +48,12 @@
</div>
<div class="cl"></div>
<div class="mt5">
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="org_document_description_editor.sync();$('#new_org_document_form').submit();">确定</a>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_topic_submit_btn">确定</a>
<span class="fr mr10 mt3">或</span>
<a href="javascript:void(0);" onclick="location=document.referrer;" class="fr mr10 mt3">取消</a>
<a href="javascript:void(0);" id="new_topic_cancel_btn" onclick="location=document.referrer;" class="fr mr10 mt3">取消</a>
<div class="cl"></div>
</div>
</div>
<% end %>
</div>
<% end %>
</div>

View File

@ -1,8 +1,12 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: false, prettify: false, init_activity: false) %>
<%= javascript_include_tag "des_KindEditor" %>
<% end %>
<script>
$(function(){
init_des_data(150);
});
function check_org_title()
{
if($("#document_title").val().trim() == "")
@ -28,15 +32,17 @@
location.href = document.referrer;
}
</script>
<%= form_tag organization_org_document_comments_path(:organization_id => @organization.id, :field_id => params[:field_id]), :id => 'new_org_document_form' do |f| %>
<div class="resources">
<div>
<div class="resources" nhname="new_topic_form">
<%= form_tag organization_org_document_comments_path(:organization_id => @organization.id, :field_id => params[:field_id]), :id => 'new_org_document_form' do |f| %>
<div>
<textarea class="postDetailInput fl mr15" style="margin-bottom:15px;" name="org_document_comment[title]" id="document_title" style="resize:none;" onfocus = "$('#org_document_editor').show();" placeholder="请输入文章标题"></textarea>
</div>
<div id="doc_title_hint"></div>
</div>
<div id="doc_title_hint">
</div>
<div id="org_document_editor" class="mt15" >
<div class="mt10">
<%= kindeditor_tag 'org_document_comment[content]','', :editor_id => 'org_document_description_editor', :height => "150px" %>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='description_textarea' name="org_document_comment[content]"></textarea>
<%#= kindeditor_tag 'org_document_comment[content]','', :editor_id => 'org_document_description_editor', :height => "150px" %>
</div>
<div class="cl"></div>
<p id="homework_course_id_span" class="c_red mt5"></p>
@ -49,12 +55,11 @@
<div class="cl"></div>
<div class="mt5">
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="create_org_document();">确定</a>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_topic_submit_btn">确定</a>
<span class="fr mr10 mt3">或</span>
<a href="javascript:void(0);" onclick="cancel_create_org_document();" class="fr mr10 mt3">取消</a>
<a href="javascript:void(0);" onclick="cancel_create_org_document();" id="new_topic_cancel_btn" class="fr mr10 mt3">取消</a>
<div class="cl"></div>
</div>
</div>
<% end %>
</div>
<% end %>

View File

@ -1,4 +1,4 @@
<div class="w985" style="padding:11px;"> <a href="javascript:void(0);" class="popupClose" onclick="hideModal()"></a>
<div class="w985"> <a href="javascript:void(0);" class="popupClose" onclick="hideModal()"></a>
<div class="f16 fb fontBlue mb10">选用题库中的题目</div>
<div class="subjectList fl mr10">
<a href="<%= user_homework_type_user_path(@user) %>" id="public_homeworks_choose" class="subjectChoose chooseActive fl" data-remote="true">公共题库</a>

View File

@ -23,6 +23,119 @@
$("#anonymous_comment").val(0);
}
}
function nh_reset_homework_form(params){
if(params.textarea.html() != "") {
cancel_edit();
} else {
params.form[0].reset();
params.textarea.empty();
if(params.editor != undefined){
params.editor.html(params.textarea.html());
}
}
}
function init_homework_form(params){
params.form.submit(function(){
var flag = false;
if(params.form.attr('data-remote') != undefined ){
flag = true
}
var is_checked = false;
checked_val();
if(!regex_homework_name()){
$("#homework_name").focus();
}
else if(!regex_homework_end_time()){
$("#homework_end_time").focus();
}
else if(!regex_homework_end_publish_time()){
$("#homework_end_time").focus();
}
else if(!regex_course_id()){
$("#course_id").focus();
}
else{
params.textarea.html(params.editor.html());
params.editor.sync();
is_checked = true;
}
/*var is_checked = nh_check_field({
issubmit:true,
content:params.editor,
contentmsg:params.contentmsg,
textarea:params.textarea
});*/
if(is_checked){
if(flag){
return true;
}else{
$(this)[0].submit();
return false;
}
}
return false;
});
}
function init_homework_editor(params){
params.textarea.removeAttr('placeholder');
var editor = params.kindutil.create(params.textarea, {
resizeType : 1,minWidth:"1px",width:"100%",minHeight:"30px",height:"30px",
items : ['code','emoticons','fontname',
'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|',
'formatblock', 'fontsize', '|','indent', 'outdent',
'|','imagedirectupload','table', 'media', 'preview',"more"
],
afterChange:function(){//按键事件
var edit = this.edit;
var body = edit.doc.body;
//paramsHeight = params.kindutil.removeUnit(this.height);
edit.iframe.height(150);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + 33, 150));
},
afterCreate:function(){
//init
var edit = this.edit;
var body = edit.doc.body;
edit.iframe[0].scroll = 'no';
body.style.overflowY = 'hidden';
//reset height
var edit = this.edit;
var body = edit.doc.body;
edit.html(params.textarea.innerHTML);
//paramsHeight = params.kindutil.removeUnit(this.height);
edit.iframe.height(150);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150));
}
}).loadPlugin('paste');
return editor;
}
KindEditor.ready(function(K){
$("div[nhname='homework_common_form']").each(function(){
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.form = $("form",params.div_form);
if(params.form==undefined || params.form.length==0){
return;
}
params.textarea = $("textarea[nhname='homework_textarea']",params.div_form);
params.cancel_btn = $("#new_message_cancel_btn");
params.submit_btn = $("#new_message_submit_btn");
if(params.textarea.data('init') == undefined) {
params.editor = init_homework_editor(params);
init_homework_form(params);
params.submit_btn.click(function () {
params.form.submit();
});
params.cancel_btn.click(function () {
reset_homework();
nh_reset_homework_form(params);
});
params.textarea.data('init', 1);
}
});
});
</script>
<% end %>
@ -70,10 +183,12 @@
<div id="homework_editor" style="display: <%= edit_mode ? 'block':'none'%>">
<div class="mt10">
<% if edit_mode %>
<%= f.kindeditor :description, :editor_id => 'homework_description_editor', :height => "150px", :owner_id => homework.id, :owner_type => OwnerTypeHelper::HOMEWORKCOMMON, at_id: homework.id, at_type: homework.class.to_s %>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='homework_textarea' name="homework_common[description]"><%=homework.description.html_safe %></textarea>
<%#= f.kindeditor :description, :editor_id => 'homework_description_editor', :height => "150px", :owner_id => homework.id, :owner_type => OwnerTypeHelper::HOMEWORKCOMMON, at_id: homework.id, at_type: homework.class.to_s %>
<% else %>
<%= hidden_field_tag :asset_id, params[:asset_id], :required => false, :style => 'display:none' %>
<%= f.kindeditor :description, :editor_id => 'homework_description_editor', :height => "150px",at_id: homework.id, at_type: homework.class.to_s %>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='homework_textarea' name="homework_common[description]"></textarea>
<%#= f.kindeditor :description, :editor_id => 'homework_description_editor', :height => "150px",at_id: homework.id, at_type: homework.class.to_s %>
<% end %>
</div>
<div class="cl"></div>
@ -89,17 +204,16 @@
<%= render :partial => 'users/user_homework_attachment', :locals => {:container => homework, :has_program=>!(edit_mode && homework.homework_type != 2), :has_group=>(!(edit_mode && homework.homework_type != 3))&& homework.student_works.empty?,:show_member => true} %>
</div>
<div class="mt5">
<% if edit_mode %>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="checked_val();submit_homework('edit_homework_common_<%= homework.id%>');">确定</a>
<a href="javascript:void(0);" id="new_message_submit_btn" class="BlueCirBtnMini fr">确定</a>
<span class="fr mr10 mt3">或</span>
<%#= link_to "取消",user_homeworks_user_path(User.current.id),:class => "fr mr10 mt3"%>
<a href="javascript:void(0);" class="fr mr10 mt3" onclick="cancel_edit();">取消</a>
<a href="javascript:void(0);" id="new_message_cancel_btn" class="fr mr10 mt3">取消</a>
<% else %>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="checked_val();submit_homework('new_homework_common');">发送</a>
<a href="javascript:void(0);" id="new_message_submit_btn" class="BlueCirBtnMini fr">发送</a>
<span class="fr mr10 mt3">或</span>
<a href="javascript:void(0);" class=" fr mr10 mt3" onclick="reset_homework();">取消</a>
<a href="javascript:void(0);" id="new_message_cancel_btn" class="fr mr10 mt3">取消</a>
<% end %>
<div class="cl"></div>
</div>

View File

@ -5,7 +5,11 @@
$("#homework_end_time").val("");
$("#course_id").val($("#option_select").val());
$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new,:has_program => true,:has_group => true })%>");
homework_description_editor.html("");
//homework_description_editor.html("");
$("#homework_name_span").text("");
$("#homework_end_time_span").text("");
$("#homework_end_time_span").text("");
$("#homework_course_id_span").text("");
$("#homework_editor").toggle();
}
@ -29,7 +33,7 @@
<% if @is_teacher%>
<!-- 老师身份才可以发布作业 -->
<div class="HomeWork mb10">
<div class="HomeWork mb10" nhname='homework_common_form'>
<% homework = HomeworkCommon.new %>
<% homework.homework_detail_manual = HomeworkDetailManual.new%>
<%= labelled_form_for homework,:url => user_new_homework_users_path,:method => "post" do |f| %>

View File

@ -1,4 +1,5 @@
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'users/show_user_homeworks') %>');
showModal('ajax-modal', '1040px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').parent().css("top","20%").css("left","25%").css("position","fixed").css("border","3px solid #269ac9");
$('#ajax-modal').parent().css("top","20%").css("left","25%").css("position","fixed").css("border","3px solid #269ac9");
$('#ajax-modal').css("margin","15px");

View File

@ -1,7 +1,7 @@
<% if @save_succ %>
<% if @user_activity_id %>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id,:is_activity=>@is_activity}) %>");
init_activity_KindEditor_data('<%= @user_activity_id%>', "", "87%", "UserActivity");
init_activity_KindEditor_data('<%= @user_activity_id%>', "", "87%", "JournalsForMessage");
<% else %>
<% if !@jfm.nil? && @jfm.jour_type == 'Principal' %>
$("#<%= @jfm.m_parent_id%>").children("div[nhname='reply_list']").prepend("<%= escape_javascript( render(:partial => 'users/user_jour_reply',:locals => {:reply=>@jfm} )) %>");

View File

@ -0,0 +1,53 @@
#coding=utf-8
# elasticsearch 在开发环境下也要打开,很烦人的
if Rails.env.development?
require 'elasticsearch/model'
module Elasticsearch
module Model
class NoObject
instance_methods.each do |m|
undef_method(m) unless [:object_id, :__send__, :undef_method, :method_missing].include?(m)
end
def method_missing(method, *args, &block)
puts "NoObject #{method} #{args}"
end
def NoObject.included(mod)
puts "#{self} included in #{mod}"
end
def self.extended(mod)
puts "#{self} extended in #{mod}"
end
def initialize
puts methods
end
end
def self.included(base)
base.instance_eval do
def settings(a)
end
def __elasticsearch__
@__elasticsearch__ ||= NoObject.new
end
end
base.class_eval do
def __elasticsearch__
@__elasticsearch__ ||= NoObject.new
end
end
end
end
end
end

View File

@ -1,9 +1,30 @@
class Subdomain
def initialize(opt={})
@opt = {}.merge(opt)
end
def matches?(request)
o = Organization.where(domain: request.subdomain).first
request.path_parameters[:id] = o.id if o
!o.nil?
puts request.path_parameters
o = Secdomain.where(subname: request.subdomain).first
if(@opt[:sub])
if o && o.sub_type == 2 && request.path_parameters[:sub_dir_name] == 'news'
request.path_parameters[:id] = o.pid
request.path_parameters[:controller] = 'org_subfields'
request.path_parameters[:action] = 'show'
return true
end
end
if o && o.controller
request.path_parameters[:id] = o.pid
request.path_parameters[:controller] = o.controller
request.path_parameters[:action] = o.action
return true
end
false
end
end

View File

@ -31,6 +31,15 @@ RedmineApp::Application.routes.draw do
# Enable Grack support
# mount Trustie::Grack.new, at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }, via: [:get, :post]
constraints(Subdomain.new) do
get '/', to: 'organizations#show'
end
constraints(Subdomain.new(sub: true)) do
get '/:sub_dir_name', to: 'fake#fake'
end
resources :shield_activities do
collection do
delete 'show_acts'
@ -76,16 +85,7 @@ RedmineApp::Application.routes.draw do
end
constraints(Subdomain.new) do
get '/', to: 'organizations#show'
end
get '/', to: 'organizations#show', defaults: { id: 5 }, constraints: {subdomain: 'micros'}
get '/', to: 'organizations#show', defaults: { id: 23 }, constraints: {subdomain: 'nubot'}
get '/', to: 'organizations#show', defaults: { id: 1 }, constraints: {subdomain: 'team'}
get '/', to: 'users#show', defaults: {id: 7}, constraints: {subdomain: 'whm'}
get '/', to: 'users#show', defaults: {id: 5}, constraints: {subdomain: 'yg'}
get '/', to: 'users#show', defaults: {id:11}, constraints: {subdomain: 'wt'}
resources :org_member do
member do

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,136 @@
function init_des_editor(params){
// var minHeight; //最小高度
var paramsHeight = params.height; //设定的高度
var paramsWidth = params.width == undefined ? "100%" : params.width;
var editor = params.kindutil.create(params.textarea, {
resizeType : 1,minWidth:"1px",width:paramsWidth,
height:"30px",// paramsHeight == undefined ? "30px":paramsHeight+"px",
minHeight:"30px",// paramsHeight == undefined ? "30px":paramsHeight+"px",
items : ['code','emoticons','fontname',
'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|',
'formatblock', 'fontsize', '|','indent', 'outdent',
'|','imagedirectupload','table', 'media', 'preview',"more"
],
afterChange:function(){//按键事件
//nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea});
var edit = this.edit;
var body = edit.doc.body;
edit.iframe.height(paramsHeight);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + 33, paramsHeight));
},
afterCreate:function(){
//init
var edit = this.edit;
var body = edit.doc.body;
edit.iframe[0].scroll = 'no';
body.style.overflowY = 'hidden';
//reset height
var edit = this.edit;
edit.html(params.textarea.innerHTML);
var body = edit.doc.body;
paramsHeight = paramsHeight == undefined ? params.kindutil.removeUnit(this.height) : paramsHeight;
edit.iframe.height(paramsHeight);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight), paramsHeight));
}
}).loadPlugin('paste');
return editor;
}
function nh_check_field(params){
var result=true;
if(!check_org_title()) {
result=false;
return result;
}
if(params.content!=undefined){
if(params.content.isEmpty()){
result=false;
}
if(params.content.html()!=params.textarea.html() || params.issubmit==true){
params.textarea.html(params.content.html());
params.content.sync();
if(params.content.isEmpty()){
params.contentmsg.html('内容不能为空');
params.contentmsg.css({color:'#ff0000'});
}else{
params.contentmsg.html('填写正确');
params.contentmsg.css({color:'#008000'});
}
}
}
return result;
}
function init_form(params){
params.form.submit(function(){
var flag = false;
if(params.form.attr('data-remote') != undefined ){
flag = true
}
var is_checked = nh_check_field({
issubmit:true,
//title:params.texttitle,
content:params.editor,
//titlemsg:params.titlemsg,
contentmsg:params.contentmsg,
textarea:params.textarea
});
if(is_checked){
if(flag){
return true;
}else{
$(this)[0].submit();
return false;
}
}
return false;
});
}
function nh_reset_form(params){
params.form[0].reset();
params.texttitle.empty();
params.textarea.empty();
if(params.editor != undefined){
params.editor.html(params.textarea.html());
}
params.contentmsg.hide();
params.titlemsg.html("");
}
//第二个参数是高度,可以传,可以不传
function init_des_data(){
var height = arguments[0] ? arguments[0] : undefined;
var width = arguments[1] ? arguments[1] : undefined;
KindEditor.ready(function (K) {
$("div[nhname='new_topic_form']").each(function () {
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.form = $("form", params.div_form);
if (params.form == undefined || params.form.length == 0) {
return;
}
//params.texttitle = $("#document_title", params.div_form);
params.textarea = $("textarea[nhname='description_textarea']", params.div_form);
//params.titlemsg = $("#doc_title_hint", params.div_form);
params.contentmsg = $("#homework_course_id_span", params.div_form);
params.cancel_btn = $("#new_topic_cancel_btn");
params.submit_btn = $("#new_topic_submit_btn");
params.height = height;
params.width = width;
if (params.textarea.data('init') == undefined) {
params.editor = init_des_editor(params);
init_form(params);
params.cancel_btn.click(function () {
nh_reset_form(params);
});
params.submit_btn.click(function () {
params.form.submit();
});
params.textarea.data('init', 1);
$(this).show();
}
});
});
}