myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [2700] trunk: added public_view and public_downlo


From: noreply
Subject: [myexperiment-hackers] [2700] trunk: added public_view and public_download to policies
Date: Tue, 13 Sep 2011 11:34:47 -0400 (EDT)

Revision
2700
Author
dgc
Date
2011-09-13 11:34:47 -0400 (Tue, 13 Sep 2011)

Log Message

added public_view and public_download to policies

Modified Paths

Diff

Modified: trunk/app/models/policy.rb (2699 => 2700)


--- trunk/app/models/policy.rb	2011-09-12 18:03:14 UTC (rev 2699)
+++ trunk/app/models/policy.rb	2011-09-13 15:34:47 UTC (rev 2700)
@@ -17,12 +17,24 @@
   
   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?
     
@@ -36,6 +48,8 @@
     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
   
   

Modified: trunk/config/base_schema.xml (2699 => 2700)


--- trunk/config/base_schema.xml	2011-09-12 18:03:14 UTC (rev 2699)
+++ trunk/config/base_schema.xml	2011-09-13 15:34:47 UTC (rev 2700)
@@ -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"/>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]