Commit 729088a7af7ef7b585066b408542b54f1a1999c5

Authored by Dmitriy Zaporozhets
1 parent a39c9106

Owner can enable public mode for project

app/contexts/project_update_context.rb
1 1 class ProjectUpdateContext < BaseContext
2 2 def execute(role = :default)
3 3 namespace_id = params[:project].delete(:namespace_id)
  4 + params[:project].delete(:public) unless can?(current_user, :change_public_mode, project)
4 5  
5 6 allowed_transfer = can?(current_user, :change_namespace, project) || role == :admin
6 7  
... ...
app/models/ability.rb
... ... @@ -90,6 +90,7 @@ class Ability
90 90 def project_admin_rules
91 91 project_master_rules + [
92 92 :change_namespace,
  93 + :change_public_mode,
93 94 :rename_project,
94 95 :remove_project
95 96 ]
... ...
app/models/project.rb
... ... @@ -26,9 +26,9 @@ class Project &lt; ActiveRecord::Base
26 26 class TransferError < StandardError; end
27 27  
28 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 33 attr_accessor :error_code
34 34  
... ...
app/views/admin/projects/index.html.haml
... ... @@ -47,7 +47,7 @@
47 47 - @projects.each do |project|
48 48 %li
49 49 - if project.public
50   - %i.icon-unlock.cred
  50 + %i.icon-share
51 51 - else
52 52 %i.icon-lock.cgreen
53 53 = link_to project.name_with_namespace, [:admin, project]
... ...
app/views/projects/_form.html.haml
... ... @@ -50,6 +50,19 @@
50 50 = f.check_box :wiki_enabled
51 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 67 - if can? current_user, :change_namespace, @project
55 68 %fieldset.features
... ...
app/views/public/projects/index.html.haml
... ... @@ -7,7 +7,7 @@
7 7 - @projects.each do |project|
8 8 %li.clearfix
9 9 %h5
10   - %i.icon-star.cgreen
  10 + %i.icon-share
11 11 = project.name_with_namespace
12 12 .right
13 13 %span.monospace.tiny
... ...