应用上传附件功能
This commit is contained in:
parent
a9e9171441
commit
bad170fdb2
|
@ -14,7 +14,7 @@ class SoftapplicationsController < ApplicationController
|
||||||
# GET /softapplications/1.json
|
# GET /softapplications/1.json
|
||||||
def show
|
def show
|
||||||
@softapplication = Softapplication.find(params[:id])
|
@softapplication = Softapplication.find(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # show.html.erb
|
format.html # show.html.erb
|
||||||
format.json { render json: @softapplication }
|
format.json { render json: @softapplication }
|
||||||
|
@ -41,7 +41,7 @@ class SoftapplicationsController < ApplicationController
|
||||||
# POST /softapplications.json
|
# POST /softapplications.json
|
||||||
def create
|
def create
|
||||||
@softapplication = Softapplication.new(params[:softapplication])
|
@softapplication = Softapplication.new(params[:softapplication])
|
||||||
|
@softapplication.save_attachments(params[:attachments])
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @softapplication.save
|
if @softapplication.save
|
||||||
format.html { redirect_to @softapplication, notice: 'Softapplication was successfully created.' }
|
format.html { redirect_to @softapplication, notice: 'Softapplication was successfully created.' }
|
||||||
|
@ -68,6 +68,12 @@ class SoftapplicationsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def add_attach
|
||||||
|
@softapplication = Softapplication.find(params[:id])
|
||||||
|
@softapplication.save_attachments(params[:attachments])
|
||||||
|
end
|
||||||
|
|
||||||
# DELETE /softapplications/1
|
# DELETE /softapplications/1
|
||||||
# DELETE /softapplications/1.json
|
# DELETE /softapplications/1.json
|
||||||
|
|
|
@ -21,6 +21,7 @@ require "fileutils"
|
||||||
class Attachment < ActiveRecord::Base
|
class Attachment < ActiveRecord::Base
|
||||||
belongs_to :container, :polymorphic => true
|
belongs_to :container, :polymorphic => true
|
||||||
belongs_to :project, foreign_key: 'container_id', conditions: "attachments.container_type = 'Project'"
|
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 :author, :class_name => "User", :foreign_key => "author_id"
|
||||||
|
|
||||||
validates_presence_of :filename, :author
|
validates_presence_of :filename, :author
|
||||||
|
@ -33,7 +34,7 @@ class Attachment < ActiveRecord::Base
|
||||||
acts_as_event :title => :filename,
|
acts_as_event :title => :filename,
|
||||||
:url => Proc.new {|o| {:controller => 'attachments', :action => 'download', :id => o.id, :filename => o.filename}}
|
:url => Proc.new {|o| {:controller => 'attachments', :action => 'download', :id => o.id, :filename => o.filename}}
|
||||||
|
|
||||||
acts_as_activity_provider :type => 'files',
|
acts_as_activity_provider :type => 'files',
|
||||||
:permission => :view_files,
|
:permission => :view_files,
|
||||||
:author_key => :author_id,
|
:author_key => :author_id,
|
||||||
:find_options => {:select => "#{Attachment.table_name}.*",
|
:find_options => {:select => "#{Attachment.table_name}.*",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class HomeworkAttach < ActiveRecord::Base
|
class HomeworkAttach < ActiveRecord::Base
|
||||||
include Redmine::SafeAttributes
|
include Redmine::SafeAttributes
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :bid
|
belongs_to :bid
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
class Softapplication < ActiveRecord::Base
|
class Softapplication < ActiveRecord::Base
|
||||||
attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id
|
attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id
|
||||||
|
acts_as_attachable
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,12 +1,64 @@
|
||||||
<h3><%=l(:label_release_softapplication)%></h3>
|
<h3><%= l(:label_release_softapplication)%></h3> <!-- <%= render 'form' %>
|
||||||
<!-- <%= render 'form' %>
|
|
||||||
|
|
||||||
<%= link_to 'Back', softapplications_path %> -->
|
<%= link_to 'Back', softapplications_path %> -->
|
||||||
|
|
||||||
<%= labelled_form_for @softapplication, :url => {:controller => 'softapplications', :action => 'create'}, method: :post do |f| %>
|
|
||||||
<div class="box tabular">
|
|
||||||
<%= render :partial => 'form', :locals => { :f => f } %>
|
|
||||||
<%= submit_tag l(:button_create) %>
|
|
||||||
|
|
||||||
|
<div id="put-bid-form" style="">
|
||||||
|
<%= form_for Softapplication.new, :url => {:controller => 'softapplications', :action => 'create'}, :update => "bidding_project_list", :complete => '$("#put-bid-form").hide();', :html => {:multipart => true, :id => 'add_homework_form'} do |f| %>
|
||||||
|
<fieldset>
|
||||||
|
<legend>
|
||||||
|
<%= l(:label_attachment_plural) %>
|
||||||
|
</legend>
|
||||||
|
<tr style="width:700px; margin-left: -10px">
|
||||||
|
<td><%= l(:label_softapplication_name) %></td>
|
||||||
|
<td style="require, color: #bb0000"> * </td>: <td ><%= f.text_field :name, :required => true, :size => 60, :style => "width:400px;" %></td>
|
||||||
|
<td><%= l(:label_softapplication_name_condition)%></td>
|
||||||
|
</tr></ br>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<tr style="width:800px;">
|
||||||
|
<td><%= l(:label_softapplication_version_available) %></td>
|
||||||
|
<td style="require, color: #bb0000"> * </td>: <td style="width: 100px"><%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:400px;" %></td>
|
||||||
|
|
||||||
|
</tr></ br>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<tr style="width:800px;">
|
||||||
|
<td><%= l(:label_softapplication_type) %></td>
|
||||||
|
|
||||||
|
<td style="require, color: #bb0000"> * </td>: <td style="width: 100px"><%= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %></td>
|
||||||
|
|
||||||
|
</tr></ br>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<tr style="width:800px;">
|
||||||
|
<td><%= l(:label_softapplication_description) %></td>
|
||||||
|
<td style="require, color: #bb0000"> * </td>: <td style="width: 100px"><%= f.text_field :description, :required => true, :size => 60, :style => "width:400px;" %></td>
|
||||||
|
|
||||||
|
</tr></ br>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<%= render_flash_messages %>
|
||||||
|
<p id="put-bid-form-partial">
|
||||||
|
<%= render :partial => 'attachments/form' %>
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
<%= submit_tag l(:button_create), :onclick => "return true" %>
|
||||||
|
<script type="text/javascript">
|
||||||
|
function j_submit () {
|
||||||
|
alert('start')
|
||||||
|
var submit_homework = function(){
|
||||||
|
$('#add_homework_form').clone().attr('action', '<%= url_for({:controller => "softapplications", :action => "create"})+".js" %>').ajaxSubmit()
|
||||||
|
};
|
||||||
|
alert('stop')
|
||||||
|
$.globalEval(submit_homework());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
|
@ -16,9 +16,7 @@
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
RedmineApp::Application.routes.draw do
|
RedmineApp::Application.routes.draw do
|
||||||
resources :softapplications
|
resources :softapplications
|
||||||
|
|
||||||
|
|
||||||
## new added by linchun #新竞赛相关
|
## new added by linchun #新竞赛相关
|
||||||
resources :contests, only: [:index] do
|
resources :contests, only: [:index] do
|
||||||
collection do
|
collection do
|
||||||
|
|
Loading…
Reference in New Issue