diff --git a/Gemfile b/Gemfile index dd19b4435..63dd32df4 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,11 @@ source 'https://rubygems.org' +unless RUBY_PLATFORM =~ /w32/ + # unix-like only + gem 'iconv' + gem 'rubyzip' + gem 'zip-zip' +end gem "rails", "3.2.13" gem "jquery-rails", "~> 2.0.2" gem "i18n", "~> 0.6.0" diff --git a/app/assets/javascripts/zipdown.js b/app/assets/javascripts/zipdown.js new file mode 100644 index 000000000..dee720fac --- /dev/null +++ b/app/assets/javascripts/zipdown.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. diff --git a/app/assets/stylesheets/zipdown.css b/app/assets/stylesheets/zipdown.css new file mode 100644 index 000000000..afad32db0 --- /dev/null +++ b/app/assets/stylesheets/zipdown.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 1c02326a7..73b1849c1 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -150,6 +150,7 @@ class AttachmentsController < ApplicationController ori = Attachment.find_by_id(attach_id) next if ori.blank? attach_copied_obj = ori.copy + attach_copied_obj.tag_list.add(ori.tag_list) # tag关联 attach_copied_obj.container = obj attach_copied_obj.created_on = Time.now attach_copied_obj.author_id = User.current.id diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index be1a331e0..991af0154 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -11,6 +11,42 @@ class ForumsController < ApplicationController include SortHelper PageLimit = 20 + + def create_memo + @memo = Memo.new(params[:memo]) + @memo.forum_id = @forum.id + @memo.author_id = User.current.id + + @memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads])) + + respond_to do |format| + if @memo.save + format.html { redirect_to (forum_memo_path(@forum, (@memo.parent_id.nil? ? @memo : @memo.parent_id))), notice: "#{l :label_memo_create_succ}" } + format.json { render json: @memo, status: :created, location: @memo } + else + sort_init 'updated_at', 'desc' + sort_update 'created_at' => "#{Memo.table_name}.created_at", + 'replies' => "#{Memo.table_name}.replies_count", + 'updated_at' => "COALESCE (last_replies_memos.created_at, #{Memo.table_name}.created_at)" + + @topic_count = @forum.topics.count + @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] + @memos = @forum.topics. + reorder("#{Memo.table_name}.sticky DESC"). + includes(:last_reply). + limit(@topic_pages.per_page). + offset(@topic_pages.offset). + order(sort_clause). + preload(:author, {:last_reply => :author}). + all + + flash.now[:error] = "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" + # back_error_page = @memo.parent_id.nil? ? forum_path(@forum) : forum_memo_path(@forum, @memo.parent_id) + format.html { render action: :show, layout: 'base_forums' }#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" } + format.json { render json: @memo.errors, status: :unprocessable_entity } + end + end + end def index @offset, @limit = api_offset_and_limit({:limit => 10}) diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index a21086da3..f6ad48801 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -47,7 +47,30 @@ class MemosController < ApplicationController else flash[:error] = "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" # back_error_page = @memo.parent_id.nil? ? forum_path(@forum) : forum_memo_path(@forum, @memo.parent_id) - format.html { redirect_to back_memo_or_forum_url}#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" } + pre_count = REPLIES_PER_PAGE + + @memo_new = @memo.dup + @memo = @memo.root # 取出楼主,防止输入帖子id让回复作为主贴显示 + @memo.update_column(:viewed_count, (@memo.viewed_count.to_i + 1)) + + page = params[:page] + if params[:r] && page.nil? + offset = @memo.children.where("#{Memo.table_name}.id < ?", params[:r].to_i).count + page = 1 + offset / pre_count + else + + end + @reply_count = @memo.children.count + @reply_pages = Paginator.new @reply_count, pre_count, page + @replies = @memo.children. + includes(:author, :attachments). + reorder("#{Memo.table_name}.created_at ASC"). + limit(@reply_pages.per_page). + offset(@reply_pages.offset). + all + + format.html { render action: :show }#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" } + # format.html { redirect_to back_memo_or_forum_url}#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" } format.json { render json: @memo.errors, status: :unprocessable_entity } end end @@ -76,7 +99,7 @@ class MemosController < ApplicationController offset(@reply_pages.offset). all - @mome_new = Memo.new + @memo_new = Memo.new # @memo = Memo.find_by_id(params[:id]) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index abe9e3291..7db953a0b 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -390,7 +390,7 @@ class ProjectsController < ApplicationController # added by bai @course.term = params[:term] @course.time = params[:time] - @course.school_id = params[:school] + @course.school_name = params[:occupation] @course.setup_time = params[:setup_time] @course.endup_time = params[:endup_time] @course.class_period = params[:class_period] diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index 05a65771b..63791795c 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -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 << "" + end + + render :text => options + + end end diff --git a/app/controllers/test_controller.rb b/app/controllers/test_controller.rb index 46ae016ed..cb28f4e66 100644 --- a/app/controllers/test_controller.rb +++ b/app/controllers/test_controller.rb @@ -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 \ No newline at end of file diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb new file mode 100644 index 000000000..12f1976e0 --- /dev/null +++ b/app/controllers/zipdown_controller.rb @@ -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 diff --git a/app/helpers/zipdown_helper.rb b/app/helpers/zipdown_helper.rb new file mode 100644 index 000000000..d0b9a4880 --- /dev/null +++ b/app/helpers/zipdown_helper.rb @@ -0,0 +1,2 @@ +module ZipdownHelper +end diff --git a/app/models/memo.rb b/app/models/memo.rb index 2e4ddb810..a0581d945 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -4,9 +4,10 @@ class Memo < ActiveRecord::Base belongs_to :author, :class_name => "User", :foreign_key => 'author_id' validates_presence_of :author_id, :forum_id, :subject - #validates :content, presence: true + # 若是主题帖,则内容可以是空 + validates :content, presence: true, if: Proc.new{|o| !o.parent_id.nil? } validates_length_of :subject, maximum: 50 - #validates_length_of :content, maximum: 3072 + validates_length_of :content, maximum: 3072 validate :cannot_reply_to_locked_topic, :on => :create acts_as_tree :counter_cache => :replies_count, :order => "#{Memo.table_name}.created_at ASC" diff --git a/app/views/attachments/_form.html.erb b/app/views/attachments/_form.html.erb index 546792d50..f34a0e4e7 100644 --- a/app/views/attachments/_form.html.erb +++ b/app/views/attachments/_form.html.erb @@ -12,11 +12,14 @@ <% end %> +<%= button_tag "浏览", :type=>"button", :onclick=>"_file.click()" %> + <%= file_field_tag 'attachments[dummy][file]', - :id => nil, + :id => '_file', :class => 'file_selector', :multiple => true, :onchange => 'addInputFiles(this);', + :style => 'display:none', :data => { :max_file_size => Setting.attachment_max_size.to_i.kilobytes, :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), @@ -24,6 +27,7 @@ :upload_path => uploads_path(:format => 'js'), :description_placeholder => l(:label_optional_description) } %> +<%= l(:label_no_file_uploaded)%> (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) diff --git a/app/views/attachments/destroy.js.erb b/app/views/attachments/destroy.js.erb index 3cfb5845f..04cd4e02d 100644 --- a/app/views/attachments/destroy.js.erb +++ b/app/views/attachments/destroy.js.erb @@ -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("已上传"+""+count+""+"个文件"); +} \ No newline at end of file diff --git a/app/views/attachments/upload.js.erb b/app/views/attachments/upload.js.erb index 4761f4635..82b79bb63 100644 --- a/app/views/attachments/upload.js.erb +++ b/app/views/attachments/upload.js.erb @@ -8,7 +8,7 @@ fileSpan.find('a.remove-upload') .attr({ "data-remote": true, "data-method": 'delete', - href: '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>' + "href": '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>' }) .off('click'); <% end %> diff --git a/app/views/bids/_bid_homework_show.html.erb b/app/views/bids/_bid_homework_show.html.erb index b44d72b5f..7c8e1468c 100644 --- a/app/views/bids/_bid_homework_show.html.erb +++ b/app/views/bids/_bid_homework_show.html.erb @@ -60,7 +60,10 @@ <% end %> - <%= bid.description %> + + <%#= bid.description %> + <%= textilizable bid, :description %> + <%= l(:label_create_time) %> :  <%=format_time bid.created_on %> <%= l(:field_deadline) %> :  <%=bid.deadline %> diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 8e0c93a79..8f87a6b37 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -14,6 +14,10 @@ <% end %> <% display_id = im_watching_student_id? @bid%> +<%= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;display: inline-block;" if( + User.current.admin? || + !(User.current.roles_for_project(@bid.courses.first).map(&:id) & ([7,9])).empty? ) || + (Rails.env.development?) %> <% @homework_list.each do |homework|%> <% if homework.attachments.any?%> @@ -22,7 +26,12 @@
- + + + + +
<%= link_to homework.user, user_path(homework.user)%> 已提交 <%= link_to homework.user, user_path(homework.user)%> 已提交 + <% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.attachments[0].created_on.to_s) %> + 迟交 + <% end %> +
  diff --git a/app/views/bids/_list_projects.html.erb b/app/views/bids/_list_projects.html.erb index 304bab413..41c5ab9d1 100644 --- a/app/views/bids/_list_projects.html.erb +++ b/app/views/bids/_list_projects.html.erb @@ -147,6 +147,13 @@ <%= format_time b_project.created_at%>
