Mercurial > hg > soundsoftware-site
comparison app/controllers/sys_controller.rb @ 1115:433d4f72a19b redmine-2.2
Update to Redmine SVN revision 11137 on 2.2-stable branch
author | Chris Cannam |
---|---|
date | Mon, 07 Jan 2013 12:01:42 +0000 |
parents | cbb26bc654de |
children | bb32da3bea34 622f24f53b42 261b3d9a4903 |
comparison
equal
deleted
inserted
replaced
929:5f33065ddc4b | 1115:433d4f72a19b |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2011 Jean-Philippe Lang | 2 # Copyright (C) 2006-2012 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
17 | 17 |
18 class SysController < ActionController::Base | 18 class SysController < ActionController::Base |
19 before_filter :check_enabled | 19 before_filter :check_enabled |
20 | 20 |
21 def projects | 21 def projects |
22 p = Project.active.has_module(:repository).find(:all, :include => :repository, :order => 'identifier') | 22 p = Project.active.has_module(:repository).find( |
23 :all, | |
24 :include => :repository, | |
25 :order => "#{Project.table_name}.identifier" | |
26 ) | |
23 # extra_info attribute from repository breaks activeresource client | 27 # extra_info attribute from repository breaks activeresource client |
24 render :xml => p.to_xml(:only => [:id, :identifier, :name, :is_public, :status], :include => {:repository => {:only => [:id, :url]}}) | 28 render :xml => p.to_xml( |
29 :only => [:id, :identifier, :name, :is_public, :status], | |
30 :include => {:repository => {:only => [:id, :url]}} | |
31 ) | |
25 end | 32 end |
26 | 33 |
27 def create_project_repository | 34 def create_project_repository |
28 project = Project.find(params[:id]) | 35 project = Project.find(params[:id]) |
29 if project.repository | 36 if project.repository |
30 render :nothing => true, :status => 409 | 37 render :nothing => true, :status => 409 |
31 else | 38 else |
32 logger.info "Repository for #{project.name} was reported to be created by #{request.remote_ip}." | 39 logger.info "Repository for #{project.name} was reported to be created by #{request.remote_ip}." |
33 project.repository = Repository.factory(params[:vendor], params[:repository]) | 40 repository = Repository.factory(params[:vendor], params[:repository]) |
34 if project.repository && project.repository.save | 41 repository.project = project |
35 render :xml => project.repository.to_xml(:only => [:id, :url]), :status => 201 | 42 if repository.save |
43 render :xml => {repository.class.name.underscore.gsub('/', '-') => {:id => repository.id, :url => repository.url}}, :status => 201 | |
36 else | 44 else |
37 render :nothing => true, :status => 422 | 45 render :nothing => true, :status => 422 |
38 end | 46 end |
39 end | 47 end |
40 end | 48 end |
41 | 49 |
42 def fetch_changesets | 50 def fetch_changesets |
43 projects = [] | 51 projects = [] |
52 scope = Project.active.has_module(:repository) | |
44 if params[:id] | 53 if params[:id] |
45 projects << Project.active.has_module(:repository).find(params[:id]) | 54 project = nil |
55 if params[:id].to_s =~ /^\d*$/ | |
56 project = scope.find(params[:id]) | |
57 else | |
58 project = scope.find_by_identifier(params[:id]) | |
59 end | |
60 raise ActiveRecord::RecordNotFound unless project | |
61 projects << project | |
46 else | 62 else |
47 projects = Project.active.has_module(:repository).find(:all, :include => :repository) | 63 projects = scope.all |
48 end | 64 end |
49 projects.each do |project| | 65 projects.each do |project| |
50 if project.repository | 66 project.repositories.each do |repository| |
51 project.repository.fetch_changesets | 67 repository.fetch_changesets |
52 end | 68 end |
53 end | 69 end |
54 render :nothing => true, :status => 200 | 70 render :nothing => true, :status => 200 |
55 rescue ActiveRecord::RecordNotFound | 71 rescue ActiveRecord::RecordNotFound |
56 render :nothing => true, :status => 404 | 72 render :nothing => true, :status => 404 |