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 82a94614..a6dd7cf3 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -505,6 +505,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..31675ca5 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 }
@@ -96,6 +101,21 @@ class SoftapplicationsController < ApplicationController
# GET /softapplications/1/edit
def edit
@softapplication = Softapplication.find(params[:id])
+
+ @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
+ @option = []
+ # @contesting_project_count = @contesting_project_all.count
+ # @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
+ @membership.each do |membership|
+ unless(membership.project.project_type==1)
+ membership.member_roles.each{|role|
+ if(role.role_id == 3)
+ @option << membership.project
+ end
+ }
+ end
+ end
+
end
# POST /softapplications
@@ -122,12 +142,14 @@ 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)
- format.js
- format.html { redirect_to show_attendingcontest_contest_path(:id => params[:contest_id]) }
+ format.html { redirect_to show_attendingcontest_contest_path(:id => params[:contest_id]), notice: l(:notice_attendingcontest_work_successfully_created) }
# format.json { render json: @softapplication, status: :created, location: @softapplication }
else
format.js { render status: 406 }
@@ -148,9 +170,10 @@ class SoftapplicationsController < ApplicationController
# @softapplication = Softapplication.find(params[:id])
@softapplication.attachments.map{|attach| attach.destroy }
@softapplication.save_attachments(params[:attachments])
+ @softapplication.deposit_project = params[:project]
respond_to do |format|
if @softapplication.update_attributes(params[:softapplication])
- format.html { redirect_to @softapplication, notice: 'Softapplication was successfully updated.' }
+ format.html { redirect_to @softapplication, notice: l(:notice_softapplication_was_successfully_updated) }
format.json { head :no_content }
else
format.html { render action: "edit" }
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 9e057058..96ea86da 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -740,7 +740,15 @@ module ApplicationHelper
end
end
end
-
+
+ def select_option_helper option
+ tmp = Hash.new
+ tmp={"" => ""}
+ option.each do |project|
+ tmp[project.name] = project.identifier
+ end
+ tmp
+ end
# Redmine links
#
# Examples:
diff --git a/app/helpers/bids_helper.rb b/app/helpers/bids_helper.rb
index 76203fdd..721b3036 100644
--- a/app/helpers/bids_helper.rb
+++ b/app/helpers/bids_helper.rb
@@ -145,13 +145,13 @@ module BidsHelper
people.include?(User.current)
end
- def select_option_helper option
- tmp = Hash.new
- option.each do |project|
- tmp[project.name] = project.identifier
- end
- tmp
- end
+ # def select_option_helper option
+ # tmp = Hash.new
+ # option.each do |project|
+ # tmp[project.name] = project.identifier
+ # end
+ # tmp
+ # end
def can_delete_project_homework bind_project,current_user
current_user.id == bind_project.user.id || current_user.admin
diff --git a/app/helpers/contests_helper.rb b/app/helpers/contests_helper.rb
index fff2f785..8206a8ff 100644
--- a/app/helpers/contests_helper.rb
+++ b/app/helpers/contests_helper.rb
@@ -157,13 +157,14 @@ module ContestsHelper
people.include?(User.current)
end
- def select_option_helper option
- tmp = Hash.new
- option.each do |project|
- tmp[project.name] = project.identifier
- end
- tmp
- end
+ # def select_option_helper option
+ # tmp = Hash.new
+ # tmp={"" => ""}
+ # option.each do |project|
+ # tmp[project.name] = project.identifier
+ # end
+ # tmp
+ # end
def select_option_app_helper options
tmp = Hash.new
options.each do |option|
diff --git a/app/helpers/softapplications_helper.rb b/app/helpers/softapplications_helper.rb
index fe78e987..8bb5d0d1 100644
--- a/app/helpers/softapplications_helper.rb
+++ b/app/helpers/softapplications_helper.rb
@@ -13,6 +13,15 @@ module SoftapplicationsHelper
content = content_tag('ul', content)
content_tag('div', content, :class => "tabs")
end
+
+ # def select_option_helper option
+ # tmp = Hash.new
+ # option.each do |project|
+ # tmp[project.name] = project.identifier
+ # end
+ # tmp
+ # end
+
end
diff --git a/app/models/project.rb b/app/models/project.rb
index 20c5de89..b8e11d99 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -55,6 +55,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 e5465827..11b168be 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -87,6 +87,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 7d2831e8..bbd01c24 100644
--- a/app/views/contests/show_attendingcontest.html.erb
+++ b/app/views/contests/show_attendingcontest.html.erb
@@ -59,35 +59,44 @@
}
-
+<%= render_flash_messages %>
-
- 温馨提示:如果您准备参加竞赛,请点击下面的"新建参赛作品"!
+
+
温馨提示:如果您准备参加竞赛,请点击下面的"新建参赛作品"!
+
1) 若您已完成开发,且只希望发布您的作品,“托管项目”一项可以不选;
+
2) 若您希望托管竞赛数据和代码以及保留开发和提交代码的轨迹,请从“托管项目”中选择一项您已创建好的项目作为该参赛作品的托管项目,若您还没有创建项目,请点击右边的“创建项目”,然后回到本页再选择。
+
<% if User.current.logged? %>
-
-
-
-
参加竞赛:
-
<%= link_to '新建参赛作品', "javascript:void(0);", onclick: "$('#put-project-form').toggle();" %>
+
+
+ 参加竞赛:
+ <%= link_to '新建参赛作品', "javascript:void(0);", onclick: "$('#put-project-form').toggle();" %>
+
+
+
-
-
-
+<% else %>
+
+ <%= l(:label_user_login_attending_contest) %>
+ <%= link_to l(:label_user_login_new), signin_path %>
+
+<% end %>
-<% end %>
+
diff --git a/app/views/softapplications/_form.html.erb b/app/views/softapplications/_form.html.erb
index b4a9c3c9..4703af9b 100644
--- a/app/views/softapplications/_form.html.erb
+++ b/app/views/softapplications/_form.html.erb
@@ -14,7 +14,7 @@