diff --git a/app/controllers/softapplications_controller.rb b/app/controllers/softapplications_controller.rb index 3bddec62c..e6fbd2e0e 100644 --- a/app/controllers/softapplications_controller.rb +++ b/app/controllers/softapplications_controller.rb @@ -14,7 +14,7 @@ class SoftapplicationsController < ApplicationController # GET /softapplications/1.json def show @softapplication = Softapplication.find(params[:id]) - + respond_to do |format| format.html # show.html.erb format.json { render json: @softapplication } @@ -41,7 +41,7 @@ class SoftapplicationsController < ApplicationController # POST /softapplications.json def create @softapplication = Softapplication.new(params[:softapplication]) - + @softapplication.save_attachments(params[:attachments]) respond_to do |format| if @softapplication.save format.html { redirect_to @softapplication, notice: 'Softapplication was successfully created.' } @@ -68,6 +68,12 @@ class SoftapplicationsController < ApplicationController end end end + + + def add_attach + @softapplication = Softapplication.find(params[:id]) + @softapplication.save_attachments(params[:attachments]) + end # DELETE /softapplications/1 # DELETE /softapplications/1.json diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 768be578f..8e607a685 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -21,6 +21,7 @@ require "fileutils" class Attachment < ActiveRecord::Base belongs_to :container, :polymorphic => true 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" validates_presence_of :filename, :author @@ -33,7 +34,7 @@ class Attachment < ActiveRecord::Base acts_as_event :title => :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, :author_key => :author_id, :find_options => {:select => "#{Attachment.table_name}.*", diff --git a/app/models/homework_attach.rb b/app/models/homework_attach.rb index 5ce08a0a8..fb743ab5c 100644 --- a/app/models/homework_attach.rb +++ b/app/models/homework_attach.rb @@ -1,5 +1,5 @@ class HomeworkAttach < ActiveRecord::Base - include Redmine::SafeAttributes + include Redmine::SafeAttributes belongs_to :user belongs_to :bid diff --git a/app/models/softapplication.rb b/app/models/softapplication.rb index 53440be81..f661ea74b 100644 --- a/app/models/softapplication.rb +++ b/app/models/softapplication.rb @@ -1,3 +1,4 @@ class Softapplication < ActiveRecord::Base attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id + acts_as_attachable end diff --git a/app/views/softapplications/new.html.erb b/app/views/softapplications/new.html.erb index 40c6a4059..820165819 100644 --- a/app/views/softapplications/new.html.erb +++ b/app/views/softapplications/new.html.erb @@ -1,12 +1,64 @@ -

<%=l(:label_release_softapplication)%>

- -<%= labelled_form_for @softapplication, :url => {:controller => 'softapplications', :action => 'create'}, method: :post do |f| %> -
- <%= render :partial => 'form', :locals => { :f => f } %> - <%= submit_tag l(:button_create) %> +
+ <%= 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| %> +
+ + <%= l(:label_attachment_plural) %> + + + <%= l(:label_softapplication_name) %> + * : <%= f.text_field :name, :required => true, :size => 60, :style => "width:400px;" %> + <%= l(:label_softapplication_name_condition)%> + +
+
+ + + <%= l(:label_softapplication_version_available) %> + * : <%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:400px;" %> + + +
+
+ + + <%= l(:label_softapplication_type) %> + + * : <%= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %> + + +
+
+ + + <%= l(:label_softapplication_description) %> + * : <%= f.text_field :description, :required => true, :size => 60, :style => "width:400px;" %> + + +
+
+ <%= render_flash_messages %> +

+ <%= render :partial => 'attachments/form' %> +

+
+ <%= submit_tag l(:button_create), :onclick => "return true" %> + +
+ <% end %>
\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 181ecb0e0..c4ad9cdff 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,9 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. RedmineApp::Application.routes.draw do - resources :softapplications - - + resources :softapplications ## new added by linchun #新竞赛相关 resources :contests, only: [:index] do collection do