OSDN Git Service

Merge branch 'authenticated_public_mode' of https://github.com/jhollingsworth/gitlabh...
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Wed, 27 Nov 2013 09:51:46 +0000 (11:51 +0200)
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Wed, 27 Nov 2013 09:51:46 +0000 (11:51 +0200)
Conflicts:
app/models/project.rb

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
1  2 
app/contexts/projects/update_context.rb
app/models/project.rb

@@@ -2,10 -2,14 +2,14 @@@ module Project
    class UpdateContext < BaseContext
      def execute(role = :default)
        params[:project].delete(:namespace_id)
-       params[:project].delete(:public) unless can?(current_user, :change_public_mode, project)
+       # check that user is allowed to set specified visibility_level
+       unless can?(current_user, :change_visibility_level, project) && Gitlab::VisibilityLevel.allowed_for?(current_user, params[:project][:visibility_level])
+         params[:project].delete(:visibility_level)
+       end
        new_branch = params[:project].delete(:default_branch)
  
 -      if project.repository.exists? && new_branch != project.repository.root_ref
 +      if project.repository.exists? && new_branch != project.default_branch
          GitlabShellWorker.perform_async(
            :update_repository_head,
            project.path_with_namespace,
@@@ -25,8 -25,9 +25,9 @@@
  
  class Project < ActiveRecord::Base
    include Gitlab::ShellAdapter
+   include Gitlab::VisibilityLevel
    extend Enumerize
 -   
 +
    ActsAsTaggableOn.strict_case_match = true
  
    attr_accessible :name, :path, :description, :issues_tracker, :label_list,
          where(path: id, namespace_id: nil).last
        end
      end
 -    
++
+     def visibility_levels
+       Gitlab::VisibilityLevel.options
+     end
    end
  
    def team
    def default_branch
      @default_branch ||= repository.root_ref if repository.exists?
    end
 -  
 +
 +  def reload_default_branch
 +    @default_branch = nil
 +    default_branch
 +  end
++
+   def visibility_level_field
+     visibility_level
+   end
  end