add hidden repository function

This commit is contained in:
yanxd 2013-11-12 10:27:36 +08:00
parent 5fb29c150b
commit 98ccc97b27
9 changed files with 459 additions and 440 deletions

View File

@ -208,6 +208,13 @@ class RepositoriesController < ApplicationController
end
def show
if !User.current.member_of?(@project)
if @project.hidden_repo
render_403
return -1
end
end
#if( !User.current.member_of?(@project) || @project.hidden_repo)
@repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty?
@entries = @repository.entries(@path, @rev)

View File

@ -702,6 +702,7 @@ class Project < ActiveRecord::Base
'description',
'homepage',
'is_public',
'hidden_repo',
'identifier',
'custom_field_values',
'custom_fields',

View File

@ -12,6 +12,7 @@
<% end %></p>
<!-- <p style="margin-left:-10px;"><%= f.text_field :homepage, :size => 60, :style => "width:488px;margin-left: 10px;" %></p> --> <!-- by huang -->
<p style="margin-left:-10px;"><em style ="color: #888888;display: block;font-size: 90%;font-style: normal;"><%= f.check_box :is_public, :style => "margin-left:10px;" %></em></p>
<p style="margin-left:-10px;"><em style ="color: #888888;display: block;font-size: 90%;font-style: normal;"><%= f.check_box :hidden_repo, :style => "margin-left:10px;" %></em></p>
<p style="display:none;"><%= f.text_field :project_type, :value => 0 %></p>
<%= wikitoolbar_for 'project_description' %>

View File

@ -1561,6 +1561,8 @@ en:
label_course_practice: Courses
label_user_home: User Space
field_hidden_repo: private code

View File

@ -1705,3 +1705,5 @@ zh:
label_duration_time: 授课时间
label_course_brief_introduction: 课程简介
field_teacher_name: 教 师
field_hidden_repo: 私有代码

View File

@ -0,0 +1,5 @@
class AddHiddenRepoToProjects < ActiveRecord::Migration
def change
add_column :projects, :hidden_repo, :boolean, :default => false, :null => false
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20131108133857) do
ActiveRecord::Schema.define(:version => 20131112005309) do
create_table "a_user_watchers", :force => true do |t|
t.string "name"
@ -540,6 +540,7 @@ ActiveRecord::Schema.define(:version => 20131108133857) do
t.integer "rgt"
t.boolean "inherit_members", :default => false, :null => false
t.integer "project_type"
t.boolean "hidden_repo", :default => false, :null => false
end
add_index "projects", ["lft"], :name => "index_projects_on_lft"

View File

@ -314,7 +314,7 @@ Redmine::MenuManager.map :project_menu do |menu|
# :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural
menu.push :files, { :controller => 'files', :action => 'index' }, :param => :project_id, :caption => :label_file_new
menu.push :repository, { :controller => 'repositories', :action => 'show', :repository_id => nil, :path => nil, :rev => nil },
:if => Proc.new { |p| p.repository && !p.repository.new_record? }
:if => Proc.new { |p| p.repository && !p.repository.new_record? && !( !User.current.member_of?(p) && p.hidden_repo ) }
menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true
end