diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index 20ae191ab..d341f0f6e 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -62,6 +62,7 @@ class AttachmentsController < ApplicationController
end
end
+
def thumbnail
if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size])
if stale?(:etag => thumbnail)
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index 8f2b79bd3..c67310f6f 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -62,7 +62,20 @@ class FilesController < ApplicationController
redirect_to project_files_path(@project)
end
- def show_by_attachtype
+ def showbyattachtype
+ sort_init 'created_on', 'desc'
+ sort_update 'created_on' => "#{Attachment.table_name}.created_on",
+ 'filename' => "#{Attachment.table_name}.filename",
+ 'size' => "#{Attachment.table_name}.filesize",
+ 'downloads' => "#{Attachment.table_name}.downloads"
+
+ @containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] #modify by Long Jun
+ @containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
+ if @project.project_type == 1
+ render :layout => 'base_courses'
+ else
+ render :layout => !request.xhr?
+ end
end
end
diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb
index 5b405a27a..c37edf2e4 100644
--- a/app/controllers/school_controller.rb
+++ b/app/controllers/school_controller.rb
@@ -61,7 +61,7 @@ class SchoolController < ApplicationController
render :text => options
end
-
+
def get_schoollist
@school = School.where("province = ?", params[:province])
diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb
index 7259e9d10..aa6a5f7f5 100644
--- a/app/helpers/attachments_helper.rb
+++ b/app/helpers/attachments_helper.rb
@@ -38,7 +38,7 @@ module AttachmentsHelper
else
false
end
-
+
end
def render_api_attachment(attachment, api)
diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb
index f58896434..ffa1348fd 100644
--- a/app/helpers/files_helper.rb
+++ b/app/helpers/files_helper.rb
@@ -44,4 +44,10 @@ module FilesHelper
File.new(zipfile_name,'w+')
end
+ def browseByCategory
+ isCategoryBrowser = 1
+ #isCategoryBrowser
+ end
+
+
end
\ No newline at end of file
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index f0533e052..6a62613bb 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -23,7 +23,7 @@ class Attachment < ActiveRecord::Base
belongs_to :project, foreign_key: 'container_id', conditions: "attachments.container_type = 'Project'"
belongs_to :softapplication, foreign_key: 'container_id', conditions: "attachments.container_type = 'Softapplication'"
belongs_to :author, :class_name => "User", :foreign_key => "author_id"
- belongs_to :attachmentstype, :foreign_key => "attachtype"
+ belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id"
validates_presence_of :filename, :author
validates_length_of :filename, :maximum => 255
diff --git a/app/models/attachmentstype.rb b/app/models/attachmentstype.rb
index 1d3c2cfcd..54102ee79 100644
--- a/app/models/attachmentstype.rb
+++ b/app/models/attachmentstype.rb
@@ -1,3 +1,4 @@
class Attachmentstype < ActiveRecord::Base
attr_accessible :typeId, :typeName
+ has_many :attachments, :foreign_key => "attachtype",:primary_key => "id"
end
diff --git a/app/views/files/_show_by_attachtype.html.erb b/app/views/files/_show_by_attachtype.html.erb
new file mode 100644
index 000000000..eedc90684
--- /dev/null
+++ b/app/views/files/_show_by_attachtype.html.erb
@@ -0,0 +1,421 @@
+
+<%isCategoryBrowser=true%>
+<% selAttachType =1%>
+<% attachmenttypes = @project.attachmenttypes %>
+
+
+
+<%=(@project.project_type == 1) ? t(:label_user_course) : t(:label_project) %>资源共享区
+
+
-
- <% if versions.any? %>
-
<%=l(:field_version)%>
- <%= select_tag "version_id", content_tag('option', '') +
- options_from_collection_for_select(versions, "id", "name") %>
- <% end %>
-
- <% if attachmenttypes.any? %>
-
<%=l(:attachment_type)%>
- <%= select_tag "attachment_type", content_tag('option', '') +
- options_from_collection_for_select(attachmenttypes, "id",
- "typeName") %>
-
- <% end %>
-
-
<%=l(:label_attachment_plural)%> <%= render :partial => 'attachments/form' %>
+
+<%isCategoryBrowser=false%>
+<% selAttachType =1%>
+<% attachmenttypes = @project.attachmenttypes %>
+
+
+
+
<%=(@project.project_type == 1) ? t(:label_user_course) : t(:label_project) %>资源共享区
+
+
+ <%#= link_to(l(:label_attachment_new), 'javascript:void(0);', :onclick=>"$('#file_buttons').slideToggle();", :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %>
+
+
+
+
+<%= javascript_tag "observeSearchfield('attach_search', null, '#{ escape_javascript attachments_autocomplete_path(:project_id => @project.id, :format => 'js') }')" %>
+
+
+<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %>
+
+<%if !isCategoryBrowser%>
+
+
+
+
+
+
+
+
+
+
+
+ <%= sort_header_tag('filename', :caption => l(:field_filename), :scope =>"col" , :id => "vzebra-adventure")%>
+ <%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope =>"col" , :id => "vzebra-comedy")%>
+ <%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope =>"col", :id=> "vzebra-children")%>
+ <%= sort_header_tag('attach_type', :caption => l(:attachment_type), :default_order => 'desc', :scope =>"col", :id=> "vzebra-attachmenttype")%>
+ <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope =>"col", :id => "vzebra-action") %>
+ <%= sort_header_tag('operation', :caption => "", :scope =>"col", :id => "vzebra-children") %>
+
+
+
+ <% @containers.each do |container| %>
+ <% next if container.attachments.empty? -%>
+ <% if container.is_a?(Version) -%>
+
+
+ <%= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package", :style => "color: #666666;") %>
+
+
+ <% end -%>
+ <% container.attachments.each do |file| %>
+ ">
+ <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %>
+ <%= format_time(file.created_on) %>
+ <%= number_to_human_size(file.filesize) %>
+ <%= file.attachmentstype.typeName %>
+ <%= file.downloads %>
+
+
+ <%= link_to(image_tag('delete.png'), attachment_path(file),
+ :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
+
+
+
+
+
+
+
+
+ <% end -%>
+ <% reset_cycle %>
+ <% end -%>
+
+
+
+
+
+
+
+<%else%>
+
+
+
+
+
+
+
+
+
+
+
+ <%= sort_header_tag('filename', :caption => l(:field_filename), :scope =>"col" , :id => "vzebra-adventure")%>
+ <%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope =>"col" , :id => "vzebra-comedy")%>
+ <%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope =>"col", :id=> "vzebra-children")%>
+ <%= sort_header_tag('attach_type', :caption => l(:attachment_type), :default_order => 'desc', :scope =>"col", :id=> "vzebra-attachmenttype")%>
+ <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope =>"col", :id => "vzebra-action") %>
+ <%= sort_header_tag('operation', :caption => "", :scope =>"col", :id => "vzebra-children") %>
+
+
+
+ <% @containers.each do |container| %>
+ <% next if container.attachments.empty? -%>
+ <% container.attachments.each do |file| %>
+ <% if file.attachtype==selAttachType%>
+ ">
+ <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %>
+ <%= format_time(file.created_on) %>
+ <%= number_to_human_size(file.filesize) %>
+ <%= file.attachmentstype.typeName %>
+ <%= file.downloads %>
+
+
+ <%= link_to(image_tag('delete.png'), attachment_path(file),
+ :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
+
+
+
+
+
+
+
+
+ <% end -%>
+ <% end -%>
+ <% reset_cycle %>
+ <% end -%>
+
+
+
+
+
+
+
+<%end%>
+<% html_title(l(:label_attachment_plural)) -%>
+
+
+
+<%inited=false%>
+
\ No newline at end of file
diff --git a/config/locales/en.yml b/config/locales/en.yml
index b5c598084..b092c3d1c 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -132,6 +132,7 @@ en:
actionview_instancetag_blank_option: Please select
+ attachment_browse: 'Attachment Browse'
attachment_type: 'Attachment Type'
general_text_No: 'No'
general_text_Yes: 'Yes'
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index 902a18298..e8fafa470 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -140,6 +140,7 @@ zh:
actionview_instancetag_blank_option: 请选择
+ attachment_browse: '分类浏览'
attachment_type: '资源分类'
general_text_No: '否'
general_text_Yes: '是'
diff --git a/config/routes.rb b/config/routes.rb
index be0d11cea..d804e5b0c 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -16,73 +16,73 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
RedmineApp::Application.routes.draw do
- resources :no_uses
- delete 'no_uses', :to => 'no_uses#delete'
-
- resources :apply_project_masters
- delete 'apply_project_masters', :to => 'apply_project_masters#delete'
-
-
- resources :open_source_projects do
- collection do
- match 'search', via: [:get, :post]
- match 'remove_condition', via: [:get, :post]
- end
- resources :relative_memos
- member do
- match 'master_apply', via: [:get, :post]
- match 'accept_master_apply', via: [:get, :post]
- match 'refuse_master_apply', via: [:get, :post]
- end
- end
- mount SeemsRateable::Engine => '/rateable', :as => :rateable
-
- namespace :zipdown do
- match 'assort'
- end
- namespace :test do
- match 'courselist'
- match 'zip'
- end
- ##new added by linchun #以发布应用的形式参与竞赛
- resources :softapplications do
-
- collection do
- match 'new_message', via: :get
- end
- member do
- match 'create_message' , via: :post
- end
- end
-
- ## new added by linchun #新竞赛相关
- resources :contests, only: [:index] do
- collection do
- match 'new_contest' , via: :get
- match 'join_in_contest' , via: :post
- match 'unjoin_in_contest' , via: :delete
- match 'create_contest' , via: :post
- match 'new_join' , via: :post
- match 'new' , via: :post
- end
- member do
- match 'add_softapplication'
- match 'update_contest' , via: [:put]
- match 'show_contest' , via: :get
- match 'show_project' , via: :get
- match 'show_softapplication', via: :get
- match 'show_participator' , via: :get
- match 'add' , via: [:get, :post]
- match 'add_softapplication' , via: [:get, :post]
- match 'create' , via: :post
- match 'settings' , via: [:get, :post]
- end
- end
-
+ resources :no_uses
+ delete 'no_uses', :to => 'no_uses#delete'
+
+ resources :apply_project_masters
+ delete 'apply_project_masters', :to => 'apply_project_masters#delete'
+
+
+ resources :open_source_projects do
+ collection do
+ match 'search', via: [:get, :post]
+ match 'remove_condition', via: [:get, :post]
+ end
+ resources :relative_memos
+ member do
+ match 'master_apply', via: [:get, :post]
+ match 'accept_master_apply', via: [:get, :post]
+ match 'refuse_master_apply', via: [:get, :post]
+ end
+ end
+ mount SeemsRateable::Engine => '/rateable', :as => :rateable
+
+ namespace :zipdown do
+ match 'assort'
+ end
+ namespace :test do
+ match 'courselist'
+ match 'zip'
+ end
+ ##new added by linchun #以发布应用的形式参与竞赛
+ resources :softapplications do
+
+ collection do
+ match 'new_message', via: :get
+ end
+ member do
+ match 'create_message' , via: :post
+ end
+ end
+
+ ## new added by linchun #新竞赛相关
+ resources :contests, only: [:index] do
+ collection do
+ match 'new_contest' , via: :get
+ match 'join_in_contest' , via: :post
+ match 'unjoin_in_contest' , via: :delete
+ match 'create_contest' , via: :post
+ match 'new_join' , via: :post
+ match 'new' , via: :post
+ end
+ member do
+ match 'add_softapplication'
+ match 'update_contest' , via: [:put]
+ match 'show_contest' , via: :get
+ match 'show_project' , via: :get
+ match 'show_softapplication', via: :get
+ match 'show_participator' , via: :get
+ match 'add' , via: [:get, :post]
+ match 'add_softapplication' , via: [:get, :post]
+ match 'create' , via: :post
+ match 'settings' , via: [:get, :post]
+ end
+ end
+
resources :stores do
collection do
match 'search', via: [:get, :post]
- end
+ end
end
resources :forums do
@@ -100,20 +100,20 @@ RedmineApp::Application.routes.draw do
end
end
- resources :shares
+ 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'
@@ -167,21 +167,21 @@ RedmineApp::Application.routes.draw do
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
+ 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 '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 '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
@@ -195,13 +195,13 @@ RedmineApp::Application.routes.draw do
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
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]
-
+ #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]
@@ -276,7 +276,7 @@ RedmineApp::Application.routes.draw do
# 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
+ match '/watcherlist', :controller=>'projects', :action=> 'watcherlist', :as => 'watcherlist', :via => :get #add by huang
# matche '/news', :controller => 'news', :action => 'index', :as => 'news', :via => :get
#end
@@ -299,7 +299,7 @@ RedmineApp::Application.routes.draw do
# 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 :files, :only => [:index, :new, :create,:showbyattachtype]
resources :versions, :except => [:index, :show, :edit, :update, :destroy] do
collection do
@@ -326,7 +326,7 @@ RedmineApp::Application.routes.draw do
resources :repositories, :except => [:index, :show] do
member do
get 'newrepo', :via => [:get, :post]
- # get 'create', :via=>[:get, :post]
+ # get 'create', :via=>[:get, :post]
end
end
match 'wiki/index', :controller => 'wiki', :action => 'index', :via => :get
@@ -518,10 +518,10 @@ RedmineApp::Application.routes.draw do
match 'uploads', :to => 'attachments#upload', :via => :post
# Added by Tao
- match 'upload_avatar', :to => 'avatar#upload', :via => :post
+ match 'upload_avatar', :to => 'avatar#upload', :via => :post
# Endof Tao's code
get 'robots.txt', :to => 'welcome#robots'
-
+
##############测试留言功能 fq
post 'words/new', :to => 'words#new'
post 'words/create', :to => 'words#create'
@@ -545,7 +545,7 @@ RedmineApp::Application.routes.draw do
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
@@ -559,24 +559,24 @@ RedmineApp::Application.routes.draw do
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'
+
+ 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'
@@ -584,10 +584,10 @@ RedmineApp::Application.routes.draw do
# added by young
match 'calls', :controller => 'bids', :action => 'index'
-
+
match 'calls/:id', :controller => 'bids', :action => 'show', :as => 'respond'
match 'contest', :controller => 'bids', :action => 'contests', :as => 'contest' #modified @20140403
-
+
########################
##added by wen##########
@@ -616,7 +616,7 @@ RedmineApp::Application.routes.draw do
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'
Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|