Diff
Modified: trunk/app/models/pack.rb (3462 => 3463)
--- trunk/app/models/pack.rb 2013-03-04 12:35:10 UTC (rev 3462)
+++ trunk/app/models/pack.rb 2013-03-04 13:16:59 UTC (rev 3463)
@@ -26,6 +26,8 @@
has_many :versions, :class_name => "PackVersion"
+ belongs_to :license
+
def find_version(version)
match = versions.find(:first, :conditions => ["version = ?", version])
return match if match
Modified: trunk/app/views/contributions/_license_form.rhtml (3462 => 3463)
--- trunk/app/views/contributions/_license_form.rhtml 2013-03-04 12:35:10 UTC (rev 3462)
+++ trunk/app/views/contributions/_license_form.rhtml 2013-03-04 13:16:59 UTC (rev 3463)
@@ -35,8 +35,8 @@
<strong>What license do you want people to adhere to if they download and use this File?</strong>
</p>
<div style="padding-left: 1em;">
- <%= select(object, :license_id, [["No license", 0]] + License.find(:all).collect {|l| [l.title, l.id] },
- { :selected => @license ? @license.id : 0 },
+ <%= select(object, :license_id, [["No license", '']] + License.find(:all).collect {|l| [l.title, l.id] },
+ { :selected => @license ? @license.id : '' },
{ : remote_function(:update => 'license_info',
:url ="" {:controller => 'licenses', :action="" 'update_license_info' },
:with => "'license_id=' + escape(value)")}) %>
Modified: trunk/app/views/packs/edit.rhtml (3462 => 3463)
--- trunk/app/views/packs/edit.rhtml 2013-03-04 12:35:10 UTC (rev 3462)
+++ trunk/app/views/packs/edit.rhtml 2013-03-04 13:16:59 UTC (rev 3463)
@@ -30,6 +30,8 @@
<% if @pack.owner?(current_user) %>
<%= render :partial => "contributions/sharing_form", :locals => { :edit => true, :contributable => @pack, :update_perms => true } %>
+
+ <%= render :partial => "contributions/license_form", :locals => { :object => :pack, :contributable => @pack, :edit => true } -%>
<% end %>
<p>
Modified: trunk/app/views/packs/new.rhtml (3462 => 3463)
--- trunk/app/views/packs/new.rhtml 2013-03-04 12:35:10 UTC (rev 3462)
+++ trunk/app/views/packs/new.rhtml 2013-03-04 13:16:59 UTC (rev 3463)
@@ -25,6 +25,8 @@
<%= render :partial => "tags/tags_form", :locals => { :edit => false, :taggable => @pack } %>
<%= render :partial => "contributions/sharing_form", :locals => { :edit => false, :contributable => @pack, :update_perms => true } %>
+
+ <%= render :partial => "contributions/license_form", :locals => { :object => :pack, :contributable => @pack, :edit => false } -%>
<p style="text-align: center;">
<%= submit_tag "Create", :disable_with => "Creating..." %>
Modified: trunk/app/views/packs/show.rhtml (3462 => 3463)
--- trunk/app/views/packs/show.rhtml 2013-03-04 12:35:10 UTC (rev 3462)
+++ trunk/app/views/packs/show.rhtml 2013-03-04 13:16:59 UTC (rev 3463)
@@ -146,7 +146,9 @@
<b><%= pluralize items_count, "item" %> in this pack</b>
</p>
</div>
-
+
+ <%= render :partial => "contributions/license_box", :locals => { :contributable => @pack } %>
+
<%= render :partial => "contributions/curation_box", :locals => { :contributable => @pack } %>
<%= render :partial => "tags/tags_box", :locals => { :taggable => @pack,
Modified: trunk/config/tables.xml
(Binary files differ)
Modified: trunk/db/schema.rb (3462 => 3463)
--- trunk/db/schema.rb 2013-03-04 12:35:10 UTC (rev 3462)
+++ trunk/db/schema.rb 2013-03-04 13:16:59 UTC (rev 3463)
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20130215162325) do
+ActiveRecord::Schema.define(:version => 20130304123620) do
create_table "activity_limits", :force => true do |t|
t.string "contributor_type", :null => false
@@ -441,6 +441,7 @@
t.datetime "created_at"
t.datetime "updated_at"
t.integer "current_version"
+ t.integer "license_id"
end
create_table "pending_invitations", :force => true do |t|
@@ -829,8 +830,6 @@
t.integer "preview_id"
end
- add_index "workflow_versions", ["workflow_id"], :name => "index_workflow_versions_on_workflow_id"
-
create_table "workflows", :force => true do |t|
t.integer "contributor_id"
t.string "contributor_type"
Modified: trunk/lib/rest.rb (3462 => 3463)
--- trunk/lib/rest.rb 2013-03-04 12:35:10 UTC (rev 3462)
+++ trunk/lib/rest.rb 2013-03-04 13:16:59 UTC (rev 3463)
@@ -1386,6 +1386,19 @@
permissions = data.find_first('/pack/permissions')
+ if license_type = parse_element(data, :text, '/pack/license-type')
+ if license_type == ""
+ ob.license = nil
+ else
+ ob.license = License.find_by_unique_name(license_type)
+
+ if ob.license.nil?
+ ob.errors.add("License type")
+ return rest_response(400, :object => ob)
+ end
+ end
+ end
+
# build the contributable
ob.title = title if title
Modified: trunk/test/functional/packs_controller_test.rb (3462 => 3463)
--- trunk/test/functional/packs_controller_test.rb 2013-03-04 12:35:10 UTC (rev 3462)
+++ trunk/test/functional/packs_controller_test.rb 2013-03-04 13:16:59 UTC (rev 3463)
@@ -39,7 +39,7 @@
num_packs = Pack.count
login_as(:john)
- post :create, :pack => { :title => 'my new pack', :description => 'a new pack lalalala' }
+ post :create, :pack => { :title => 'my new pack', :description => 'a new pack lalalala', :license_id => '2' }
assert_response :redirect
assert_redirected_to(pack_url(assigns(:pack)))
@@ -60,7 +60,8 @@
def test_update
login_as(:john)
- post :update, :id => @first_id, :pack => { :title => 'edited pack', :description => 'a new pack' }
+ post :update, :id => @first_id, :pack => { :title => 'edited pack', :description => 'a new pack',
+ :license_id => '3' }
assert_response :redirect
assert_redirected_to :action ="" 'show', :id => @first_id