-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #187 from projecthydra/visibility_changed
Visibility changed
- Loading branch information
Showing
8 changed files
with
108 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,3 @@ | ||
# Copyright © 2012 The Pennsylvania State University | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
class GenericFile < ActiveFedora::Base | ||
include Sufia::GenericFile | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
module Sufia | ||
module GenericFile | ||
module Visibility | ||
extend ActiveSupport::Concern | ||
extend Deprecation | ||
include ActiveModel::Dirty | ||
|
||
included do | ||
define_attribute_methods :visibility | ||
end | ||
|
||
def visibility= (value) | ||
# only set explicit permissions | ||
case value | ||
when "open" | ||
public_visibility! | ||
when "psu" | ||
registered_visibility! | ||
when "restricted" | ||
private_visibility! | ||
end | ||
end | ||
|
||
def public_visibility! | ||
visibility_will_change! unless visibility == 'public' | ||
self.datastreams["rightsMetadata"].permissions({:group=>"public"}, "read") | ||
end | ||
|
||
def registered_visibility! | ||
visibility_will_change! unless visibility == 'registered' | ||
self.datastreams["rightsMetadata"].permissions({:group=>"registered"}, "read") | ||
self.datastreams["rightsMetadata"].permissions({:group=>"public"}, "none") | ||
end | ||
|
||
def private_visibility! | ||
visibility_will_change! unless visibility == 'private' | ||
self.datastreams["rightsMetadata"].permissions({:group=>"registered"}, "none") | ||
self.datastreams["rightsMetadata"].permissions({:group=>"public"}, "none") | ||
end | ||
|
||
def visibility | ||
if read_groups.include? 'public' | ||
'public' | ||
elsif read_groups.include? 'registered' | ||
'registered' | ||
else | ||
'private' | ||
end | ||
end | ||
|
||
def set_visibility(visibility) | ||
Deprecation.warn Permissions, "set_visibility is deprecated, use visibility= instead. set_visibility will be removed in sufia 3.0", caller | ||
self.visibility= visibility | ||
end | ||
end | ||
end | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters