增加帖子-组织栏目关联表
This commit is contained in:
parent
188bb0c1a7
commit
2220e0b7cc
|
@ -18,8 +18,8 @@
|
||||||
class BoardsController < ApplicationController
|
class BoardsController < ApplicationController
|
||||||
layout 'base_projects'#by young
|
layout 'base_projects'#by young
|
||||||
default_search_scope :messages
|
default_search_scope :messages
|
||||||
before_filter :find_project_by_project_id, :find_board_if_available
|
before_filter :find_project_by_project_id, :find_board_if_available, :except => [:join_to_org_subfields]
|
||||||
before_filter :authorize, :except => [:new, :show, :create, :index]
|
before_filter :authorize, :except => [:new, :show, :create, :index, :join_to_org_subfields]
|
||||||
accept_rss_auth :index, :show
|
accept_rss_auth :index, :show
|
||||||
|
|
||||||
|
|
||||||
|
@ -225,6 +225,16 @@ class BoardsController < ApplicationController
|
||||||
redirect_to_settings_in_projects
|
redirect_to_settings_in_projects
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def join_to_org_subfields
|
||||||
|
if params[:id]
|
||||||
|
@board = Board.find(params[:id])
|
||||||
|
@org_subfield_ids = params[:org_subfield_ids]
|
||||||
|
@org_subfield_ids.each do |id|
|
||||||
|
OrgSubfieldBoard.create(:org_subfield_id => id.to_i, :board_id => params[:id].to_i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def redirect_to_settings_in_projects
|
def redirect_to_settings_in_projects
|
||||||
redirect_to settings_project_url(@project, :tab => 'boards')
|
redirect_to settings_project_url(@project, :tab => 'boards')
|
||||||
|
|
|
@ -19,6 +19,8 @@ class Board < ActiveRecord::Base
|
||||||
include Redmine::SafeAttributes
|
include Redmine::SafeAttributes
|
||||||
belongs_to :project,:touch => true
|
belongs_to :project,:touch => true
|
||||||
belongs_to :course,:touch=>true
|
belongs_to :course,:touch=>true
|
||||||
|
has_many :org_subfield_boards
|
||||||
|
has_many :org_subfields, :class_name => "OrgSubfield", :through => :org_subfield_boards
|
||||||
has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC"
|
has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC"
|
||||||
has_many :messages, :dependent => :destroy, :order => "#{Message.table_name}.created_on DESC"
|
has_many :messages, :dependent => :destroy, :order => "#{Message.table_name}.created_on DESC"
|
||||||
belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id
|
belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id
|
||||||
|
|
|
@ -2,6 +2,8 @@ class OrgSubfield < ActiveRecord::Base
|
||||||
belongs_to :organization, :foreign_key => :organization_id
|
belongs_to :organization, :foreign_key => :organization_id
|
||||||
has_many :org_document_comments, :dependent => :destroy
|
has_many :org_document_comments, :dependent => :destroy
|
||||||
has_many :files
|
has_many :files
|
||||||
|
has_many :org_subfield_boards
|
||||||
|
has_many :boards, :through => :org_subfield_boards
|
||||||
acts_as_attachable
|
acts_as_attachable
|
||||||
|
|
||||||
def project
|
def project
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class OrgSubfieldBoard < ActiveRecord::Base
|
||||||
|
belongs_to :org_subfield
|
||||||
|
belongs_to :board
|
||||||
|
# attr_accessible :title, :body
|
||||||
|
end
|
|
@ -406,6 +406,7 @@ RedmineApp::Application.routes.draw do
|
||||||
|
|
||||||
# boards
|
# boards
|
||||||
match 'boards/:board_id/topics/new', :to => 'messages#new', :via => [:get, :post], :as => 'new_board_message'
|
match 'boards/:board_id/topics/new', :to => 'messages#new', :via => [:get, :post], :as => 'new_board_message'
|
||||||
|
match 'boards/:id/join_to_org_subfields', :to => 'boards#join_to_org_subfields'
|
||||||
get 'boards/:board_id/topics/:id', :to => 'messages#show', :as => 'board_message'
|
get 'boards/:board_id/topics/:id', :to => 'messages#show', :as => 'board_message'
|
||||||
match 'boards/:board_id/topics/quote/:id', :to => 'messages#quote', :via => [:get, :post]
|
match 'boards/:board_id/topics/quote/:id', :to => 'messages#quote', :via => [:get, :post]
|
||||||
get 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
|
get 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
class CreateTableOrgSubfieldBoards < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
create_table :org_subfield_boards do |t|
|
||||||
|
t.integer :org_subfield_id
|
||||||
|
t.integer :board_id
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
drop_table :org_subfield_boards
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddBoardTypeToOrgSubfieldBoards < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :org_subfield_boards, :board_type, :string
|
||||||
|
end
|
||||||
|
end
|
14
db/schema.rb
14
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20151218110033) do
|
ActiveRecord::Schema.define(:version => 20151222072758) do
|
||||||
|
|
||||||
create_table "activities", :force => true do |t|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
@ -1196,6 +1196,14 @@ ActiveRecord::Schema.define(:version => 20151218110033) do
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "org_subfield_boards", :force => true do |t|
|
||||||
|
t.integer "org_subfield_id"
|
||||||
|
t.integer "board_id"
|
||||||
|
t.datetime "created_at", :null => false
|
||||||
|
t.datetime "updated_at", :null => false
|
||||||
|
t.string "board_type"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "org_subfields", :force => true do |t|
|
create_table "org_subfields", :force => true do |t|
|
||||||
t.integer "organization_id"
|
t.integer "organization_id"
|
||||||
t.integer "priority"
|
t.integer "priority"
|
||||||
|
@ -1634,6 +1642,10 @@ ActiveRecord::Schema.define(:version => 20151218110033) do
|
||||||
t.string "extra"
|
t.string "extra"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "temp", :id => false, :force => true do |t|
|
||||||
|
t.integer "id", :default => 0, :null => false
|
||||||
|
end
|
||||||
|
|
||||||
create_table "time_entries", :force => true do |t|
|
create_table "time_entries", :force => true do |t|
|
||||||
t.integer "project_id", :null => false
|
t.integer "project_id", :null => false
|
||||||
t.integer "user_id", :null => false
|
t.integer "user_id", :null => false
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :org_subfield_board, :class => 'OrgSubfieldBoards' do
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe OrgSubfieldBoards, :type => :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
Loading…
Reference in New Issue