Merge branch 'szzh' into dev_hjq

This commit is contained in:
huang 2015-06-05 15:36:05 +08:00
commit 1f6308b97e
35 changed files with 1307 additions and 1270 deletions

View File

@ -15,11 +15,10 @@ class ActivityNotifysController < ApplicationController
end
if( query != nil )
logger.info('xxoo')
limit = 10;
@obj_count = query.count();
@obj_pages = Paginator.new @obj_count,limit,params['page']
list = query.order('id desc').limit(limit).offset(@obj_pages.offset).all();
list = query.order('is_read,id desc').limit(limit).offset(@obj_pages.offset).all();
events=[];
for item in list
event = item.activity;
@ -29,7 +28,6 @@ class ActivityNotifysController < ApplicationController
end
@events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
@controller_name = 'ActivityNotifys'
logger.info('aavv')
end
respond_to do |format|
format.html {render :template => 'courses/show', :layout => 'base_courses'}

View File

@ -62,6 +62,16 @@ class AttachmentsController < ApplicationController
render :action => 'file'
end
def pdf?(file)
file.downcase.end_with?(".pdf")
end
def direct_download
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
:type => detect_content_type(@attachment),
:disposition => 'attachment' #inline can open in browser
end
def download
# modify by nwb
# 下载添加权限设置
@ -69,20 +79,30 @@ class AttachmentsController < ApplicationController
if candown || User.current.admin? || User.current.id == @attachment.author_id
@attachment.increment_download
if stale?(:etag => @attachment.digest)
convered_file = File.join(Rails.root, "files", "convered_office", @attachment.disk_filename + ".html")
if File.exist?(convered_file)
send_file convered_file, :type => 'text/html; charset=utf-8', :disposition => 'inline'
if params[:force] == 'true'
direct_download
else
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
:type => detect_content_type(@attachment),
:disposition => 'attachment' #inline can open in browser
convered_file = @attachment.diskfile
#如果本身不是pdf文件则先寻找是不是已转换化如果没有则转化
unless pdf?(convered_file)
convered_file = File.join(Rails.root, "files", "convered_office", @attachment.disk_filename + ".pdf")
unless File.exist?(convered_file)
office = Trustie::Utils::Office.new(@attachment.diskfile)
office.conver(convered_file)
end
end
if File.exist?(convered_file) && pdf?(convered_file)
send_file convered_file, :type => 'application/pdf; charset=utf-8', :disposition => 'inline'
else
direct_download
end
end
end
else
render_403 :message => :notice_not_authorized
end
rescue => e
redirect_to "http: //" + (Setting.host_name.to_s) +"/file_not_found.html"
redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html"
end
#更新资源文件类型
@ -196,13 +216,13 @@ class AttachmentsController < ApplicationController
if @attachment.container.is_a?(News)
format.html { redirect_to_referer_or news_path(@attachment.container) }
elsif @attachment.container.is_a?(StudentWorksScore)
@is_destroy = true #根据ID删除页面对应的数据js刷新页面
@is_destroy = true unless params[:attachment_id] #根据ID删除页面对应的数据js刷新页面
format.js
elsif @attachment.container.is_a?(HomeworkCommon)
@is_destroy = true #根据ID删除页面对应的数据js刷新页面
@is_destroy = true unless params[:attachment_id] #根据ID删除页面对应的数据js刷新页面
format.js
elsif @attachment.container.is_a?(StudentWork)
@is_destroy = true #根据ID删除页面对应的数据js刷新页面
@is_destroy = true unless params[:attachment_id] #根据ID删除页面对应的数据js刷新页面
format.js
elsif @attachment.container.is_a?(Message)
format.html { redirect_to_referer_or new_board_message_path(@attachment.container) }
@ -226,7 +246,7 @@ class AttachmentsController < ApplicationController
end
format.js
end
end
end
def delete_homework

File diff suppressed because it is too large Load Diff

View File

@ -94,12 +94,12 @@ class MessagesController < ApplicationController
update_kindeditor_assets_owner ids,@message.id,OwnerTypeHelper::MESSAGE
end
# 与我相关动态的记录add start
if(@board.course_id>0) #项目的先不管
teachers = searchTeacherAndAssistant(@board.course);
if(@board && @board.course) #项目的先不管
teachers = searchTeacherAndAssistant(@board.course)
for teacher in teachers
if(teacher.user_id != User.current.id)
notify = ActivityNotify.new()
if(@board.course_id>0)
if(@board.course)
notify.activity_container_id = @board.course_id
notify.activity_container_type = 'Course'
else
@ -178,7 +178,7 @@ class MessagesController < ApplicationController
end
# 与我相关动态的记录add start
if(@board.course_id>0) #项目的先不管
if(@board && @board.course) #项目的先不管
notifyto_arr = {}
notifyto_arr[@topic.author_id] = @topic.author_id
if( params[:parent_topic] != nil && params[:parent_topic] != '')
@ -188,7 +188,7 @@ class MessagesController < ApplicationController
notifyto_arr.each do |k,user_id|
if(user_id != User.current.id)
notify = ActivityNotify.new()
if(@board.course_id>0)
if(@board.course)
notify.activity_container_id = @board.course_id
notify.activity_container_type = 'Course'
else

