Commit 729088a7af7ef7b585066b408542b54f1a1999c5
1 parent
a39c9106
Exists in
master
and in
4 other branches
Owner can enable public mode for project
Showing
6 changed files
with
19 additions
and
4 deletions
Show diff stats
app/contexts/project_update_context.rb
| 1 | class ProjectUpdateContext < BaseContext | 1 | class ProjectUpdateContext < BaseContext |
| 2 | def execute(role = :default) | 2 | def execute(role = :default) |
| 3 | namespace_id = params[:project].delete(:namespace_id) | 3 | namespace_id = params[:project].delete(:namespace_id) |
| 4 | + params[:project].delete(:public) unless can?(current_user, :change_public_mode, project) | ||
| 4 | 5 | ||
| 5 | allowed_transfer = can?(current_user, :change_namespace, project) || role == :admin | 6 | allowed_transfer = can?(current_user, :change_namespace, project) || role == :admin |
| 6 | 7 |
app/models/ability.rb
| @@ -90,6 +90,7 @@ class Ability | @@ -90,6 +90,7 @@ class Ability | ||
| 90 | def project_admin_rules | 90 | def project_admin_rules |
| 91 | project_master_rules + [ | 91 | project_master_rules + [ |
| 92 | :change_namespace, | 92 | :change_namespace, |
| 93 | + :change_public_mode, | ||
| 93 | :rename_project, | 94 | :rename_project, |
| 94 | :remove_project | 95 | :remove_project |
| 95 | ] | 96 | ] |
app/models/project.rb
| @@ -26,9 +26,9 @@ class Project < ActiveRecord::Base | @@ -26,9 +26,9 @@ class Project < ActiveRecord::Base | ||
| 26 | class TransferError < StandardError; end | 26 | class TransferError < StandardError; end |
| 27 | 27 | ||
| 28 | attr_accessible :name, :path, :description, :default_branch, :issues_enabled, | 28 | attr_accessible :name, :path, :description, :default_branch, :issues_enabled, |
| 29 | - :wall_enabled, :merge_requests_enabled, :wiki_enabled, as: [:default, :admin] | 29 | + :wall_enabled, :merge_requests_enabled, :wiki_enabled, :public, as: [:default, :admin] |
| 30 | 30 | ||
| 31 | - attr_accessible :namespace_id, :creator_id, :public, as: :admin | 31 | + attr_accessible :namespace_id, :creator_id, as: :admin |
| 32 | 32 | ||
| 33 | attr_accessor :error_code | 33 | attr_accessor :error_code |
| 34 | 34 |
app/views/admin/projects/index.html.haml
| @@ -47,7 +47,7 @@ | @@ -47,7 +47,7 @@ | ||
| 47 | - @projects.each do |project| | 47 | - @projects.each do |project| |
| 48 | %li | 48 | %li |
| 49 | - if project.public | 49 | - if project.public |
| 50 | - %i.icon-unlock.cred | 50 | + %i.icon-share |
| 51 | - else | 51 | - else |
| 52 | %i.icon-lock.cgreen | 52 | %i.icon-lock.cgreen |
| 53 | = link_to project.name_with_namespace, [:admin, project] | 53 | = link_to project.name_with_namespace, [:admin, project] |
app/views/projects/_form.html.haml
| @@ -50,6 +50,19 @@ | @@ -50,6 +50,19 @@ | ||
| 50 | = f.check_box :wiki_enabled | 50 | = f.check_box :wiki_enabled |
| 51 | %span.descr Pages for project documentation | 51 | %span.descr Pages for project documentation |
| 52 | 52 | ||
| 53 | + - if can? current_user, :change_public_mode, @project | ||
| 54 | + %fieldset.features | ||
| 55 | + %legend | ||
| 56 | + %i.icon-share | ||
| 57 | + Public mode: | ||
| 58 | + .control-group | ||
| 59 | + = f.label :public, class: 'control-label' do | ||
| 60 | + %span Public http clone | ||
| 61 | + .controls | ||
| 62 | + = f.check_box :public | ||
| 63 | + %span.descr | ||
| 64 | + If checked this project will be available for clone without any authentification. Also it will appears on #{link_to "Public page", public_root_path} | ||
| 65 | + | ||
| 53 | 66 | ||
| 54 | - if can? current_user, :change_namespace, @project | 67 | - if can? current_user, :change_namespace, @project |
| 55 | %fieldset.features | 68 | %fieldset.features |
app/views/public/projects/index.html.haml
| @@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
| 7 | - @projects.each do |project| | 7 | - @projects.each do |project| |
| 8 | %li.clearfix | 8 | %li.clearfix |
| 9 | %h5 | 9 | %h5 |
| 10 | - %i.icon-star.cgreen | 10 | + %i.icon-share |
| 11 | = project.name_with_namespace | 11 | = project.name_with_namespace |
| 12 | .right | 12 | .right |
| 13 | %span.monospace.tiny | 13 | %span.monospace.tiny |