diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb
index debda938..e7490f5b 100644
--- a/app/controllers/contests_controller.rb
+++ b/app/controllers/contests_controller.rb
@@ -293,7 +293,7 @@ class ContestsController < ApplicationController
###我要参赛
def show_attendingcontest
-##取出参赛项目
+##取出参赛项目--项目列表
@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
@option = []
# @contesting_project_count = @contesting_project_all.count
@@ -333,7 +333,7 @@ class ContestsController < ApplicationController
@contesting_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
end
end
-##取出参赛应用
+##取出参赛应用 --应用列表
@softapplication = Softapplication.all
@contesting_softapplication = @contest.contesting_softapplications.
joins("LEFT JOIN softapplications ON contesting_softapplications.softapplication_id=softapplications.id").
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index d26cf698..8313d5e7 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -564,6 +564,7 @@ class ProjectsController < ApplicationController
@issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.sorted.all
@project = Project.new
+ @project.user_id = User.current.id
@project.safe_attributes = params[:project]
if @course_tag == '1'
@project.identifier = @course.extra
diff --git a/app/controllers/softapplications_controller.rb b/app/controllers/softapplications_controller.rb
index 6860bfa6..7904ec5a 100644
--- a/app/controllers/softapplications_controller.rb
+++ b/app/controllers/softapplications_controller.rb
@@ -47,6 +47,7 @@ class SoftapplicationsController < ApplicationController
def show
@softapplication = Softapplication.find(params[:id])
+ @project = Project.find_by_identifier(@softapplication.deposit_project)
# 打分统计
stars_reates = @softapplication.
rates(:quality)
@@ -86,7 +87,11 @@ class SoftapplicationsController < ApplicationController
# GET /softapplications/new.json
def new
@softapplication = Softapplication.new
-
+
+ #添加当前用户创建过的项目作为托管项目(下拉项目列表)
+ project = Project.find(params[:user_id])
+ #end
+
respond_to do |format|
format.html # new.html.erb
format.json { render json: @softapplication }
@@ -122,7 +127,10 @@ class SoftapplicationsController < ApplicationController
def create
@softapplication = Softapplication.new(params[:softapplication])
@softapplication.user = User.current
+ @softapplication.deposit_project = params[:project]
+
@softapplication.save_attachments(params[:attachments])
+
respond_to do |format|
if @softapplication.save
ContestingSoftapplication.create(:contest_id => params[:contest_id], :softapplication_id => @softapplication.id)
diff --git a/app/models/project.rb b/app/models/project.rb
index e0cc27b3..21dd4a43 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -56,6 +56,8 @@ class Project < ActiveRecord::Base
#added by xianbo for delete biding_project
has_many :biding_projects, :dependent => :destroy
has_many :contesting_projects, :dependent => :destroy
+ has_many :projecting_softapplications, :dependent => :destroy
+ has_many :softapplications, :through => :projecting_softapplications
#ended by xianbo
# added by fq
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
diff --git a/app/models/projecting_softapplication.rb b/app/models/projecting_softapplication.rb
new file mode 100644
index 00000000..e4c8a872
--- /dev/null
+++ b/app/models/projecting_softapplication.rb
@@ -0,0 +1,16 @@
+
+class ProjectingSoftapplication < ActiveRecord::Base
+ attr_accessible :project_id, :softapplication_id, :user_id
+
+ belongs_to :project
+ belongs_to :softapplication
+ belongs_to :user
+
+
+ def self.create_softapplication_projecting(project_id, softapplication_id)
+ self.create(:user_id => User.current.id, :project_id => project_id,
+ :softapplication_id => softapplication_id)
+ end
+
+
+end
diff --git a/app/models/softapplication.rb b/app/models/softapplication.rb
index 3911424e..5e1e1bd5 100644
--- a/app/models/softapplication.rb
+++ b/app/models/softapplication.rb
@@ -1,12 +1,14 @@
class Softapplication < ActiveRecord::Base
- attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id, :contest_id, :application_developers, :deposit_project_url
+ attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id, :contest_id, :application_developers, :deposit_project_url, :deposit_project
acts_as_attachable
seems_rateable :allow_update => true, :dimensions => :quality
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
has_many :contesting_softapplications, :dependent => :destroy
+ has_many :projecting_softapplications, :dependent => :destroy
belongs_to :user
+ belongs_to :project
has_many :contests, :through => :contesting_softapplications
def add_jour(user, notes, reference_user_id = 0, options = {})
diff --git a/app/models/user.rb b/app/models/user.rb
index 20624888..ae00e438 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -80,6 +80,7 @@ class User < Principal
has_many :biding_projects, :dependent => :destroy
has_many :contesting_projects, :dependent => :destroy
has_many :contesting_softapplications, :dependent => :destroy
+ has_many :projecting_softapplications, :dependent => :destroy
belongs_to :softapplication, :foreign_key => 'id', :dependent => :destroy
##ended by xianbo
diff --git a/app/views/contests/show_attendingcontest.html.erb b/app/views/contests/show_attendingcontest.html.erb
index ad822222..93a3144a 100644
--- a/app/views/contests/show_attendingcontest.html.erb
+++ b/app/views/contests/show_attendingcontest.html.erb
@@ -124,6 +124,14 @@
+
+