View File

@ -25,7 +25,7 @@ class UsersController < ApplicationController
menu_item :user_course, :only => :user_courses
menu_item :user_homework, :only => :user_homeworks
menu_item :user_project, :only => [:user_projects, :watch_projects]
menu_item :requirement_focus, :only => :watch_bids
# menu_item :requirement_focus, :only => :watch_bids
menu_item :requirement_focus, :only => :watch_contests
menu_item :user_newfeedback, :only => :user_newfeedback
@ -36,14 +36,14 @@ class UsersController < ApplicationController
#
before_filter :can_show_course, :only => [:user_courses,:user_homeworks]
before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_bids, :watch_contests, :info,
before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_contests, :info,
:user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index,
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
:activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities,:user_projects_index]
#edit has been deleted by huang, 2013-9-23
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses,
:user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
:watch_bids, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index,
:watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index,
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index]
before_filter :auth_user_extension, only: :show
@ -141,25 +141,25 @@ class UsersController < ApplicationController
##added by fq
def watch_bids
cond = 'bids.reward_type <> 1'
@bids = Bid.watched_by(@user).where('reward_type = ?', 1) # added by huang
@offset, @limit = api_offset_and_limit({:limit => 10})
@bid_count = @bids.count
@bid_pages = Paginator.new @bid_count, @limit, params['page']
@offset ||= @bid_pages.reverse_offset
unless @offset == 0
@bid = @bids.offset(@offset).limit(@limit).all.reverse
else
limit = @bid_count % @limit
@bid = @bids.offset(@offset).limit(limit).all.reverse
end
respond_to do |format|
format.html {
render :layout => 'base_users'
}
format.api
end
# cond = 'bids.reward_type <> 1'
# @bids = Bid.watched_by(@user).where('reward_type = ?', 1) # added by huang
# @offset, @limit = api_offset_and_limit({:limit => 10})
# @bid_count = @bids.count
# @bid_pages = Paginator.new @bid_count, @limit, params['page']
# @offset ||= @bid_pages.reverse_offset
# unless @offset == 0
# @bid = @bids.offset(@offset).limit(@limit).all.reverse
# else
# limit = @bid_count % @limit
# @bid = @bids.offset(@offset).limit(limit).all.reverse
# end
#
# respond_to do |format|
# format.html {
# render :layout => 'base_users'
# }
# format.api
# end
end
#new add by linchun
@ -215,24 +215,24 @@ class UsersController < ApplicationController
# added by huang
def user_homeworks
@membership = @user.memberships.all(:conditions => Project.visible_condition(User.current))
@memberships = []
@membership.each do |membership|
if membership.project.project_type == 1
@memberships << membership
end
end
@bid = []
@memberships.each do |membership|
@bid += membership.project.homeworks
end
@bid = @bid.group_by {|bid| bid.courses.first.id}
unless User.current.admin?
if !@user.active?
render_404
return
end
end
# @membership = @user.memberships.all(:conditions => Project.visible_condition(User.current))
# @memberships = []
# @membership.each do |membership|
# if membership.project.project_type == 1
# @memberships << membership
# end
# end
# @bid = []
# @memberships.each do |membership|
# @bid += membership.project.homeworks
# end
# @bid = @bid.group_by {|bid| bid.courses.first.id}
# unless User.current.admin?
# if !@user.active?
# render_404
# return
# end
# end
end
@ -757,7 +757,7 @@ class UsersController < ApplicationController
when '3' then
@obj = Issue.find_by_id(@obj_id)
when '4' then
@obj = Bid.find_by_id(@obj_id)
# @obj = Bid.find_by_id(@obj_id)
when '5' then
@obj = Forum.find_by_id(@obj_id)
when '6'
@ -800,7 +800,7 @@ class UsersController < ApplicationController
when '3' then
@obj = Issue.find_by_id(@obj_id)
when '4' then
@obj = Bid.find_by_id(@obj_id)
# @obj = Bid.find_by_id(@obj_id)
when '5' then
@obj = Forum.find_by_id(@obj_id)
when '6'

