diff --git a/app/controllers/open_source_projects_controller.rb b/app/controllers/open_source_projects_controller.rb index 52b81610..1ca7ddce 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/helpers/open_source_projects_helper.rb b/app/helpers/open_source_projects_helper.rb index ce1593cf..f1c1cd35 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/models/bug_to_osp.rb b/app/models/bug_to_osp.rb index 7cfca2aa..5471bd3f 100644 --- a/app/models/bug_to_osp.rb +++ b/app/models/bug_to_osp.rb @@ -1,3 +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 6413a0d9..e3556ce5 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/relative_memo.rb b/app/models/relative_memo.rb index 11766bb0..073d1ca1 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/views/open_source_projects/_show_topics.html.erb b/app/views/open_source_projects/_show_topics.html.erb index b2fca57f..3ba46394 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 @@
@@ -417,7 +421,7 @@
- +

全球热帖

<%= link_to "更多>>", :controller => "open_source_projects",:action => "showmemo", :id => @open_source_project.id %>
diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 4ff4b0c5..190fc7d0 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1906,4 +1906,5 @@ zh: # ajax异步验证 modal_valid_passing: 可以使用 + label_bug: 漏洞 \ No newline at end of file