+ <% if Time.parse(@bid.deadline.to_s) < Time.parse(b_project.created_at.to_s) %> + 迟交 + <% end %> +
diff --git a/app/views/bids/show_project.html.erb b/app/views/bids/show_project.html.erb index 4b4d7040b..d22ddded6 100644 --- a/app/views/bids/show_project.html.erb +++ b/app/views/bids/show_project.html.erb @@ -1,6 +1,6 @@ -<% if @bid.homework_type == 1%> +<% if @bid.homework_type == Bid::HomeworkFile %> <%= render :partial => 'homework' %> <% else %> diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index f3f0524ae..677416a6d 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -2,7 +2,7 @@ diff --git a/app/views/memos/_reply_box.html.erb b/app/views/memos/_reply_box.html.erb index a8991b572..e0c6acf13 100644 --- a/app/views/memos/_reply_box.html.erb +++ b/app/views/memos/_reply_box.html.erb @@ -1,4 +1,4 @@ -<%= form_for(@mome_new, url: forum_memos_path, :html => {:multipart => true}) do |f| %> +<%= form_for(@memo_new, url: forum_memos_path, :html => {:multipart => true}) do |f| %> <%= f.hidden_field :subject, :required => true, value: @memo.subject %> <%= f.hidden_field :forum_id, :required => true, value: @memo.forum_id %> <%= f.hidden_field :parent_id, :required => true, value: @memo.id %> diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index d085c01d2..6ea5b17bc 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -1,7 +1,7 @@
-
<%= link_to image_tag(url_to_avatar(@memo.author), :class => "avatar"), user_path(@memo.author) %>
-

<%=link_to @memo.author.name, user_path(@memo.author) %>

+
<%= link_to image_tag(url_to_avatar(@memo.author), :class => "avatar"), user_path(@memo.author) %>
+

<%=link_to @memo.author.name, user_path(@memo.author) %>

diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index cca7b8546..6ff37ed7c 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -1,3 +1,20 @@ + + +
<%= link_to(l(:button_change_password), {:action => 'password'}, :class => 'icon icon-passwd') if @user.change_password_allowed? %> <%= call_hook(:view_my_account_contextual, :user => @user)%> @@ -61,13 +78,23 @@ <% end %> - <% unless @user.user_extensions.nil?%> -

<%= l(:field_occupation)%> <%= text_field_tag "occupation", @user.user_extensions.occupation, :class => 'occupation'%> + + + +

+ <%= l(:field_occupation) %> *<%= select_tag "province", options_from_collection_for_select(School.find_by_sql("select distinct province from schools"), :province, :province), :onchange => "get_options(this.value)" %> + + <%= select_tag "occupation", options_for_select([['安徽大学','安徽大学'],['合肥工业大学','合肥工业大学'],['中国科技大学','中国科技大学']]) %> +

+ + diff --git a/app/views/projects/_course_form.html.erb b/app/views/projects/_course_form.html.erb index ff45f2375..ca736b05a 100644 --- a/app/views/projects/_course_form.html.erb +++ b/app/views/projects/_course_form.html.erb @@ -1,4 +1,19 @@ - + + <% object = [] %> @@ -269,10 +284,12 @@ + +

+ <%=l(:label_new_course_school)%>*    + <%= select_tag "province", options_from_collection_for_select(School.find_by_sql("select distinct province from schools"), :province, :province), :onclick => "get_options(this.value)" %> -

- - <%= select_tag 'school', options_from_collection_for_select(School.all, :id, :name)%> + <%= select_tag "occupation", options_for_select([['安徽大学','安徽大学'],['合肥工业大学','合肥工业大学'],['中国科技大学','中国科技大学']]) %>

diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 565a31383..493280647 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -22,6 +22,7 @@ :class => 'repository' + (repo == @repository ? ' selected' : '') }.join(' | ').html_safe %>)

<% else %> +

项目代码请设置好正确的编码方式(utf-8),否则中文会出现乱码

建立版本库文件夹,打开命令行执行如下:

git init

@@ -30,11 +31,22 @@

git remote add origin <%= @repos_url%>

git push -u origin master:master

-

已经有本地库,打开命令行执行如下:

+

已经有本地库,还没有配置远程地址,打开命令行执行如下:

git remote add origin <%= @repos_url%>

+

git add .

+

git commit -m "first commit"

git push -u origin master:matser

+ +

从网上获取别人的开源版本库,转交到trustie网站上,打开命令行执行如下:

+
+

git remote add trustie <%= @repos_url%>

+

git add .

+

git commit -m "first commit"

+

git push -u trustie master:matser

+

<%= link_to "李海提供", user_path(646)%>

+
<% end %> <% if !@entries.nil? && authorize_for('repositories', 'browse') %> diff --git a/app/views/test/courselist.html.erb b/app/views/test/courselist.html.erb new file mode 100644 index 000000000..61cd69e13 --- /dev/null +++ b/app/views/test/courselist.html.erb @@ -0,0 +1,42 @@ + +<% @courses.each do |course| %> +
+ <%= course.name %> + + <% course.homeworks.each do |homework| %> + <% homeworks_attach_path = [] %> +
+ <%= link_to homework.name, respond_path(homework) %>(<%=homework.homeworks.count %>)<%#Bid%> +
+ <%= link_to "package", test_zip_path(:homework_id => homework.id)%>
+ <% homework.homeworks.each do |homeattach|%><%#homework.class == Bid %> + <% homeattach.attachments.each do |attach|%> + <%= link_to_attachment attach, author: true, :download => true %> (<%=attach.author%>) +
+ <% homeworks_attach_path << attach.storage_path %> + <% end %> + <% end %> +
+ <%# 所有作业的文件列表%> + +
+ <% end %> +
+
+<% end %> diff --git a/app/views/test/zip.html.erb b/app/views/test/zip.html.erb new file mode 100644 index 000000000..8992b9bb2 --- /dev/null +++ b/app/views/test/zip.html.erb @@ -0,0 +1 @@ +<%= debug @paths.to_yaml %> \ No newline at end of file diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 6c4cd3e6b..c1b5bba9f 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -245,7 +245,7 @@
- +
diff --git a/app/views/zipdown/assort.html.erb b/app/views/zipdown/assort.html.erb new file mode 100644 index 000000000..c9056b4fa --- /dev/null +++ b/app/views/zipdown/assort.html.erb @@ -0,0 +1,2 @@ +

Download Status:

