From 6c416aaac85fe16cd4900a686714627e9a0fcdbc Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> Date: Mon, 6 Feb 2012 19:40:32 +0200 Subject: [PATCH] Issues, MR, Wall can be enabled/disabled per project --- app/controllers/issues_controller.rb | 5 ++ app/controllers/merge_requests_controller.rb | 5 ++ app/controllers/projects_controller.rb | 2 + app/views/layouts/_project_side.html.haml | 20 ++++---- app/views/projects/_form.html.haml | 16 ++++++- app/views/projects/info.html.haml | 47 +++++++++++++++++-- app/views/widgets/_project_member.html.haml | 19 ++++---- ...170141_add_modularity_fields_to_project.rb | 7 +++ db/schema.rb | 21 +++++++-- 9 files changed, 116 insertions(+), 26 deletions(-) create mode 100644 db/migrate/20120206170141_add_modularity_fields_to_project.rb diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 7c10d2a8ef..ed1a5864f2 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -1,6 +1,7 @@ class IssuesController < ApplicationController before_filter :authenticate_user! before_filter :project + before_filter :module_enabled before_filter :issue, :only => [:edit, :update, :destroy, :show] layout "project" @@ -132,4 +133,8 @@ class IssuesController < ApplicationController def authorize_admin_issue! can?(current_user, :admin_issue, @issue) end + + def module_enabled + return render_404 unless @project.issues_enabled + end end diff --git a/app/controllers/merge_requests_controller.rb b/app/controllers/merge_requests_controller.rb index 9ab62f5e72..b02934421a 100644 --- a/app/controllers/merge_requests_controller.rb +++ b/app/controllers/merge_requests_controller.rb @@ -1,6 +1,7 @@ class MergeRequestsController < ApplicationController before_filter :authenticate_user! before_filter :project + before_filter :module_enabled before_filter :merge_request, :only => [:edit, :update, :destroy, :show, :commits, :diffs] layout "project" @@ -114,4 +115,8 @@ class MergeRequestsController < ApplicationController def authorize_admin_merge_request! can?(current_user, :admin_merge_request, @merge_request) end + + def module_enabled + return render_404 unless @project.merge_requests_enabled + end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 6530f47eee..c9ffa5b72a 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -85,6 +85,8 @@ class ProjectsController < ApplicationController # def wall + return render_404 unless @project.wall_enabled + @note = Note.new @notes = @project.common_notes.order("created_at DESC") @notes = @notes.fresh.limit(20) diff --git a/app/views/layouts/_project_side.html.haml b/app/views/layouts/_project_side.html.haml index 1e553788f8..cc3174fe60 100644 --- a/app/views/layouts/_project_side.html.haml +++ b/app/views/layouts/_project_side.html.haml @@ -9,11 +9,15 @@ = link_to "Code", tree_project_ref_path(@project, @project.root_ref), :class => tree_tab_class = link_to "Commits", project_commits_path(@project), :class => (controller.controller_name == "commits") ? "current" : nil = link_to "Network", graph_project_path(@project), :class => current_page?(:controller => "projects", :action => "graph", :id => @project) ? "current" : nil - = link_to project_issues_filter_path(@project), :class => (controller.controller_name == "issues") ? "current" : nil do - Issues - = link_to project_merge_requests_path(@project), :class => (controller.controller_name == "merge_requests") ? "current" : nil do - Merge Requests - = link_to wall_project_path(@project), :class => current_page?(:controller => "projects", :action => "wall", :id => @project) ? "current" : nil do - @Wall - - if @project.common_notes.today.count > 0 - %span.label= @project.common_notes.today.count + - if @project.issues_enabled + = link_to project_issues_filter_path(@project), :class => (controller.controller_name == "issues") ? "current" : nil do + Issues + - if @project.merge_requests_enabled + = link_to project_merge_requests_path(@project), :class => (controller.controller_name == "merge_requests") ? "current" : nil do + Merge Requests + + - if @project.wall_enabled + = link_to wall_project_path(@project), :class => current_page?(:controller => "projects", :action => "wall", :id => @project) ? "current" : nil do + @Wall + - if @project.common_notes.today.count > 0 + %span.label= @project.common_notes.today.count diff --git a/app/views/projects/_form.html.haml b/app/views/projects/_form.html.haml index 44b7233605..37446585d9 100644 --- a/app/views/projects/_form.html.haml +++ b/app/views/projects/_form.html.haml @@ -23,10 +23,24 @@ = f.label :default_branch, "Default Branch" .input= f.select(:default_branch, @project.heads.map(&:name), {}, :style => "width:210px;") + .well + %h5 Features + + .clearfix + = f.label :issues_enabled, "Issues" + .input= f.check_box :issues_enabled + + .clearfix + = f.label :merge_requests_enabled, "Merge Requests" + .input= f.check_box :merge_requests_enabled + + .clearfix + = f.label :wall_enabled, "Wall" + .input= f.check_box :wall_enabled .clearfix = f.label :description - .input= f.text_area :description, :placeholder => "project description", :style => "height:50px" + .input= f.text_area :description, :placeholder => "project description", :class => "xlarge", :rows => 4 %br diff --git a/app/views/projects/info.html.haml b/app/views/projects/info.html.haml index 513b2ab2cd..d119687361 100644 --- a/app/views/projects/info.html.haml +++ b/app/views/projects/info.html.haml @@ -1,12 +1,17 @@ = render "project_head" -%h3= @project.name -%br - +.entry + %h3= @project.name + %br + + + + %pre + = "git clone #{@project.url_to_repo}" + -%pre - = "git clone #{@project.url_to_repo}" +%h4 Details: %table %tr @@ -54,6 +59,38 @@ %tr %td{:colspan => 2}= simple_format @project.description + +%h4 Features: + +%table + %tr + %td Issues + %td + - if @project.issues_enabled + .alert-message.success + Enabled + - else + .alert-message.error + Disabled + + %tr + %td Merge Requests + %td + - if @project.merge_requests_enabled + .alert-message.success + Enabled + - else + .alert-message.error + Disabled + %tr + %td Wall + %td + - if @project.wall_enabled + .alert-message.success + Enabled + - else + .alert-message.error + Disabled .actions = link_to "Edit", edit_project_path(@project), :class => "btn" diff --git a/app/views/widgets/_project_member.html.haml b/app/views/widgets/_project_member.html.haml index 1af911120d..0380033d1d 100644 --- a/app/views/widgets/_project_member.html.haml +++ b/app/views/widgets/_project_member.html.haml @@ -16,13 +16,14 @@ %span.label= member.repo_access_human - if can? current_user, :write_project, @project - %hr - .span3 - %p You have access to create new issue or merge request. - %div - = link_to new_project_issue_path(@project), :title => "New Issue", :class => "" do - New Issue » - %div - = link_to new_project_merge_request_path(@project), :title => "New Merge Request", :class => "" do - New Merge Request » + - if @project.issues_enabled && @project.merge_requests_enabled + %hr + .span3 + %p You have access to create new issue or merge request. + %div + = link_to new_project_issue_path(@project), :title => "New Issue", :class => "" do + New Issue » + %div + = link_to new_project_merge_request_path(@project), :title => "New Merge Request", :class => "" do + New Merge Request » diff --git a/db/migrate/20120206170141_add_modularity_fields_to_project.rb b/db/migrate/20120206170141_add_modularity_fields_to_project.rb new file mode 100644 index 0000000000..d63de0c2be --- /dev/null +++ b/db/migrate/20120206170141_add_modularity_fields_to_project.rb @@ -0,0 +1,7 @@ +class AddModularityFieldsToProject < ActiveRecord::Migration + def change + add_column :projects, :issues_enabled, :boolean, :null => false, :default => true + add_column :projects, :wall_enabled, :boolean, :null => false, :default => true + add_column :projects, :merge_requests_enabled, :boolean, :null => false, :default => true + end +end diff --git a/db/schema.rb b/db/schema.rb index 2d891917fd..a6522e8e92 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,19 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120121122616) do +ActiveRecord::Schema.define(:version => 20120206170141) do + + create_table "features", :force => true do |t| + t.string "name" + t.string "branch_name" + t.integer "assignee_id" + t.integer "author_id" + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + t.string "version" + t.integer "status", :default => 0, :null => false + end create_table "issues", :force => true do |t| t.string "title" @@ -73,10 +85,13 @@ ActiveRecord::Schema.define(:version => 20120121122616) do t.text "description" t.datetime "created_at" t.datetime "updated_at" - t.boolean "private_flag", :default => true, :null => false + t.boolean "private_flag", :default => true, :null => false t.string "code" t.integer "owner_id" - t.string "default_branch", :default => "master", :null => false + t.string "default_branch", :default => "master", :null => false + t.boolean "issues_enabled", :default => true, :null => false + t.boolean "wall_enabled", :default => true, :null => false + t.boolean "merge_requests_enabled", :default => true, :null => false end create_table "snippets", :force => true do |t| -- 2.30.9