You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

boards_controller.rb 4.3 kB

13 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
13 years ago
13 years ago
​
13 years ago
13 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
13 years ago
​
13 years ago
13 years ago
​
​
​
​
​
​
​
​
​
​
​
13 years ago
​
​
​
​
​
​
13 years ago
​
13 years ago
​
13 years ago
​
13 years ago
​
​
​
​
13 years ago
​
​
​
​
​
​
​
13 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2013 Jean-Philippe Lang
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. class BoardsController < ApplicationController
  18. layout 'base_projects'#by young
  19. default_search_scope :messages
  20. before_filter :find_project_by_project_id, :find_board_if_available
  21. before_filter :authorize, :except => [:new, :show, :create, :index]
  22. accept_rss_auth :index, :show
  23. helper :sort
  24. include SortHelper
  25. helper :watchers
  26. def index
  27. #modify by nwb
  28. if @project
  29. @boards = @project.boards.includes(:last_message => :author).all
  30. @boards = [] << @boards[0] if @boards.any?
  31. if @boards.size == 1
  32. @board = @boards.first
  33. show and return
  34. end
  35. render :layout => false if request.xhr?
  36. elsif @course
  37. @boards = @course.boards.includes(:last_message => :author).all
  38. @boards = [] << @boards[0] if @boards.any?
  39. if @boards.size == 1
  40. @board = @boards.first
  41. show and return
  42. end
  43. render :layout => 'base_courses'
  44. end
  45. end
  46. def show
  47. respond_to do |format|
  48. format.html {
  49. sort_init 'updated_on', 'desc'
  50. sort_update 'created_on' => "#{Message.table_name}.created_on",
  51. 'replies' => "#{Message.table_name}.replies_count",
  52. 'updated_on' => "COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on)"
  53. @topic_count = @board.topics.count
  54. @topic_pages = Paginator.new @topic_count, per_page_option, params['page']
  55. @topics = @board.topics.
  56. reorder("#{Message.table_name}.sticky DESC").
  57. includes(:last_reply).
  58. limit(@topic_pages.per_page).
  59. offset(@topic_pages.offset).
  60. order(sort_clause).
  61. preload(:author, {:last_reply => :author}).
  62. all
  63. @message = Message.new(:board => @board)
  64. #modify by nwb
  65. if @project
  66. render :action => 'show', :layout => !request.xhr?
  67. elsif @course
  68. render :action => 'show', :layout => 'base_courses'
  69. end
  70. }
  71. format.atom {
  72. @messages = @board.messages.
  73. reorder('created_on DESC').
  74. includes(:author, :board).
  75. limit(Setting.feeds_limit.to_i).
  76. all
  77. if @project
  78. render_feed(@messages, :title => "#{@project}: #{@board}")
  79. elsif @course
  80. render_feed(@messages, :title => "#{@course}: #{@board}")
  81. end
  82. }
  83. end
  84. end
  85. def new
  86. @board = @project.boards.build
  87. @board.safe_attributes = params[:board]
  88. if @project.project_type == 1
  89. render :layout => 'base_courses'
  90. end
  91. end
  92. def create
  93. @board = @project.boards.build
  94. @board.safe_attributes = params[:board]
  95. if @board.save
  96. flash[:notice] = l(:notice_successful_create)
  97. #Modified by young
  98. #redirect_to_settings_in_projects
  99. redirect_to project_board_path(@project, @board)
  100. #Ended by young
  101. else
  102. render :action => 'new'
  103. end
  104. end
  105. def edit
  106. if @project.project_type == 1
  107. render :layout => 'base_courses'
  108. end
  109. end
  110. def update
  111. @board.safe_attributes = params[:board]
  112. if @board.save
  113. redirect_to_settings_in_projects
  114. else
  115. render :action => 'edit'
  116. end
  117. end
  118. def destroy
  119. @board.destroy
  120. redirect_to_settings_in_projects
  121. end
  122. private
  123. def redirect_to_settings_in_projects
  124. redirect_to settings_project_path(@project, :tab => 'boards')
  125. end
  126. def find_board_if_available
  127. @board = @project.boards.find(params[:id]) if params[:id]
  128. rescue ActiveRecord::RecordNotFound
  129. render_404
  130. end
  131. end

软件技术创新是当今国家整体创新能力的重要基础和发展引擎。近年来,大众参与的软件创新与创业活动已经成为网络时代软件开发和应用的新形态,正在快速改变着全球软件创新模式和软件产业格局。 ...