+<%= @error.class %> \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index a006ae53c..2423b8485 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -741,6 +741,7 @@ zh: label_latest_revision_plural: 最近的修订版本 label_view_revisions: 查看修订 label_view_all_revisions: 查看所有修订 + label_no_file_uploaded: 未上传文件 label_max_size: 最大文件大小 label_sort_highest: 置顶 label_sort_higher: 上移 @@ -1746,6 +1747,7 @@ zh: label_exit_course: 退出课程 label_new_join: 加入 label_new_course_password: 课程密码 + label_new_course_school: 开课学校 label_new_course_description: 课程描述 label_new_join_order: 请输入课程密码 label_task_submit_form_accessory: 作业最终以附件形式提交 diff --git a/config/routes.rb b/config/routes.rb index ec3440cec..8e7a2501e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,561 +1,577 @@ -# Redmine - project management software -# Copyright (C) 2006-2013 Jean-Philippe Lang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write tobthe Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -RedmineApp::Application.routes.draw do - resources :stores do - collection do - match 'search', via: [:get, :post] - end - end - - resources :forums do - collection do - match 'search_forum', :via => [:get, :post] - end - member do - match 'search_memo', :via => [:get, :post] - end - resources :memos do - collection do - get "quote" - end - end - end - - - resources :shares - - #added by william - get "tags/index" - - get "tags/show" - - get "praise_tread/praise_plus" - - get "praise_tread/tread_plus" - #end - - root :to => 'welcome#index', :as => 'home' - - #added by baiyu - match 'git_usage/ch_usage', :controller => 'git_usage', :action => 'ch_usage', :via => :get, :as => 'ch_usage' - match 'git_usage/en_usage', :controller => 'git_usage', :action => 'en_usage', :via => :get, :as => 'en_usage' - #added by nie - match '/projects/search', :controller => 'projects', :action => 'search', :via => [:get, :post] - match '/users/search', :controller => 'users', :action => 'search', :via => [:get, :post] - #end - match 'login', :to => 'account#login', :as => 'signin', :via => [:get, :post] - match 'logout', :to => 'account#logout', :as => 'signout', :via => [:get, :post] - match 'account/register', :to => 'account#register', :via => [:get, :post], :as => 'register' - match 'account/lost_password', :to => 'account#lost_password', :via => [:get, :post], :as => 'lost_password' - match 'account/activate', :to => 'account#activate', :via => :get - - match '/news/preview', :controller => 'previews', :action => 'news', :as => 'preview_news', :via => [:get, :post, :put] - match '/issues/preview/new/:project_id', :to => 'previews#issue', :as => 'preview_new_issue', :via => [:get, :post, :put] - match '/issues/preview/edit/:id', :to => 'previews#issue', :as => 'preview_edit_issue', :via => [:get, :post, :put] - match '/issues/preview', :to => 'previews#issue', :as => 'preview_issue', :via => [:get, :post, :put] - - match 'projects/:id/wiki', :to => 'wikis#edit', :via => :post - match 'projects/:id/wiki/destroy', :to => 'wikis#destroy', :via => [:get, :post] - - # boards - match 'boards/:board_id/topics/new', :to => 'messages#new', :via => [:get, :post], :as => 'new_board_message' - get 'boards/:board_id/topics/:id', :to => 'messages#show', :as => 'board_message' - match 'boards/:board_id/topics/quote/:id', :to => 'messages#quote', :via => [:get, :post] - get 'boards/:board_id/topics/:id/edit', :to => 'messages#edit' - - post 'boards/:board_id/topics/preview', :to => 'messages#preview', :as => 'preview_board_message' - post 'boards/:board_id/topics/:id/replies', :to => 'messages#reply' - post 'boards/:board_id/topics/:id/edit', :to => 'messages#edit' - post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy' - # boards end - post 'bids/homework_destroy', :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' - match '/issues/context_menu', :to => 'context_menus#issues', :as => 'issues_context_menu', :via => [:get, :post] - match '/issues/changes', :to => 'journals#index', :as => 'issue_changes', :via => :get - match '/issues/:id/quoted', :to => 'journals#new', :id => /\d+/, :via => :post, :as => 'quoted_issue' - - match '/journals/diff/:id', :to => 'journals#diff', :id => /\d+/, :via => :get - match '/journals/edit/:id', :to => 'journals#edit', :id => /\d+/, :via => [:get, :post] - match '/journals/destroy/:id', :to => 'journals#destroy', :id => /\d+/, :via => [:get, :post] - - - get '/projects/:project_id/issues/gantt', :to => 'gantts#show', :as => 'project_gantt' - get '/issues/gantt', :to => 'gantts#show' - - get '/projects/:project_id/issues/calendar', :to => 'calendars#show', :as => 'project_calendar' - get '/issues/calendar', :to => 'calendars#show' - - get 'projects/:id/issues/report', :to => 'reports#issue_report', :as => 'project_issues_report' - get 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :as => 'project_issues_report_details' - post '/users/:id/user_activities', :to => 'users#show', :as => "user_activities" - - #added by young - resources :users do - member do - match 'user_projects', :to => 'users#user_projects', :via => :get - match 'user_activities', :to => 'users#show', :via => :get, :as => "user_activities" - match 'user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "user_newfeedback" - match 'watch_calls', :controller => 'users', :action => 'watch_bids', :via => [:get , :post] - match 'info', :to => 'users#info', :via => [:get , :post], :as => 'user_info' - match 'user_watchlist', :to => 'users#user_watchlist', :via => :get, :as => "user_watchlist" #add by huang - match 'user_fanslist', :to => 'users#user_fanslist', :via => :get, :as => "user_fanslist" #add by huang - match 'user_courses', :to => 'users#user_courses', :via => :get - match 'user_homeworks', :to => 'users#user_homeworks', :via => :get - match 'watch_projects', :to => 'users#watch_projects', :via => :get - # added by bai - match 'show_score', :to => 'users#show_score', :via => :get - match 'topic_score_index', :controller => 'users', :action => 'topic_score_index', :via => [:get, :post] - match 'project_score_index', :to => 'users#project_score_index', :via => :get - match 'activity_score_index', :to => 'users#activity_score_index', :via => :get - match 'influence_score_index', :to => 'users#influence_score_index', :via => :get - match 'score_index', :to => 'users#score_index', :via => :get - - match 'show_projects_score', :to => 'projects#show_projects_score', :via => [:get, :post] - match 'issue_score_index', :to => 'projects#issue_score_index', :via => [:get, :post] - match 'news_score_index', :to => 'projects#news_score_index', :via => [:get, :post] - match 'file_score_index', :to => 'projects#file_score_index', :via => [:get, :post] - match 'code_submit_score_index', :to => 'projects#code_submit_score_index', :via => [:get, :post] - match 'projects_topic_score_index', :to => 'projects#projects_topic_score_index', :via => [:get, :post] - # end - end - end - match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback" - match 'users/:id/user_projects', :controller => 'users', :action => 'user_projects', :via => :get - #match 'user/:id/watch_calls', :controller => 'users', :action => 'watch_bids', :via => [:get , :post] - - #end - match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :post] - match 'my/account/destroy', :controller => 'my', :action => 'destroy', :via => [:get, :post] - match 'my/page', :controller => 'my', :action => 'page', :via => :get - match 'my', :controller => 'my', :action => 'index', :via => :get # Redirects to my/page - match 'my/reset_rss_key', :controller => 'my', :action => 'reset_rss_key', :via => :post - match 'my/reset_api_key', :controller => 'my', :action => 'reset_api_key', :via => :post - match 'my/password', :controller => 'my', :action => 'password', :via => [:get, :post] - match 'my/page_layout', :controller => 'my', :action => 'page_layout', :via => :get - match 'my/add_block', :controller => 'my', :action => 'add_block', :via => :post - match 'my/remove_block', :controller => 'my', :action => 'remove_block', :via => :post - match 'my/order_blocks', :controller => 'my', :action => 'order_blocks', :via => :post - - resources :users - match 'users/:id/memberships/:membership_id', :to => 'users#edit_membership', :via => :put, :as => 'user_membership' - match 'users/:id/memberships/:membership_id', :to => 'users#destroy_membership', :via => :delete - match 'users/:id/memberships', :to => 'users#edit_membership', :via => :post, :as => 'user_memberships' - ################# added by william - match 'users/tag_save', :to => 'users#tag_save', :via => :post, :as => 'tag' - - post 'watchers/watch', :to => 'watchers#watch', :as => 'watch' - delete 'watchers/watch', :to => 'watchers#unwatch' - get 'watchers/new', :to => 'watchers#new' - post 'watchers', :to => 'watchers#create' - post 'watchers/append', :to => 'watchers#append' - delete 'watchers', :to => 'watchers#destroy' - get 'watchers/autocomplete_for_user', :to => 'watchers#autocomplete_for_user' - # Specific routes for issue watchers API - post 'issues/:object_id/watchers', :to => 'watchers#create', :object_type => 'issue' - delete 'issues/:object_id/watchers/:user_id' => 'watchers#destroy', :object_type => 'issue' - - resources :bids, :only=>[:edit,:update,:show] do - member do - match 'homework_ajax_modal' - end - end - resources :projects do - member do - post 'finishcourse' - post 'restartcourse' - get 'settings(/:tab)', :action => 'settings', :as => 'settings' - #by young - get 'member', :controller => 'projects', :action => 'member', :as => 'member' - get 'file', :action => 'file', :as => 'file' - get 'statistics', :action => 'statistics', :as => 'statistics' - get 'feedback', :action => 'feedback', :as => 'project_feedback' - get 'watcherlist', :action=> 'watcherlist' - match 'user_watcherlist', :to => 'projects#watcherlist', :via => :get, :as => "watcherlist" #add by huang - get 'homework', :action => 'homework', :as => 'homework' - get 'new_homework', :action => 'new_homework', :as => 'new_homework' - #get 'news', :action => 'news', :as => 'news' - #end - post 'modules' - post 'archive' - post 'unarchive' - post 'close' - post 'reopen' - match 'copy', :via => [:get, :post] - end - - - #by young - match '/member', :controller => 'projects', :action => 'member', :as => 'member', :via => :get - match '/file', :controller => 'projects', :action => 'file', :as => 'file', :via => :get - match '/statistics', :controller => 'projects', :action => 'statistics', :as => 'statistics', :via => :get - # match '/investor', :controller => 'projects', :action => 'investor', :as => 'investor', :via => :get - match '/homework', :controller => 'projects', :action => 'homework', :as => 'homework', :via => :get - - - # match '/activity', :controller => 'activities', :action => 'index', :as => 'activity', :via => :get - # match '/repository', :controller => 'repositories', :action => 'show', :repository_id => nil, :path => nil, :rev => nil, :as => 'repository', :via => :get - # match '/', :controller => 'projects', :action => 'show', :as => 'project_show', :via => :get - # get 'projects/:project_id/show', :to => 'projects#show', :as => 'project_show' - # get 'projects/:project_id/repository', :to => 'repositories#show', :as => 'project_repository' - - # match '/show', :controller => 'projects', :action => 'show', :as => 'project_show', :via => :get - match '/watcherlist', :controller=>'projects', :action=> 'watcherlist', :as => 'watcherlist', :via => :get #add by huang - # matche '/news', :controller => 'news', :action => 'index', :as => 'news', :via => :get - #end - - resources :memberships, :shallow => true, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do - collection do - get 'autocomplete' - end - end - - resource :enumerations, :controller => 'project_enumerations', :only => [:update, :destroy] - - get 'issues/:copy_from/copy', :to => 'issues#new', :as => 'copy_issue' - resources :issues, :only => [:index, :new, :create] do - resources :time_entries, :controller => 'timelog' do - collection do - get 'report' - end - end - end - # issue form update - match 'issues/update_form', :controller => 'issues', :action => 'update_form', :via => [:put, :post], :as => 'issue_form' - - resources :files, :only => [:index, :new, :create] - - resources :versions, :except => [:index, :show, :edit, :update, :destroy] do - collection do - put 'close_completed' - end - end - get 'versions.:format', :to => 'versions#index' - get 'roadmap', :to => 'versions#index', :format => false - get 'versions', :to => 'versions#index' - - resources :news, :except => [:show, :edit, :update, :destroy] - resources :time_entries, :controller => 'timelog' do - get 'report', :on => :collection - end - resources :queries, :only => [:new, :create] - resources :issue_categories, :shallow => true - resources :documents, :except => [:show, :edit, :update, :destroy] - resources :boards - resources :repositories, :shallow => true, :except => [:index, :show] do - member do - match 'committers', :via => [:get, :post] - end - end - resources :repositories, :except => [:index, :show] do - member do - get 'newrepo', :via => [:get, :post] - # get 'create', :via=>[:get, :post] - end - end - match 'wiki/index', :controller => 'wiki', :action => 'index', :via => :get - resources :wiki, :except => [:index, :new, :create], :as => 'wiki_page' do - member do - get 'rename' - post 'rename' - get 'history' - get 'diff' - match 'preview', :via => [:post, :put] - post 'protect' - post 'add_attachment' - end - collection do - get 'export' - get 'date_index' - end - end - match 'wiki', :controller => 'wiki', :action => 'show', :via => :get - get 'wiki/:id/:version', :to => 'wiki#show', :constraints => {:version => /\d+/} - delete 'wiki/:id/:version', :to => 'wiki#destroy_version' - get 'wiki/:id/:version/annotate', :to => 'wiki#annotate' - get 'wiki/:id/:version/diff', :to => 'wiki#diff' - end - - resources :issues do - collection do - match 'bulk_edit', :via => [:get, :post] - post 'bulk_update' - end - resources :time_entries, :controller => 'timelog' do - collection do - get 'report' - end - end - resources :relations, :shallow => true, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy] - end - match '/issues', :controller => 'issues', :action => 'destroy', :via => :delete - - resources :queries, :except => [:show] - - resources :news, :only => [:index, :show, :edit, :update, :destroy] - match '/news/:id/comments', :to => 'comments#create', :via => :post - match '/news/:id/comments/:comment_id', :to => 'comments#destroy', :via => :delete - - resources :versions, :only => [:show, :edit, :update, :destroy] do - post 'status_by', :on => :member - end - - resources :documents, :only => [:show, :edit, :update, :destroy] do - post 'add_attachment', :on => :member - end - - match '/time_entries/context_menu', :to => 'context_menus#time_entries', :as => :time_entries_context_menu, :via => [:get, :post] - - resources :time_entries, :controller => 'timelog', :except => :destroy do - collection do - get 'report' - get 'bulk_edit' - post 'bulk_update' - end - end - match '/time_entries/:id', :to => 'timelog#destroy', :via => :delete, :id => /\d+/ - # TODO: delete /time_entries for bulk deletion - match '/time_entries/destroy', :to => 'timelog#destroy', :via => :delete - - get 'projects/:id/activity', :to => 'activities#index' - get 'projects/:id/activity.:format', :to => 'activities#index' - get 'activity', :to => 'activities#index' - - # repositories routes - get 'projects/:id/repository/:repository_id/statistics', :to => 'repositories#stats' - get 'projects/:id/repository/:repository_id/graph', :to => 'repositories#graph' - - get 'projects/:id/repository/:repository_id/changes(/*path(.:ext))', :to => 'repositories#changes' - - get 'projects/:id/repository/:repository_id/revisions/:rev', :to => 'repositories#revision' - get 'projects/:id/repository/:repository_id/revision', :to => 'repositories#revision' - post 'projects/:id/repository/:repository_id/revisions/:rev/issues', :to => 'repositories#add_related_issue' - delete 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue' - get 'projects/:id/repository/:repository_id/revisions', :to => 'repositories#revisions' - get 'projects/:id/repository/:repository_id/revisions/:rev/:action(/*path(.:ext))', - :controller => 'repositories', - :format => false, - :constraints => { - :action => /(browse|show|entry|raw|annotate|diff)/, - :rev => /[a-z0-9\.\-_]+/ - } - - get 'projects/:id/repository/statistics', :to => 'repositories#stats' - get 'projects/:id/repository/graph', :to => 'repositories#graph' - - get 'projects/:id/repository/changes(/*path(.:ext))', :to => 'repositories#changes' - - get 'projects/:id/repository/revisions', :to => 'repositories#revisions' - get 'projects/:id/repository/revisions/:rev', :to => 'repositories#revision' - get 'projects/:id/repository/revision', :to => 'repositories#revision' - post 'projects/:id/repository/revisions/:rev/issues', :to => 'repositories#add_related_issue' - delete 'projects/:id/repository/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue' - get 'projects/:id/repository/revisions/:rev/:action(/*path(.:ext))', - :controller => 'repositories', - :format => false, - :constraints => { - :action => /(browse|show|entry|raw|annotate|diff)/, - :rev => /[a-z0-9\.\-_]+/ - } - get 'projects/:id/repository/:repository_id/:action(/*path(.:ext))', - :controller => 'repositories', - :action => /(browse|show|entry|raw|changes|annotate|diff)/ - get 'projects/:id/repository/:action(/*path(.:ext))', - :controller => 'repositories', - :action => /(browse|show|entry|raw|changes|annotate|diff)/ - - get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil - get 'projects/:id/repository', :to => 'repositories#show', :path => nil - - # additional routes for having the file name at the end of url - get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment' - get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment' - get 'attachments/download/:id', :to => 'attachments#download', :id => /\d+/ - get 'attachments/thumbnail/:id(/:size)', :to => 'attachments#thumbnail', :id => /\d+/, :size => /\d+/, :as => 'thumbnail' - get 'attachments/autocomplete' - match 'attachments/autocomplete', :to => 'attachments#autocomplete', via: [:post] - post 'attachments/relationfile', to: 'attachments#add_exist_file_to_project', as: 'attach_relation' - resources :attachments, :only => [:show, :destroy] - - resources :groups do - member do - get 'autocomplete_for_user' - end - end - - match 'groups/:id/users', :controller => 'groups', :action => 'add_users', :id => /\d+/, :via => :post, :as => 'group_users' - match 'groups/:id/users/:user_id', :controller => 'groups', :action => 'remove_user', :id => /\d+/, :via => :delete, :as => 'group_user' - match 'groups/destroy_membership/:id', :controller => 'groups', :action => 'destroy_membership', :id => /\d+/, :via => :post - match 'groups/edit_membership/:id', :controller => 'groups', :action => 'edit_membership', :id => /\d+/, :via => :post - - resources :trackers, :except => :show do - collection do - match 'fields', :via => [:get, :post] - end - end - resources :issue_statuses, :except => :show do - collection do - post 'update_issue_done_ratio' - end - end - resources :custom_fields, :except => :show - resources :roles do - collection do - match 'permissions', :via => [:get, :post] - end - end - resources :enumerations, :except => :show - match 'enumerations/:type', :to => 'enumerations#index', :via => :get - - get 'projects/:id/search', :controller => 'search', :action => 'index' - get 'search', :controller => 'search', :action => 'index' - - match 'mail_handler', :controller => 'mail_handler', :action => 'index', :via => :post - - match 'admin', :controller => 'admin', :action => 'index', :via => :get - match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get - match 'admin/plugins', :controller => 'admin', :action => 'plugins', :via => :get - match 'admin/info', :controller => 'admin', :action => 'info', :via => :get - match 'admin/test_email', :controller => 'admin', :action => 'test_email', :via => :get - match 'admin/default_configuration', :controller => 'admin', :action => 'default_configuration', :via => :post - - resources :auth_sources do - member do - get 'test_connection', :as => 'try_connection' - end - collection do - get 'autocomplete_for_new_user' - end - end - - - - match 'workflows', :controller => 'workflows', :action => 'index', :via => :get - match 'workflows/edit', :controller => 'workflows', :action => 'edit', :via => [:get, :post] - match 'workflows/permissions', :controller => 'workflows', :action => 'permissions', :via => [:get, :post] - match 'workflows/copy', :controller => 'workflows', :action => 'copy', :via => [:get, :post] - match 'settings', :controller => 'settings', :action => 'index', :via => :get - match 'settings/edit', :controller => 'settings', :action => 'edit', :via => [:get, :post] - match 'settings/plugin/:id', :controller => 'settings', :action => 'plugin', :via => [:get, :post], :as => 'plugin_settings' - - match 'sys/projects', :to => 'sys#projects', :via => :get - match 'sys/projects/:id/repository', :to => 'sys#create_project_repository', :via => :post - match 'sys/fetch_changesets', :to => 'sys#fetch_changesets', :via => :get - - match 'uploads', :to => 'attachments#upload', :via => :post - # Added by Tao - match 'upload_avatar', :to => 'avatar#upload', :via => :post - # Endof Tao's code - get 'robots.txt', :to => 'welcome#robots' - - Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir| - file = File.join(plugin_dir, "config/routes.rb") - if File.exists?(file) - begin - instance_eval File.read(file) - rescue Exception => e - puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}." - exit 1 - end - end - end - - ##############测试留言功能 fq - post 'words/new', :to => 'words#new' - post 'words/create', :to => 'words#create' - post 'words/append', :to => 'words#append' - post 'words/create_reply', :to => 'words#create_reply' - delete 'words/destroy', :to => 'words#destroy' - get 'words/more', :to => 'words#more' - get 'words/back', :to=> 'words#back' - ############## fq - post 'calls/create', :to => 'bids#create' - delete 'calls/destroy', :to => 'bids#destroy' - match 'calls/new', :controller => 'bids', :action => 'new', :via => [:get , :post] - get 'calls/more', :to => 'bids#more' - get 'calls/back', :to=> 'bids#back' - match 'calls/new_bid', :controller => 'bids', :action => 'new_bid' - match 'contest/new_contest', :controller => 'bids', :action => 'new_contest' #huang - match 'calls/:id/show_project', :controller => 'bids', :action => 'show_project', :as => 'project_for_bid' - match 'calls/:id/show_project_homework', :controller => 'bids', :action => 'show_project_homework', :as => 'project_for_bid_homework' # by huang - match 'calls/:id/add', :controller => 'bids', :action => 'add' - match 'calls/:id/add_homework', :controller => 'bids', :action => 'add_homework', via: :post - match 'calls/:id/new_submit_homework', to: 'bids#new_submit_homework', via: :get, as: 'new_submit_homework' - match 'words/add_project_respond', :controller => 'words', :action => 'add_project_respond' - match 'words/:id/leave_project_message', :controller => 'words', :action => 'leave_project_message' - - match 'projects/:id/feedback', :to => 'projects#feedback', :via => :get, :as => 'project_feedback' - match 'calls/create_bid', :to => 'bids#create_bid' - match 'contest/create_contest', :to => 'bids#create_contest' #huang - match 'calls/create_homework', :to => 'bids#create_homework' - match 'calls/:id/homework_respond', :to => 'bids#homework_respond' - match 'calls/:id/homework_statistics', :to => 'bids#homework_statistics' - match 'calls/:id/fork', :to => 'bids#fork', :as => 'fork' - match 'calls/:id/create_fork', :to => 'bids#create_fork' - match 'project/enterprise_course', :to => 'projects#enterprise_course' - match 'project/course_enterprise', :to => 'projects#course_enterprise' - match 'calls/:id/show_course', :to => 'bids#show_course', :as => 'show_course' - match 'calls/:id/show_bid_project', :to => 'bids#show_bid_project', :as => 'show_bid_project' - match 'calls/:id/show_bid_user', :to => 'bids#show_bid_user', :as => 'show_bid_user' - - match 'project/:id/share', :to => 'projects#share', :as => 'share_show' #share - - post 'join_in/join', :to => 'courses#join', :as => 'join' - delete 'join_in/join', :to => 'courses#unjoin' - post 'calls/:id/join_in_contest', :to => 'bids#join_in_contest', :as => 'join_in_contest' - delete 'calls/:id/join_in_contest', :to => 'bids#unjoin_in_contest' - match 'calls/:id/show_participator', :to => 'bids#show_participator' #bai - match 'calls/:id/update_contest', :to => 'bids#update_contest' #bai - match 'calls/:id/settings', :to => 'bids#settings' #bai - - delete 'attachment/:id', :to => 'attachments#delete_homework' - match 'new_join', :to => 'projects#new_join', :as => 'try_join' - match 'new_join_in_contest', :to => 'bids#new_join', :as => 'try_join_in_contest' - match 'projects/:id/respond', :to => 'projects#project_respond', :via => :post - match 'calls/:id/manage',:to => 'bids#manage',:via => [:get,:post] - match 'project/course', :to => 'projects#course', :as => 'course' - - #added by william - # match 'calls/:id/set_results',:controller => 'bids', :action => 'set_results',:via => [:get,:post],:as => 'set_results' - # match 'calls/:id/set_prizes',:controller => 'bids',:action => 'set_prizes',:as => 'set_prizes' - match 'calls/:id/set_reward',:controller => 'bids',:action => 'set_reward',:as => 'set_reward' - - ## 测试用 - match 'test/index', :controller => 'test', :action => 'index' - # added by young - match 'calls', :controller => 'bids', :action => 'index' - - match 'calls/:id', :controller => 'bids', :action => 'show', :as => 'respond' - match 'contest', :controller => 'bids', :action => 'contest', :as => 'contest' - - ######added by nie - match 'tags/show_projects_tags',:to => 'tags#show_projects_tags' - ########### added by liuping - match 'tags/add_tag',:to => 'tags#add_tag',:as=>"add_tag" - match 'tags/delete_tag',:to => 'tags#delete_tag',:as=>"add_tag" - match 'tags/show_all',:to => 'tags#show_all' - match 'parise_tread/praise_plus',:to => 'parise_tread#praise_plus',:as=>"praise" - match 'parise_tread/tread_plus',:to => 'parise_tread#tread_plus',:as=>"tread" - match 'tags/delete',:to=>'tags#delete' - match 'tags/remove_tag',:to=>'tags#remove_tag',:as=>"remove_tag" - - match 'words/add_brief_introdution', :controller => 'words', :action => 'add_brief_introdution' - - get ':controller(/:action(/:id))' -end +# Redmine - project management software +# Copyright (C) 2006-2013 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write tobthe Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +RedmineApp::Application.routes.draw do + namespace :zipdown do + match 'assort' + end + namespace :test do + match 'courselist' + match 'zip' + end + + resources :stores do + collection do + match 'search', via: [:get, :post] + end + end + + resources :forums do + collection do + match 'search_forum', :via => [:get, :post] + end + member do + post 'create_memo' + match 'search_memo', :via => [:get, :post] + end + resources :memos do + collection do + get "quote" + end + end + end + + + resources :shares + + #added by william + get "tags/index" + + get "tags/show" + + get "praise_tread/praise_plus" + + get "praise_tread/tread_plus" + #end + + root :to => 'welcome#index', :as => 'home' + + #added by baiyu + match 'git_usage/ch_usage', :controller => 'git_usage', :action => 'ch_usage', :via => :get, :as => 'ch_usage' + match 'git_usage/en_usage', :controller => 'git_usage', :action => 'en_usage', :via => :get, :as => 'en_usage' + #added by nie + match '/projects/search', :controller => 'projects', :action => 'search', :via => [:get, :post] + match '/users/search', :controller => 'users', :action => 'search', :via => [:get, :post] + #end + match 'login', :to => 'account#login', :as => 'signin', :via => [:get, :post] + match 'logout', :to => 'account#logout', :as => 'signout', :via => [:get, :post] + match 'account/register', :to => 'account#register', :via => [:get, :post], :as => 'register' + match 'account/lost_password', :to => 'account#lost_password', :via => [:get, :post], :as => 'lost_password' + match 'account/activate', :to => 'account#activate', :via => :get + + match '/news/preview', :controller => 'previews', :action => 'news', :as => 'preview_news', :via => [:get, :post, :put] + match '/issues/preview/new/:project_id', :to => 'previews#issue', :as => 'preview_new_issue', :via => [:get, :post, :put] + match '/issues/preview/edit/:id', :to => 'previews#issue', :as => 'preview_edit_issue', :via => [:get, :post, :put] + match '/issues/preview', :to => 'previews#issue', :as => 'preview_issue', :via => [:get, :post, :put] + + match 'projects/:id/wiki', :to => 'wikis#edit', :via => :post + match 'projects/:id/wiki/destroy', :to => 'wikis#destroy', :via => [:get, :post] + + # boards + match 'boards/:board_id/topics/new', :to => 'messages#new', :via => [:get, :post], :as => 'new_board_message' + get 'boards/:board_id/topics/:id', :to => 'messages#show', :as => 'board_message' + match 'boards/:board_id/topics/quote/:id', :to => 'messages#quote', :via => [:get, :post] + get 'boards/:board_id/topics/:id/edit', :to => 'messages#edit' + + post 'boards/:board_id/topics/preview', :to => 'messages#preview', :as => 'preview_board_message' + post 'boards/:board_id/topics/:id/replies', :to => 'messages#reply' + post 'boards/:board_id/topics/:id/edit', :to => 'messages#edit' + post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy' + # boards end + post 'bids/homework_destroy', :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' + match '/issues/context_menu', :to => 'context_menus#issues', :as => 'issues_context_menu', :via => [:get, :post] + match '/issues/changes', :to => 'journals#index', :as => 'issue_changes', :via => :get + match '/issues/:id/quoted', :to => 'journals#new', :id => /\d+/, :via => :post, :as => 'quoted_issue' + + match '/journals/diff/:id', :to => 'journals#diff', :id => /\d+/, :via => :get + match '/journals/edit/:id', :to => 'journals#edit', :id => /\d+/, :via => [:get, :post] + match '/journals/destroy/:id', :to => 'journals#destroy', :id => /\d+/, :via => [:get, :post] + + + get '/projects/:project_id/issues/gantt', :to => 'gantts#show', :as => 'project_gantt' + get '/issues/gantt', :to => 'gantts#show' + + get '/projects/:project_id/issues/calendar', :to => 'calendars#show', :as => 'project_calendar' + get '/issues/calendar', :to => 'calendars#show' + + get 'projects/:id/issues/report', :to => 'reports#issue_report', :as => 'project_issues_report' + get 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :as => 'project_issues_report_details' + post '/users/:id/user_activities', :to => 'users#show', :as => "user_activities" + + #added by young + resources :users do + member do + match 'user_projects', :to => 'users#user_projects', :via => :get + match 'user_activities', :to => 'users#show', :via => :get, :as => "user_activities" + match 'user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "user_newfeedback" + match 'watch_calls', :controller => 'users', :action => 'watch_bids', :via => [:get , :post] + match 'info', :to => 'users#info', :via => [:get , :post], :as => 'user_info' + match 'user_watchlist', :to => 'users#user_watchlist', :via => :get, :as => "user_watchlist" #add by huang + match 'user_fanslist', :to => 'users#user_fanslist', :via => :get, :as => "user_fanslist" #add by huang + match 'user_courses', :to => 'users#user_courses', :via => :get + match 'user_homeworks', :to => 'users#user_homeworks', :via => :get + match 'watch_projects', :to => 'users#watch_projects', :via => :get + # added by bai + match 'show_score', :to => 'users#show_score', :via => :get + match 'topic_score_index', :controller => 'users', :action => 'topic_score_index', :via => [:get, :post] + match 'project_score_index', :to => 'users#project_score_index', :via => :get + match 'activity_score_index', :to => 'users#activity_score_index', :via => :get + match 'influence_score_index', :to => 'users#influence_score_index', :via => :get + match 'score_index', :to => 'users#score_index', :via => :get + + match 'show_projects_score', :to => 'projects#show_projects_score', :via => [:get, :post] + match 'issue_score_index', :to => 'projects#issue_score_index', :via => [:get, :post] + match 'news_score_index', :to => 'projects#news_score_index', :via => [:get, :post] + match 'file_score_index', :to => 'projects#file_score_index', :via => [:get, :post] + match 'code_submit_score_index', :to => 'projects#code_submit_score_index', :via => [:get, :post] + match 'projects_topic_score_index', :to => 'projects#projects_topic_score_index', :via => [:get, :post] + # end + end + end + match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback" + match 'users/:id/user_projects', :controller => 'users', :action => 'user_projects', :via => :get + #match 'user/:id/watch_calls', :controller => 'users', :action => 'watch_bids', :via => [:get , :post] + + #end + match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :post] + match 'my/account/destroy', :controller => 'my', :action => 'destroy', :via => [:get, :post] + match 'my/page', :controller => 'my', :action => 'page', :via => :get + match 'my', :controller => 'my', :action => 'index', :via => :get # Redirects to my/page + match 'my/reset_rss_key', :controller => 'my', :action => 'reset_rss_key', :via => :post + match 'my/reset_api_key', :controller => 'my', :action => 'reset_api_key', :via => :post + match 'my/password', :controller => 'my', :action => 'password', :via => [:get, :post] + match 'my/page_layout', :controller => 'my', :action => 'page_layout', :via => :get + match 'my/add_block', :controller => 'my', :action => 'add_block', :via => :post + match 'my/remove_block', :controller => 'my', :action => 'remove_block', :via => :post + match 'my/order_blocks', :controller => 'my', :action => 'order_blocks', :via => :post + + resources :users + match 'users/:id/memberships/:membership_id', :to => 'users#edit_membership', :via => :put, :as => 'user_membership' + match 'users/:id/memberships/:membership_id', :to => 'users#destroy_membership', :via => :delete + match 'users/:id/memberships', :to => 'users#edit_membership', :via => :post, :as => 'user_memberships' + ################# added by william + match 'users/tag_save', :to => 'users#tag_save', :via => :post, :as => 'tag' + + post 'watchers/watch', :to => 'watchers#watch', :as => 'watch' + delete 'watchers/watch', :to => 'watchers#unwatch' + get 'watchers/new', :to => 'watchers#new' + post 'watchers', :to => 'watchers#create' + post 'watchers/append', :to => 'watchers#append' + delete 'watchers', :to => 'watchers#destroy' + get 'watchers/autocomplete_for_user', :to => 'watchers#autocomplete_for_user' + # Specific routes for issue watchers API + post 'issues/:object_id/watchers', :to => 'watchers#create', :object_type => 'issue' + delete 'issues/:object_id/watchers/:user_id' => 'watchers#destroy', :object_type => 'issue' + + resources :bids, :only=>[:edit,:update,:show] do + member do + match 'homework_ajax_modal' + end + end + resources :projects do + member do + post 'finishcourse' + post 'restartcourse' + get 'settings(/:tab)', :action => 'settings', :as => 'settings' + #by young + get 'member', :controller => 'projects', :action => 'member', :as => 'member' + get 'file', :action => 'file', :as => 'file' + get 'statistics', :action => 'statistics', :as => 'statistics' + get 'feedback', :action => 'feedback', :as => 'project_feedback' + get 'watcherlist', :action=> 'watcherlist' + match 'user_watcherlist', :to => 'projects#watcherlist', :via => :get, :as => "watcherlist" #add by huang + get 'homework', :action => 'homework', :as => 'homework' + get 'new_homework', :action => 'new_homework', :as => 'new_homework' + #get 'news', :action => 'news', :as => 'news' + #end + post 'modules' + post 'archive' + post 'unarchive' + post 'close' + post 'reopen' + match 'copy', :via => [:get, :post] + end + + + #by young + match '/member', :controller => 'projects', :action => 'member', :as => 'member', :via => :get + match '/file', :controller => 'projects', :action => 'file', :as => 'file', :via => :get + match '/statistics', :controller => 'projects', :action => 'statistics', :as => 'statistics', :via => :get + # match '/investor', :controller => 'projects', :action => 'investor', :as => 'investor', :via => :get + match '/homework', :controller => 'projects', :action => 'homework', :as => 'homework', :via => :get + + + # match '/activity', :controller => 'activities', :action => 'index', :as => 'activity', :via => :get + # match '/repository', :controller => 'repositories', :action => 'show', :repository_id => nil, :path => nil, :rev => nil, :as => 'repository', :via => :get + # match '/', :controller => 'projects', :action => 'show', :as => 'project_show', :via => :get + # get 'projects/:project_id/show', :to => 'projects#show', :as => 'project_show' + # get 'projects/:project_id/repository', :to => 'repositories#show', :as => 'project_repository' + + # match '/show', :controller => 'projects', :action => 'show', :as => 'project_show', :via => :get + match '/watcherlist', :controller=>'projects', :action=> 'watcherlist', :as => 'watcherlist', :via => :get #add by huang + # matche '/news', :controller => 'news', :action => 'index', :as => 'news', :via => :get + #end + + resources :memberships, :shallow => true, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do + collection do + get 'autocomplete' + end + end + + resource :enumerations, :controller => 'project_enumerations', :only => [:update, :destroy] + + get 'issues/:copy_from/copy', :to => 'issues#new', :as => 'copy_issue' + resources :issues, :only => [:index, :new, :create] do + resources :time_entries, :controller => 'timelog' do + collection do + get 'report' + end + end + end + # issue form update + match 'issues/update_form', :controller => 'issues', :action => 'update_form', :via => [:put, :post], :as => 'issue_form' + + resources :files, :only => [:index, :new, :create] + + resources :versions, :except => [:index, :show, :edit, :update, :destroy] do + collection do + put 'close_completed' + end + end + get 'versions.:format', :to => 'versions#index' + get 'roadmap', :to => 'versions#index', :format => false + get 'versions', :to => 'versions#index' + + resources :news, :except => [:show, :edit, :update, :destroy] + resources :time_entries, :controller => 'timelog' do + get 'report', :on => :collection + end + resources :queries, :only => [:new, :create] + resources :issue_categories, :shallow => true + resources :documents, :except => [:show, :edit, :update, :destroy] + resources :boards + resources :repositories, :shallow => true, :except => [:index, :show] do + member do + match 'committers', :via => [:get, :post] + end + end + resources :repositories, :except => [:index, :show] do + member do + get 'newrepo', :via => [:get, :post] + # get 'create', :via=>[:get, :post] + end + end + match 'wiki/index', :controller => 'wiki', :action => 'index', :via => :get + resources :wiki, :except => [:index, :new, :create], :as => 'wiki_page' do + member do + get 'rename' + post 'rename' + get 'history' + get 'diff' + match 'preview', :via => [:post, :put] + post 'protect' + post 'add_attachment' + end + collection do + get 'export' + get 'date_index' + end + end + match 'wiki', :controller => 'wiki', :action => 'show', :via => :get + get 'wiki/:id/:version', :to => 'wiki#show', :constraints => {:version => /\d+/} + delete 'wiki/:id/:version', :to => 'wiki#destroy_version' + get 'wiki/:id/:version/annotate', :to => 'wiki#annotate' + get 'wiki/:id/:version/diff', :to => 'wiki#diff' + end + + resources :issues do + collection do + match 'bulk_edit', :via => [:get, :post] + post 'bulk_update' + end + resources :time_entries, :controller => 'timelog' do + collection do + get 'report' + end + end + resources :relations, :shallow => true, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy] + end + match '/issues', :controller => 'issues', :action => 'destroy', :via => :delete + + resources :queries, :except => [:show] + + resources :news, :only => [:index, :show, :edit, :update, :destroy] + match '/news/:id/comments', :to => 'comments#create', :via => :post + match '/news/:id/comments/:comment_id', :to => 'comments#destroy', :via => :delete + + resources :versions, :only => [:show, :edit, :update, :destroy] do + post 'status_by', :on => :member + end + + resources :documents, :only => [:show, :edit, :update, :destroy] do + post 'add_attachment', :on => :member + end + + match '/time_entries/context_menu', :to => 'context_menus#time_entries', :as => :time_entries_context_menu, :via => [:get, :post] + + resources :time_entries, :controller => 'timelog', :except => :destroy do + collection do + get 'report' + get 'bulk_edit' + post 'bulk_update' + end + end + match '/time_entries/:id', :to => 'timelog#destroy', :via => :delete, :id => /\d+/ + # TODO: delete /time_entries for bulk deletion + match '/time_entries/destroy', :to => 'timelog#destroy', :via => :delete + + get 'projects/:id/activity', :to => 'activities#index' + get 'projects/:id/activity.:format', :to => 'activities#index' + get 'activity', :to => 'activities#index' + + # repositories routes + get 'projects/:id/repository/:repository_id/statistics', :to => 'repositories#stats' + get 'projects/:id/repository/:repository_id/graph', :to => 'repositories#graph' + + get 'projects/:id/repository/:repository_id/changes(/*path(.:ext))', :to => 'repositories#changes' + + get 'projects/:id/repository/:repository_id/revisions/:rev', :to => 'repositories#revision' + get 'projects/:id/repository/:repository_id/revision', :to => 'repositories#revision' + post 'projects/:id/repository/:repository_id/revisions/:rev/issues', :to => 'repositories#add_related_issue' + delete 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue' + get 'projects/:id/repository/:repository_id/revisions', :to => 'repositories#revisions' + get 'projects/:id/repository/:repository_id/revisions/:rev/:action(/*path(.:ext))', + :controller => 'repositories', + :format => false, + :constraints => { + :action => /(browse|show|entry|raw|annotate|diff)/, + :rev => /[a-z0-9\.\-_]+/ + } + + get 'projects/:id/repository/statistics', :to => 'repositories#stats' + get 'projects/:id/repository/graph', :to => 'repositories#graph' + + get 'projects/:id/repository/changes(/*path(.:ext))', :to => 'repositories#changes' + + get 'projects/:id/repository/revisions', :to => 'repositories#revisions' + get 'projects/:id/repository/revisions/:rev', :to => 'repositories#revision' + get 'projects/:id/repository/revision', :to => 'repositories#revision' + post 'projects/:id/repository/revisions/:rev/issues', :to => 'repositories#add_related_issue' + delete 'projects/:id/repository/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue' + get 'projects/:id/repository/revisions/:rev/:action(/*path(.:ext))', + :controller => 'repositories', + :format => false, + :constraints => { + :action => /(browse|show|entry|raw|annotate|diff)/, + :rev => /[a-z0-9\.\-_]+/ + } + get 'projects/:id/repository/:repository_id/:action(/*path(.:ext))', + :controller => 'repositories', + :action => /(browse|show|entry|raw|changes|annotate|diff)/ + get 'projects/:id/repository/:action(/*path(.:ext))', + :controller => 'repositories', + :action => /(browse|show|entry|raw|changes|annotate|diff)/ + + get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil + get 'projects/:id/repository', :to => 'repositories#show', :path => nil + + # additional routes for having the file name at the end of url + get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment' + get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment' + get 'attachments/download/:id', :to => 'attachments#download', :id => /\d+/ + get 'attachments/thumbnail/:id(/:size)', :to => 'attachments#thumbnail', :id => /\d+/, :size => /\d+/, :as => 'thumbnail' + get 'attachments/autocomplete' + match 'attachments/autocomplete', :to => 'attachments#autocomplete', via: [:post] + post 'attachments/relationfile', to: 'attachments#add_exist_file_to_project', as: 'attach_relation' + resources :attachments, :only => [:show, :destroy] + + resources :groups do + member do + get 'autocomplete_for_user' + end + end + + match 'groups/:id/users', :controller => 'groups', :action => 'add_users', :id => /\d+/, :via => :post, :as => 'group_users' + match 'groups/:id/users/:user_id', :controller => 'groups', :action => 'remove_user', :id => /\d+/, :via => :delete, :as => 'group_user' + match 'groups/destroy_membership/:id', :controller => 'groups', :action => 'destroy_membership', :id => /\d+/, :via => :post + match 'groups/edit_membership/:id', :controller => 'groups', :action => 'edit_membership', :id => /\d+/, :via => :post + + resources :trackers, :except => :show do + collection do + match 'fields', :via => [:get, :post] + end + end + resources :issue_statuses, :except => :show do + collection do + post 'update_issue_done_ratio' + end + end + resources :custom_fields, :except => :show + resources :roles do + collection do + match 'permissions', :via => [:get, :post] + end + end + resources :enumerations, :except => :show + match 'enumerations/:type', :to => 'enumerations#index', :via => :get + + get 'projects/:id/search', :controller => 'search', :action => 'index' + get 'search', :controller => 'search', :action => 'index' + + match 'mail_handler', :controller => 'mail_handler', :action => 'index', :via => :post + + match 'admin', :controller => 'admin', :action => 'index', :via => :get + match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get + match 'admin/plugins', :controller => 'admin', :action => 'plugins', :via => :get + match 'admin/info', :controller => 'admin', :action => 'info', :via => :get + match 'admin/test_email', :controller => 'admin', :action => 'test_email', :via => :get + match 'admin/default_configuration', :controller => 'admin', :action => 'default_configuration', :via => :post + + resources :auth_sources do + member do + get 'test_connection', :as => 'try_connection' + end + collection do + get 'autocomplete_for_new_user' + end + end + + + + match 'workflows', :controller => 'workflows', :action => 'index', :via => :get + match 'workflows/edit', :controller => 'workflows', :action => 'edit', :via => [:get, :post] + match 'workflows/permissions', :controller => 'workflows', :action => 'permissions', :via => [:get, :post] + match 'workflows/copy', :controller => 'workflows', :action => 'copy', :via => [:get, :post] + match 'settings', :controller => 'settings', :action => 'index', :via => :get + match 'settings/edit', :controller => 'settings', :action => 'edit', :via => [:get, :post] + match 'settings/plugin/:id', :controller => 'settings', :action => 'plugin', :via => [:get, :post], :as => 'plugin_settings' + + match 'sys/projects', :to => 'sys#projects', :via => :get + match 'sys/projects/:id/repository', :to => 'sys#create_project_repository', :via => :post + match 'sys/fetch_changesets', :to => 'sys#fetch_changesets', :via => :get + + match 'uploads', :to => 'attachments#upload', :via => :post + # Added by Tao + match 'upload_avatar', :to => 'avatar#upload', :via => :post + # Endof Tao's code + get 'robots.txt', :to => 'welcome#robots' + + Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir| + file = File.join(plugin_dir, "config/routes.rb") + if File.exists?(file) + begin + instance_eval File.read(file) + rescue Exception => e + puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}." + exit 1 + end + end + end + + ##############测试留言功能 fq + post 'words/new', :to => 'words#new' + post 'words/create', :to => 'words#create' + post 'words/append', :to => 'words#append' + post 'words/create_reply', :to => 'words#create_reply' + delete 'words/destroy', :to => 'words#destroy' + get 'words/more', :to => 'words#more' + get 'words/back', :to=> 'words#back' + ############## fq + post 'calls/create', :to => 'bids#create' + delete 'calls/destroy', :to => 'bids#destroy' + match 'calls/new', :controller => 'bids', :action => 'new', :via => [:get , :post] + get 'calls/more', :to => 'bids#more' + get 'calls/back', :to=> 'bids#back' + match 'calls/new_bid', :controller => 'bids', :action => 'new_bid' + match 'contest/new_contest', :controller => 'bids', :action => 'new_contest' #huang + match 'calls/:id/show_project', :controller => 'bids', :action => 'show_project', :as => 'project_for_bid' + match 'calls/:id/show_project_homework', :controller => 'bids', :action => 'show_project_homework', :as => 'project_for_bid_homework' # by huang + match 'calls/:id/add', :controller => 'bids', :action => 'add' + match 'calls/:id/add_homework', :controller => 'bids', :action => 'add_homework', via: :post + match 'calls/:id/new_submit_homework', to: 'bids#new_submit_homework', via: :get, as: 'new_submit_homework' + match 'words/add_project_respond', :controller => 'words', :action => 'add_project_respond' + match 'words/:id/leave_project_message', :controller => 'words', :action => 'leave_project_message' + + match 'projects/:id/feedback', :to => 'projects#feedback', :via => :get, :as => 'project_feedback' + match 'calls/create_bid', :to => 'bids#create_bid' + match 'contest/create_contest', :to => 'bids#create_contest' #huang + match 'calls/create_homework', :to => 'bids#create_homework' + match 'calls/:id/homework_respond', :to => 'bids#homework_respond' + match 'calls/:id/homework_statistics', :to => 'bids#homework_statistics' + match 'calls/:id/fork', :to => 'bids#fork', :as => 'fork' + match 'calls/:id/create_fork', :to => 'bids#create_fork' + match 'project/enterprise_course', :to => 'projects#enterprise_course' + match 'project/course_enterprise', :to => 'projects#course_enterprise' + match 'calls/:id/show_course', :to => 'bids#show_course', :as => 'show_course' + match 'calls/:id/show_bid_project', :to => 'bids#show_bid_project', :as => 'show_bid_project' + match 'calls/:id/show_bid_user', :to => 'bids#show_bid_user', :as => 'show_bid_user' + + match 'project/:id/share', :to => 'projects#share', :as => 'share_show' #share + + post 'join_in/join', :to => 'courses#join', :as => 'join' + delete 'join_in/join', :to => 'courses#unjoin' + post 'calls/:id/join_in_contest', :to => 'bids#join_in_contest', :as => 'join_in_contest' + delete 'calls/:id/join_in_contest', :to => 'bids#unjoin_in_contest' + match 'calls/:id/show_participator', :to => 'bids#show_participator' #bai + match 'calls/:id/update_contest', :to => 'bids#update_contest' #bai + match 'calls/:id/settings', :to => 'bids#settings' #bai + + delete 'attachment/:id', :to => 'attachments#delete_homework' + match 'new_join', :to => 'projects#new_join', :as => 'try_join' + match 'new_join_in_contest', :to => 'bids#new_join', :as => 'try_join_in_contest' + match 'projects/:id/respond', :to => 'projects#project_respond', :via => :post + match 'calls/:id/manage',:to => 'bids#manage',:via => [:get,:post] + match 'project/course', :to => 'projects#course', :as => 'course' + + #added by william + # match 'calls/:id/set_results',:controller => 'bids', :action => 'set_results',:via => [:get,:post],:as => 'set_results' + # match 'calls/:id/set_prizes',:controller => 'bids',:action => 'set_prizes',:as => 'set_prizes' + match 'calls/:id/set_reward',:controller => 'bids',:action => 'set_reward',:as => 'set_reward' + + # added by young + match 'calls', :controller => 'bids', :action => 'index' + + match 'calls/:id', :controller => 'bids', :action => 'show', :as => 'respond' + match 'contest', :controller => 'bids', :action => 'contest', :as => 'contest' + + + ######################## + ##added by wen########## + #######confusing######## + post 'school/get_options/:province', :to => 'school#get_options' + get 'school/get_options/:province', :to => 'school#get_options' + + + + ######added by nie + match 'tags/show_projects_tags',:to => 'tags#show_projects_tags' + ########### added by liuping + match 'tags/add_tag',:to => 'tags#add_tag',:as=>"add_tag" + match 'tags/delete_tag',:to => 'tags#delete_tag',:as=>"add_tag" + match 'tags/show_all',:to => 'tags#show_all' + match 'parise_tread/praise_plus',:to => 'parise_tread#praise_plus',:as=>"praise" + match 'parise_tread/tread_plus',:to => 'parise_tread#tread_plus',:as=>"tread" + match 'tags/delete',:to=>'tags#delete' + match 'tags/remove_tag',:to=>'tags#remove_tag',:as=>"remove_tag" + + match 'words/add_brief_introdution', :controller => 'words', :action => 'add_brief_introdution' + + get ':controller(/:action(/:id))' +end diff --git a/db/migrate/20140415090718_remove_schoolid_from_courses.rb b/db/migrate/20140415090718_remove_schoolid_from_courses.rb new file mode 100644 index 000000000..96b3a4ace --- /dev/null +++ b/db/migrate/20140415090718_remove_schoolid_from_courses.rb @@ -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 diff --git a/db/migrate/20140415090829_add_school_name_to_courses.rb b/db/migrate/20140415090829_add_school_name_to_courses.rb new file mode 100644 index 000000000..1c9175e12 --- /dev/null +++ b/db/migrate/20140415090829_add_school_name_to_courses.rb @@ -0,0 +1,6 @@ +class AddSchoolNameToCourses < ActiveRecord::Migration + def change + add_column :courses, :school_name, :string + + end +end diff --git a/db/schema.rb b/db/schema.rb index 9584fa817..a5cb5409c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140320022724) do +ActiveRecord::Schema.define(:version => 20140415090829) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -157,6 +157,38 @@ ActiveRecord::Schema.define(:version => 20140320022724) do add_index "comments", ["author_id"], :name => "index_comments_on_author_id" add_index "comments", ["commented_id", "commented_type"], :name => "index_comments_on_commented_id_and_commented_type" + create_table "contesting_projects", :force => true do |t| + t.integer "project_id" + t.string "contest_id" + t.integer "user_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + end + + create_table "contesting_softapplications", :force => true do |t| + t.integer "softapplication_id" + t.integer "contest_id" + t.integer "user_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + end + + create_table "contests", :force => true do |t| + t.string "name" + t.integer "budget" + t.integer "author_id" + t.date "deadline" + t.string "description" + t.integer "commit" + t.string "password" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + end + create_table "courses", :force => true do |t| t.integer "tea_id" t.string "name" @@ -173,7 +205,7 @@ ActiveRecord::Schema.define(:version => 20140320022724) do t.string "setup_time" t.string "endup_time" t.string "class_period" - t.integer "school_id" + t.string "school_name" end create_table "custom_fields", :force => true do |t| @@ -354,6 +386,13 @@ ActiveRecord::Schema.define(:version => 20140320022724) do add_index "issues", ["status_id"], :name => "index_issues_on_status_id" add_index "issues", ["tracker_id"], :name => "index_issues_on_tracker_id" + create_table "join_in_competitions", :force => true do |t| + t.integer "user_id" + t.integer "competition_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "join_in_contests", :force => true do |t| t.integer "user_id" t.integer "bid_id" @@ -645,6 +684,21 @@ ActiveRecord::Schema.define(:version => 20140320022724) do t.string "description" end + create_table "softapplications", :force => true do |t| + t.string "name" + t.string "description" + t.integer "app_type_id" + t.string "app_type_name" + t.string "android_min_version_available" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "contest_id" + t.integer "softapplication_id" + t.integer "is_public" + t.string "application_developers" + end + create_table "students_for_courses", :force => true do |t| t.integer "student_id" t.integer "course_id" @@ -758,6 +812,16 @@ ActiveRecord::Schema.define(:version => 20140320022724) do add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id" + create_table "user_scores", :force => true do |t| + t.integer "user_id", :null => false + t.integer "collaboration" + t.integer "influence" + t.integer "skill" + t.integer "active" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "user_statuses", :force => true do |t| t.integer "changesets_count" t.integer "watchers_count" diff --git a/lib/tasks/rubyzip.rake b/lib/tasks/rubyzip.rake new file mode 100644 index 000000000..349ced29b --- /dev/null +++ b/lib/tasks/rubyzip.rake @@ -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 \ No newline at end of file diff --git a/public/images/footer_logo/buaa_scse.jpg b/public/images/footer_logo/buaa_scse.jpg new file mode 100644 index 000000000..68ebbc1d3 Binary files /dev/null and b/public/images/footer_logo/buaa_scse.jpg differ diff --git a/public/images/footer_logo/inforbus.jpg b/public/images/footer_logo/inforbus.jpg new file mode 100644 index 000000000..f3249be16 Binary files /dev/null and b/public/images/footer_logo/inforbus.jpg differ diff --git a/public/images/footer_logo/iscas.jpg b/public/images/footer_logo/iscas.jpg new file mode 100644 index 000000000..a26ccad38 Binary files /dev/null and b/public/images/footer_logo/iscas.jpg differ diff --git a/public/images/footer_logo/nudt.jpg b/public/images/footer_logo/nudt.jpg new file mode 100644 index 000000000..15adbbfd9 Binary files /dev/null and b/public/images/footer_logo/nudt.jpg differ diff --git a/public/images/footer_logo/pdl.jpg b/public/images/footer_logo/pdl.jpg new file mode 100644 index 000000000..15adbbfd9 Binary files /dev/null and b/public/images/footer_logo/pdl.jpg differ diff --git a/public/images/footer_logo/peking_eecs.jpg b/public/images/footer_logo/peking_eecs.jpg new file mode 100644 index 000000000..e00692bc5 Binary files /dev/null and b/public/images/footer_logo/peking_eecs.jpg differ diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js index 7b8394fe8..3d1520f84 100644 --- a/public/javascripts/attachments.js +++ b/public/javascripts/attachments.js @@ -7,14 +7,14 @@ function addFile(inputEl, file, eagerUpload) { var attachmentId = addFile.nextAttachmentId++; - var fileSpan = $('', { id: 'attachments_' + attachmentId }); + var fileSpan = $('', { 'id': 'attachments_' + attachmentId, 'class':'attachment' }); fileSpan.append( - $('', { type: 'text', 'class': 'filename readonly', name: 'attachments[' + attachmentId + '][filename]', readonly: 'readonly'} ).val(file.name), - $('', { type: 'text', 'class': 'description', name: 'attachments[' + attachmentId + '][description]', maxlength: 255, placeholder: $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload), - $(' ').attr({ href: "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload) + $('', { 'type': 'text', 'class': 'filename readonly', 'name': 'attachments[' + attachmentId + '][filename]', 'readonly': 'readonly'} ).val(file.name), + $('', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 255, 'placeholder': $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload), + $(' ').attr({ 'href': "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload) ).appendTo('#attachments_fields'); - + if(eagerUpload) { ajaxUpload(file, attachmentId, fileSpan, inputEl); } @@ -63,6 +63,22 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) { } form.dequeue('upload'); }); + + //gcm files count and add delete_all link + + var count=$('#attachments_fields>span').length; + $('#upload_file_count').html("已上传"+""+count+""+"个文件"); + + if(count>=1){ + var add_attachs=$('.add_attachment'); + var delete_all=$('.remove_all'); + if(delete_all.length<1){ + add_attachs.append($(" ").attr({"href":"javascript:void(0)", 'class': 'remove_all',"onclick": "removeAll()"})); + } + } + + //gcm + } var progressSpan = $('
').insertAfter(fileSpan.find('input.filename')); @@ -84,6 +100,16 @@ function removeFile() { return false; } +//gcm delete all file +function removeAll(){ + if(confirm("您确定要删除所有文件吗?")){ + $(".remove-upload").removeAttr("data-confirm"); + $(".remove-upload").click(); + } +// return false; +} +//gcm + function uploadBlob(blob, uploadUrl, attachmentId, options) { var actualOptions = $.extend({ diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index e60316841..c3572f930 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -1727,7 +1727,7 @@ ul.properties li span {font-style:italic;} /*end*/ .autoscroll {overflow-x: auto; padding:1px; margin-bottom: 1.2em;} -#user_login, #user_firstname, #user_lastname, #user_mail, #my_account_form select, #user_form select, #user_identity_url { width: 60%; } +/*#user_login, #user_firstname, #user_lastname, #user_mail, #my_account_form select, #user_form select, #user_identity_url { width: 45%; }*/ #workflow_copy_form select { width: 200px; } table.transitions td.enabled {background: #bfb;} @@ -1821,6 +1821,11 @@ span.required {color: #bb0000;} a.remove-upload {background: url(../images/delete.png) no-repeat 1px 50%; width:1px; display:inline-block; padding-left:16px;} a.remove-upload:hover {text-decoration:none !important;} +/*gcm upload file count and deleteall*/ +#upload_file_count #count {color:red; font-size:1.5em;} +span.add_attachment .remove_all {background:none;background: url(../images/delete.png) no-repeat 1px 50%; width:1px; display:inline-block;position:absolute;right:21px;text-decoration:none;} + + div.fileover { background-color: lavender; } div.attachments { margin-top: 12px; } diff --git a/public/themes/redpenny-master/stylesheets/application.css b/public/themes/redpenny-master/stylesheets/application.css index c68e36cd7..cc321a425 100644 --- a/public/themes/redpenny-master/stylesheets/application.css +++ b/public/themes/redpenny-master/stylesheets/application.css @@ -456,6 +456,7 @@ ul.projects li.root width:auto; float:center; min-height:800px; + border: 1px solid #ffffff; } /*by huang*/ @@ -981,7 +982,8 @@ hr } p { - font-size: 13px + font-size: 13px; + position:relative;/*gcm*/ } /*end*/ div.issue @@ -1906,6 +1908,10 @@ input[type="submit"], .button_submit { text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.2), 0px 1px 0px rgb(255, 255, 255); cursor: pointer; } +.button_submit_font_white{ + color: white !important ; + font-weight: 400; +} input[type="button-submit"] { padding-bottom: 5px; diff --git a/test/functional/zipdown_controller_test.rb b/test/functional/zipdown_controller_test.rb new file mode 100644 index 000000000..f74dcc1c0 --- /dev/null +++ b/test/functional/zipdown_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ZipdownControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/unit/helpers/zipdown_helper_test.rb b/test/unit/helpers/zipdown_helper_test.rb new file mode 100644 index 000000000..ca30cb362 --- /dev/null +++ b/test/unit/helpers/zipdown_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class ZipdownHelperTest < ActionView::TestCase +end
当前网站状态 活跃项目:<%=@projectCount%>个