View File

@ -30,8 +30,7 @@ class ZipdownController < ApplicationController
if file_count > 0
zipfile = zip_bid bid
else
render file: 'public/no_file_found.html'
return
zipfile = {:message => "no file"}
end
elsif params[:obj_class] == "HomeworkCommon"
homework = HomeworkCommon.find params[:obj_id]
@ -41,8 +40,7 @@ class ZipdownController < ApplicationController
if file_count > 0
zipfile = zip_homework_common homework
else
render file: 'public/no_file_found.html'
return
zipfile = {:message => "no file"}
end
else
logger.error "[ZipDown#assort] ===> #{params[:obj_class]} unKown !!"
@ -62,7 +60,7 @@ class ZipdownController < ApplicationController
unless homework.attachments.empty?
zipfile = zip_homework_by_user homework
send_file zipfile.file_path, :filename => ((homework.user.user_extensions.nil? || homework.user.user_extensions.student_id.nil?) ? "" : homework.user.user_extensions.student_id) +
"_" + (homework.user.lastname.nil? ? "" : homework.user.lastname) + (homework.user.firstname.nil? ? "" : homework.user.firstname) +
"_" + homework.user.show_name +
"_" + homework.name + ".zip", :type => detect_content_type(zipfile.file_path) if(zipfile)
else
render file: 'public/no_file_found.html'
@ -150,7 +148,7 @@ class ZipdownController < ApplicationController
end
end
out_file = find_or_pack(homework_attach.bid_id, homework_attach.user_id, digests.sort){
zipping("#{homework_attach.user.lastname}#{homework_attach.user.firstname}_#{((homework_attach.user.user_extensions.nil? || homework_attach.user.user_extensions.student_id.nil?) ? "" : homework_attach.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip",
zipping("#{homework_attach.user.show_name}_#{((homework_attach.user.user_extensions.nil? || homework_attach.user.user_extensions.student_id.nil?) ? "" : homework_attach.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip",
homeworks_attach_path, OUTPUT_FOLDER, true, not_exist_file)
}
end
@ -170,7 +168,7 @@ class ZipdownController < ApplicationController
end
end
out_file = find_or_pack(work.homework_common_id, work.user_id, digests.sort){
zipping("#{work.user.lastname}#{work.user.firstname}_#{((work.user.user_extensions.nil? || work.user.user_extensions.student_id.nil?) ? "" : work.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip",
zipping("#{work.user.show_name}_#{((work.user.user_extensions.nil? || work.user.user_extensions.student_id.nil?) ? "" : work.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip",
homeworks_attach_path, OUTPUT_FOLDER, true, not_exist_file)
}
end

View File

@ -72,8 +72,8 @@ class Attachment < ActiveRecord::Base
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
before_save :files_to_final_location
after_create :office_conver, :be_user_score ,:act_as_forge_activity# user_score
after_update :be_user_score
after_create :office_conver, :be_user_score,:act_as_forge_activity# user_score
after_update :office_conver, :be_user_score
after_destroy :delete_from_disk,:down_user_score
# add by nwb
@ -259,12 +259,14 @@ class Attachment < ActiveRecord::Base
end
def office_conver
saved_path = File.join(Rails.root, "files", "convered_office")
unless Dir.exist?(saved_path)
Dir.mkdir(saved_path)
end
convered_file = File.join(saved_path, self.disk_filename + ".html")
OfficeConverTask.new.conver(self.diskfile, convered_file)
# 不在这里做后台转换,换为点击时做转换
# return unless %w(Project Course).include? (self.container_type)
# saved_path = File.join(Rails.root, "files", "convered_office")
# unless Dir.exist?(saved_path)
# Dir.mkdir(saved_path)
# end
# convered_file = File.join(saved_path, self.disk_filename + ".pdf")
# OfficeConverTask.new.conver(self.diskfile, convered_file)
end
# Copies the temporary file to its final location

View File

@ -277,15 +277,18 @@ class User < Principal
end
def show_name
name = ""
unless self.user_extensions.nil?
if self.user_extensions.identity == 2
firstname
name = firstname
else
lastname+firstname
name = lastname+firstname
end
else
lastname+firstname
name = lastname+firstname
end
name = name.empty? || name.nil? ? login : name
name
end
## end

View File

@ -255,7 +255,9 @@ class UsersService
watcher.push(params[:user_id])
scope = scope.where("id not in (?)",watcher)
end
scope = scope.like(params[:name],search_by)
#scope = scope.like(params[:name],search_by)
scope = scope.where("( LOWER(login) LIKE ? or LOWER(concat(lastname, firstname)) LIKE ? or LOWER(mail) LIKE ? )",
"%#{params[:name]}%","%#{params[:name]}%","%#{params[:name]}%")
end
#modify by yutao 2015/5/18 没有params[:user_id]参数时去掉"id not in (?)"条件 end
else

View File

@ -1,11 +1,11 @@
<style type="text/css">
div.ke-toolbar{display:none;width:400px;border:none;background:none;padding:0px 0px;}
/*div.ke-toolbar{display:none;width:400px;border:none;background:none;padding:0px 0px;}
span.ke-toolbar-icon{line-height:26px;font-size:14px;padding-left:26px;}
span.ke-toolbar-icon-url{background-image:url( /images/public_icon.png )}
div.ke-toolbar .ke-outline{padding:0px 0px;line-height:26px;font-size:14px;}
span.ke-icon-emoticons{background-position:0px -671px;width:50px;height:26px;}
span.ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;}
div.ke-toolbar .ke-outline{border:none;}
div.ke-toolbar .ke-outline{border:none;}*/
.break_word {width:100%;}
</style>
<script type="text/javascript">
@ -33,7 +33,8 @@
else if (window.attachEvent)
window.attachEvent("onload", buildsubmenus)
</script>
<%= javascript_include_tag "/assets/kindeditor/kindeditor-min" %>
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<%#= javascript_include_tag "/assets/kindeditor/kindeditor-min" %>
<% if @project %>
<%= render :partial => 'project_show', locals: {project: @project} %>
@ -123,21 +124,20 @@ function nh_init_board(params){
if(params.textarea.data('init') == undefined){
//初始化编辑器
var editor = params.kindutil.create(params.textarea, {
resizeType : 1,
allowPreviewEmoticons : false,
allowImageUpload : false,
minWidth:"1px",
width:"565px",
items : ['emoticons'],
// allowPreviewEmoticons : false,
// allowImageUpload : false,
resizeType : 1,minWidth:"1px",width:"565px",height:"150px",
allowFileManager:true,uploadJson:"/kindeditor/upload",
fileManagerJson:"/kindeditor/filemanager",
afterChange:function(){//按键事件
nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea});
},
afterCreate:function(){
var toolbar = $("div[class='ke-toolbar']",params.about_talk);
$(".ke-outline>.ke-toolbar-icon",toolbar).append('表情');
params.toolbar_container.append(toolbar);
// var toolbar = $("div[class='ke-toolbar']",params.about_talk);
// $(".ke-outline>.ke-toolbar-icon",toolbar).append('表情');
// params.toolbar_container.append(toolbar);
}
});
}).loadPlugin('paste');
//主题输入框按键事件
params.inputsubject.keyup(function(){

View File

@ -3,7 +3,9 @@
<a class="fl about_me" href="<%=course_path(@course)%>"><%= l(:label_activity)%></a>
<h2 class="fl project_h2">与我相关</h2>
<div class="fr mt10 mr5 c_grey02">
<label class="mr5" style="cursor:pointer;" data-href="<%= course_activity_notifys_path(@course) %>/chang_read_flag" nhname='nh_act_link_all'>全部标为已读</label>
<a class="c_dblue">
<label class="mr5" style="cursor:pointer;" data-href="<%= course_activity_notifys_path(@course) %>/chang_read_flag" nhname='nh_act_link_all'>全部标为已读</label>
</a>
</div>
<% else %>
<h2 class="fl project_h2"><%= l(:label_activity)%></h2>
@ -35,7 +37,7 @@
:class => "problem_tit c_dblue fl fb",'data-type'=>e.event_type,
'data-notify-id'=>(e.respond_to?('get_notify_id') ? e.get_notify_id : ''),:nhname=>"nh_act_link",
'data-href'=>(course_activity_notifys_path(@course)+"/chang_read_flag?an_id="+(e.respond_to?('get_notify_id') ? e.get_notify_id : '').to_s)%>
<%if @controller_name=='ActivityNotifys' && !e.get_notify_is_read%>
<%if @controller_name=='ActivityNotifys' && e.get_notify_is_read!=1%>
<span nhname="nh_act_flag" class="ml10 fl"><img src="/images/new.png" width="35" height="15"/></span>
<%end%>
<br />
@ -49,6 +51,8 @@
</div><!--课程动态 end-->
<% end%>
<% end%>
<% elsif @controller_name=='ActivityNotifys' %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end%>
<% if @obj_pages.next_page.nil? && @controller_name!='ActivityNotifys' %>
<div class="problem_main">

View File

@ -31,7 +31,7 @@
}
showModal('ajax-modal', '513px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;padding-left: 513px;'><a href='javascript:void(0)' onclick='closeModal()'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='closeModal()' style='margin-left: 480px;'><img src='/images/bid/close.png' width='26px' height='26px' /></a>");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("popbox_polls");
}

View File

@ -31,15 +31,16 @@
<%= link_to("选入我的其他课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select c_lorange",:remote => true) if has_course?(User.current,file) %>
<% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %>
<span id="is_public_<%= file.id %>">
<%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open c_blue",:method => :post %>
</span>
<span id="is_public_<%= file.id %>">
<%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open c_blue",:method => :post %>
</span>
<% else %>
<!-- <#%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %> -->
<% end %>
<% else %>
<%= link_to("选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select c_lorange",:remote => true) if has_course?(User.current,file) %>
<% end %>
<%= link_to '下载',download_named_attachment_path(file.id, file.filename, force: true),class: 'f_l re_open' %>
<% else %>
<% end %>
</div>
@ -65,4 +66,4 @@
<ul class="wlist">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
</ul>
<div class="cl"></div>
<div class="cl"></div>

View File

@ -30,6 +30,7 @@
<% else %>
<%= link_to(l(:label_slected_to_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %>
<% end %>
<%= link_to '下载',download_named_attachment_path(file.id, file.filename, force: true),class: 'f_l re_open' %>
<% end %>
</div>
<div class="cl"></div>
@ -37,7 +38,7 @@
<p class="f_l c_grey02 font">文件大小:<%= number_to_human_size(file.filesize) %></p>
<%= link_to( l(:button_delete), attachment_path(file),
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if manage_allowed && file.container_id == project.id && file.container_type == "Project"%>
<p class="f_r c_grey02" ><%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>&nbsp;&nbsp;|&nbsp;&nbsp;下载<%= file.downloads %>&nbsp;&nbsp;|&nbsp;&nbsp;引用<%= file.quotes.nil? ? 0:file.quotes %> </p>
<p class="f_r c_grey02" ><%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>&nbsp;&nbsp;|&nbsp;&nbsp;下载<%= file.downloads %>&nbsp;&nbsp;|&nbsp;&nbsp;引用<%= file.quotes.nil? ? 0:file.quotes %> </p>
</div>
<div class="cl"></div>
<div class="tag_h">
@ -51,4 +52,4 @@
<ul class="wlist">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
</ul>
<div class="cl"></div>
<div class="cl"></div>

View File

@ -5,7 +5,7 @@
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'upload_show_project',:locals => {:project => project}) %>');
showModal('ajax-modal', '513px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;padding-left: 513px;'><a href='javascript:void(0)' onclick='closeModal()'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='closeModal()' style='margin-left: 480px;'><img src='/images/bid/close.png' width='26px' height='26px' /></a>");
$('#ajax-modal').parent().css("top","40%").css("left","36%");
$('#ajax-modal').parent().addClass("popbox_polls");
}

View File

@ -6,6 +6,6 @@
showModal('ajax-modal', '513px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;padding-left: 513px;'><a href='javascript:void(0)' onclick='closeModal()'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='closeModal()' style='margin-left: 480px;'><img src='/images/bid/close.png' width='26px' height='26px' /></a>");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("popbox_polls");

View File

@ -6,6 +6,6 @@
showModal('ajax-modal', '513px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;padding-left: 513px;'><a href='javascript:void(0)' onclick='closeModal()'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='closeModal()' style='margin-left: 480px;'><img src='/images/bid/close.png' width='26px' height='26px' /></a>");
$('#ajax-modal').parent().css("top","30%").css("left","35%");
$('#ajax-modal').parent().addClass("popbox_polls");

View File

@ -16,9 +16,9 @@
<div class="problem_main">
<%= link_to(image_tag(url_to_avatar(homework.user), :width => "42", :height => "42"), user_path(homework.user), :class => "problem_pic fl") %>
<div class="problem_txt fl mt5">
<%= link_to(homework.user.lastname+homework.user.firstname, user_path(homework.user),:class => 'problem_name fl') %>
<%= link_to(homework.user.lastname+homework.user.firstname, user_path(homework.user),:class => 'problem_name fl',:target => "_blank") %>
<span class="fl"> <%= l(:label_user_create_project_homework) %></span>
<%= link_to(homework.name, student_work_index_path(:homework => homework.id), :class => 'problem_tit fl fb c_dblue') %>
<%= link_to(homework.name, student_work_index_path(:homework => homework.id), :class => 'problem_tit fl fb c_dblue',:target => "_blank") %>
<div class="cl mb5"></div>
<p class="fl ">
<%= l(:lebel_homework_commit)%>

View File

@ -218,9 +218,8 @@
</td>
</tr>
<% end %>
<% unless @user.user_extensions.nil?&&@user.user_extensions.location.empty?%>
<% if @user.user_extensions && @user.user_extensions.location && !@user.user_extensions.location.empty?%>
<tr>
<td style=" float: right" width="70px">
<span style="float: right"> <%= l(:label_location) %></span>
</td>

View File

@ -131,9 +131,9 @@
<%= link_to image_tag(url_to_avatar(reply.author), :class => "avatar"), user_path(reply.author) %>
</td>
<td class="comments" style="word-wrap: break-word;word-break: break-all;">
<div class="reply_content" >
<%=h sanitize(reply.content.html_safe) %>
</div>
<div class="reply_content" >
<%=h sanitize(reply.content.html_safe) %>
</div>
<p>
<% if reply.attachments.any?%>
<% options = {:author => true, :deletable => reply.deleted_attach_able_by?(User.current) } %>
@ -183,4 +183,4 @@
});
};
$("img").removeAttr("align");
</script>
</script>

View File

@ -36,7 +36,7 @@
</span>
<% if @show_all%>
<input type="text" value="<%= @name%>" placeholder="昵称、学号、姓名搜索" class="min_search ml10 fl" onkeypress="SearchByName($(this),'<%= student_work_index_path(:homework => @homework.id)%>',event);">
<a class="student_work_search fl" onclick="SearchByName($(this).prev(),'<%= student_work_index_path(:homework => @homework.id)%>');" href="javascript:void(0)">搜索</a>
<a class="student_work_search fl" onclick="SearchByName_1($(this).prev(),'<%= student_work_index_path(:homework => @homework.id)%>');" href="javascript:void(0)">搜索</a>
<% end%>
<% if @is_teacher%>
<div class="fr">

View File

@ -30,8 +30,8 @@
<td rowspan="2" >
<div class="project-search" style="float: right">
<!--label for="user_browse_label"><%#= l(:label_user_search_type) %></label-->
<%= select_tag(:search_by,options_for_select([["昵称","0"],["姓名","1"],["邮箱","2"]],@search_by), :onchange => "searchByChange();" ) %>
<%= text_field_tag 'name', params[:name], :size => 30 %>
<%= select_tag(:search_by,options_for_select([["昵称","0"],["姓名","1"],["邮箱","2"]],@search_by), :onchange => "searchByChange();",:style=>'display:none;' ) %>
<%= text_field_tag 'name', params[:name], :size => 30, :placeholder=>'昵称/姓名/邮箱' %>
<input type="text" name="search_by_input" hidden="hidden;" id="search_by_input" value="0">
<input type="button" class="enterprise" value="<%= l(:label_search) %>" onclick="searchUser();"/>
<%#= submit_tag l(:label_search), :class => "enterprise", :name => nil %>

View File

@ -73,11 +73,13 @@ form #search_by
{
if($("#search_type").val() == "users")
{
$("#search_by").show();
$("#q").attr('placeholder','昵称/姓名/邮箱');
// $("#search_by").show();
}
else
{
$("#search_by").hide();
$("#q").attr('placeholder',"<%=l('welcome.search.information')%>");
}
}
@ -93,7 +95,7 @@ form #search_by
<%= text_field_tag :q, nil, :placeholder => l('welcome.search.information'), style:"float:left; width:185px;" %>
<input type="text" name="search_by_input" style="display: none" id="search_by_input" value="0">
<%= select_tag(:search_type, options_for_select(select_option), :onchange => "searchTypeChange();", :style => "float:right" ) %>
<%= select_tag(:search_by,options_for_select([[l('welcome.search.select.userinfo.nickname'),"0"],[l('welcome.search.select.userinfo.showname'),"1"],[l('welcome.search.select.userinfo.email'),"2"]]), :onchange => "searchByChange();",:style => "float:right" ) %>
<%= select_tag(:search_by,options_for_select([[l('welcome.search.select.userinfo.nickname'),"0"],[l('welcome.search.select.userinfo.showname'),"1"],[l('welcome.search.select.userinfo.email'),"2"]]), :onchange => "searchByChange();",:style => "float:right;display:none;" ) %>
</div>
<%#= hidden_field_tag 'project_type', project_type %>
</div>

View File

@ -1,3 +0,0 @@
if Rails.env.production?
config.cache_store = :redis_store, 'redis://localhost:6379/0/cache', { expires_in: 90.minutes }
end

View File

@ -67,6 +67,8 @@ module RedmineApp
# Do not include all helpers
config.action_controller.include_all_helpers = false
config.action_view.sanitized_allowed_tags = 'div', 'p', 'span', 'img', 'embed'
if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
instance_eval File.read(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
end

View File

@ -257,7 +257,6 @@ RedmineApp::Application.routes.draw do
post 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy'
# boards end
# delete 'bids/homework', :to => 'bids#homework_destroy'
# Misc issue routes. TODO: move into resources
match '/issues/auto_complete', :to => 'auto_completes#issues', :via => :get, :as => 'auto_complete_issues'
@ -764,7 +763,6 @@ RedmineApp::Application.routes.draw do
delete 'attachment/:id', :to => 'attachments#delete_homework'
match 'new_join', :to => 'courses#new_join', :as => 'try_join'
match 'new_join_group', :to => 'courses#new_join_group', :as => 'try_join_group'
# match 'new_join_in_contest', :to => 'bids#new_join', :as => 'try_join_in_contest'
match 'projects/:id/respond', :to => 'projects#project_respond', :via => :post
########################

View File

@ -451,7 +451,7 @@ Redmine::MenuManager.map :user_enterprise_menu do |menu|
menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.host_name}
menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.host_user}
# menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.host_user}
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.host_user}
end
@ -459,7 +459,7 @@ Redmine::MenuManager.map :user_menu_self do |menu|
menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.host_name }
menu.push :user_information, {:controller => 'users', :action => 'info', :host => Setting.host_user}
menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.host_name}
menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.host_user}
# menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.host_user}
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.host_user}
end

