parent
0772e04510
commit
284e6ba20a
|
@ -66,6 +66,30 @@ class Attachment < ActiveRecord::Base
|
||||||
copy
|
copy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#获取资源的后缀类型
|
||||||
|
def suffix_type
|
||||||
|
childArr = self.filename.split('.')
|
||||||
|
suffix = '*'
|
||||||
|
if childArr.length > 1
|
||||||
|
suffix = childArr[childArr.length-1]
|
||||||
|
end
|
||||||
|
suffix
|
||||||
|
end
|
||||||
|
|
||||||
|
#获取用来显示的后缀名称
|
||||||
|
def show_suffix_type
|
||||||
|
suffix = 'other'
|
||||||
|
temp = self.suffix_type.downcase
|
||||||
|
if self.attachmentstype.suffixArr.include?(temp)
|
||||||
|
suffix = temp
|
||||||
|
end
|
||||||
|
suffix
|
||||||
|
end
|
||||||
|
|
||||||
|
def suffixArr
|
||||||
|
@@SuffixArr
|
||||||
|
end
|
||||||
|
|
||||||
def validate_max_file_size
|
def validate_max_file_size
|
||||||
if @temp_file && self.filesize > Setting.attachment_max_size.to_i.kilobytes
|
if @temp_file && self.filesize > Setting.attachment_max_size.to_i.kilobytes
|
||||||
errors.add(:base, l(:error_attachment_too_big, :max_size => Setting.attachment_max_size.to_i.kilobytes))
|
errors.add(:base, l(:error_attachment_too_big, :max_size => Setting.attachment_max_size.to_i.kilobytes))
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
class Attachmentstype < ActiveRecord::Base
|
class Attachmentstype < ActiveRecord::Base
|
||||||
attr_accessible :typeId, :typeName
|
attr_accessible :typeId, :typeName
|
||||||
has_many :attachments, :foreign_key => "attachtype",:primary_key => "id"
|
has_many :attachments, :foreign_key => "attachtype",:primary_key => "id"
|
||||||
|
|
||||||
|
# 当前使用的文件内容分类列表
|
||||||
|
@@SuffixArr = ['pdf','zip','doc','docx','rar','txt','jpg','bmp','xls','xlsx']
|
||||||
|
|
||||||
|
def suffixArr
|
||||||
|
@@SuffixArr
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -164,6 +164,14 @@ class Project < ActiveRecord::Base
|
||||||
@attachmenttypes = Attachmentstype.find(:all, :conditions => ["#{Attachmentstype.table_name}.typeId= ?",self.attachmenttype ])
|
@attachmenttypes = Attachmentstype.find(:all, :conditions => ["#{Attachmentstype.table_name}.typeId= ?",self.attachmenttype ])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 获取资源后缀名列表
|
||||||
|
def contenttypes
|
||||||
|
attachmenttypes
|
||||||
|
if @attachmenttypes.length >0
|
||||||
|
@attachmenttypes.last().suffixArr
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
#自定义验证
|
#自定义验证
|
||||||
def validation
|
def validation
|
||||||
if !class_period.match([0-9])
|
if !class_period.match([0-9])
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %>
|
<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %>
|
||||||
|
<% edit_allowed = User.current.allowed_to?(:manage_files, @project) %>
|
||||||
<ul id="all_browse_ul">
|
<ul id="all_browse_ul">
|
||||||
<table class="list files" id="ver-zebra" >
|
<table class="list files" id="ver-zebra" >
|
||||||
<colgroup>
|
<colgroup>
|
||||||
|
@ -12,7 +13,8 @@
|
||||||
<%= sort_header_tag('filename', :caption => l(:field_filename), :scope =>"col" , :id => "vzebra-adventure")%>
|
<%= 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('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('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('attach_type', :caption => l(:attachment_browse), :default_order => 'desc', :scope =>"col", :id=> "vzebra-attachmenttype")%>
|
||||||
|
<%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope =>"col", :id=> "vzebra-contenttype")%>
|
||||||
<%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope =>"col", :id => "vzebra-action") %>
|
<%= 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") %>
|
<%= sort_header_tag('operation', :caption => "", :scope =>"col", :id => "vzebra-children") %>
|
||||||
<!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> -->
|
<!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> -->
|
||||||
|
@ -33,6 +35,7 @@
|
||||||
<td class="created_on"><%= format_time(file.created_on) %></td>
|
<td class="created_on"><%= format_time(file.created_on) %></td>
|
||||||
<td class="filesize"><%= number_to_human_size(file.filesize) %></td>
|
<td class="filesize"><%= number_to_human_size(file.filesize) %></td>
|
||||||
<td class="attach_type"><%= file.attachmentstype.typeName %></td>
|
<td class="attach_type"><%= file.attachmentstype.typeName %></td>
|
||||||
|
<td class="content_type"><%= file.show_suffix_type %></td>
|
||||||
<td class="downloads"><%= file.downloads %></td>
|
<td class="downloads"><%= file.downloads %></td>
|
||||||
<!-- <td class="digest" width="300px"><%= file.description %></td> -->
|
<!-- <td class="digest" width="300px"><%= file.description %></td> -->
|
||||||
<td align="center">
|
<td align="center">
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<% selAttachType =@attachtype %>
|
<% selAttachType =@attachtype %>
|
||||||
<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %>
|
<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %>
|
||||||
|
<% edit_allowed = User.current.allowed_to?(:manage_files, @project) %>
|
||||||
<div id="catarory_browse_div" class="catarory_browse_div">
|
<div id="catarory_browse_div" class="catarory_browse_div">
|
||||||
<ul id="catarory_browse_ul">
|
<ul id="catarory_browse_ul">
|
||||||
<table class="list files" id="ver-zebra1">
|
<table class="list files" id="ver-zebra1">
|
||||||
|
@ -15,7 +16,8 @@
|
||||||
<%= sort_header_tag('filename', :caption => l(:field_filename), :scope => "col", :id => "vzebra-adventure") %>
|
<%= 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('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('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('attach_type', :caption => l(:attachment_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-attachmenttype") %>
|
||||||
|
<%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope =>"col", :id=> "vzebra-contenttype")%>
|
||||||
<%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %>
|
<%= 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") %>
|
<%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %>
|
||||||
<!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> -->
|
<!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> -->
|
||||||
|
@ -31,6 +33,7 @@
|
||||||
<td class="created_on"><%= format_time(file.created_on) %></td>
|
<td class="created_on"><%= format_time(file.created_on) %></td>
|
||||||
<td class="filesize"><%= number_to_human_size(file.filesize) %></td>
|
<td class="filesize"><%= number_to_human_size(file.filesize) %></td>
|
||||||
<td class="attach_type"><%= file.attachmentstype.typeName %></td>
|
<td class="attach_type"><%= file.attachmentstype.typeName %></td>
|
||||||
|
<td class="content_type"><%= file.show_suffix_type %></td>
|
||||||
<td class="downloads"><%= file.downloads %></td>
|
<td class="downloads"><%= file.downloads %></td>
|
||||||
<!-- <td class="digest" width="300px"><%= file.description %></td> -->
|
<!-- <td class="digest" width="300px"><%= file.description %></td> -->
|
||||||
<td align="center">
|
<td align="center">
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<!-- <h3> --><!-- %=l(:label_attachment_plural)%></h3 -->
|
<!-- <h3> --><!-- %=l(:label_attachment_plural)%></h3 -->
|
||||||
<% attachmenttypes = @project.attachmenttypes %>
|
<% attachmenttypes = @project.attachmenttypes %>
|
||||||
|
<% sufixtypes = @project.contenttypes %>
|
||||||
<style>
|
<style>
|
||||||
#ver-zebra, .file_table_des
|
#ver-zebra, .file_table_des
|
||||||
{
|
{
|
||||||
|
@ -187,6 +188,11 @@
|
||||||
<%= select_tag "attachment_browse", content_tag('option', '') +options_from_collection_for_select(attachmenttypes, "id", "typeName"),
|
<%= select_tag "attachment_browse", content_tag('option', '') +options_from_collection_for_select(attachmenttypes, "id", "typeName"),
|
||||||
:onchange=>"attachmenttypes_searchex(this.value)"%>
|
:onchange=>"attachmenttypes_searchex(this.value)"%>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% if sufixtypes.any? %>
|
||||||
|
<label for=""><%=l(:attachment_sufix_browse)%></label>
|
||||||
|
<%= select_tag "attach_sufix_browse", content_tag('option', '') +options_for_select(sufixtypes),
|
||||||
|
:onchange=>"attachment_contenttypes_searchex(this.value)"%>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div id="upload_file_div" class="relation_file_div hidden" >
|
<div id="upload_file_div" class="relation_file_div hidden" >
|
||||||
<%= render :partial => 'new', locals: {project: @project}%>
|
<%= render :partial => 'new', locals: {project: @project}%>
|
||||||
|
@ -278,17 +284,33 @@
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function attachmenttypes_searchex(value){
|
function attachmenttypes_searchex(value) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '<%=getattachtype_project_files_path(project_id: @project)%>'+ '?type='+encodeURIComponent(value),
|
url: '<%=getattachtype_project_files_path(project_id: @project)%>' + '?type=' + encodeURIComponent(value),
|
||||||
type :"POST"
|
type: "POST"
|
||||||
|
|
||||||
}).complete(function (xhr, textStatus) {
|
}).complete(function (xhr, textStatus) {
|
||||||
if (textStatus == 'success') {
|
if (textStatus == 'success') {
|
||||||
eval(xhr.responseText);
|
eval(xhr.responseText);
|
||||||
} else if(textStatus =='error'){
|
} else if (textStatus == 'error') {
|
||||||
alert('error');
|
alert('error');
|
||||||
};
|
}
|
||||||
});
|
;
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function attachment_contenttypes_searchex(value) {
|
||||||
|
$.ajax({
|
||||||
|
url: '<%=getattachtype_project_files_path(project_id: @project)%>' + '?type=' + encodeURIComponent(value),
|
||||||
|
type: "POST"
|
||||||
|
|
||||||
|
}).complete(function (xhr, textStatus) {
|
||||||
|
if (textStatus == 'success') {
|
||||||
|
eval(xhr.responseText);
|
||||||
|
} else if (textStatus == 'error') {
|
||||||
|
alert('error');
|
||||||
|
}
|
||||||
|
;
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
|
@ -10,5 +10,6 @@ if Dir.glob(File.join(vendor_plugins_dir, "*")).any?
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# Initialize the rails application
|
# Initialize the rails application
|
||||||
RedmineApp::Application.initialize!
|
RedmineApp::Application.initialize!
|
||||||
|
|
|
@ -132,8 +132,9 @@ en:
|
||||||
|
|
||||||
actionview_instancetag_blank_option: Please select
|
actionview_instancetag_blank_option: Please select
|
||||||
|
|
||||||
attachment_browse: 'Attachment Browse'
|
attachment_browse: "Attachment Content Browse"
|
||||||
attachment_type: 'Attachment Type'
|
attachment_sufix_browse: "Attachment Type Browse"
|
||||||
|
attachment_type: "Attachment Type"
|
||||||
general_text_No: 'No'
|
general_text_No: 'No'
|
||||||
general_text_Yes: 'Yes'
|
general_text_Yes: 'Yes'
|
||||||
general_text_no: 'no'
|
general_text_no: 'no'
|
||||||
|
|
|
@ -140,7 +140,8 @@ zh:
|
||||||
|
|
||||||
actionview_instancetag_blank_option: 请选择
|
actionview_instancetag_blank_option: 请选择
|
||||||
|
|
||||||
attachment_browse: '分类浏览'
|
attachment_sufix_browse: "文件类型"
|
||||||
|
attachment_browse: "内容类型"
|
||||||
attachment_type: '资源分类'
|
attachment_type: '资源分类'
|
||||||
general_text_No: '否'
|
general_text_No: '否'
|
||||||
general_text_Yes: '是'
|
general_text_Yes: '是'
|
||||||
|
|
|
@ -4,6 +4,12 @@ class CreateAttachmentstypes < ActiveRecord::Migration
|
||||||
t.column :typeId, :integer, :null => false
|
t.column :typeId, :integer, :null => false
|
||||||
t.column :typeName, :string, :limit =>50
|
t.column :typeName, :string, :limit =>50
|
||||||
end
|
end
|
||||||
|
Attachmentstype.create(typeId:1,typeName:'源代码')
|
||||||
|
Attachmentstype.create(typeId:1,typeName:'课件')
|
||||||
|
Attachmentstype.create(typeId:1,typeName:'研究报告')
|
||||||
|
Attachmentstype.create(typeId:2,typeName:'源代码')
|
||||||
|
Attachmentstype.create(typeId:2,typeName:'课件')
|
||||||
|
Attachmentstype.create(typeId:2,typeName:'研究报告')
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.down
|
def self.down
|
||||||
|
|
50
db/schema.rb
50
db/schema.rb
|
@ -23,6 +23,15 @@ ActiveRecord::Schema.define(:version => 20140509020307) do
|
||||||
add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type"
|
add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type"
|
||||||
add_index "activities", ["user_id"], :name => "index_activities_on_user_id"
|
add_index "activities", ["user_id"], :name => "index_activities_on_user_id"
|
||||||
|
|
||||||
|
create_table "apply_project_masters", :force => true do |t|
|
||||||
|
t.integer "user_id"
|
||||||
|
t.string "apply_type"
|
||||||
|
t.integer "apply_id"
|
||||||
|
t.integer "status"
|
||||||
|
t.datetime "created_at", :null => false
|
||||||
|
t.datetime "updated_at", :null => false
|
||||||
|
end
|
||||||
|
|
||||||
create_table "attachments", :force => true do |t|
|
create_table "attachments", :force => true do |t|
|
||||||
t.integer "container_id"
|
t.integer "container_id"
|
||||||
t.string "container_type", :limit => 30
|
t.string "container_type", :limit => 30
|
||||||
|
@ -36,7 +45,7 @@ ActiveRecord::Schema.define(:version => 20140509020307) do
|
||||||
t.datetime "created_on"
|
t.datetime "created_on"
|
||||||
t.string "description"
|
t.string "description"
|
||||||
t.string "disk_directory"
|
t.string "disk_directory"
|
||||||
t.integer "attachtype"
|
t.integer "attachtype", :default => 1
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id"
|
add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id"
|
||||||
|
@ -527,6 +536,14 @@ ActiveRecord::Schema.define(:version => 20140509020307) do
|
||||||
add_index "news", ["created_on"], :name => "index_news_on_created_on"
|
add_index "news", ["created_on"], :name => "index_news_on_created_on"
|
||||||
add_index "news", ["project_id"], :name => "news_project_id"
|
add_index "news", ["project_id"], :name => "news_project_id"
|
||||||
|
|
||||||
|
create_table "no_uses", :force => true do |t|
|
||||||
|
t.integer "user_id", :null => false
|
||||||
|
t.string "no_use_type"
|
||||||
|
t.integer "no_use_id"
|
||||||
|
t.datetime "created_at", :null => false
|
||||||
|
t.datetime "updated_at", :null => false
|
||||||
|
end
|
||||||
|
|
||||||
create_table "open_id_authentication_associations", :force => true do |t|
|
create_table "open_id_authentication_associations", :force => true do |t|
|
||||||
t.integer "issued"
|
t.integer "issued"
|
||||||
t.integer "lifetime"
|
t.integer "lifetime"
|
||||||
|
@ -542,6 +559,19 @@ ActiveRecord::Schema.define(:version => 20140509020307) do
|
||||||
t.string "salt", :null => false
|
t.string "salt", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "open_source_projects", :force => true do |t|
|
||||||
|
t.string "name"
|
||||||
|
t.text "description"
|
||||||
|
t.integer "commit_count", :default => 0
|
||||||
|
t.integer "code_line", :default => 0
|
||||||
|
t.integer "users_count", :default => 0
|
||||||
|
t.date "last_commit_time"
|
||||||
|
t.string "url"
|
||||||
|
t.date "date_collected"
|
||||||
|
t.datetime "created_at", :null => false
|
||||||
|
t.datetime "updated_at", :null => false
|
||||||
|
end
|
||||||
|
|
||||||
create_table "praise_tread_caches", :force => true do |t|
|
create_table "praise_tread_caches", :force => true do |t|
|
||||||
t.integer "object_id", :null => false
|
t.integer "object_id", :null => false
|
||||||
t.string "object_type"
|
t.string "object_type"
|
||||||
|
@ -622,6 +652,24 @@ ActiveRecord::Schema.define(:version => 20140509020307) do
|
||||||
add_index "queries", ["project_id"], :name => "index_queries_on_project_id"
|
add_index "queries", ["project_id"], :name => "index_queries_on_project_id"
|
||||||
add_index "queries", ["user_id"], :name => "index_queries_on_user_id"
|
add_index "queries", ["user_id"], :name => "index_queries_on_user_id"
|
||||||
|
|
||||||
|
create_table "relative_memos", :force => true do |t|
|
||||||
|
t.integer "osp_id", :null => false
|
||||||
|
t.integer "parent_id"
|
||||||
|
t.string "subject", :null => false
|
||||||
|
t.text "content", :null => false
|
||||||
|
t.integer "author_id"
|
||||||
|
t.integer "replies_count", :default => 0
|
||||||
|
t.integer "last_reply_id"
|
||||||
|
t.boolean "lock", :default => false
|
||||||
|
t.boolean "sticky", :default => false
|
||||||
|
t.boolean "is_quote", :default => false
|
||||||
|
t.datetime "created_at", :null => false
|
||||||
|
t.datetime "updated_at", :null => false
|
||||||
|
t.integer "viewed_count_crawl", :default => 0
|
||||||
|
t.integer "viewed_count_local", :default => 0
|
||||||
|
t.string "url"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "repositories", :force => true do |t|
|
create_table "repositories", :force => true do |t|
|
||||||
t.integer "project_id", :default => 0, :null => false
|
t.integer "project_id", :default => 0, :null => false
|
||||||
t.string "url", :default => "", :null => false
|
t.string "url", :default => "", :null => false
|
||||||
|
|
Loading…
Reference in New Issue