gentoo-overlay/www-apps/gitlabhq/files/gitlabhq-4.0.0-public-projects.patch

142 lines
5.5 KiB
Diff
Raw Normal View History

diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb
index 1fcadbfefbaf4d015d68ab7bc349f67becb717df..9d6a9449fcdcfbd138c7f8d4feb1e6b0e5a11926 100644
--- a/app/controllers/dashboard_controller.rb
+++ b/app/controllers/dashboard_controller.rb
@@ -14,6 +14,8 @@ class DashboardController < ApplicationController
@projects.personal(current_user)
when 'joined' then
@projects.joined(current_user)
+ when 'public' then
+ @projects.public_only
else
@projects
end
diff --git a/app/models/ability.rb b/app/models/ability.rb
index 2d80c6720b79da74ae9e4d20d816b2433f3082a8..946ec1e1128da3f55ac9b7198b6c0fbdc1d4aba7 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -27,6 +27,8 @@ class Ability
elsif project.guest_access_for?(user)
rules << project_guest_rules
+ elsif project.public?
+ rules << project_public_rules
end
if project.namespace
@@ -104,6 +106,10 @@ class Ability
]
end
+ def project_public_rules
+ project_report_rules
+ end
+
def group_abilities user, group
rules = []
diff --git a/app/models/project.rb b/app/models/project.rb
index 3e5c912e0b47a22cc5489b9cbfb1dd53da5095e9..f10a6afde27ce4226677c0aa28aabd7497fb4a9d 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -30,7 +30,7 @@ class Project < ActiveRecord::Base
class TransferError < StandardError; end
attr_accessible :name, :path, :description, :default_branch, :issues_enabled,
- :wall_enabled, :merge_requests_enabled, :wiki_enabled, as: [:default, :admin]
+ :wall_enabled, :merge_requests_enabled, :wiki_enabled, :private_flag, as: [:default, :admin]
attr_accessible :namespace_id, :owner_id, as: :admin
@@ -87,7 +87,7 @@ class Project < ActiveRecord::Base
class << self
def authorized_for user
projects = includes(:users_projects, :namespace)
- projects = projects.where("users_projects.user_id = :user_id or projects.owner_id = :user_id or namespaces.owner_id = :user_id", user_id: user.id)
+ projects = projects.where("users_projects.user_id = :user_id or projects.owner_id = :user_id or namespaces.owner_id = :user_id or projects.private_flag = false", user_id: user.id)
end
def active
diff --git a/app/roles/authority.rb b/app/roles/authority.rb
--- a/app/roles/authority.rb
+++ b/app/roles/authority.rb
@@ -20,2 +20,3 @@ module Authority
def repository_readers
+ return ['@all'] if public?
diff --git a/app/views/admin/projects/_form.html.haml b/app/views/admin/projects/_form.html.haml
index 27c22872d501456bc4b7fd4bfd2a31c45b0a0a53..793f6a22ac3a96540c4f18e518d2197de51482bf 100644
--- a/app/views/admin/projects/_form.html.haml
+++ b/app/views/admin/projects/_form.html.haml
@@ -24,6 +24,10 @@
= f.label :default_branch, "Default Branch"
.input= f.select(:default_branch, project.heads.map(&:name), {}, style: "width:210px;")
+ .clearfix
+ = f.label :private_flag, "Private"
+ .input= f.check_box :private_flag
+
%fieldset.adv_settings
%legend Features:
diff --git a/app/views/admin/projects/show.html.haml b/app/views/admin/projects/show.html.haml
index 634b1836754a026cd26a32a30e4b0745629fc1e5..7bcedf6156e341ce7be48bee56cf1087ba63ccdb 100644
--- a/app/views/admin/projects/show.html.haml
+++ b/app/views/admin/projects/show.html.haml
@@ -102,6 +102,13 @@
%td
= check_box_tag :post_receive_file, 1, @project.has_post_receive_file?, disabled: true
+ %tr
+ %td
+ %b
+ Private:
+ %td
+ = check_box_tag :private_flag, 1, @project.private?, disabled: true
+
%br
%h5
Team
diff --git a/app/views/dashboard/_projects.html.haml b/app/views/dashboard/_projects.html.haml
index cffafb5445c2b476018974c500f3e924dd8ee9c7..058e13f1741a52aedf7632052f745bf52ee00bbe 100644
--- a/app/views/dashboard/_projects.html.haml
+++ b/app/views/dashboard/_projects.html.haml
@@ -15,6 +15,8 @@
= link_to "Personal", dashboard_path(scope: 'personal')
= nav_tab :scope, 'joined' do
= link_to "Joined", dashboard_path(scope: 'joined')
+ = nav_tab :scope, 'public' do
+ = link_to "Public", dashboard_path(scope: 'public')
%ul.well-list
- projects.each do |project|
diff --git a/app/views/projects/_form.html.haml b/app/views/projects/_form.html.haml
index 7044d1f20be1183c446de80268903f3018b7646e..2073b78d0606b688ffda69209130a4fb9f6d513c 100644
--- a/app/views/projects/_form.html.haml
+++ b/app/views/projects/_form.html.haml
@@ -23,6 +23,11 @@
= f.label :default_branch, "Default Branch"
.input= f.select(:default_branch, @project.heads.map(&:name), {}, style: "width:210px;")
+ .control-group
+ = f.label :private_flag, "Private"
+ .controls
+ = f.check_box :private_flag
+
%fieldset.features
%legend Features:
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 83a769760987b719e10892723c78ae797bed01d0..31ce053a7657d3d834a99d33faa5c6ebdfa03fbe 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -42,7 +42,7 @@ describe Project do
describe "Mass assignment" do
it { should_not allow_mass_assignment_of(:namespace_id) }
it { should_not allow_mass_assignment_of(:owner_id) }
- it { should_not allow_mass_assignment_of(:private_flag) }
+ it { should allow_mass_assignment_of(:private_flag) }
end
describe "Validation" do