Commit b765a7958d5d8602d0f8cc3b23b07cfa4f304208
1 parent
112dc875
Exists in
master
and in
4 other branches
Move snippets to own tab as feature. Make it disabled for new projects by default
Showing
7 changed files
with
25 additions
and
3 deletions
Show diff stats
app/contexts/projects/create_context.rb
@@ -32,8 +32,9 @@ module Projects | @@ -32,8 +32,9 @@ module Projects | ||
32 | @project.namespace_id = current_user.namespace_id | 32 | @project.namespace_id = current_user.namespace_id |
33 | end | 33 | end |
34 | 34 | ||
35 | - # Disable wall by default | 35 | + # Disable less important features by default |
36 | @project.wall_enabled = false | 36 | @project.wall_enabled = false |
37 | + @project.snippets_enabled = false | ||
37 | 38 | ||
38 | @project.creator = current_user | 39 | @project.creator = current_user |
39 | 40 |
app/controllers/snippets_controller.rb
1 | class SnippetsController < ProjectResourceController | 1 | class SnippetsController < ProjectResourceController |
2 | + before_filter :module_enabled | ||
2 | before_filter :snippet, only: [:show, :edit, :destroy, :update, :raw] | 3 | before_filter :snippet, only: [:show, :edit, :destroy, :update, :raw] |
3 | 4 | ||
4 | # Allow read any snippet | 5 | # Allow read any snippet |
@@ -84,4 +85,8 @@ class SnippetsController < ProjectResourceController | @@ -84,4 +85,8 @@ class SnippetsController < ProjectResourceController | ||
84 | def authorize_admin_snippet! | 85 | def authorize_admin_snippet! |
85 | return render_404 unless can?(current_user, :admin_snippet, @snippet) | 86 | return render_404 unless can?(current_user, :admin_snippet, @snippet) |
86 | end | 87 | end |
88 | + | ||
89 | + def module_enabled | ||
90 | + return render_404 unless @project.snippet_enabled | ||
91 | + end | ||
87 | end | 92 | end |
app/models/project.rb
@@ -29,7 +29,7 @@ class Project < ActiveRecord::Base | @@ -29,7 +29,7 @@ class Project < ActiveRecord::Base | ||
29 | class TransferError < StandardError; end | 29 | class TransferError < StandardError; end |
30 | 30 | ||
31 | attr_accessible :name, :path, :description, :default_branch, :issues_tracker, | 31 | attr_accessible :name, :path, :description, :default_branch, :issues_tracker, |
32 | - :issues_enabled, :wall_enabled, :merge_requests_enabled, :issues_tracker_id, | 32 | + :issues_enabled, :wall_enabled, :merge_requests_enabled, :snippets_enabled, :issues_tracker_id, |
33 | :wiki_enabled, :public, :import_url, as: [:default, :admin] | 33 | :wiki_enabled, :public, :import_url, as: [:default, :admin] |
34 | 34 | ||
35 | attr_accessible :namespace_id, :creator_id, as: :admin | 35 | attr_accessible :namespace_id, :creator_id, as: :admin |
app/views/layouts/project_resource.html.haml
@@ -43,6 +43,10 @@ | @@ -43,6 +43,10 @@ | ||
43 | = nav_link(path: 'projects#wall') do | 43 | = nav_link(path: 'projects#wall') do |
44 | = link_to 'Wall', wall_project_path(@project) | 44 | = link_to 'Wall', wall_project_path(@project) |
45 | 45 | ||
46 | + - if @project.snippets_enabled | ||
47 | + = nav_link(controller: :snippets) do | ||
48 | + = link_to 'Snippets', project_snippets_path(@project) | ||
49 | + | ||
46 | - if can? current_user, :admin_project, @project | 50 | - if can? current_user, :admin_project, @project |
47 | = nav_link(html_options: {class: "#{project_tab_class}"}) do | 51 | = nav_link(html_options: {class: "#{project_tab_class}"}) do |
48 | = link_to edit_project_path(@project), class: "stat-tab tab " do | 52 | = link_to edit_project_path(@project), class: "stat-tab tab " do |
app/views/projects/_form.html.haml
@@ -88,6 +88,12 @@ | @@ -88,6 +88,12 @@ | ||
88 | %span.descr Simple chat system for broadcasting inside project | 88 | %span.descr Simple chat system for broadcasting inside project |
89 | 89 | ||
90 | .control-group | 90 | .control-group |
91 | + = f.label :snippets_enabled, "Snippets", class: 'control-label' | ||
92 | + .controls | ||
93 | + = f.check_box :snippets_enabled | ||
94 | + %span.descr Share code pastes with others out of git repository | ||
95 | + | ||
96 | + .control-group | ||
91 | = f.label :wiki_enabled, "Wiki", class: 'control-label' | 97 | = f.label :wiki_enabled, "Wiki", class: 'control-label' |
92 | .controls | 98 | .controls |
93 | = f.check_box :wiki_enabled | 99 | = f.check_box :wiki_enabled |
db/schema.rb
@@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
11 | # | 11 | # |
12 | # It's strongly recommended to check this file into your version control system. | 12 | # It's strongly recommended to check this file into your version control system. |
13 | 13 | ||
14 | -ActiveRecord::Schema.define(:version => 20130315124931) do | 14 | +ActiveRecord::Schema.define(:version => 20130318212250) do |
15 | 15 | ||
16 | create_table "events", :force => true do |t| | 16 | create_table "events", :force => true do |t| |
17 | t.string "target_type" | 17 | t.string "target_type" |
@@ -155,6 +155,7 @@ ActiveRecord::Schema.define(:version => 20130315124931) do | @@ -155,6 +155,7 @@ ActiveRecord::Schema.define(:version => 20130315124931) do | ||
155 | t.boolean "public", :default => false, :null => false | 155 | t.boolean "public", :default => false, :null => false |
156 | t.string "issues_tracker", :default => "gitlab", :null => false | 156 | t.string "issues_tracker", :default => "gitlab", :null => false |
157 | t.string "issues_tracker_id" | 157 | t.string "issues_tracker_id" |
158 | + t.boolean "snippets_enabled", :default => true, :null => false | ||
158 | end | 159 | end |
159 | 160 | ||
160 | add_index "projects", ["creator_id"], :name => "index_projects_on_owner_id" | 161 | add_index "projects", ["creator_id"], :name => "index_projects_on_owner_id" |