Commit b765a795 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Move snippets to own tab as feature. Make it disabled for new projects by default

parent 112dc875
......@@ -32,8 +32,9 @@ module Projects
@project.namespace_id = current_user.namespace_id
end
# Disable wall by default
# Disable less important features by default
@project.wall_enabled = false
@project.snippets_enabled = false
@project.creator = current_user
......
class SnippetsController < ProjectResourceController
before_filter :module_enabled
before_filter :snippet, only: [:show, :edit, :destroy, :update, :raw]
# Allow read any snippet
......@@ -84,4 +85,8 @@ class SnippetsController < ProjectResourceController
def authorize_admin_snippet!
return render_404 unless can?(current_user, :admin_snippet, @snippet)
end
def module_enabled
return render_404 unless @project.snippet_enabled
end
end
......@@ -29,7 +29,7 @@ class Project < ActiveRecord::Base
class TransferError < StandardError; end
attr_accessible :name, :path, :description, :default_branch, :issues_tracker,
:issues_enabled, :wall_enabled, :merge_requests_enabled, :issues_tracker_id,
:issues_enabled, :wall_enabled, :merge_requests_enabled, :snippets_enabled, :issues_tracker_id,
:wiki_enabled, :public, :import_url, as: [:default, :admin]
attr_accessible :namespace_id, :creator_id, as: :admin
......
......@@ -43,6 +43,10 @@
= nav_link(path: 'projects#wall') do
= link_to 'Wall', wall_project_path(@project)
- if @project.snippets_enabled
= nav_link(controller: :snippets) do
= link_to 'Snippets', project_snippets_path(@project)
- if can? current_user, :admin_project, @project
= nav_link(html_options: {class: "#{project_tab_class}"}) do
= link_to edit_project_path(@project), class: "stat-tab tab " do
......
......@@ -87,6 +87,12 @@
= f.check_box :wall_enabled
%span.descr Simple chat system for broadcasting inside project
.control-group
= f.label :snippets_enabled, "Snippets", class: 'control-label'
.controls
= f.check_box :snippets_enabled
%span.descr Share code pastes with others out of git repository
.control-group
= f.label :wiki_enabled, "Wiki", class: 'control-label'
.controls
......
class AddSnippetsToFeatures < ActiveRecord::Migration
def change
add_column :projects, :snippets_enabled, :boolean, null: false, default: true
end
end
......@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130315124931) do
ActiveRecord::Schema.define(:version => 20130318212250) do
create_table "events", :force => true do |t|
t.string "target_type"
......@@ -155,6 +155,7 @@ ActiveRecord::Schema.define(:version => 20130315124931) do
t.boolean "public", :default => false, :null => false
t.string "issues_tracker", :default => "gitlab", :null => false
t.string "issues_tracker_id"
t.boolean "snippets_enabled", :default => true, :null => false
end
add_index "projects", ["creator_id"], :name => "index_projects_on_owner_id"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment