commit
f0b497e455
@ -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,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.
|
||||
*/
|
@ -0,0 +1,4 @@
|
||||
/*
|
||||
Place all the styles related to the matching controller here.
|
||||
They will automatically be included in application.css.
|
||||
*/
|
File diff suppressed because it is too large
Load Diff
@ -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.id}>#{s.name}</option>"
|
||||
end
|
||||
|
||||
render :text => options
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,194 @@
|
||||
class SoftapplicationsController < ApplicationController
|
||||
# GET /softapplications
|
||||
# GET /softapplications.json
|
||||
def index
|
||||
@softapplications = Softapplication.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @softapplications }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /softapplications/1
|
||||
# GET /softapplications/1.json
|
||||
def show
|
||||
@softapplication = Softapplication.find(params[:id])
|
||||
@jours = @softapplication.journals_for_messages.order('created_on DESC')
|
||||
@image_results = []
|
||||
@softapplication.attachments.each do |f|
|
||||
f.image? ? @image_results << f : @image_results
|
||||
end
|
||||
@app_items = []
|
||||
@softapplication.attachments.each do |f|
|
||||
f.pack? ? @app_items << f : @app_items
|
||||
end
|
||||
@limit = 10
|
||||
@feedback_count = @jours.count
|
||||
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||
@offset ||= @feedback_pages.offset
|
||||
@jour = @jours[@offset, @limit]
|
||||
@state = false
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render json: @softapplication }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /softapplications/new
|
||||
# GET /softapplications/new.json
|
||||
def new
|
||||
@softapplication = Softapplication.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @softapplication }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /softapplications/1/edit
|
||||
def edit
|
||||
@softapplication = Softapplication.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /softapplications
|
||||
# POST /softapplications.json
|
||||
def create
|
||||
@softapplication = Softapplication.new(params[:softapplication])
|
||||
@softapplication.user = User.current
|
||||
@softapplication.save_attachments(params[:attachments])
|
||||
respond_to do |format|
|
||||
if @softapplication.save
|
||||
format.html { redirect_to @softapplication, notice: 'Softapplication was successfully created.' }
|
||||
format.json { render json: @softapplication, status: :created, location: @softapplication }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @softapplication.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /softapplications/1
|
||||
# PUT /softapplications/1.json
|
||||
def update
|
||||
@softapplication = Softapplication.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @softapplication.update_attributes(params[:softapplication])
|
||||
format.html { redirect_to @softapplication, notice: 'Softapplication was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: @softapplication.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def add_attach
|
||||
@softapplication = Softapplication.find(params[:id])
|
||||
@softapplication.save_attachments(params[:attachments])
|
||||
end
|
||||
|
||||
# DELETE /softapplications/1
|
||||
# DELETE /softapplications/1.json
|
||||
def destroy
|
||||
@softapplication = Softapplication.find(params[:id])
|
||||
@softapplication.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to softapplications_url }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
#应用评价涉及到的方法
|
||||
def new_message
|
||||
@jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id]
|
||||
if @jour
|
||||
user = @jour.user
|
||||
text = @jour.notes
|
||||
else
|
||||
user = @softapplication.user
|
||||
text = @softapplication.description
|
||||
end
|
||||
text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]')
|
||||
@content = "> #{ll(User.current.language, :text_user_wrote, user)}\n> "
|
||||
@content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
|
||||
@id = user.id
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
#新建评价
|
||||
def create_message
|
||||
|
||||
if params[:softapplication_message][:message].size>0
|
||||
if params[:reference_content]
|
||||
message = params[:softapplication_message][:message] + "\n" + params[:reference_content]
|
||||
else
|
||||
message = params[:softapplication_message][:message]
|
||||
end
|
||||
refer_user_id = params[:softapplication_message][:reference_user_id].to_i
|
||||
@softapplication = Softapplication.find(params[:id])
|
||||
@softapplication.add_jour(User.current, message, refer_user_id)
|
||||
|
||||
end
|
||||
|
||||
@user = @softapplication.user
|
||||
@jours = @softapplication.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||
|
||||
@limit = 10
|
||||
@feedback_count = @jours.count
|
||||
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||
@offset ||= @feedback_pages.offset
|
||||
@jour = @jours[@offset, @limit]
|
||||
#@softapplication.set_commit(@feedback_count)
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
##删除评价
|
||||
def destroy_message
|
||||
@user = @softapplication.user
|
||||
if User.current.admin? || User.current.id == @user.id
|
||||
JournalsForMessage.delete_message(params[:object_id])
|
||||
end
|
||||
@jours = @softapplication.journals_for_messages.reverse
|
||||
@limit = 10
|
||||
@feedback_count = @jours.count
|
||||
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||
@offset ||= @feedback_pages.offset
|
||||
@jour = @jours[@offset, @limit]
|
||||
|
||||
@softapplication.set_commit(@feedback_count)
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
#
|
||||
def more
|
||||
@jour = @softapplication.journals_for_messages
|
||||
@jour.each_with_index {|j,i| j.indice = i+1}
|
||||
@state = true
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :back }
|
||||
format.js
|
||||
#format.api { render_api_ok }
|
||||
end
|
||||
end
|
||||
#
|
||||
def back
|
||||
@jour = @softapplication.journals_for_messages
|
||||
@jour.each_with_index {|j,i| j.indice = i+1}
|
||||
@state = false
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :back }
|
||||
format.js
|
||||
#format.api { render_api_ok }
|
||||
end
|
||||
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
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue