Modified: branches/versions/app/models/workflow.rb (3062 => 3063)
--- branches/versions/app/models/workflow.rb 2012-07-31 14:47:00 UTC (rev 3062)
+++ branches/versions/app/models/workflow.rb 2012-07-31 14:47:48 UTC (rev 3063)
@@ -52,8 +52,7 @@
:attributes => [ :contributor, :title, :unique_name, :body, :body_html,
:content_blob_id, :file_ext, :last_edited_by,
- :content_type_id, :preview_id, :image, :svg,
- :revision_comments ],
+ :content_type_id, :preview_id, :image, :svg ],
:mutable => [ :contributor, :title, :unique_name, :body, :body_html,
:file_ext, :last_edited_by, :content_type_id, :image, :svg ]
Modified: branches/versions/app/views/blobs/_breadcrumbs.rhtml (3062 => 3063)
--- branches/versions/app/views/blobs/_breadcrumbs.rhtml 2012-07-31 14:47:00 UTC (rev 3062)
+++ branches/versions/app/views/blobs/_breadcrumbs.rhtml 2012-07-31 14:47:48 UTC (rev 3063)
@@ -1,6 +1,6 @@
<li><%= link_to 'Files', blobs_path -%></li>
-<% if ["show", "new", "edit", "all", "search"].include? controller.action_name.to_s -%>
+<% if ["show", "new", "edit", "all", "search", "suggestions"].include? controller.action_name.to_s -%>
<li>></li>
<% case controller.action_name.to_s; when "show" -%>
@@ -15,6 +15,10 @@
<li>All Files</li>
<% when "search" %>
<li>Search Results</li>
+ <% when "suggestions" %>
+ <li><%= link_to "#{contributable_name(@blob.id, 'Blob')}", blob_path(@blob) -%></li>
+ <li>></li>
+ <li>Suggestions</li>
<% else %>
<!-- no breadcrumb -->
<% end %>
Modified: branches/versions/lib/rest.rb (3062 => 3063)
--- branches/versions/lib/rest.rb 2012-07-31 14:47:00 UTC (rev 3062)
+++ branches/versions/lib/rest.rb 2012-07-31 14:47:48 UTC (rev 3063)
@@ -684,7 +684,7 @@
when 'Attribution'; return nil
when 'Tagging'; return nil
- when 'Workflow::Version'; return "#{rest_resource_uri(ob.workflow)}?version=#{ob.version}"
+ when 'WorkflowVersion'; return "#{rest_resource_uri(ob.workflow)}?version=#{ob.version}"
end
raise "Class not processed in rest_resource_uri: #{ob.class.to_s}"
@@ -728,7 +728,7 @@
when 'Creditation'; return "#{base}/credit.xml?id=#{ob.id}"
when 'Attribution'; return nil
- when 'Workflow::Version'; return "#{base}/workflow.xml?id=#{ob.workflow.id}&version=#{ob.version}"
+ when 'WorkflowVersion'; return "#{base}/workflow.xml?id=#{ob.workflow.id}&version=#{ob.version}"
end
raise "Class not processed in rest_access_uri: #{ob.class.to_s}"
@@ -752,7 +752,7 @@
when 'Download'; return 'download'
when 'PackContributableEntry'; return rest_object_tag_text(ob.contributable)
when 'PackRemoteEntry'; return 'external'
- when 'Workflow::Version'; return 'workflow'
+ when 'WorkflowVersion'; return 'workflow'
when 'Comment'; return 'comment'
when 'Bookmark'; return 'favourite'
when 'ContentType'; return 'type'
@@ -784,7 +784,7 @@
when 'Download'; return ''
when 'PackContributableEntry'; return rest_object_label_text(ob.contributable)
when 'PackRemoteEntry'; return ob.title
- when 'Workflow::Version'; return ob.title
+ when 'WorkflowVersion'; return ob.title
when 'ContentType'; return ob.title
when 'License'; return ob.title
when 'CurationEvent'; return ob.category
@@ -1140,7 +1140,11 @@
case action
when 'create':
return rest_response(401, :reason => "Not authorised to create a file") unless Authorization.is_authorized_for_type?('create', 'Blob', opts[:user], nil)
- ob = Blob.new(:contributor => opts[:user])
+ if opts[:query]['id']
+ ob, error = obtain_rest_resource('Blob', opts[:query]['id'], opts[:query]['version'], opts[:user], action)
+ else
+ ob = Blob.new(:contributor => opts[:user])
+ end
when 'read', 'update', 'destroy':
ob, error = obtain_rest_resource('Blob', opts[:query]['id'], opts[:query]['version'], opts[:user], action)
else
@@ -1151,18 +1155,21 @@
if action == "destroy"
+ return rest_response(400, :reason => "Cannot delete individual versions") if opts[:query]['version']
+
ob.destroy
else
data = ""
- title = parse_element(data, :text, '/file/title')
- description = parse_element(data, :text, '/file/description')
- license_type = parse_element(data, :text, '/file/license-type')
- type = parse_element(data, :text, '/file/type')
- content_type = parse_element(data, :text, '/file/content-type')
- content = parse_element(data, :binary, '/file/content')
+ title = parse_element(data, :text, '/file/title')
+ description = parse_element(data, :text, '/file/description')
+ license_type = parse_element(data, :text, '/file/license-type')
+ type = parse_element(data, :text, '/file/type')
+ content_type = parse_element(data, :text, '/file/content-type')
+ content = parse_element(data, :binary, '/file/content')
+ revision_comment = parse_element(data, :text, '/workflow/revision-comment')
permissions = data.find_first('/file/permissions')
@@ -1214,18 +1221,29 @@
ob.content_blob = ContentBlob.new(:data ="" content) if content
- if not ob.save
- return rest_response(400, :object => ob)
+ new_version = action == 'create' && opts[:query][:id]
+
+ if new_version
+ ob[:revision_comments] = revision_comment
end
- if ob.contribution.policy.nil?
- ob.contribution.policy = create_default_policy(opts[:user])
- ob.contribution.save
+ success = ob.save
+
+ return rest_response(400, :object => ob) unless success
+
+ if opts[:query]['version'].nil?
+
+ if ob.contribution.policy.nil?
+ ob.contribution.policy = create_default_policy(opts[:user])
+ ob.contribution.save
+ end
+
+ update_permissions(ob, permissions)
end
-
- update_permissions(ob, permissions)
end
+ ob = ob.versioned_resource if ob.respond_to?("versioned_resource")
+
rest_get_request(ob, opts[:user], { "id" => ob.id.to_s })
end
@@ -2239,10 +2257,10 @@
# Call dispatcher
def rest_call_request(opts)
- begin
+# begin
send(opts[:rules]['Function'], opts)
- rescue
- return rest_response(500)
- end
+# rescue
+# return rest_response(500)
+# end
end