View File

@ -1,16 +1,18 @@
#coding=utf-8
namespace :office do
desc "conver any files to html"
task :conver => :environment do
all_count = Attachment.count
all_count = Attachment.where(["container_type IN (?)", %w(Project Course)]).count
i = 0
Attachment.find_each do |a|
Attachment.where(["container_type IN (?)", %w(Project Course)]).find_each do |a|
i += 1
puts "process [#{i}/#{all_count}] => id #{a.id}"
saved_path = File.join(Rails.root, "files", "convered_office")
unless Dir.exist?(saved_path)
Dir.mkdir(saved_path)
end
convered_file = File.join(saved_path, a.disk_filename + ".html")
convered_file = File.join(saved_path, a.disk_filename + ".pdf")
office = Trustie::Utils::Office.new(a.diskfile)
if office.conver(convered_file)
puts "process ok: #{convered_file} "

View File

@ -1,3 +1,5 @@
#coding=utf-8
module Trustie
module Utils
class Office
@ -7,7 +9,7 @@ module Trustie
end
def office?
%w(doc docx ppt pptx xls xlsx pdf).any?{|word| @file.downcase.end_with?(word)}
%w(doc docx ppt pptx xls xlsx).any?{|word| @file.downcase.end_with?(word)}
end
def conver(saved_file, force=false)
@ -15,14 +17,18 @@ module Trustie
if File.exist? @file
if office?
begin
resource = RestClient::Resource.new(
'http://192.168.80.107/Any2HtmlHandler.ashx',
:timeout => -1,
:open_timeout => -1
)
req = resource.post :txtDes => File.new(@file, 'rb')
File.open(saved_file, "wb+") do |f|
f.write(req.body)
# resource = RestClient::Resource.new(
# 'http://192.168.80.107/Any2HtmlHandler.ashx',
# :timeout => -1,
# :open_timeout => -1
# )
# req = resource.post :txtDes => File.new(@file, 'rb')
req = RestClient.post 'http://192.168.80.107/Any2HtmlHandler.ashx',:txtDes => File.new(@file, 'rb')
File.delete(saved_file) if File.exist?(saved_file)
if req.body.length > 10 && !req.body.eql?('转换出错')
File.open(saved_file, "wb+") do |f|
f.write(req.body)
end
end
return true
rescue =>e

