diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb
index debda938f..e7490f5b0 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/open_source_projects_controller.rb b/app/controllers/open_source_projects_controller.rb
index 52b81610f..1ca7ddcef 100644
--- a/app/controllers/open_source_projects_controller.rb
+++ b/app/controllers/open_source_projects_controller.rb
@@ -65,6 +65,8 @@ class OpenSourceProjectsController < ApplicationController
offset(@topic_pages.offset).
order(sort_clause).
all
+
+ @bugs = @open_source_project.bugs.limit(6)
respond_to do |format|
format.html {
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 82a94614f..a6dd7cf35 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 6860bfa6a..31675ca5d 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 228f57ab6..96ea86da2 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -473,7 +473,7 @@ module ApplicationHelper
end
def user_url_and_time(user_name, user_url, created)
- unless user_name.nil?
+ unless user_name.nil? || user_name == ''
l(:label_added_time_by, :author => link_to(user_name, user_url), :age => time_tag(created)).html_safe
else
l(:label_added_time, :age => time_tag(created)).html_safe
@@ -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 76203fdd7..721b30361 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 fff2f785a..8206a8ff0 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/open_source_projects_helper.rb b/app/helpers/open_source_projects_helper.rb
index ce1593cf1..f1c1cd35e 100644
--- a/app/helpers/open_source_projects_helper.rb
+++ b/app/helpers/open_source_projects_helper.rb
@@ -38,4 +38,12 @@ module OpenSourceProjectsHelper
def show_origin(url)
end
+
+ def show_description(bug, open_source_project)
+ description = BugToOsp.where("osp_id = ? and relative_memo_id = ?", open_source_project.id, bug.id).first.description
+ if description.nil? || description == ''
+ description = open_source_project.name + l(:label_bug)
+ end
+ description
+ end
end
diff --git a/app/helpers/softapplications_helper.rb b/app/helpers/softapplications_helper.rb
index fe78e9875..8bb5d0d1a 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/bug_to_osp.rb b/app/models/bug_to_osp.rb
new file mode 100644
index 000000000..5471bd3f9
--- /dev/null
+++ b/app/models/bug_to_osp.rb
@@ -0,0 +1,8 @@
+class BugToOsp < ActiveRecord::Base
+ # attr_accessible :title, :body
+ belongs_to :open_source_project, :foreign_key => "osp_id"
+ belongs_to :bug, :class_name => 'RelativeMemo', :foreign_key => "relative_memo_id"
+
+ validates_presence_of :osp_id, :relative_memo_id
+
+end
diff --git a/app/models/open_source_project.rb b/app/models/open_source_project.rb
index 6413a0d9f..e3556ce55 100644
--- a/app/models/open_source_project.rb
+++ b/app/models/open_source_project.rb
@@ -13,6 +13,10 @@ class OpenSourceProject < ActiveRecord::Base
has_many :admin, :through => :masters, :class_name => 'User'
has_many :apply_tips, :class_name => 'ApplyProjectMaster', :as => :apply, :dependent => :delete_all, :conditions => "#{ApplyProjectMaster.table_name}.status = 1"
has_many :applicants, :class_name => 'User', :through => :apply_tips, :source => :user
+
+ has_many :bugs_to_osp, :class_name => 'BugToOsp', :foreign_key => 'osp_id', :dependent => :destroy
+ has_many :bugs, :through => :bugs_to_osp, :class_name => "RelativeMemo", :order => "#{RelativeMemo.table_name}.created_at DESC"
+
validates_uniqueness_of :name
diff --git a/app/models/project.rb b/app/models/project.rb
index 20c5de89b..b8e11d99e 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 000000000..e4c8a872a
--- /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/relative_memo.rb b/app/models/relative_memo.rb
index 11766bb05..073d1ca12 100644
--- a/app/models/relative_memo.rb
+++ b/app/models/relative_memo.rb
@@ -11,6 +11,9 @@ class RelativeMemo < ActiveRecord::Base
has_many :no_uses, :as => :no_use, :dependent => :delete_all
+ has_many :bugs_to_osp, :class_name => 'BugToOsp', :foreign_key => 'relative_memo_id', :dependent => :destroy
+
+
acts_as_taggable
validates_presence_of :subject
diff --git a/app/models/softapplication.rb b/app/models/softapplication.rb
index 3911424e9..5e1e1bd50 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 e54658274..11b168be0 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 7d2831e8f..bbd01c241 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();" %>
+<% if User.current.logged? %>
+
+
+ 参加竞赛:
+ <%= 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/open_source_projects/_show_memo.html.erb b/app/views/open_source_projects/_show_memo.html.erb
index 8c1cbc819..63de42132 100644
--- a/app/views/open_source_projects/_show_memo.html.erb
+++ b/app/views/open_source_projects/_show_memo.html.erb
@@ -14,7 +14,12 @@
- <%= link_to h(topic.subject), open_source_project_relative_memo_path(open_source_project, topic) %> |
+
+ <% if topic.url.nil? || topic.url == '' %>
+ <%= link_to h(topic.subject), open_source_project_relative_memo_path(open_source_project, topic) %>
+ <% else %>
+ <%= link_to h(topic.subject), topic.url %>
+ <% end %> |
@@ -48,11 +53,11 @@
|
-
+
帖子来源:<%=link_to 'OSChina', topic.url %>
|
diff --git a/app/views/open_source_projects/_show_topics.html.erb b/app/views/open_source_projects/_show_topics.html.erb
index c6df07c8e..3ba463944 100644
--- a/app/views/open_source_projects/_show_topics.html.erb
+++ b/app/views/open_source_projects/_show_topics.html.erb
@@ -24,25 +24,29 @@
@@ -52,23 +56,32 @@
-
+
全球热帖
<%= link_to "更多>>", :controller => "open_source_projects",:action => "showmemo", :id => @open_source_project.id %>
@@ -366,7 +435,7 @@
- <%= link_to h(topic.subject), open_source_project_relative_memo_path(open_source_project, topic) %> |
+ <%= link_to h(topic.subject), topic.url %> |
diff --git a/app/views/open_source_projects/index.html.erb b/app/views/open_source_projects/index.html.erb
index d958165ed..e51ef4fc1 100644
--- a/app/views/open_source_projects/index.html.erb
+++ b/app/views/open_source_projects/index.html.erb
@@ -148,7 +148,7 @@ li {
| | | |