diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-09-14 11:34:08 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-09-14 11:34:08 +0000 |
commit | 21c97c6a1376a38a3951c57069317c17c81029f8 (patch) | |
tree | 8d38f129585767d4c1eb2c78d0b9b978aff14d70 /app/controllers | |
parent | 29348fafb7ca43cb00ef80f29e61167647df0cd8 (diff) | |
download | redmine-21c97c6a1376a38a3951c57069317c17c81029f8.tar.gz redmine-21c97c6a1376a38a3951c57069317c17c81029f8.zip |
Added project module concept.
A project module (eg. issue tracking, news, wiki,...) is a set of permissions that can enabled/disabled at project level.
For each project, modules can be enabled on the project settings view ('Modules' tab).
This requires a specific permission: 'Select project modules' (if this permission is turned off, only Redmine administrators can choose which modules a project uses).
When applying this migration, all modules are enabled for all existing projects.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@725 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/members_controller.rb | 22 | ||||
-rw-r--r-- | app/controllers/projects_controller.rb | 55 | ||||
-rw-r--r-- | app/controllers/repositories_controller.rb | 34 | ||||
-rw-r--r-- | app/controllers/wikis_controller.rb | 44 |
4 files changed, 99 insertions, 56 deletions
diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index dfaad7fa3..a1706e601 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -17,13 +17,23 @@ class MembersController < ApplicationController layout 'base' - before_filter :find_project, :authorize + before_filter :find_member, :except => :new + before_filter :find_project, :only => :new + before_filter :authorize + def new + @project.members << Member.new(params[:member]) if request.post? + respond_to do |format| + format.html { redirect_to :action => 'settings', :tab => 'members', :id => @project } + format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'projects/settings/members'} } + end + end + def edit if request.post? and @member.update_attributes(params[:member]) respond_to do |format| format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project } - format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'projects/members'} } + format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'projects/settings/members'} } end end end @@ -32,12 +42,18 @@ class MembersController < ApplicationController @member.destroy respond_to do |format| format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project } - format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'projects/members'} } + format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'projects/settings/members'} } end end private def find_project + @project = Project.find(params[:id]) + rescue ActiveRecord::RecordNotFound + render_404 + end + + def find_member @member = Member.find(params[:id]) @project = @member.project rescue ActiveRecord::RecordNotFound diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 0acd64009..148d54d48 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -73,16 +73,9 @@ class ProjectsController < ApplicationController else @project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids] @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => (params[:custom_fields] ? params["custom_fields"][x.id.to_s] : nil)) } - @project.custom_values = @custom_values - if params[:repository_enabled] && params[:repository_enabled] == "1" - @project.repository = Repository.factory(params[:repository_scm]) - @project.repository.attributes = params[:repository] - end - if "1" == params[:wiki_enabled] - @project.wiki = Wiki.new - @project.wiki.attributes = params[:wiki] - end + @project.custom_values = @custom_values if @project.save + @project.enabled_module_names = params[:enabled_modules] flash[:notice] = l(:notice_successful_create) redirect_to :controller => 'admin', :action => 'projects' end @@ -107,6 +100,8 @@ class ProjectsController < ApplicationController @issue_category ||= IssueCategory.new @member ||= @project.members.new @custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) } + @repository ||= @project.repository + @wiki ||= @project.wiki end # Edit @project @@ -117,24 +112,6 @@ class ProjectsController < ApplicationController @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) } @project.custom_values = @custom_values end - if params[:repository_enabled] - case params[:repository_enabled] - when "0" - @project.repository = nil - when "1" - @project.repository ||= Repository.factory(params[:repository_scm]) - @project.repository.update_attributes params[:repository] if @project.repository - end - end - if params[:wiki_enabled] - case params[:wiki_enabled] - when "0" - @project.wiki.destroy if @project.wiki - when "1" - @project.wiki ||= Wiki.new - @project.wiki.update_attributes params[:wiki] - end - end @project.attributes = params[:project] if @project.save flash[:notice] = l(:notice_successful_update) @@ -145,6 +122,11 @@ class ProjectsController < ApplicationController end end end + + def modules + @project.enabled_module_names = params[:enabled_modules] + redirect_to :action => 'settings', :id => @project, :tab => 'modules' + end def archive @project.archive if request.post? && @project.active? @@ -195,25 +177,6 @@ class ProjectsController < ApplicationController end end - # Add a new member to @project - def add_member - @member = @project.members.build(params[:member]) - if request.post? && @member.save - respond_to do |format| - format.html { redirect_to :action => 'settings', :tab => 'members', :id => @project } - format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'members'} } - end - else - settings - render :action => 'settings' - end - end - - # Show members list of @project - def list_members - @members = @project.members.find(:all) - end - # Add a new document to @project def add_document @categories = Enumeration::get_values('DCAT') diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index f99ea0b35..12439cfab 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -21,10 +21,29 @@ require 'digest/sha1' class RepositoriesController < ApplicationController layout 'base' - before_filter :find_project, :except => [:update_form] - before_filter :authorize, :except => [:update_form] + before_filter :find_repository, :except => :edit + before_filter :find_project, :only => :edit + before_filter :authorize accept_key_auth :revisions + def edit + @repository = @project.repository + if !@repository + @repository = Repository.factory(params[:repository_scm]) + @repository.project = @project + end + if request.post? + @repository.attributes = params[:repository] + @repository.save + end + render(:update) {|page| page.replace_html "tab-content-repository", :partial => 'projects/settings/repository'} + end + + def destroy + @repository.destroy + redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'repository' + end + def show # check if new revisions have been committed in the repository @repository.fetch_changesets if Setting.autofetch_changesets? @@ -113,14 +132,15 @@ class RepositoriesController < ApplicationController end end - def update_form - @repository = Repository.factory(params[:repository_scm]) - render :partial => 'projects/repository', :locals => {:repository => @repository} - end - private def find_project @project = Project.find(params[:id]) + rescue ActiveRecord::RecordNotFound + render_404 + end + + def find_repository + @project = Project.find(params[:id]) @repository = @project.repository render_404 and return false unless @repository @path = params[:path].squeeze('/') if params[:path] diff --git a/app/controllers/wikis_controller.rb b/app/controllers/wikis_controller.rb new file mode 100644 index 000000000..146aaac8a --- /dev/null +++ b/app/controllers/wikis_controller.rb @@ -0,0 +1,44 @@ +# redMine - project management software +# Copyright (C) 2006-2007 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class WikisController < ApplicationController + layout 'base' + before_filter :find_project, :authorize + + # Create or update a project's wiki + def edit + @wiki = @project.wiki || Wiki.new(:project => @project) + @wiki.attributes = params[:wiki] + @wiki.save if @request.post? + render(:update) {|page| page.replace_html "tab-content-wiki", :partial => 'projects/settings/wiki'} + end + + # Delete a project's wiki + def destroy + if request.post? && params[:confirm] && @project.wiki + @project.wiki.destroy + redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'wiki' + end + end + +private + def find_project + @project = Project.find(params[:id]) + rescue ActiveRecord::RecordNotFound + render_404 + end +end |