From d3ead651fe651e2d8e205f7da239dc2e1a948da9 Mon Sep 17 00:00:00 2001 From: fanqiang <316257774@qq.com> Date: Thu, 22 May 2014 17:04:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=98=BE=E7=A4=BA=E5=AE=89?= =?UTF-8?q?=E5=85=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open_source_projects_controller.rb | 2 ++ app/helpers/open_source_projects_helper.rb | 8 ++++++++ app/models/bug_to_osp.rb | 5 +++++ app/models/open_source_project.rb | 4 ++++ app/models/relative_memo.rb | 3 +++ .../_show_topics.html.erb | 20 +++++++++++-------- config/locales/zh.yml | 1 + 7 files changed, 35 insertions(+), 8 deletions(-) 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 @@