Diff
Modified: trunk/app/controllers/blobs_controller.rb (2492 => 2493)
--- trunk/app/controllers/blobs_controller.rb 2010-08-04 14:55:15 UTC (rev 2492)
+++ trunk/app/controllers/blobs_controller.rb 2010-08-10 22:01:41 UTC (rev 2493)
@@ -92,7 +92,7 @@
# POST /blobs
def create
-
+
# don't create new blob if no file has been selected
if params[:blob][:data].size == 0
respond_to do |format|
@@ -106,6 +106,8 @@
params[:blob].delete('data')
params[:blob][:contributor_type], params[:blob][:contributor_id] = "User", current_user.id
+
+ params[:blob][:license_id] = nil if params[:blob][:license_id] && params[:blob][:license_id] == "0"
@blob = Blob.new(params[:blob])
@blob.content_blob = ContentBlob.new(:data ="" data)
@@ -160,6 +162,8 @@
end
end
+ params[:blob][:license_id] = nil if params[:blob][:license_id] && params[:blob][:license_id] == "0"
+
# 'Data' (ie: the actual file) cannot be updated!
params[:blob].delete('data') if params[:blob][:data]
Modified: trunk/app/controllers/licenses_controller.rb (2492 => 2493)
--- trunk/app/controllers/licenses_controller.rb 2010-08-04 14:55:15 UTC (rev 2492)
+++ trunk/app/controllers/licenses_controller.rb 2010-08-10 22:01:41 UTC (rev 2493)
@@ -87,7 +87,7 @@
end
def update_license_info
- license = License.find(params[:license_id])
+ license = License.find_by_id(params[:license_id])
render :partial => "licenses/view", :locals => { :license => license }
end
Modified: trunk/app/controllers/workflows_controller.rb (2492 => 2493)
--- trunk/app/controllers/workflows_controller.rb 2010-08-04 14:55:15 UTC (rev 2492)
+++ trunk/app/controllers/workflows_controller.rb 2010-08-10 22:01:41 UTC (rev 2493)
@@ -232,7 +232,7 @@
@workflow = Workflow.new
@workflow.contributor = current_user
@workflow.last_edited_by = current_user.id
- @workflow.license_id = params[:workflow][:license_id]
+ @workflow.license_id = params[:workflow][:license_id] == "0" ? nil : params[:workflow][:license_id]
@workflow.content_blob = ContentBlob.new(:data ="" file.read)
@workflow.file_ext = file.original_filename.split(".").last.downcase
@@ -426,6 +426,8 @@
end
end
+ params[:workflow][:license_id] = nil if params[:workflow][:license_id] && params[:workflow][:license_id] == "0"
+
respond_to do |format|
# Here we assume that no actual workflow metadata is being updated that affects workflow versions,
# so we need to prevent the timestamping update of workflow version objects.
Modified: trunk/app/models/blob.rb (2492 => 2493)
--- trunk/app/models/blob.rb 2010-08-04 14:55:15 UTC (rev 2492)
+++ trunk/app/models/blob.rb 2010-08-10 22:01:41 UTC (rev 2493)
@@ -37,7 +37,6 @@
# :dependent => :destroy is not supported in belongs_to in rails 1.2.6
after_destroy { |b| b.content_blob.destroy }
- validates_presence_of :license_id
validates_presence_of :content_blob
validates_presence_of :content_type
Modified: trunk/app/models/workflow.rb (2492 => 2493)
--- trunk/app/models/workflow.rb 2010-08-04 14:55:15 UTC (rev 2492)
+++ trunk/app/models/workflow.rb 2010-08-10 22:01:41 UTC (rev 2493)
@@ -96,7 +96,6 @@
validates_presence_of :unique_name
validates_uniqueness_of :unique_name
- validates_presence_of :license_id
validates_presence_of :content_blob
validates_presence_of :content_type
Deleted: trunk/app/views/blobs/_license_form.rhtml (2492 => 2493)
--- trunk/app/views/blobs/_license_form.rhtml 2010-08-04 14:55:15 UTC (rev 2492)
+++ trunk/app/views/blobs/_license_form.rhtml 2010-08-10 22:01:41 UTC (rev 2493)
@@ -1,46 +0,0 @@
-<% if params[:blob] && !params[:blob][:license_id].blank? %>
- <% @license = License.find(params[:blob][:license_id]) %>
-<% elsif edit %>
- <% @license = License.find(@blob.license_id) %>
-<% else %>
- <% @license = License.find(2) %>
-<% end %>
-
-<div class="fold">
- <div class="foldTitle">
- <%= info_icon_with_tooltip("This section allows you to specify the <strong>rights</strong> that people have when they download and use this File, by setting the license. <br/><br/>By default, the license specifies that people are allowed to build on this File as long as they give the original author credit and share their resulting work under the same conditions.") %>
- License/Rights
- <% if edit %>
- <hr />
- <small>Current: <%= @license.title %> (<%= link_to h(@license.url), @license.url %>) </small>
- <% else %>
- <hr />
- <small>Default: <%= @license.title %> (<%= link_to h(@license.url), @license.url %>)</small>
- <% end %>
- </div>
- <div class="foldContent" style="display: none;">
- <p class="box_infotext">
- This section allows you to specify the <strong>rights</strong> that people have when they download and use this File, by setting the license.
- </p>
- <br />
- <p>
- <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(:blob, :license_id, License.find(:all).collect {|l| [l.title, l.id] },
- { :selected => @license.id },
- { : remote_function(:update => 'license_info',
- :url ="" {:controller => 'licenses', :action="" 'update_license_info' },
- :with => "'license_id=' + escape(value)")}) %>
-
- </div>
- <hr/>
- <div id="license_info" style="padding: 0 20px;">
- <%= render :partial => "licenses/view", :locals => { :license => @license } %>
- </div>
- </div>
-</div>
-
-
-
-
Modified: trunk/app/views/blobs/_table.rhtml (2492 => 2493)
--- trunk/app/views/blobs/_table.rhtml 2010-08-04 14:55:15 UTC (rev 2492)
+++ trunk/app/views/blobs/_table.rhtml 2010-08-10 22:01:41 UTC (rev 2493)
@@ -61,7 +61,11 @@
</p>
<% end %>
- <p style="font-size:85%;"><b>License: </b><% @license = License.find(blob.license_id) %><%= link_to h(@license.title), license_path(@license) %></p>
+ <% if blob.license_id.nil? %>
+ <p style="font-size:85%;"><b>License: </b>No license</p>
+ <% else %>
+ <p style="font-size:85%;"><b>License: </b><% @license = License.find(blob.license_id) %><%= link_to h(@license.title), license_path(@license) %></p>
+ <% end %>
<div class="desc" style="font-size: 85%;">
<% if blob.body and blob.body.length > 0 %>
Modified: trunk/app/views/blobs/edit.rhtml (2492 => 2493)
--- trunk/app/views/blobs/edit.rhtml 2010-08-04 14:55:15 UTC (rev 2492)
+++ trunk/app/views/blobs/edit.rhtml 2010-08-10 22:01:41 UTC (rev 2493)
@@ -31,8 +31,8 @@
<%= render :partial => "contributions/credit_attribution_form", :locals => { :edit => true, :contributable => @blob } %>
<% if @blob.owner?(current_user) %>
- <%= render :partial => "contributions/sharing_form", :locals => { :edit => true, :contributable => @blob, :update_perms => true } %>
- <%= render :partial => "blobs/license_form", :locals => { :edit => true } %>
+ <%= render :partial => "contributions/sharing_form", :locals => { :edit => true, :contributable => @blob, :update_perms => true } %>
+ <%= render :partial => "contributions/license_form", :locals => { :object => :blob, :contributable => @blob, :edit => true } %>
<% end %>
<p>
Modified: trunk/app/views/blobs/new.rhtml (2492 => 2493)
--- trunk/app/views/blobs/new.rhtml 2010-08-04 14:55:15 UTC (rev 2492)
+++ trunk/app/views/blobs/new.rhtml 2010-08-10 22:01:41 UTC (rev 2493)
@@ -39,7 +39,7 @@
<%= render :partial => "contributions/sharing_form", :locals => { :edit => false, :contributable => @blob, :update_perms => true } %>
- <%= render :partial => "blobs/license_form", :locals => { :edit => false } %>
+ <%= render :partial => "contributions/license_form", :locals => { :object => :blob, :contributable => @blob, :edit => false } %>
<%= render :partial => 'contributions/terms_and_conditions' %>
Modified: trunk/app/views/contributions/_license_box.rhtml (2492 => 2493)
--- trunk/app/views/contributions/_license_box.rhtml 2010-08-04 14:55:15 UTC (rev 2492)
+++ trunk/app/views/contributions/_license_box.rhtml 2010-08-10 22:01:41 UTC (rev 2493)
@@ -7,44 +7,47 @@
<a name="license"></a>
</p>
+ <% if contributable.license_id %>
-<% dc_title = contributable.title %>
-<% dc_description = h(contributable.respond_to?('description_html') ? contributable.description_html : contributable.body_html) %>
-<% dc_date = contributable.created_at %>
-<% dc_creator = contributor(contributable.contribution.contributor_id, contributable.contribution.contributor_type, link=false) %>
-<% dc_source = Conf.base_uri + request.request_uri %>
+ <% dc_title = contributable.title %>
+ <% dc_description = h(contributable.respond_to?('description_html') ? contributable.description_html : contributable.body_html) %>
+ <% dc_date = contributable.created_at %>
+ <% dc_creator = contributor(contributable.contribution.contributor_id, contributable.contribution.contributor_type, link=false) %>
+ <% dc_source = Conf.base_uri + request.request_uri %>
-<% @license = License.find(contributable.license_id) %>
+ <% @license = License.find(contributable.license_id) %>
-<%= "<!--
+ <%= "<!--
-<rdf:RDF xmlns=\"http://creativecommons.org/ns#\"
- xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
- xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">
-<Work rdf:about=\"\">
- <dc:title>#{dc_title}</dc:title>
- <dc:date>#{dc_date}</dc:date>
- <dc:description>#{dc_description}</dc:description>
- <dc:creator><Agent>
- <dc:title>#{dc_creator}</dc:title>
- </Agent></dc:creator>
- <dc:rights><Agent>
- <dc:title>#{dc_creator}</dc:title>
- </Agent></dc:rights>
- <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/Data\" />
- <dc:source rdf:resource=\"#{dc_source}\"/>
- <license rdf:resource=\"address@hidden" />
-</Work>
+ <rdf:RDF xmlns=\"http://creativecommons.org/ns#\"
+ xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
+ xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">
+ <Work rdf:about=\"\">
+ <dc:title>#{dc_title}</dc:title>
+ <dc:date>#{dc_date}</dc:date>
+ <dc:description>#{dc_description}</dc:description>
+ <dc:creator><Agent>
+ <dc:title>#{dc_creator}</dc:title>
+ </Agent></dc:creator>
+ <dc:rights><Agent>
+ <dc:title>#{dc_creator}</dc:title>
+ </Agent></dc:rights>
+ <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/Data\" />
+ <dc:source rdf:resource=\"#{dc_source}\"/>
+ <license rdf:resource=\"address@hidden" />
+ </Work>
-<License rdf:about=\"address@hidden">"%>
-<% @license.license_attributes.each do |attrib| %><%= " <#{attrib.predicate} rdf:resource=\"#{attrib.uri}\" />" %><% end %>
-</License>
+ <License rdf:about=\"address@hidden">"%>
+ <% @license.license_attributes.each do |attrib| %><%= " <#{attrib.predicate} rdf:resource=\"#{attrib.uri}\" />" %><% end %>
+ </License>
-</rdf:RDF>
+ </rdf:RDF>
--->
+ -->
+ <% end %>
+
<div class="contribution_currentlicense">
<p>
<% if contributable.respond_to?('versions') %>
@@ -52,7 +55,11 @@
<% else %>
This <%= visible_name(contributable) -%> is
<% end %>
- licensed under: <br/><br/><%= license_icon_link(@license) %>
+ <% if contributable.license_id %>
+ licensed under: <br/><br/><%= license_icon_link(@license) %>
+ <% else %>
+ not licensed.
+ <% end %>
</p>
</div>
Added: trunk/app/views/contributions/_license_form.rhtml (0 => 2493)
--- trunk/app/views/contributions/_license_form.rhtml (rev 0)
+++ trunk/app/views/contributions/_license_form.rhtml 2010-08-10 22:01:41 UTC (rev 2493)
@@ -0,0 +1,51 @@
+<% if params[object] && !params[object][:license_id].blank? %>
+ <% @license = License.find(params[object][:license_id]) %>
+<% elsif edit %>
+ <% @license = License.find_by_id(contributable.license_id) %>
+<% else %>
+ <% @license = License.find(2) %>
+<% end %>
+
+<div class="fold">
+ <div class="foldTitle">
+ <%= info_icon_with_tooltip("This section allows you to specify the <strong>rights</strong> that people have when they download and use this File, by setting the license. <br/><br/>By default, the license specifies that people are allowed to build on this File as long as they give the original author credit and share their resulting work under the same conditions.") %>
+ License/Rights
+ <% if edit %>
+ <hr />
+ <% if @license %>
+ <small>Current: <%= @license.title %> (<%= link_to h(@license.url), @license.url %>) </small>
+ <% else %>
+ <small>Current: No license</small>
+ <% end %>
+ <% else %>
+ <hr />
+ <% if @license %>
+ <small>Default: <%= @license.title %> (<%= link_to h(@license.url), @license.url %>)</small>
+ <% else %>
+ <small>Default: No license</small>
+ <% end %>
+ <% end %>
+ </div>
+ <div class="foldContent" style="display: none;">
+ <p class="box_infotext">
+ This section allows you to specify the <strong>rights</strong> that people have when they download and use this File, by setting the license.
+ </p>
+ <br />
+ <p>
+ <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 },
+ { : remote_function(:update => 'license_info',
+ :url ="" {:controller => 'licenses', :action="" 'update_license_info' },
+ :with => "'license_id=' + escape(value)")}) %>
+
+ </div>
+ <hr/>
+ <div id="license_info" style="padding: 0 20px;">
+ <%= render :partial => "licenses/view", :locals => { :license => @license } %>
+ </div>
+ </div>
+</div>
+
Modified: trunk/app/views/licenses/_view.rhtml (2492 => 2493)
--- trunk/app/views/licenses/_view.rhtml 2010-08-04 14:55:15 UTC (rev 2492)
+++ trunk/app/views/licenses/_view.rhtml 2010-08-10 22:01:41 UTC (rev 2493)
@@ -1,3 +1,4 @@
+<% if license %>
<p style="text-align: center;">
<b><big><%= license_icon_link(license) %></big></b>
<br/>
@@ -12,4 +13,9 @@
</p>
<% end %>
<br/>
- <small><%= license.description %></small>
\ No newline at end of file
+ <small><%= license.description %></small>
+<% else %>
+ <p style="text-align: center;">
+ No license details.
+ </p>
+<% end %>
Deleted: trunk/app/views/workflows/_license_form.rhtml (2492 => 2493)
--- trunk/app/views/workflows/_license_form.rhtml 2010-08-04 14:55:15 UTC (rev 2492)
+++ trunk/app/views/workflows/_license_form.rhtml 2010-08-10 22:01:41 UTC (rev 2493)
@@ -1,46 +0,0 @@
-<% if params[:workflow] && !params[:workflow][:license_id].blank? %>
- <% @license = License.find(params[:workflow][:license_id]) %>
-<% elsif edit %>
- <% @license = License.find(@workflow.license_id) %>
-<% else %>
- <% @license = License.find(2) %>
-<% end %>
-
-<div class="fold">
- <div class="foldTitle">
- <%= info_icon_with_tooltip("This section allows you to specify the <strong>rights</strong> that people have when they download and use this File, by setting the license. <br/><br/>By default, the license specifies that people are allowed to build on this File as long as they give the original author credit and share their resulting work under the same conditions.") %>
- License/Rights
- <% if edit %>
- <hr />
- <small>Current: <%= @license.title %> (<%= link_to h(@license.url), @license.url %>) </small>
- <% else %>
- <hr />
- <small>Default: <%= @license.title %> (<%= link_to h(@license.url), @license.url %>)</small>
- <% end %>
- </div>
- <div class="foldContent" style="display: none;">
- <p class="box_infotext">
- This section allows you to specify the <strong>rights</strong> that people have when they download and use this File, by setting the license.
- </p>
- <br />
- <p>
- <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(:workflow, :license_id, License.find(:all).collect {|l| [l.title, l.id] },
- { :selected => @license.id },
- { : remote_function(:update => 'license_info',
- :url ="" {:controller => 'licenses', :action="" 'update_license_info' },
- :with => "'license_id=' + escape(value)")}) %>
-
- </div>
- <hr/>
- <div id="license_info" style="padding: 0 20px;">
- <%= render :partial => "licenses/view", :locals => { :license => @license } %>
- </div>
- </div>
-</div>
-
-
-
-
Modified: trunk/app/views/workflows/_table.rhtml (2492 => 2493)
--- trunk/app/views/workflows/_table.rhtml 2010-08-04 14:55:15 UTC (rev 2492)
+++ trunk/app/views/workflows/_table.rhtml 2010-08-10 22:01:41 UTC (rev 2493)
@@ -68,7 +68,11 @@
</p>
<% end %>
- <p style="font-size:85%;"><b>License: </b><% @license = License.find(workflow.license_id) %><%= link_to h(@license.title), license_path(@license) %></p>
+ <% if workflow.license_id.nil? %>
+ <p style="font-size:85%;"><b>License: </b>No license</p>
+ <% else %>
+ <p style="font-size:85%;"><b>License: </b><% @license = License.find(workflow.license_id) %><%= link_to h(@license.title), license_path(@license) %></p>
+ <% end %>
<table style="width: 99%;">
<tbody>
Modified: trunk/app/views/workflows/edit.rhtml (2492 => 2493)
--- trunk/app/views/workflows/edit.rhtml 2010-08-04 14:55:15 UTC (rev 2492)
+++ trunk/app/views/workflows/edit.rhtml 2010-08-10 22:01:41 UTC (rev 2493)
@@ -21,7 +21,7 @@
<% if @workflow.owner?(current_user) %>
<%= render :partial => "contributions/sharing_form", :locals => { :edit => true, :contributable => @workflow, :update_perms => true } %>
- <%= render :partial => "workflows/license_form", :locals => { :edit => true } %>
+ <%= render :partial => "contributions/license_form", :locals => { :object => :workflow, :contributable => @workflow, :edit => true } %>
<% end %>
<p>
Modified: trunk/app/views/workflows/new.rhtml (2492 => 2493)
--- trunk/app/views/workflows/new.rhtml 2010-08-04 14:55:15 UTC (rev 2492)
+++ trunk/app/views/workflows/new.rhtml 2010-08-10 22:01:41 UTC (rev 2493)
@@ -43,7 +43,7 @@
<%= render :partial => "contributions/sharing_form", :locals => { :edit => false, :contributable => @workflow, :update_perms => true } -%>
<!-- License/Rights -->
- <%= render :partial => "workflows/license_form", :locals => { :edit => false } -%>
+ <%= render :partial => "contributions/license_form", :locals => { :object => :workflow, :contributable => @workflow, :edit => false } -%>
<!-- Terms and conditions -->
Modified: trunk/lib/rest.rb (2492 => 2493)
--- trunk/lib/rest.rb 2010-08-04 14:55:15 UTC (rev 2492)
+++ trunk/lib/rest.rb 2010-08-10 22:01:41 UTC (rev 2493)
@@ -240,11 +240,20 @@
else
+ foreign_ob = nil
+ text = ""
+
+ if model_data['Foreign Accessor'][i]
+ foreign_ob = eval("ob.#{model_data['Foreign Accessor'][i]}")
+ end
+
if accessor
- if query['version'] and model_data['Versioned'][i] == 'yes'
- text = eval("ob.versions[#{(query['version'].to_i - 1).to_s}].#{accessor}").to_s
- else
- text = eval("ob.#{accessor}").to_s
+ if model_data['Foreign Accessor'][i].nil? || foreign_ob
+ if query['version'] and model_data['Versioned'][i] == 'yes'
+ text = eval("ob.versions[#{(query['version'].to_i - 1).to_s}].#{accessor}").to_s
+ else
+ text = eval("ob.#{accessor}").to_s
+ end
end
end
@@ -884,10 +893,22 @@
# build the contributable
- ob.title = title if title
- ob.body = description if description
- ob.license = License.find_by_unique_name(license_type) if license_type
+ ob.title = title if title
+ ob.body = description if description
+ if 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
+
# handle workflow type
if type
@@ -1038,11 +1059,16 @@
ob.title = title if title
ob.body = description if description
- if license_type
- ob.license = License.find_by_unique_name(license_type)
- if ob.license.nil?
- ob.errors.add("License type")
- return rest_response(400, :object => ob)
+ if 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
@@ -1570,20 +1596,22 @@
when :text
if doc.find_first(query)
- enc = doc.find_first(query)['encoding']
- el = doc.find_first("#{query}/text()")
+ enc = doc.find_first(query)['encoding']
+ el = doc.find_first("#{query}")
+ text = doc.find_first("#{query}/text()")
if el
if enc == 'base64'
- return Base64::decode64(el.to_s)
+ return Base64::decode64(text.to_s)
else
- return el.to_s
+ return text.to_s
end
end
end
when :binary
- el = doc.find_first("#{query}/text()")
- return Base64::decode64(el.to_s) if el
+ el = doc.find_first("#{query}")
+ text = doc.find_first("#{query}/text()")
+ return Base64::decode64(text.to_s) if el
when :resource
return resolve_resource_node(doc.find_first(query))
end