commit
f6a1e90ad1
@ -0,0 +1,2 @@
|
||||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
@ -0,0 +1,4 @@
|
||||
/*
|
||||
Place all the styles related to the matching controller here.
|
||||
They will automatically be included in application.css.
|
||||
*/
|
@ -1,2 +1,15 @@
|
||||
class SchoolController < ApplicationController
|
||||
def get_options
|
||||
@school = School.where("province = ?", params[:province])
|
||||
p = params[:province]
|
||||
##@school = School.all
|
||||
options = ""
|
||||
|
||||
@school.each do |s|
|
||||
options << "<option value=#{s.name}>#{s.name}</option>"
|
||||
end
|
||||
|
||||
render :text => options
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -1,160 +1,56 @@
|
||||
class TestController < ApplicationController
|
||||
|
||||
before_filter :find_user, :only => [:new, :create, :destroy]
|
||||
|
||||
|
||||
def index
|
||||
# @users = User.where('status = ?', 1)
|
||||
# for user in @users
|
||||
# if user.user_extensions.nil?
|
||||
# UserExtensions.create(:user_id => user.id)
|
||||
# end
|
||||
# end
|
||||
|
||||
# @message = Message.all
|
||||
# @message.each do |m|
|
||||
# Activity.create(:act_id => m.id, :act_type => 'Message', :user_id => m.author_id)
|
||||
# end
|
||||
# activity = Message.all
|
||||
# activity += News.all
|
||||
# activity += Journal.all
|
||||
# activity += Issue.all
|
||||
# activity += Bid.all
|
||||
# @activity = activity.sort {|x,y| x.created_on <=> y.created_on}
|
||||
# @activity.each do |act|
|
||||
# if act.instance_of?(Bid)
|
||||
# act.acts << Activity.new(:user_id => act.author_id)
|
||||
# elsif act.instance_of?(News)
|
||||
# act.acts << Activity.new(:user_id => act.author_id)
|
||||
# elsif act.instance_of?(Message)
|
||||
# act.acts << Activity.new(:user_id => act.author_id)
|
||||
# elsif act.instance_of?(Journal)
|
||||
# act.acts << Activity.new(:user_id => act.user_id)
|
||||
# elsif act.instance_of?(Issue)
|
||||
# act.acts << Activity.new(:user_id => act.author_id)
|
||||
# elsif act.instance_of?(Changeset)
|
||||
# act.acts << Activity.new(:user_id => act.user_id)
|
||||
# end
|
||||
# end
|
||||
|
||||
|
||||
#@watchers_of_projects = WatchersOfProjects.new
|
||||
#@watchers_of_projects.user_id = 1
|
||||
#@watchers_of_projects.project_id = 1
|
||||
#@watchers_of_projects.save
|
||||
|
||||
#测试user表与watch_project表之间的关联是否成功
|
||||
#@user = User.find(params[:id])
|
||||
#@watch_table = @user.watch_projects.to_a.first
|
||||
|
||||
#@watch = WatchProject.find(1)
|
||||
#@watcher = @watch.user
|
||||
|
||||
#测试通过watch_project表使user表可以访问project表
|
||||
#@watch_project = @user.projects
|
||||
#watch_project_path(@watch)
|
||||
|
||||
#@project = Project.find(11)
|
||||
#project_path(@project)
|
||||
#@member = @project.users
|
||||
#@watched = @project.watch_projects
|
||||
#@issue = Issue.find(6)
|
||||
|
||||
|
||||
#user_path(@user)
|
||||
#issue_path(@issue)
|
||||
|
||||
#@watcher2=WatchProject.where("#{WatchProject.table_name}.project_id = ?" , temp)
|
||||
|
||||
#测试where语句
|
||||
#temp = 1
|
||||
#@watcher2=WatchProject.where(:project_id => temp).to_a
|
||||
|
||||
#测试新建记录
|
||||
#@watch_new = WatchProject.new
|
||||
#@watch_new.user_id = 4
|
||||
#@watch_new.project_id = 1
|
||||
#@watch_new.save
|
||||
#@id = params[:id]
|
||||
|
||||
#测试添加关注项目功能
|
||||
#WatchersOfProjects.watch(3,10)
|
||||
#Project.find(50)
|
||||
#测试统计关注该项目的用户数
|
||||
#@count = WatchersOfProjects.watcher_count(@watch_project.to_a.first)
|
||||
#测试取消关注功能
|
||||
#WatchersOfProjects.watch_cancle(10,35)
|
||||
|
||||
#测试关注用户功能
|
||||
#测试关注功能
|
||||
#WatchersOfUser.watch_user(7,7)
|
||||
#测试取消关注功能
|
||||
#WatchersOfUser.cancel_watching_user(1,2)
|
||||
#测试查找关注的人功能
|
||||
#@user = WatchersOfUser.find_users(1)
|
||||
#测试查找被关注的人功能
|
||||
#@user = WatchersOfUser.find_watchers(10)
|
||||
|
||||
#测试用户留言功能
|
||||
#测试留言功能
|
||||
# MessagesForUser.leave_message(User.current.id, 6, 'test')
|
||||
#测试查找留言功能
|
||||
#@message_table = MessagesForUser.find_message(3)
|
||||
#测试查找留言用户功能
|
||||
#@messager=@message_table.first.find_messager
|
||||
|
||||
|
||||
#测试需求
|
||||
#测试新建需求
|
||||
#bids = Bid.creat_bids(10000, '2013.7.25', 'test', 'sfsadgfag')
|
||||
#测试修改需求
|
||||
#bids.update_bids(10, '2014.7.222', 'asdf')
|
||||
#测试删除需求
|
||||
# bids = Bid.where('id = ?', 5)
|
||||
# bids.each do |bid|
|
||||
# bid.delete_bids
|
||||
# end
|
||||
def zip
|
||||
homeworks_attach_path = []
|
||||
homework_id = params[:homework_id]
|
||||
bid = Bid.find_by_id(homework_id)
|
||||
|
||||
bid.homeworks.each do |homeattach|
|
||||
homeattach.attachments.each do |attach|
|
||||
length = attach.storage_path.length
|
||||
homeworks_attach_path << attach.diskfile.to_s.slice((length+1)..-1)
|
||||
end
|
||||
end
|
||||
|
||||
# ##########留言功能 message by fq
|
||||
# def new
|
||||
# end
|
||||
#
|
||||
# def create
|
||||
#
|
||||
# if params[:user_search].size>0
|
||||
# unless params[:user_id].nil?
|
||||
# message = params[:user_search]
|
||||
# MessagesForUser.leave_message(User.current.id, params[:user_id], message)
|
||||
# @message = MessagesForUser.find_message(@user.id)
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# respond_to do |format|
|
||||
# # format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}}
|
||||
# format.js
|
||||
# #format.api { render_api_ok }
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# def destroy
|
||||
# MessagesForUser.delete_message(params[:object_id])
|
||||
# @message = MessagesForUser.find_message(@user.id)
|
||||
# respond_to do |format|
|
||||
# format.html { redirect_to :back }
|
||||
# format.js
|
||||
# #format.api { render_api_ok }
|
||||
# end
|
||||
# end
|
||||
@paths = homeworks_attach_path
|
||||
zipfile = ziping homeworks_attach_path
|
||||
send_file zipfile, :filename => bid.name,
|
||||
:type => detect_content_type(zipfile)
|
||||
rescue Errno::ENOENT => e
|
||||
logger.error "[Errno::ENOENT] ===> #{e}"
|
||||
|
||||
end
|
||||
|
||||
def courselist
|
||||
@courses = Project.course_entities
|
||||
end
|
||||
|
||||
def ziping files_path
|
||||
ic = Iconv.new('GBK//IGNORE', 'UTF-8//IGNORE')
|
||||
folder = "#{Rails.root}/files"
|
||||
input_filename = files_path
|
||||
zipfile_name = "#{Rails.root}/tmp/archiveZip/archive_#{Time.now.to_i}.zip"
|
||||
|
||||
Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name))
|
||||
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
|
||||
input_filename.each do |filename|
|
||||
zipfile.add(ic.iconv(filename_to_real(File.basename(filename))), folder + '/' + filename)
|
||||
end
|
||||
zipfile.get_output_stream("ReadMe"){ |os|
|
||||
os.write "Homeworks"
|
||||
}
|
||||
end
|
||||
zipfile_name
|
||||
end
|
||||
|
||||
def detect_content_type(name)
|
||||
content_type = Redmine::MimeType.of(name)
|
||||
content_type.to_s
|
||||
end
|
||||
|
||||
# private
|
||||
#
|
||||
# def find_user
|
||||
# if params[:user_id]
|
||||
# @user = User.find(params[:user_id])
|
||||
# end
|
||||
# rescue
|
||||
# render_404
|
||||
# end
|
||||
#######end of message
|
||||
def filename_to_real name
|
||||
attach = Attachment.find_by_disk_filename(name)
|
||||
attach.filename
|
||||
end
|
||||
|
||||
|
||||
end
|
@ -0,0 +1,68 @@
|
||||
class ZipdownController < ApplicationController
|
||||
def assort
|
||||
obj_class = params[:obj_class]
|
||||
obj_id = params[:obj_id]
|
||||
obj = obj_class.constantize.find(obj_id)
|
||||
case obj.class.to_s.to_sym
|
||||
when :Bid
|
||||
zip obj
|
||||
else
|
||||
logger.error "[ZipDown#assort] ===> #{obj.class.to_s.to_sym} unKown !!"
|
||||
end
|
||||
|
||||
rescue NameError, ActiveRecord::RecordNotFound => e
|
||||
logger.error "[ZipDown] ===> #{e}"
|
||||
@error = e
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def zip bid
|
||||
# Todo: User Access Controll
|
||||
homeworks_attach_path = []
|
||||
bid.homeworks.each do |homeattach|
|
||||
homeattach.attachments.each do |attach|
|
||||
length = attach.storage_path.length
|
||||
homeworks_attach_path << attach.diskfile.to_s.slice((length+1)..-1)
|
||||
end
|
||||
end
|
||||
@paths = homeworks_attach_path
|
||||
zipfile = ziping homeworks_attach_path
|
||||
send_file zipfile, :filename => bid.name,
|
||||
:type => detect_content_type(zipfile)
|
||||
rescue Errno::ENOENT => e
|
||||
logger.error "[Errno::ENOENT] ===> #{e}"
|
||||
@error = e
|
||||
end
|
||||
|
||||
def ziping files_path
|
||||
ic = Iconv.new('GBK//IGNORE', 'UTF-8//IGNORE')
|
||||
folder = "#{Rails.root}/files"
|
||||
input_filename = files_path
|
||||
zipfile_name = "#{Rails.root}/tmp/archiveZip/archive_#{Time.now.to_i}.zip"
|
||||
|
||||
Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name))
|
||||
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
|
||||
input_filename.each do |filename|
|
||||
zipfile.add(ic.iconv(filename_to_real(File.basename(filename))), folder + '/' + filename)
|
||||
end
|
||||
zipfile.get_output_stream("ReadMe"){ |os|
|
||||
os.write "Homeworks"
|
||||
}
|
||||
end
|
||||
zipfile_name
|
||||
rescue Errno=> e
|
||||
logger.error "[zipdown#zipping] ===> #{e}"
|
||||
@error = e
|
||||
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
|
@ -0,0 +1,2 @@
|
||||
module ZipdownHelper
|
||||
end
|
@ -1 +1,8 @@
|
||||
$('#attachments_<%= j params[:attachment_id] %>').remove();
|
||||
var count=$('#attachments_fields>span').length;
|
||||
if(count<=0){
|
||||
$("#upload_file_count").text("未上传文件");
|
||||
$(".remove_all").remove();
|
||||
}else{
|
||||
$("#upload_file_count").html("已上传"+"<span id=\"count\">"+count+"</span>"+"个文件");
|
||||
}
|
@ -1,20 +1,31 @@
|
||||
<!--add by huang-->
|
||||
<div class="clearfix"></div>
|
||||
<div id="footer" style="margin-left:-5px;padding-top: 50px;clear: both;">
|
||||
<div id="footer" style="margin-left:-5px;padding-top: 50px;clear: both;font-size: 12px;">
|
||||
<div style="border-top:solid 1px #C6E9F1;width:940px;margin-left:auto;margin-right:auto;margin-bottom: 5px;margin-top: -10px;"></div>
|
||||
<div class="base_footer"><div align="center">
|
||||
<span> Trustie 研发团队 2007~2014 </span>
|
||||
</div></div>
|
||||
<div class="base_footer">
|
||||
<div align="center">
|
||||
<!--gcm-->
|
||||
<p>
|
||||
主办单位
|
||||
</p>
|
||||
<p style="">
|
||||
<%= link_to image_tag('/images/footer_logo/pdl.jpg',:size=>'150x40',:alt=>"国防科学技术大学并行与分布处理国家重点实验室"), "http://www.nudt.edu.cn/ArticleShow.asp?ID=47", :target=>"_blank"%>
|
||||
<%= link_to "Trustie 开发团队 ","http://forge.trustie.net/projects/2/member",:target=>"_blank",:style=>"position:relative; top:-15px; left:5px; font-weight: bold"%>
|
||||
</p>
|
||||
<p>
|
||||
核心技术团队
|
||||
</p>
|
||||
<div id="logo_link">
|
||||
<%= link_to image_tag('/images/footer_logo/nudt.jpg',:size=>'150x40',:alt=>"国防科学技术大学计算机学院"),"http://www.nudt.edu.cn/special.asp?classid=12"%>
|
||||
<%= link_to image_tag('/images/footer_logo/peking_eecs.jpg',:size=>'150x40',:alt=>"北京大学信息科学技术学院软件研究所"), "http://eecs.pku.edu.cn"%>
|
||||
<%= link_to image_tag('/images/footer_logo/buaa_scse.jpg',:size=>'150x40',:alt=>"北京航空航天大学计算机学院"), "http://scse.buaa.edu.cn/iniAction.action"%>
|
||||
<%= link_to image_tag('/images/footer_logo/iscas.jpg',:size=>'150x40',:alt=>"中国科学院软件研究所"), "http://www.iscas.ac.cn"%>
|
||||
<%= link_to image_tag('/images/footer_logo/inforbus.jpg',:size=>'150x40',:alt=>"山东中创软件商用中间件股份有限公司"), "http://www.inforbus.com"%>
|
||||
</div>
|
||||
<p style="font-size: 1em">
|
||||
国防科学技术大学并行与分布处理国家重点实验室 版权@2007~2014 湘ICP备09019772
|
||||
</p>
|
||||
<!--gcm-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<%= debug(params) if Rails.env.development? %>
|
||||
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-46523987-1', 'trustie.net');
|
||||
ga('send', 'pageview');
|
||||
|
||||
</script>
|
@ -0,0 +1,42 @@
|
||||
<style type="text/css">
|
||||
.courses_list{
|
||||
font-size: 18px;
|
||||
font-weight: 800;
|
||||
margin: 40px 10px;
|
||||
}
|
||||
.homeworks{
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
margin: 5px 40px 20px;
|
||||
}
|
||||
.attach_item{
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
margin: auto 60px;
|
||||
}
|
||||
</style>
|
||||
<% @courses.each do |course| %>
|
||||
<div class="courses_list">
|
||||
<%= course.name %>
|
||||
|
||||
<% course.homeworks.each do |homework| %>
|
||||
<% homeworks_attach_path = [] %>
|
||||
<div class="homeworks">
|
||||
<%= link_to homework.name, respond_path(homework) %>(<%=homework.homeworks.count %>)<%#Bid%>
|
||||
<div class="attach_item">
|
||||
<%= link_to "package", test_zip_path(:homework_id => homework.id)%><br/>
|
||||
<% homework.homeworks.each do |homeattach|%><%#homework.class == Bid %>
|
||||
<% homeattach.attachments.each do |attach|%>
|
||||
<%= link_to_attachment attach, author: true, :download => true %> (<%=attach.author%>)
|
||||
<br/>
|
||||
<% homeworks_attach_path << attach.storage_path %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<%# 所有作业的文件列表%>
|
||||
<!-- (<%=homeworks_attach_path.count%>):<%= homeworks_attach_path.to_json %> -->
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<hr/>
|
||||
<% end %>
|
@ -0,0 +1 @@
|
||||
<%= debug @paths.to_yaml %>
|
@ -0,0 +1,2 @@
|
||||
<h1>Download Status:</h1>
|
||||
<%= @error.class %>
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,11 @@
|
||||
class RemoveSchoolidFromCourses < ActiveRecord::Migration
|
||||
def up
|
||||
remove_column :courses, :school_id
|
||||
|
||||
end
|
||||
|
||||
def down
|
||||
add_column :courses, :school_id, :integer
|
||||
|
||||
end
|
||||
end
|
@ -0,0 +1,6 @@
|
||||
class AddSchoolNameToCourses < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :courses, :school_name, :string
|
||||
|
||||
end
|
||||
end
|
@ -0,0 +1,38 @@
|
||||
desc "nyan ruby zip operation"
|
||||
task :zip do
|
||||
puts "input rake zip:clean_tmp will removed tmp/*.zip ."
|
||||
end
|
||||
|
||||
namespace :zip do
|
||||
desc "ruby zip sweeper"
|
||||
task :clean_tmp do
|
||||
unless File.exist?(Dir.pwd+"/tmp/archiveZip")
|
||||
puts "tmp/archiveZip folder is not exist. "
|
||||
next
|
||||
end
|
||||
|
||||
puts "ruby zip sweeping..."
|
||||
Dir.chdir('tmp/archiveZip') do
|
||||
Dir['*'].select do |file|
|
||||
if file =~ /archive_\d+\.zip/
|
||||
File.delete(file)
|
||||
puts "#{file} is deleted."
|
||||
end
|
||||
end
|
||||
end
|
||||
puts "ruby zip sweeping is done."
|
||||
end
|
||||
end
|
||||
|
||||
desc "create tmp file, to test"
|
||||
file 'tmp/test.yml' do
|
||||
require 'yaml'
|
||||
var = {
|
||||
:name => "name",
|
||||
:age => "age",
|
||||
:agent => "agent"
|
||||
}
|
||||
File.open('tmp/test.yml', 'w') do |f|
|
||||
f.write YAML.dump({'conf' => var })
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 22 KiB |
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ZipdownControllerTest < ActionController::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
@ -0,0 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ZipdownHelperTest < ActionView::TestCase
|
||||
end
|
Loading…
Reference in new issue