Refactor project membership and private repo functionality into generic protected...
[gitorious:mainline.git] / app / controllers / project_memberships_controller.rb
1 # encoding: utf-8
2 #--
3 #   Copyright (C) 2012 Gitorious AS
4 #
5 #   This program is free software: you can redistribute it and/or modify
6 #   it under the terms of the GNU Affero General Public License as published by
7 #   the Free Software Foundation, either version 3 of the License, or
8 #   (at your option) any later version.
9 #
10 #   This program is distributed in the hope that it will be useful,
11 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #   GNU Affero General Public License for more details.
14 #
15 #   You should have received a copy of the GNU Affero General Public License
16 #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 #++
18
19 class ProjectMembershipsController < ContentMembershipsController
20   include ProjectFilters
21   before_filter :find_project
22   before_filter :require_admin
23
24   protected
25   def require_private_repos
26     if !GitoriousConfig["enable_private_repositories"]
27       find_project if @project.nil?
28       redirect_to project_path(@project)
29     end
30   end
31
32   def content
33     @project
34   end
35
36   def memberships_path(content)
37     project_project_memberships_path(content)
38   end
39
40   def membership_path(content, membership)
41     project_project_membership_path(content, membership)
42   end
43
44   def new_membership_path(content)
45     new_project_project_membership_path(content)
46   end
47
48   def content_path(content)
49     project_path(content)
50   end
51 end