diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-04-01 19:43:59 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-04-01 19:43:59 +0000 |
commit | 4ff8386e3dfee800591e7f856a26ccc700149b02 (patch) | |
tree | 75cd4a45ab9e0298299c821029d6066c29bfbc2b /app | |
parent | cb6c8bee473332dfacea8d53745eb75407877a06 (diff) | |
download | redmine-4ff8386e3dfee800591e7f856a26ccc700149b02.tar.gz redmine-4ff8386e3dfee800591e7f856a26ccc700149b02.zip |
Initial commit for svn repository management and access control:
* Identifier attribute added on Project model. Used as the unix group name for the project
* Web services (disabled by default) and scripts for repository management on a remote svn host
git-svn-id: http://redmine.rubyforge.org/svn/trunk@396 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/apis/sys_api.rb | 25 | ||||
-rw-r--r-- | app/controllers/sys_controller.rb | 44 | ||||
-rw-r--r-- | app/models/project.rb | 18 | ||||
-rw-r--r-- | app/views/projects/_form.rhtml | 1 | ||||
-rw-r--r-- | app/views/settings/edit.rhtml | 3 |
5 files changed, 87 insertions, 4 deletions
diff --git a/app/apis/sys_api.rb b/app/apis/sys_api.rb new file mode 100644 index 000000000..3a10c0402 --- /dev/null +++ b/app/apis/sys_api.rb @@ -0,0 +1,25 @@ +# 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 SysApi < ActionWebService::API::Base + api_method :projects, + :expects => [], + :returns => [[Project]] + api_method :repository_created, + :expects => [:int, :string], + :returns => [:int] +end diff --git a/app/controllers/sys_controller.rb b/app/controllers/sys_controller.rb new file mode 100644 index 000000000..4900a845a --- /dev/null +++ b/app/controllers/sys_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 SysController < ActionController::Base + wsdl_service_name 'Sys' + web_service_api SysApi + web_service_scaffold :invoke + + before_invocation :check_enabled + + def projects + Project.find(:all, :include => :repository) + end + + def repository_created(project_id, url) + project = Project.find_by_id(project_id) + return 0 unless project && project.repository.nil? + logger.debug "Repository for #{project.name} created" + repository = Repository.new(:project => project, :url => url) + repository.root_url = url + repository.save + repository.id + end + +protected + + def check_enabled(name, args) + Setting.sys_api_enabled? + end +end diff --git a/app/models/project.rb b/app/models/project.rb index 10730ed1e..fe02cd829 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -30,13 +30,23 @@ class Project < ActiveRecord::Base has_one :wiki, :dependent => :destroy has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}", :association_foreign_key => 'custom_field_id' acts_as_tree :order => "name", :counter_cache => true - - validates_presence_of :name, :description - validates_uniqueness_of :name + + validates_presence_of :name, :description, :identifier + validates_uniqueness_of :name, :identifier validates_associated :custom_values, :on => :update validates_associated :repository, :wiki validates_format_of :name, :with => /^[\w\s\'\-]*$/i - + validates_length_of :identifier, :maximum => 12 + validates_format_of :identifier, :with => /^[a-z0-9\-]*$/ + + def identifier=(identifier) + super unless identifier_frozen? + end + + def identifier_frozen? + errors[:identifier].nil? && !(new_record? || identifier.blank?) + end + # returns latest created projects # non public projects will be returned only if user is a member of those def self.latest(user=nil, count=5) diff --git a/app/views/projects/_form.rhtml b/app/views/projects/_form.rhtml index ded227197..184370b92 100644 --- a/app/views/projects/_form.rhtml +++ b/app/views/projects/_form.rhtml @@ -9,6 +9,7 @@ <% end %> <p><%= f.text_area :description, :required => true, :cols => 60, :rows => 3 %></p> +<p><%= f.text_field :identifier, :required => true, :size => 15, :disabled => @project.identifier_frozen? %><br /><em><%= l(:text_project_identifier_info) unless @project.identifier_frozen? %></em></p> <p><%= f.text_field :homepage, :size => 40 %></p> <p><%= f.check_box :is_public %></p> diff --git a/app/views/settings/edit.rhtml b/app/views/settings/edit.rhtml index 223df7a9d..7a678c53f 100644 --- a/app/views/settings/edit.rhtml +++ b/app/views/settings/edit.rhtml @@ -48,6 +48,9 @@ <p><label><%= l(:setting_autofetch_changesets) %></label> <%= check_box_tag 'settings[autofetch_changesets]', 1, Setting.autofetch_changesets? %><%= hidden_field_tag 'settings[autofetch_changesets]', 0 %></p> +<p><label><%= l(:setting_sys_api_enabled) %></label> +<%= check_box_tag 'settings[sys_api_enabled]', 1, Setting.sys_api_enabled? %><%= hidden_field_tag 'settings[sys_api_enabled]', 0 %></p> + </div> <%= submit_tag l(:button_save) %> </div> |