diff options
author | Jason Hollingsworth <jhworth.developer@gmail.com> | 2013-11-06 09:13:21 -0600 |
---|---|---|
committer | Jason Hollingsworth <jhworth.developer@gmail.com> | 2013-11-26 22:22:07 -0600 |
commit | d9bb4230cc3aa161876df821c34d8e9c53d2e7a6 (patch) | |
tree | d9923bbf4ebe3f6cf96f71cdcfe4c07cc94b6752 /app/models/project.rb | |
parent | 51b5509bacdfba1d3ca84a4b56c6bd21942f1d2e (diff) | |
download | gitlab-ce-d9bb4230cc3aa161876df821c34d8e9c53d2e7a6.tar.gz |
Adding authenticated public mode (internal).
Added visibility_level icons to project view (rather than just text).
Added public projects to search results.
Added ability to restrict visibility levels standard users can set.
Diffstat (limited to 'app/models/project.rb')
-rw-r--r-- | app/models/project.rb | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index eab7c14d6c6..9ac078fcfa6 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -14,24 +14,25 @@ # merge_requests_enabled :boolean default(TRUE), not null # wiki_enabled :boolean default(TRUE), not null # namespace_id :integer -# public :boolean default(FALSE), not null # issues_tracker :string(255) default("gitlab"), not null # issues_tracker_id :string(255) # snippets_enabled :boolean default(TRUE), not null # last_activity_at :datetime # imported :boolean default(FALSE), not null # import_url :string(255) +# visibility_level :integer default(0), not null # 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, :issues_enabled, :wall_enabled, :merge_requests_enabled, :snippets_enabled, :issues_tracker_id, - :wiki_enabled, :public, :import_url, :last_activity_at, as: [:default, :admin] + :wiki_enabled, :visibility_level, :import_url, :last_activity_at, as: [:default, :admin] attr_accessible :namespace_id, :creator_id, as: :admin @@ -108,7 +109,8 @@ class Project < ActiveRecord::Base scope :sorted_by_activity, -> { reorder("projects.last_activity_at DESC") } scope :personal, ->(user) { where(namespace_id: user.namespace_id) } scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) } - scope :public_only, -> { where(public: true) } + scope :public_only, -> { where(visibility_level: PUBLIC) } + scope :public_or_internal_only, ->(user) { where("visibility_level IN (:levels)", levels: user ? [ INTERNAL, PUBLIC ] : [ PUBLIC ]) } enumerize :issues_tracker, in: (Gitlab.config.issues_tracker.keys).append(:gitlab), default: :gitlab @@ -140,6 +142,10 @@ class Project < ActiveRecord::Base where(path: id, namespace_id: nil).last end end + + def visibility_levels + Gitlab::VisibilityLevel.options + end end def team @@ -451,4 +457,8 @@ class Project < ActiveRecord::Base def default_branch @default_branch ||= repository.root_ref if repository.exists? end + + def visibility_level_field + visibility_level + end end |