parent
42e6fc6a68
commit
753746f833
|
@ -53,7 +53,7 @@ class FilesController < ApplicationController
|
|||
|
||||
def create
|
||||
container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id]))
|
||||
attachments = Attachment.attach_files(container, params[:attachments])
|
||||
attachments = Attachment.attach_filesex(container, params[:attachments],params[:attachment_type])
|
||||
render_attachment_warning_if_needed(container)
|
||||
|
||||
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
|
||||
|
|
|
@ -261,6 +261,12 @@ class Attachment < ActiveRecord::Base
|
|||
result
|
||||
end
|
||||
|
||||
def self.attach_filesex(obj, attachments,attachment_type)
|
||||
result = obj.save_attachmentsex(attachments, User.current,attachment_type)
|
||||
obj.attach_saved_attachments
|
||||
result
|
||||
end
|
||||
|
||||
def self.latest_attach(attachments, filename)
|
||||
attachments.sort_by(&:created_on).reverse.detect {
|
||||
|att| att.filename.downcase == filename.downcase
|
||||
|
|
|
@ -38,8 +38,7 @@ class Project < ActiveRecord::Base
|
|||
:conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})"
|
||||
has_many :users, :through => :members
|
||||
has_many :principals, :through => :member_principals, :source => :principal
|
||||
|
||||
has_many :enabled_modules, :dependent => :delete_all
|
||||
has_many :enabled_modules, :dependent => :delete_all
|
||||
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
|
||||
has_many :issues, :dependent => :destroy, :include => [:status, :tracker]
|
||||
has_many :issue_changes, :through => :issues, :source => :journals
|
||||
|
@ -159,8 +158,12 @@ class Project < ActiveRecord::Base
|
|||
def new_course
|
||||
self.where('project_type = ?', 1)
|
||||
end
|
||||
|
||||
|
||||
|
||||
# 获取项目的资源类型列表
|
||||
def attachmenttypes
|
||||
@attachmenttypes = Attachmentstype.find(:all, :conditions => ["#{Attachmentstype.table_name}.typeId= ?",self.attachmenttype ])
|
||||
end
|
||||
|
||||
# 项目留言 added by fq
|
||||
def self.add_jour(user, notes)
|
||||
project = Project.find('trustie')
|
||||
|
@ -726,7 +729,8 @@ class Project < ActiveRecord::Base
|
|||
'custom_fields',
|
||||
'tracker_ids',
|
||||
'issue_custom_field_ids',
|
||||
'project_type'
|
||||
'project_type',
|
||||
'attachmenttype'
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<h3><%=l(:label_attachment_new)%></h3>
|
||||
<% versions = project.versions.sort %>
|
||||
<% attachmenttypes = project.attachmenttypes %>
|
||||
<%= error_messages_for 'attachment' %>
|
||||
<%= form_tag(project_files_path(project), :multipart => true, :class => "tabular") do %>
|
||||
<div class="box">
|
||||
|
@ -10,6 +11,14 @@
|
|||
options_from_collection_for_select(versions, "id", "name") %></p>
|
||||
<% end %>
|
||||
|
||||
<% if attachmenttypes.any? %>
|
||||
<p> <label for="attachment_type"><%=l(:attachment_type)%></label>
|
||||
<%= select_tag "attachment_type", content_tag('option', '') +
|
||||
options_from_collection_for_select(attachmenttypes, "id",
|
||||
"typeName") %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<p><label><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form' %></p>
|
||||
</div>
|
||||
<%= submit_tag l(:button_add) %>
|
||||
|
|
Loading…
Reference in New Issue