Skip to content

Commit

Permalink
added public_view and public_download to policies
Browse files Browse the repository at this point in the history
git-svn-id: http://myexperiment.rubyforge.org/svn/trunk@2700 4f7b4649-9ca9-420a-81b3-55a188e4d46f
  • Loading branch information
dgc committed Sep 13, 2011
1 parent 1782479 commit c224f81
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
16 changes: 15 additions & 1 deletion app/models/policy.rb
Expand Up @@ -17,12 +17,24 @@ class Policy < ActiveRecord::Base

validates_presence_of :contributor, :name

before_save do |policy|

if policy.share_mode
policy.public_view = policy.share_mode < 3
policy.public_download = policy.share_mode < 1
end

true
end

# THIS IS THE DEFAULT POLICY (see /app/views/policies/_list_form.rhtml)
def self._default(c_utor, c_ution=nil)
rtn = Policy.new(:name => "A default policy", # "anyone can view and download and no one else can edit"
:contributor => c_utor,
:share_mode => 0,
:update_mode => 6)
:update_mode => 6,
:public_view => false,
:public_download => false)

c_ution.policy = rtn unless c_ution.nil?

Expand All @@ -36,6 +48,8 @@ def copy_values_from(other)
self.contributor = other.contributor
self.share_mode = other.share_mode
self.update_mode = other.update_mode
self.public_view = other.public_view
self.public_download = other.public_download
end


Expand Down
14 changes: 14 additions & 0 deletions config/base_schema.xml
Expand Up @@ -32,6 +32,20 @@

</table>

<table name="policies">

<column type="integer" name="contributor_id"/>
<column type="string" name="contributor_type"/>
<column type="string" name="name"/>
<column type="datetime" name="created_at"/>
<column type="datetime" name="updated_at"/>
<column type="integer" name="share_mode"/>
<column type="integer" name="update_mode"/>
<column type="boolean" name="public_view" default="false"/>
<column type="boolean" name="public_download" default="false"/>

</table>

<table name="downloads">

<column type="integer" name="contribution_id"/>
Expand Down

0 comments on commit c224f81

Please sign in to comment.