View File

@ -901,24 +901,30 @@ $(function(){
$('#download_homework_attachments').bind('ajax:complete', function (event, data, status, xhr) {
if(status == 'success'){
var res = JSON.parse(data.responseText);
if(res.length<1){
if(res.length == null){
alert("该作业没有任何附件可下载");
}
else if(res.length<1){
return;
}
if(res.length==1){
location.href = '/zipdown/download?file='+res[0].file;return;
}
document.getElementById('light').style.display='block';
$container = $('#light .upload_box_ul');
$container.empty();
for(var i = 0; i <res.length; ++i){
var des = '';
if(res.count > 1){
des = '第'+res[i].index+'-'+(res[i].count+res[i].index-1)+'个学生的作品下载';
} else {
des = '第'+res[i].index+'个学生的作品下载';
else
{
if(res.length==1){
location.href = '/zipdown/download?file='+res[0].file;return;
}
$('<li><span class="upload_box_span" >'+(i+1)+'.</span> <a href="/zipdown/download?file='+res[i].file+'">'+des+'</a><span class="c_grey">&nbsp;&nbsp;(共'+res[i].size+'M</span> </li>').appendTo($container);
document.getElementById('light').style.display='block';
$container = $('#light .upload_box_ul');
$container.empty();
for(var i = 0; i <res.length; ++i){
var des = '';
if(res.count > 1){
des = '第'+res[i].index+'-'+(res[i].count+res[i].index-1)+'个学生的作品下载';
} else {
des = '第'+res[i].index+'个学生的作品下载';
}
$('<li><span class="upload_box_span" >'+(i+1)+'.</span> <a href="/zipdown/download?file='+res[i].file+'">'+des+'</a><span class="c_grey">&nbsp;&nbsp;(共'+res[i].size+'M</span> </li>').appendTo($container);
}
}
}
});

View File

@ -757,8 +757,8 @@ function goTopEx() {
}
}
//匿评评分提示
$(function(){
//匿评评分提示
$(".student_score_info").bind("mouseover",function(e){
//alert($(this).html());
$(this).find("div").show();
@ -769,6 +769,8 @@ $(function(){
//alert($(this).html());
$(this).find("div").hide();
});
$("#about_project label").eq(1).remove();
});
//匿评弹框取消按钮
@ -793,11 +795,7 @@ function SearchByName(obj,url,event)
location.href = url + "&name=" + obj.val();
}
}
function SearchByName(obj,url)
function SearchByName_1(obj,url)
{
location.href = url + "&name=" + obj.val();
}
$(function(){
$("#about_project label").eq(1).remove();
});

View File

@ -380,8 +380,6 @@ span.add_attachment {font-size: 80%;line-height: 2.5em;}
.attachments_fields span .boldSpan{display:block; white-space:nowrap; font-family:'微软雅黑';}
.attachments_fields div.ui-progressbar { width: 100px; height:14px; margin: 2px 0 -5px 8px; display: inline-block; }
a.remove-upload:hover {text-decoration:none !important;}
.attachments_fields input.is_public_checkbox {width:20px;}
.attachments_fields span.ispublic-label {display: inline-block;width: 30px;margin-left: 10px;}
a.remove-upload {background: url(../images/delete.png) no-repeat 1px 50%;width: 1px;display: inline-block;padding-left: 16px;}

View File

@ -241,8 +241,6 @@ blockquote {background: #eeeeee;padding: 10px;margin-bottom: 10px;}
#attachments_fields span .boldSpan{display:block; white-space:nowrap; font-family:'微软雅黑';}
#attachments_fields div.ui-progressbar { width: 100px; height:14px; margin: 2px 0 -5px 8px; display: inline-block; }
a.remove-upload:hover {text-decoration:none !important;}
#attachments_fields input.is_public_checkbox {width:20px;}
#attachments_fields span.ispublic-label {display: inline-block;width: 30px;margin-left: 10px;}
a.remove-upload {background: url(../images/delete.png) no-repeat 1px 50%;width: 1px;display: inline-block;padding-left: 16px;}

View File

@ -438,3 +438,4 @@ a.box_close{background:url(../images/img_floatbox.png) -22px 0 no-repeat;}
.tl{text-align: left;}
img{max-width: 100%;}
.attachments {clear: both;}
.is_public_checkbox{margin-left: 15px;margin-right: 10px;}

View File

@ -2,16 +2,16 @@
#
#:author_id, :budget, :deadline, :name, :description, :homework_type, :password
FactoryGirl.define do
factory :homework, class: Bid do
name "test homework"
budget 0
deadline {(Time.now+1.days).strftime('%Y-%m-%d')}
description "description"
homework_type 3
reward_type 3
end
factory :homework_attach, class: HomeworkAttach do
end
end
# FactoryGirl.define do
# factory :homework, class: Bid do
# name "test homework"
# budget 0
# deadline {(Time.now+1.days).strftime('%Y-%m-%d')}
# description "description"
# homework_type 3
# reward_type 3
# end
#
# factory :homework_attach, class: HomeworkAttach do
# end
# end