diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index 3c57636b5..f3c337cd1 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -75,15 +75,9 @@ module Mobile authenticate! - subscribe = 0 #默认未关注 - - #-------------------获取用户是否关注此公众号----------------------------- - openid = session[:wechat_openid] - raise "无法获取到openid,请在微信中打开本页面" unless openid - user_info = Wechat.api.user(openid) - Rails.logger.info "user_info!!!!!!!!!" - Rails.logger.info user_info - subscribe = user_info["subscribe"] + ## 能进来的就是已关注 + ## 因为取消订阅的记录被删除了 + subscribe = 1 #默认未关注 status = 0 tip = 0 #0班级1项目 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 20e0463d0..4f723fb28 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -35,11 +35,11 @@ class UsersController < ApplicationController # before_filter :can_show_course, :only => [:user_courses,:user_homeworks] - before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, :unsolved_issues_list, :unfinished_homework_list, + before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, :unsolved_issues_list, :unfinished_homework_list, :user_manage_homeworks, :unfinished_poll_list, :user_homeworks,:student_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, - :anonymous_evaluation_list,:unfinished_test_list, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, + :anonymous_evaluation_list,:unfinished_test_list, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, :user_receive_homeworks, :unapproval_applied_list, :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,:user_resource,:user_contestlist, + :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,:user_contestlist, :user_manage_issues, :user_receive_issues, :user_courses4show,:user_projects4show,:user_contests4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction, :user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course,:user_courselist,:user_projectlist,:sort_syllabus_list, :sort_project_list,:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks, :cancel_or_collect,:expand_courses,:homepage, :user_issues, :course_community, :project_community, :contest_community] @@ -150,6 +150,98 @@ class UsersController < ApplicationController end end +# 我发布的issue +def user_manage_issues + @manage_issues = "我发布的Issue" + # 排序(默认以更新时间降序) + order = "updated_on desc" + if params[:reorder_release_time] + order = "created_on #{params[:reorder_release_time]}" + elsif params[:reorder_turnover_time] + order = "updated_on #{params[:reorder_turnover_time]}" + end + + @subject = params[:subject] + params[:assigned_to_id].to_i == 0 ? @assigned_to = nil : @assigned_to = params[:assigned_to_id].to_i + params[:author_id].to_i == 0 ? author_id = nil : author_id = params[:author_id].to_i + params[:project_id].to_i == 0 ? @project_id = nil : @project_id = params[:project_id] + if @project_id.nil? + @issues = Issue.where("author_id =? and subject like ?", + @user.id, "%#{@subject}%").order(order) + else + @issues = Issue.where("author_id =? and project_id=? and subject like ?", + @user.id, @project_id, "%#{@subject}%").order(order) + end + @issues_filter = Issue.where("author_id =?", @user.id).order('updated_on desc') + @issue_open_count = Issue.where(:author_id => @user.id, :status_id => [1, 2, 3, 4, 6]).count + @issue_close_count = Issue.where(:author_id => @user.id, :status_id => 5).count + + # 导出excel的issues + @excel_issues = @issues + @issue_count = @issues.count + @limit = 10 + @is_remote = true + @issue_pages = Paginator.new @issue_count, @limit, params['page'] || 1 + @offset ||= @issue_pages.offset + @issues = paginateHelper @issues, @limit + # @issues.limit(@issue_pages.per_page).offset(@issue_pages.offset).reorder(order).all + respond_to do |format| + format.html{render :layout => 'static_base'} + format.xls{ + filename = "我发布的_#{l(:label_issue_list_xls)}.xls" + send_data(issue_list_xls(@excel_issues), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename)) + } + format.api + format.js + end +end + +# 我收到的issue +def user_receive_issues + @receive_issues = "我收到的Issue" + # 排序(默认以更新时间降序) + order = "updated_on desc" + if params[:reorder_release_time] + order = "created_on #{params[:reorder_release_time]}" + elsif params[:reorder_turnover_time] + order = "updated_on #{params[:reorder_turnover_time]}" + end + + @subject = params[:subject] + params[:assigned_to_id].to_i == 0 ? @assigned_to = nil : @assigned_to = params[:assigned_to_id].to_i + params[:author_id].to_i == 0 ? author_id = nil : author_id = params[:author_id].to_i + params[:project_id].to_i == 0 ? @project_id = nil : @project_id = params[:project_id] + if @project_id.nil? + @issues = Issue.where("assigned_to_id =? and subject like ?", + @user.id, "%#{@subject}%").order(order) + else + @issues = Issue.where("assigned_to_id =? and project_id=? and subject like ?", + @user.id, @project_id, "%#{@subject}%").order(order) + end + @issues_filter = Issue.where("assigned_to_id =?", @user.id).order('updated_on desc') + @issue_open_count = Issue.where(:assigned_to_id => @user.id, :status_id => [1, 2, 3, 4, 6]).count + @issue_close_count = Issue.where(:assigned_to_id => @user.id, :status_id => 5).count + + # 导出excel的issues + @excel_issues = @issues + @issue_count = @issues.count + @limit = 10 + @is_remote = true + @issue_pages = Paginator.new @issue_count, @limit, params['page'] || 1 + @offset ||= @issue_pages.offset + @issues = paginateHelper @issues, @limit + # @issues.limit(@issue_pages.per_page).offset(@issue_pages.offset).reorder(order).all + respond_to do |format| + format.html{render :layout => 'static_base'} + format.xls{ + filename = "我发布的_#{l(:label_issue_list_xls)}.xls" + send_data(issue_list_xls(@excel_issues), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename)) + } + format.api + format.js + end +end + #展开所有回复 def show_all_replies case params[:type] @@ -362,7 +454,7 @@ class UsersController < ApplicationController messages.each do |message_all| # 未读的消息存放在数组 mess = message_all.message - if (message_all.message_type != "SystemMessage"&& !mess.nil? && (mess.viewed == 0 || !mess.viewed)) || (message_all.message_type == "SystemMessage"&& !mess.nil? && mess.created_at > onclick_time) + if (message_all.message_type != "SystemMessage" && !mess.nil? && (mess.viewed == 0 || !mess.viewed)) || (message_all.message_type == "SystemMessage"&& !mess.nil? && mess.created_at > onclick_time) unless (message_all.message_type == 'CourseMessage' && mess && mess.course && mess.course.is_delete == 1) @message_alls << mess end @@ -1738,6 +1830,72 @@ class UsersController < ApplicationController end end + # 用户发布的作业 + def user_manage_homeworks + @manage_homeworks = "我发布的作业" + @order,@b_sort,@type = params[:order] || "created_at",params[:sort] || "desc", 1 + @r_sort = @b_sort == "desc" ? "asc" : "desc" + @type = @type.to_i + tea_courses = @user.courses.visible.not_deleted.select{|course| @user.has_teacher_role(course)} + tea_course_ids = tea_courses.empty? ? "(-1)" : "(" + tea_courses.map{|course| course.id}.join(',') + ")" + @homeworks = HomeworkCommon.where("course_id in #{tea_course_ids}").order("#{@order} #{@b_sort}") + if params[:property] + all_homework_ids = @homeworks.empty? ? "(-1)" : "(" + @homeworks.map{|h| h.id}.join(",") + ")" + if params[:property] == "1" + @homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 1") + elsif params[:property] == "2" + @homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 2") + elsif params[:property] == "3" + @homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 3") + end + end + @limit = 10 + @is_remote = true + @hw_count = @homeworks.count + @hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1 + @offset ||= @hw_pages.offset + @homeworks = paginateHelper @homeworks,@limit + @search = "" + @property = params[:property] + respond_to do |format| + format.js + format.html {render :layout => 'static_base'} + end + end + + # 用户收到的作业 + def user_receive_homeworks + @receive_homeworks = "我收到的作业" + @order,@b_sort,@type = params[:order] || "created_at",params[:sort] || "desc", 2 + @r_sort = @b_sort == "desc" ? "asc" : "desc" + @type = @type.to_i + stu_courses = @user.courses.visible.not_deleted.select{|course| @user.has_student_role(course)} + stu_course_ids = stu_courses.empty? ? "(-1)" : "(" + stu_courses.map{|course| course.id}.join(',') + ")" + @homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}") + if params[:property] + all_homework_ids = @homeworks.empty? ? "(-1)" : "(" + @homeworks.map{|h| h.id}.join(",") + ")" + if params[:property] == "1" + @homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 1") + elsif params[:property] == "2" + @homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 2") + elsif params[:property] == "3" + @homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 3") + end + end + @limit = 10 + @is_remote = true + @hw_count = @homeworks.count + @hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1 + @offset ||= @hw_pages.offset + @homeworks = paginateHelper @homeworks,@limit + @search = "" + @property = params[:property] + respond_to do |format| + format.js + format.html {render :layout => 'static_base'} + end + end + #我管理/收到的作业 def manage_or_receive_homeworks @order,@b_sort,@type = params[:order] || "created_at",params[:sort] || "desc",params[:type] || 1 diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 25ce1f83e..07177736e 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -515,8 +515,8 @@ class WechatsController < ActionController::Base private def get_openid_from_code(code) - if code =='only-for-test' - openid = 'o3ss_wHOOnHkz1khBJxH8RF4SfPY' + if code =='test' + openid = 'orgVLv8TlS6e7FDiI6xdTGHRaaRo' session[:wechat_openid] = openid return openid end @@ -545,6 +545,8 @@ class WechatsController < ActionController::Base return openid end + ## 能进来的就是已关注 + ## 因为取消订阅的记录被删除了 def user_binded?(openid) uw = UserWechat.where(openid: openid).first if uw && uw.bindtype == 0 diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 15eccba1e..6ed1a2e4b 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -1,18 +1,16 @@ #coding=utf-8 -require "base64" -require 'zip' - class ZipdownController < ApplicationController #查找项目(课程) before_filter :find_project_by_bid_id, :only => [:assort] #检查权限 #勿删 before_filter :authorize, :only => [:assort,:download_user_homework] - SAVE_FOLDER = "#{Rails.root}/files" - OUTPUT_FOLDER = "#{Rails.root}/files/archiveZip" - MAX_PATH = 50 + ## 200M + MAX_DOWN_SIZE = 200 * 1024 * 1024 - #统一下载功能 + include ZipService + + #统一下载功能 def download if User.current.logged? begin @@ -35,34 +33,21 @@ class ZipdownController < ApplicationController if params[:obj_class] == "Bid" bid = Bid.find params[:obj_id] render_403 if User.current.allowed_to?(:as_teacher,bid.courses.first) - file_count = 0 - bid.homeworks.map { |homework| file_count += homework.attachments.count} - if file_count > 0 - zipfile = zip_bid bid - else - zipfile = {:message => "no file"} - end + zipfile = checkfileSize(bid.homeworks) { + zip_bid bid + } elsif params[:obj_class] == "HomeworkCommon" homework = HomeworkCommon.find params[:obj_id] render_403 if User.current.allowed_to?(:as_teacher,homework.course) - file_count = 0 - homework.student_works.map { |work| file_count += work.attachments.count} - if file_count > 0 - zipfile = zip_homework_common homework - else - zipfile = {:message => "no file"} - end + zipfile = checkfileSize(homework.student_works) { + zip_homework_common homework + } elsif params[:obj_class] == "Work" homework = Work.find params[:obj_id] render_403 if User.current.admin_of_contest?(homework.contest) - file_count = 0 - homework.contestant_works.map { |work| file_count += work.attachments.count} - if file_count > 0 - zipfile = zip_homework_common homework - else - zipfile = {:message => "no file"} - end - + zipfile = checkfileSize(homework.contestant_works) { + zip_homework_common homework + } else logger.error "[ZipDown#assort] ===> #{params[:obj_class]} unKown !!" end @@ -98,7 +83,6 @@ class ZipdownController < ApplicationController end private - #通过作业Id找到项目(课程) def find_project_by_bid_id obj_class = params[:obj_class] @@ -110,275 +94,23 @@ class ZipdownController < ApplicationController end end - def zip_bid(bid) - # Todo: User Access Controll - bid_homework_path = [] - digests = [] - bid.homeworks.each do |homeattach| - unless homeattach.attachments.empty? - out_file = zip_homework_by_user(homeattach) - bid_homework_path << out_file.file_path - digests << out_file.file_digest - end - end - homework_id = bid.id - user_id = bid.author_id - out_file = find_or_pack(homework_id, user_id, digests.sort){ - zipping("#{Time.now.to_i}_#{bid.name}.zip", - bid_homework_path, OUTPUT_FOLDER) - } - [{files:[out_file.file_path], count: 1, index: 1, - real_file: out_file.file_path, - file: File.basename(out_file.file_path), - base64file: encode64(File.basename(out_file.file_path)), - size:(out_file.pack_size / 1024.0 / 1024.0).round(2) - }] - end - - def encode64(str) - Base64.urlsafe_encode64(str) - end - - def decode64(str) - Base64.urlsafe_decode64(str) - end - - def zip_homework_common homework_common - bid_homework_path = [] - digests = [] - homework_common.student_works.each do |work| - unless work.attachments.empty? - out_file = zip_student_work_by_user(work) - - bid_homework_path << out_file.file_path - digests << out_file.file_digest - - - end - end - homework_id = homework_common.id - user_id = homework_common.user_id - out_file = find_or_pack(homework_id, user_id, digests.sort){ - zipping("#{Time.now.to_i}_#{homework_common.name}.zip", - bid_homework_path, OUTPUT_FOLDER) - } - [{files:[out_file.file_path], count: 1, index: 1, - real_file: out_file.file_path, - file: File.basename(out_file.file_path), - base64file: encode64(File.basename(out_file.file_path)), - size:(out_file.pack_size / 1024.0 / 1024.0).round(2) - }] - end - - def zip_contest_work homework_common - bid_homework_path = [] - digests = [] - homework_common.contestant_works.each do |work| - unless work.attachments.empty? - out_file = zip_student_work_by_user(work) - - bid_homework_path << out_file.file_path - digests << out_file.file_digest - - - end - end - homework_id = homework_common.id - user_id = homework_common.user_id - out_file = find_or_pack(homework_id, user_id, digests.sort){ - zipping("#{Time.now.to_i}_#{homework_common.name}.zip", - bid_homework_path, OUTPUT_FOLDER) - } - [{files:[out_file.file_path], count: 1, index: 1, - real_file: out_file.file_path, - file: File.basename(out_file.file_path), - base64file: encode64(File.basename(out_file.file_path)), - size:(out_file.pack_size / 1024.0 / 1024.0).round(2) - }] - end - - def zip_homework_by_user(homework_attach) - homeworks_attach_path = [] - not_exist_file = [] - # 需要将所有homework.attachments遍历加入zip - digests = [] - homework_attach.attachments.each do |attach| - if File.exist?(attach.diskfile) - homeworks_attach_path << attach.diskfile - digests << attach.digest - else - not_exist_file << attach.filename - digests << 'not_exist_file' - end - end - out_file = find_or_pack(homework_attach.bid_id, homework_attach.user_id, digests.sort){ - 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 - - def make_zip_name(work) - "#{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}" - end - - def zip_student_work_by_user(work) - homeworks_attach_path = [] - not_exist_file = [] - # 需要将所有homework.attachments遍历加入zip - digests = [] - work.attachments.each do |attach| - if File.exist?(attach.diskfile) - homeworks_attach_path << attach.diskfile - digests << attach.digest - else - not_exist_file << attach.filename - digests << 'not_exist_file' + def checkfileSize(works) + file_count = 0 + file_size = 0 + works.each do |work| + file_count += work.attachments.count + work.attachments.each do |attach| + file_size += attach.filesize end end - #单个文件的话,不需要压缩,只改名 - out_file = nil - if homeworks_attach_path.size == 1 - out_file = find_or_pack(work.homework_common_id, work.user_id, digests.sort){ - des_path = "#{OUTPUT_FOLDER}/#{make_zip_name(work)}_#{File.basename(homeworks_attach_path.first)}" - FileUtils.cp homeworks_attach_path.first, des_path - des_path - } + if file_size > MAX_DOWN_SIZE + {err: -1, message: 'file size to large'} + elsif file_count > 0 + yield if block_given? else - out_file = find_or_pack(work.homework_common_id, work.user_id, digests.sort){ - zipping("#{make_zip_name(work)}.zip", - homeworks_attach_path, OUTPUT_FOLDER, true, not_exist_file) - } + {err: -2, :message => "no file"} end - out_file - end - def zip_student_work_by_user(work) - homeworks_attach_path = [] - not_exist_file = [] - # 需要将所有homework.attachments遍历加入zip - digests = [] - work.attachments.each do |attach| - if File.exist?(attach.diskfile) - homeworks_attach_path << attach.diskfile - digests << attach.digest - else - not_exist_file << attach.filename - digests << 'not_exist_file' - end - end - - #单个文件的话,不需要压缩,只改名 - out_file = nil - if homeworks_attach_path.size == 1 - out_file = find_or_pack(work.homework_common_id, work.user_id, digests.sort){ - des_path = "#{OUTPUT_FOLDER}/#{make_zip_name(work)}_#{File.basename(homeworks_attach_path.first)}" - FileUtils.cp homeworks_attach_path.first, des_path - des_path - } - else - out_file = find_or_pack(work.homework_common_id, work.user_id, digests.sort){ - zipping("#{make_zip_name(work)}.zip", - homeworks_attach_path, OUTPUT_FOLDER, true, not_exist_file) - } - end - out_file - - end - - - def find_or_pack(homework_id, user_id, digests) - raise "please given a pack block" unless block_given? - - out_file = ZipPack.packed?(homework_id, user_id, digests.sort) - - unless out_file && out_file.file_valid? - file = yield - - ZipPack.where(homework_id: homework_id, - user_id: user_id).delete_all - - out_file = ZipPack.create(homework_id: homework_id, - user_id: user_id, - file_digest: Trustie::Utils.digest(file), - file_path: file, - pack_size: File.size(file), - file_digests: digests.join(',') - ) - else - out_file.pack_times = out_file.pack_times + 1 - out_file.save - end - - out_file - end - - - def zipping(zip_name_refer, files_paths, output_path, is_attachment=false, not_exist_file=[]) - rename_zipfile = zip_name_refer ||= "#{Time.now.to_i.to_s}.zip" - # 文件名过长 - - if rename_zipfile.size > MAX_PATH - rename_zipfile = rename_zipfile[0,rename_zipfile.size-4][0,MAX_PATH-4] + rename_zipfile[-4,4] - end - - zipfile_name = "#{output_path}/#{rename_zipfile}" - - Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name)) - Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| - files_paths.each do |filename| - rename_file = File.basename(filename) - rename_file = filename_to_real( File.basename(filename)) if is_attachment - - begin - zipfile.add(rename_file, filename) - rescue Exception => e - zipfile.get_output_stream('FILE_NOTICE.txt'){|os| os.write l(:label_file_exist)} - next - end - end - unless not_exist_file.empty? - zipfile.get_output_stream('FILE_LOST.txt'){|os| os.write l(:label_file_lost) + not_exist_file.join(',').to_s} - end - end - zipfile_name - end - - # 合理分配文件打包 - # 如果小于 pack_attachment_max_size, 则返回单个文件 - # 反之则切分为多个文件组返回 - def split_pack_files(files, pack_attachment_max_size) - max_size = 0 - last_files = [] - ret_files = [] - files.each_with_index do |f,i| - if (max_size += File.size(f)) > pack_attachment_max_size - max_size = 0 - if last_files.empty? #如果单个文件超过大小,也将此文件作为一组 - ret_files << {files: [f], count: 1, index: ret_files.count+1} - last_files.clear - else - ret_files << {files:last_files, count: last_files.count, index: ret_files.count+1} - last_files.clear - redo - end - else - last_files << f - end - end - - ret_files << {files:last_files, count: last_files.count, index: ret_files.count+1} unless last_files.empty? - ret_files - end - - def detect_content_type(name) - content_type = Redmine::MimeType.of(name) - content_type.to_s - end - - def filename_to_real(name) - attach = Attachment.find_by_disk_filename(name) - attach.filename - end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e7fed44fb..a40254b97 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1348,6 +1348,14 @@ module ApplicationHelper title << @course_community elsif !@contest_community.blank? title << @contest_community + elsif !@manage_issues.blank? + title << @manage_issues + elsif !@receive_issues.blank? + title << @receive_issues + elsif !@manage_homeworks.blank? + title << @manage_homeworks + elsif !@receive_homeworks.blank? + title << @receive_homeworks else title << @user.try(:realname) end @@ -2920,6 +2928,20 @@ module ApplicationHelper @user_course_total = @my_joined_course_count + @my_course_count end + # 用户发布的作业数 + def user_manage_homework_count + tea_courses = @user.courses.visible.not_deleted.select{|course| @user.has_teacher_role(course)} + tea_course_ids = tea_courses.map{|course| course.id} + @manage_homeworks = HomeworkCommon.where(:course_id => tea_course_ids).count + end + + # 用户收到的作业数 + def user_receive_homework_count + stu_courses = @user.courses.visible.not_deleted.select{|course| @user.has_student_role(course)} + stu_course_ids = stu_courses.empty? ? "(-1)" : "(" + stu_courses.map{|course| course.id}.join(',') + ")" + @homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and publish_time <= '#{Date.today}'").count + end + # 用户发布的issue数 def issues_author_is_self_count @issues = Issue.where( :author_id => @user.id ) diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index bda7831fe..b2fd4161c 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -130,7 +130,7 @@ module IssuesHelper end def options_for_version_isuue_list(project) - versions = Version.where(:project_id => project, :status => "open").map{|version| [version.name, version.id]}.unshift(["里程碑", 0]) + versions = Version.where(:project_id => project, :status => "open").order("created_on desc").map{|version| [version.name, version.id]}.unshift(["里程碑", 0]) end def render_issue_subject_with_tree(issue) diff --git a/app/models/memo.rb b/app/models/memo.rb index a580f02a8..3c36875d1 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -203,7 +203,7 @@ class Memo < ActiveRecord::Base end def destroyable_by? user - (user && self.author == user) || user.admin? + (user && self.author == user) || user.admin? || self.forum.creator == user #self.author == user || user.admin? end diff --git a/app/models/news.rb b/app/models/news.rb index 4c0e58238..aa04cea08 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -235,6 +235,8 @@ class News < ActiveRecord::Base vs << {course_message_type:'News',course_message_id:self.id, :user_id => m.user_id, :course_id => self.course_id, :viewed => false} + #delayed_job卡住的原因是一次执行的条数太多,导致超时。 + #现在把每次只执行不超过30条,就不会超了。 if vs.size >= 30 self.delay.contain_news_message(vs) vs.clear diff --git a/app/services/zip_service.rb b/app/services/zip_service.rb new file mode 100644 index 000000000..0866033bd --- /dev/null +++ b/app/services/zip_service.rb @@ -0,0 +1,281 @@ +require "base64" +require 'zip' + +module ZipService + + SAVE_FOLDER = "#{Rails.root}/files" + OUTPUT_FOLDER = "#{Rails.root}/files/archiveZip" + MAX_PATH = 50 + + def zip_bid(bid) + # Todo: User Access Controll + bid_homework_path = [] + digests = [] + bid.homeworks.each do |homeattach| + unless homeattach.attachments.empty? + out_file = zip_homework_by_user(homeattach) + bid_homework_path << out_file.file_path + digests << out_file.file_digest + end + end + homework_id = bid.id + user_id = bid.author_id + out_file = find_or_pack(homework_id, user_id, digests.sort){ + zipping("#{Time.now.to_i}_#{bid.name}.zip", + bid_homework_path, OUTPUT_FOLDER) + } + [{files:[out_file.file_path], count: 1, index: 1, + real_file: out_file.file_path, + file: File.basename(out_file.file_path), + base64file: encode64(File.basename(out_file.file_path)), + size:(out_file.pack_size / 1024.0 / 1024.0).round(2) + }] + end + + def encode64(str) + Base64.urlsafe_encode64(str) + end + + def decode64(str) + Base64.urlsafe_decode64(str) + end + + def zip_homework_common homework_common + bid_homework_path = [] + digests = [] + homework_common.student_works.each do |work| + unless work.attachments.empty? + out_file = zip_student_work_by_user(work) + + bid_homework_path << out_file.file_path + digests << out_file.file_digest + + + end + end + homework_id = homework_common.id + user_id = homework_common.user_id + out_file = find_or_pack(homework_id, user_id, digests.sort){ + zipping("#{Time.now.to_i}_#{homework_common.name}.zip", + bid_homework_path, OUTPUT_FOLDER) + } + [{files:[out_file.file_path], count: 1, index: 1, + real_file: out_file.file_path, + file: File.basename(out_file.file_path), + base64file: encode64(File.basename(out_file.file_path)), + size:(out_file.pack_size / 1024.0 / 1024.0).round(2) + }] + end + + def zip_contest_work homework_common + bid_homework_path = [] + digests = [] + homework_common.contestant_works.each do |work| + unless work.attachments.empty? + out_file = zip_student_work_by_user(work) + + bid_homework_path << out_file.file_path + digests << out_file.file_digest + + + end + end + homework_id = homework_common.id + user_id = homework_common.user_id + out_file = find_or_pack(homework_id, user_id, digests.sort){ + zipping("#{Time.now.to_i}_#{homework_common.name}.zip", + bid_homework_path, OUTPUT_FOLDER) + } + [{files:[out_file.file_path], count: 1, index: 1, + real_file: out_file.file_path, + file: File.basename(out_file.file_path), + base64file: encode64(File.basename(out_file.file_path)), + size:(out_file.pack_size / 1024.0 / 1024.0).round(2) + }] + end + + def zip_homework_by_user(homework_attach) + homeworks_attach_path = [] + not_exist_file = [] + # 需要将所有homework.attachments遍历加入zip + digests = [] + homework_attach.attachments.each do |attach| + if File.exist?(attach.diskfile) + homeworks_attach_path << attach.diskfile + digests << attach.digest + else + not_exist_file << attach.filename + digests << 'not_exist_file' + end + end + out_file = find_or_pack(homework_attach.bid_id, homework_attach.user_id, digests.sort){ + 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 + + def make_zip_name(work) + "#{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}" + end + + def zip_student_work_by_user(work) + homeworks_attach_path = [] + not_exist_file = [] + # 需要将所有homework.attachments遍历加入zip + digests = [] + work.attachments.each do |attach| + if File.exist?(attach.diskfile) + homeworks_attach_path << attach.diskfile + digests << attach.digest + else + not_exist_file << attach.filename + digests << 'not_exist_file' + end + end + + #单个文件的话,不需要压缩,只改名 + out_file = nil + if homeworks_attach_path.size == 1 + out_file = find_or_pack(work.homework_common_id, work.user_id, digests.sort){ + des_path = "#{OUTPUT_FOLDER}/#{make_zip_name(work)}_#{File.basename(homeworks_attach_path.first)}" + FileUtils.cp homeworks_attach_path.first, des_path + des_path + } + else + out_file = find_or_pack(work.homework_common_id, work.user_id, digests.sort){ + zipping("#{make_zip_name(work)}.zip", + homeworks_attach_path, OUTPUT_FOLDER, true, not_exist_file) + } + end + out_file + + end + + def zip_student_work_by_user(work) + homeworks_attach_path = [] + not_exist_file = [] + # 需要将所有homework.attachments遍历加入zip + digests = [] + work.attachments.each do |attach| + if File.exist?(attach.diskfile) + homeworks_attach_path << attach.diskfile + digests << attach.digest + else + not_exist_file << attach.filename + digests << 'not_exist_file' + end + end + + #单个文件的话,不需要压缩,只改名 + out_file = nil + if homeworks_attach_path.size == 1 + out_file = find_or_pack(work.homework_common_id, work.user_id, digests.sort){ + des_path = "#{OUTPUT_FOLDER}/#{make_zip_name(work)}_#{File.basename(homeworks_attach_path.first)}" + FileUtils.cp homeworks_attach_path.first, des_path + des_path + } + else + out_file = find_or_pack(work.homework_common_id, work.user_id, digests.sort){ + zipping("#{make_zip_name(work)}.zip", + homeworks_attach_path, OUTPUT_FOLDER, true, not_exist_file) + } + end + out_file + + end + + + def find_or_pack(homework_id, user_id, digests) + raise "please given a pack block" unless block_given? + + out_file = ZipPack.packed?(homework_id, user_id, digests.sort) + + unless out_file && out_file.file_valid? + file = yield + + ZipPack.where(homework_id: homework_id, + user_id: user_id).delete_all + + out_file = ZipPack.create(homework_id: homework_id, + user_id: user_id, + file_digest: Trustie::Utils.digest(file), + file_path: file, + pack_size: File.size(file), + file_digests: digests.join(',') + ) + else + out_file.pack_times = out_file.pack_times + 1 + out_file.save + end + + out_file + end + + + def zipping(zip_name_refer, files_paths, output_path, is_attachment=false, not_exist_file=[]) + rename_zipfile = zip_name_refer ||= "#{Time.now.to_i.to_s}.zip" + # 文件名过长 + + if rename_zipfile.size > MAX_PATH + rename_zipfile = rename_zipfile[0,rename_zipfile.size-4][0,MAX_PATH-4] + rename_zipfile[-4,4] + end + + zipfile_name = "#{output_path}/#{rename_zipfile}" + + Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name)) + Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| + files_paths.each do |filename| + rename_file = File.basename(filename) + rename_file = filename_to_real( File.basename(filename)) if is_attachment + + begin + zipfile.add(rename_file, filename) + rescue Exception => e + zipfile.get_output_stream('FILE_NOTICE.txt'){|os| os.write l(:label_file_exist)} + next + end + end + unless not_exist_file.empty? + zipfile.get_output_stream('FILE_LOST.txt'){|os| os.write l(:label_file_lost) + not_exist_file.join(',').to_s} + end + end + zipfile_name + end + + # 合理分配文件打包 + # 如果小于 pack_attachment_max_size, 则返回单个文件 + # 反之则切分为多个文件组返回 + def split_pack_files(files, pack_attachment_max_size) + max_size = 0 + last_files = [] + ret_files = [] + files.each_with_index do |f,i| + if (max_size += File.size(f)) > pack_attachment_max_size + max_size = 0 + if last_files.empty? #如果单个文件超过大小,也将此文件作为一组 + ret_files << {files: [f], count: 1, index: ret_files.count+1} + last_files.clear + else + ret_files << {files:last_files, count: last_files.count, index: ret_files.count+1} + last_files.clear + redo + end + else + last_files << f + end + end + + ret_files << {files:last_files, count: last_files.count, index: ret_files.count+1} unless last_files.empty? + ret_files + end + + def detect_content_type(name) + content_type = Redmine::MimeType.of(name) + content_type.to_s + end + + def filename_to_real(name) + attach = Attachment.find_by_disk_filename(name) + attach.filename + end +end \ No newline at end of file diff --git a/app/views/layouts/_show_messages_list.html.erb b/app/views/layouts/_show_messages_list.html.erb index 654222978..a3ec254d3 100644 --- a/app/views/layouts/_show_messages_list.html.erb +++ b/app/views/layouts/_show_messages_list.html.erb @@ -194,6 +194,10 @@
  • <%=ma.forge_message.author.show_name %> 发布了新闻:<%= ma.forge_message.title.html_safe%>
  • <% elsif ma.forge_message_type == "Comment" %>
  • <%=ma.forge_message.author.show_name %> 评论了新闻:<%= ma.forge_message.commented.title%>
  • + <%# elsif ma.forge_message_type == "PullRequest" && PullRequest.where(:pull_request_id => ma.forge_message_id).count != 0%> + <%# send_message_user = PullRequest.where(:pull_request_id => ma.forge_message_id) %> + <%# author = User.find(ma.operate_user_id.nil? ? 2 : ma.operate_user_id) %> + <% end %> <% elsif ma.class == MemoMessage %> <% if ma.memo_type == "Memo" && !ma.memo.nil? && !ma.memo.author.nil? %> @@ -223,8 +227,8 @@ <% end %> <% end %> - -<%= link_to '查看全部', user_message_path(User.current),:id =>'show_all_messages', :class => "shadowbox_news_all", :style => "display:none", :target =>"_Blank" %> + +<%= link_to '查看全部', user_message_path(User.current),:id =>'show_all_messages', :class => "shadowbox_news_all", :target =>"_Blank" %> + diff --git a/app/views/users/_my_receive_issue_list.html.erb b/app/views/users/_my_receive_issue_list.html.erb new file mode 100644 index 000000000..820c4fbad --- /dev/null +++ b/app/views/users/_my_receive_issue_list.html.erb @@ -0,0 +1,84 @@ +<% unless activity.author.nil? %> +
    +
    + <% if activity.status_id.to_i == 5 %> + + <% else %> + + <% end %> +
    +
    + +
    +

    <%= format_time(activity.created_on) %> 发布

    +

    <%= format_time(activity.updated_on) %> 更新

    +
    +
    + +
    +<% end %> + + + diff --git a/app/views/users/_receive_homework_list.html.erb b/app/views/users/_receive_homework_list.html.erb index c5b073ee2..70de76eb9 100644 --- a/app/views/users/_receive_homework_list.html.erb +++ b/app/views/users/_receive_homework_list.html.erb @@ -5,29 +5,22 @@ <% else %> <% homeworks.each do |homework| %> diff --git a/app/views/users/user_manage_homeworks.html.erb b/app/views/users/user_manage_homeworks.html.erb new file mode 100644 index 000000000..83bd70ab6 --- /dev/null +++ b/app/views/users/user_manage_homeworks.html.erb @@ -0,0 +1,42 @@ + +
    + +
    +
    +
    +
    + <%= render :partial=>'my_homeworks_search', :locals => {:type => @type,:property => nil, :order => @order, :search => ''} %> +
    + +
    + <%= render :partial => "manage_homework_list", :locals => {:homeworks => @homeworks, :is_manage => 1} %> +
    + +
    +
    +
      + <%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%> +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/users/user_manage_homeworks.js.erb b/app/views/users/user_manage_homeworks.js.erb new file mode 100644 index 000000000..1ddc4687d --- /dev/null +++ b/app/views/users/user_manage_homeworks.js.erb @@ -0,0 +1,7 @@ +$("#my_homework_list").html('<%= escape_javascript(render :partial => "manage_homework_list", :locals => {:homeworks => @homeworks, :is_manage => 1})%>'); +$("#homework_list_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %>'); +$("#my_homework_sort").html('<%= escape_javascript( render :partial => 'users/my_homework_sort', :locals => {:type => @type,:property => @property,:order => @order,:search => @search})%>'); +$("#homework_type_all").attr('href','<%= manage_or_receive_homeworks_user_path(@user, :type => @type, :property => 0) %>'); +$("#homework_type_nor").attr('href','<%= manage_or_receive_homeworks_user_path(@user, :type => @type, :property => 1) %>'); +$("#homework_type_pro").attr('href','<%= manage_or_receive_homeworks_user_path(@user, :type => @type, :property => 2) %>'); +$("#homework_type_gro").attr('href','<%= manage_or_receive_homeworks_user_path(@user, :type => @type, :property => 3) %>'); \ No newline at end of file diff --git a/app/views/users/user_manage_issues.html.erb b/app/views/users/user_manage_issues.html.erb new file mode 100644 index 000000000..6a69800e1 --- /dev/null +++ b/app/views/users/user_manage_issues.html.erb @@ -0,0 +1,312 @@ +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: true,init_activity: true) %> +<% end %> + + + + +
    +
    +

    我发布的Issue

    +
    +
    + + +
    + <%= form_tag( user_manage_issues_user_path(@user), :remote => 'xls', :method => "post", :id => "issue_query_form", :class => 'query_form') do %> +
    + + 清除 + +
    + +
    + +
    +
    + <%= select( :project, :project_id, options_for_issue_project_list(@issues_filter), + { :include_blank => false,:selected => @project_id ? @project_id : 0 }, + { :onchange => "remote_function();add_style();", :id => "project_id", :name => "project_id", :class => "fl", :style=>"width: 80px; margin-right:20px;"} + )%> + + + <%= select( :issue, :user_id, [[@user.show_name, @user.id]].unshift(["指派给",0]), + { :include_blank => false, :selected => @assigned_to ? @assigned_to : 0}, + {:onchange=>"remote_function();add_style();",:id => "assigned_to_id",:name => "assigned_to_id", :class => "fl", :style => "visibility:hidden; width:0px;margin:0px;padding:0px;"} ) + %> + + + + + +
    +
    +
    + <% end %> + <% if @issues.empty? %> +

    <%= l(:label_no_data) %>

    + <% else %> +
    + <%= render :partial => 'users/user_manage_issue_list', :locals => {:issues => @issues, :issue_pages => @issue_pages, :issue_count => @issue_count, :subject => @subject } %> +
    + <% end %> +
    +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + diff --git a/app/views/users/user_manage_issues.js.erb b/app/views/users/user_manage_issues.js.erb new file mode 100644 index 000000000..7a24c05f4 --- /dev/null +++ b/app/views/users/user_manage_issues.js.erb @@ -0,0 +1,3 @@ +$("#issue_filter_all").html("<%= escape_javascript(render :partial => 'users/my_issue_filter_all') %>"); +$("#issue_list").html("<%= escape_javascript(render :partial => 'users/user_manage_issue_list',:locals => {:issues => @issues, :issue_pages=> @issue_pages, :issue_count => @issue_count })%>"); +$("#issue_list_pagination").html('<%= pagination_links_full @issue_pages, @issue_count, :issues => @issues, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %>'); \ No newline at end of file diff --git a/app/views/users/user_newfeedback.html.erb b/app/views/users/user_newfeedback.html.erb index ddf686b6a..81e2fe399 100644 --- a/app/views/users/user_newfeedback.html.erb +++ b/app/views/users/user_newfeedback.html.erb @@ -14,16 +14,18 @@
    -
    <%= link_to image_tag(url_to_avatar(User.current),:class=>"fl mr10", :width => "50", :height => "50"), :alt => "用户头像" %> -
    - <%= form_for('new_form',:url => leave_user_message_path(@user.id), :html =>{:id => "user_feedback_new"}, :method => "post") do |f|%> - <%=render :partial => "jour_form", :locals => {:f => f} %> - - 留言 - 私信 - <% end %> -
    -
    + <% unless is_current_user %> +
    <%= link_to image_tag(url_to_avatar(User.current),:class=>"fl mr10", :width => "50", :height => "50"), :alt => "用户头像" %> +
    + <%= form_for('new_form',:url => leave_user_message_path(@user.id), :html =>{:id => "user_feedback_new"}, :method => "post") do |f|%> + <%= render :partial => "jour_form", :locals => {:f => f} %> + + 留言 + 私信 + <% end %> +
    +
    + <% end %> <%=render :partial => "users/user_jours_list", :locals => {:jours =>@jour, :page => 0, :type => @type, :count => @jour_count} %>
    diff --git a/app/views/users/user_receive_homeworks.html.erb b/app/views/users/user_receive_homeworks.html.erb new file mode 100644 index 000000000..58a79ba5c --- /dev/null +++ b/app/views/users/user_receive_homeworks.html.erb @@ -0,0 +1,42 @@ + +
    + +
    +
    +
    +
    + <%= render :partial=>'my_homeworks_search', :locals => {:type => @type,:property => nil, :order => @order, :search => ''} %> +
    + +
    + <%= render :partial => "receive_homework_list", :locals => {:homeworks => @homeworks} %> +
    + +
    +
    +
      + <%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%> +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/users/user_receive_homeworks.js.erb b/app/views/users/user_receive_homeworks.js.erb new file mode 100644 index 000000000..3ffbfaaa3 --- /dev/null +++ b/app/views/users/user_receive_homeworks.js.erb @@ -0,0 +1,7 @@ +$("#my_homework_list").html('<%= escape_javascript(render :partial => "receive_homework_list", :locals => {:homeworks => @homeworks})%>'); +$("#homework_list_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %>'); +$("#my_homework_sort").html('<%= escape_javascript( render :partial => 'users/my_homework_sort', :locals => {:type => @type,:property => @property,:order => @order,:search => @search})%>'); +$("#homework_type_all").attr('href','<%= manage_or_receive_homeworks_user_path(@user, :type => @type, :property => 0) %>'); +$("#homework_type_nor").attr('href','<%= manage_or_receive_homeworks_user_path(@user, :type => @type, :property => 1) %>'); +$("#homework_type_pro").attr('href','<%= manage_or_receive_homeworks_user_path(@user, :type => @type, :property => 2) %>'); +$("#homework_type_gro").attr('href','<%= manage_or_receive_homeworks_user_path(@user, :type => @type, :property => 3) %>'); \ No newline at end of file diff --git a/app/views/users/user_receive_issues.html.erb b/app/views/users/user_receive_issues.html.erb new file mode 100644 index 000000000..883b77688 --- /dev/null +++ b/app/views/users/user_receive_issues.html.erb @@ -0,0 +1,313 @@ +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: true,init_activity: true) %> +<% end %> + + + + +
    +
    +

    我收到的Issue

    +
    +
    + + +
    + <%= form_tag( user_receive_issues_user_path(@user), :remote => 'xls', :method => "post", :id => "issue_query_form", :class => 'query_form') do %> +
    + + 清除 + +
    + +
    + +
    +
    + <%= select( :project, :project_id, options_for_issue_project_list(@issues_filter), + { :include_blank => false,:selected => @project_id ? @project_id : 0 }, + { :onchange => "remote_function();add_style();", :id => "project_id", :name => "project_id", :class => "fl", :style=>"width: 80px; margin-right:20px;"} + )%> + + <%= select( :issue, :user_id, [[@user.show_name, @user.id]].unshift(["发布人",0]), + {:include_blank => false,:selected => @author_id ? @author_id : 0}, + {:onchange => "remote_function();add_style();",:id => "author_id", :name => "author_id", :class => "fl", :style => "visibility:hidden;width: 0px;margin:0px;padding:0px;"} + ) + %> + + + + + + +
    +
    +
    + <% end %> + <% if @issues.empty? %> +

    <%= l(:label_no_data) %>

    + <% else %> +
    + <%= render :partial => 'users/user_receive_issues_list', :locals => {:issues => @issues, :issue_pages => @issue_pages, :issue_count => @issue_count, :subject => @subject } %> +
    + <% end %> +
    +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + diff --git a/app/views/users/user_receive_issues.js.erb b/app/views/users/user_receive_issues.js.erb new file mode 100644 index 000000000..41f8ac63c --- /dev/null +++ b/app/views/users/user_receive_issues.js.erb @@ -0,0 +1,3 @@ +$("#issue_filter_all").html("<%= escape_javascript(render :partial => 'users/my_issue_filter_all') %>"); +$("#issue_list").html("<%= escape_javascript(render :partial => 'users/user_receive_issues_list',:locals => {:issues => @issues, :issue_pages=> @issue_pages, :issue_count => @issue_count })%>"); +$("#issue_list_pagination").html('<%= pagination_links_full @issue_pages, @issue_count, :issues => @issues, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %>'); \ No newline at end of file diff --git a/config/locales/commons/zh.yml b/config/locales/commons/zh.yml index a670b6497..c153ba334 100644 --- a/config/locales/commons/zh.yml +++ b/config/locales/commons/zh.yml @@ -291,7 +291,7 @@ zh: label_tags_project_name: "项目名称:" label_projects_new_name: "项目名称" - label_tags_project_description: "项目描述" + label_tags_project_description: "项目简介" label_organization_name: "组织名称" label_organization_description: "组织描述" diff --git a/config/routes.rb b/config/routes.rb index 3453a5258..cb1218965 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -732,6 +732,10 @@ RedmineApp::Application.routes.draw do get 'edit_brief_introduction' get "user_resource" match "user_issues", :to => 'users#user_issues', :via => [:get, :post], :as => "user_issues" + match "user_manage_issues", :to => 'users#user_manage_issues', :via => [:get, :post], :as => "user_manage_issues" + match "user_receive_issues", :to => 'users#user_receive_issues', :via => [:get, :post], :as => "user_receive_issues" + match "user_manage_homeworks", :to => 'users#user_manage_homeworks', :via => [:get, :post], :as => "user_manage_homeworks" + match "user_receive_homeworks", :to =>'users#user_receive_homeworks', :via => [:get, :post], :as => "user_receive_homeworks" get "import_resources" get "import_resources_search" post "import_into_container" diff --git a/db/schema.rb b/db/schema.rb index 4929caadb..697f7588f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,8 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20161230061940) do - +ActiveRecord::Schema.define(:version => 20161223083022) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false t.string "act_type", :null => false @@ -2434,16 +2433,6 @@ ActiveRecord::Schema.define(:version => 20161230061940) do t.datetime "updated_at", :null => false end - create_table "wechat_logs", :force => true do |t| - t.string "openid", :null => false - t.text "request_raw" - t.text "response_raw" - t.text "session_raw" - t.datetime "created_at", :null => false - end - - add_index "wechat_logs", ["openid"], :name => "index_wechat_logs_on_openid" - create_table "wiki_content_versions", :force => true do |t| t.integer "wiki_content_id", :null => false t.integer "page_id", :null => false diff --git a/lib/tasks/zip.rake b/lib/tasks/zip.rake new file mode 100644 index 000000000..ca5707989 --- /dev/null +++ b/lib/tasks/zip.rake @@ -0,0 +1,18 @@ +#coding=utf-8 + +namespace :zip do + desc "手工打包作品" + task :pack => :environment do + include ZipService + include Redmine::I18n + homework = Object.const_get(ENV['CLASS']).find ENV["ID"] + file_count = 0 + homework.student_works.map { |work| file_count += work.attachments.count} + if file_count > 0 + zipfile = zip_homework_common homework + else + zipfile = {:message => "no file"} + end + puts "out: #{zipfile}" + end +end diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index e5b61cc52..9b378c72c 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -126,7 +126,7 @@
    - +
    @@ -140,11 +140,17 @@
    -
    -
    - +
    +
    +
    + +
    +
      +
    • {{person.name}}

      ({{person.login}})

    • +
    • {{person.name}}

      ({{person.login}})

    • +
    • {{person.name}}

      ({{person.login}})

    • +
    • {{person.name}}

      ({{person.login}})

    • +
    • {{person.name}}

      ({{person.login}})

    • +
    -
      -
    • {{person.name}}

      ({{person.login}})

    • -
    diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 0313687af..ba9d205ce 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -942,6 +942,14 @@ $(function(){ $('a.tb_all').bind('ajax:complete', function (event, data, status, xhr) { if(status == 'success'){ var res = JSON.parse(data.responseText); + if(res.err == -1){ + var htmlvalue = '

    温馨提示

    '+ + '

    因附件资源太大,请通过微信或者QQ联系Trustie管理员
    辅助您完成下载

    '+ + '确  定
    '; + pop_box_new(htmlvalue,380,166); + return; + } + if(res.length<1){ return; } @@ -974,7 +982,7 @@ $(function(){ }); $('#download_homework_attachments').bind('ajax:complete', function (event, data, status, xhr) { if(status == 'success'){ - var res = JSON.parse(data.responseText); + var res = JSON.parse(data.responseText); if(res.length == null){ alert("该作业没有任何附件可下载"); } diff --git a/public/stylesheets/css/common.css b/public/stylesheets/css/common.css index c57424f9f..7aa5dba04 100644 --- a/public/stylesheets/css/common.css +++ b/public/stylesheets/css/common.css @@ -248,6 +248,7 @@ h4{ font-size:14px;}/*color:#3b3b3b;*/ .w56 {width:56px;} .w60{ width:60px;} .w61{ width:61px;} +.w65{ width:65px;} .w70{ width:70px;} .w80{ width:80px;} .w90{ width:90px;} @@ -878,6 +879,9 @@ input.btn-blue{background: #3b94d6; color: #fff; cursor:pointer;} input:hover.btn-blue{background: #2788d0; color: #fff;} input.btn-grey{background: #d9d9d9; color: #656565; cursor:default;} input.btn-grey:hover{background: #717171; color: #fff; cursor:default;} +.icons-user-homework{background:url(/images/user/home-user-left.png) 0px -150px no-repeat; } +.homework-user-leftnav-li{ height: 25px; line-height: 40px; padding-left: 25px; color: #666;background:url(/images/user/home-user-left.png) 0px -149px no-repeat; font-size: 14px; position: relative; } +.homework-user-leftnav-li:hover{ height: 25px; line-height: 40px; padding-left: 25px; background:#f4f4f4; background:url(/images/user/home-user-left.png) 0px -186px no-repeat; font-size: 14px; position: relative; } .separator_short{margin-top: 5px; margin-bottom: 5px; margin-left: 37px; width: 433px; display: block; border-bottom: 1px solid #d9d9d9;} .separator_long{margin-top: 5px; margin-bottom: 5px; margin-left: 37px; width: 522px; display: block; border-bottom: 1px solid #d9d9d9;} diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index d8c272b93..0c6a2cbb6 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -283,7 +283,9 @@ a.underline {text-decoration:underline;} .weixin-users-all li:hover{ background:#f4f4f4;} /*弹出@选择对话框 guange*/ -.wechat-at {position: absolute; z-index: 999; top: 0; left:0; width: 100%; height: 100%; background-color: #ffffff;} - +.wechat-at {position: fixed; z-index: 999; top: 0; left:0; width: 100%; height: 100%; background-color: #ffffff;} +.wechat-at-inner{overflow-y: scroll; + -webkit-overflow-scrolling: touch; + height: 100%;} /*@页面的取消按钮*/ -.cancel-btn-new {position: absolute; font-size: 13px; height: 24px; line-height: 24px; vertical-align: middle; padding: 0 7px; color: #888; background-color: #fff; outline: none; border: none; top: 11px; right: 10px;} +.cancel-btn-new {font-size: 13px; height: 24px; line-height: 24px; padding: 0 7px; color: #888; background-color: #fff; outline: none; border: none; margin-top: 11px; margin-right: 10px;}