Modified: branches/versions/app/controllers/blobs_controller.rb (3056 => 3057)
--- branches/versions/app/controllers/blobs_controller.rb 2012-07-30 15:29:06 UTC (rev 3056)
+++ branches/versions/app/controllers/blobs_controller.rb 2012-07-31 10:28:25 UTC (rev 3057)
@@ -14,7 +14,7 @@
before_filter :initiliase_empty_objects_for_new_pages, : [:new, :create]
before_filter :set_sharing_mode_variables, : [:show, :new, :create, :edit, :update]
- before_filter :check_is_owner, : [:edit, :update]
+ before_filter :check_is_owner, : [:edit, :update, :suggestions, :process_suggestions]
# declare sweepers and which actions should invoke them
cache_sweeper :blob_sweeper, : [ :create, :update, :destroy ]
@@ -212,8 +212,21 @@
update_layout(@blob, params[:layout])
if policy_err_msg.blank?
- flash[:notice] = 'File was successfully updated.'
- format.html { redirect_to blob_url(@blob) }
+ format.html {
+
+ if @blob.new_version_number
+ @version = @blob.find_version(@blob.new_version_number)
+ else
+ @version.reload
+ end
+
+ if @version.suggestions?
+ redirect_to(blob_version_suggestions_path(@blob, @version.version))
+ else
+ flash[:notice] = 'File was successfully updated.'
+ redirect_to blob_url(@blob)
+ end
+ }
else
flash[:error] = policy_err_msg
format.html { redirect_to :controller => 'blobs', :id => @blob, :action ="" "edit" }
@@ -302,6 +315,30 @@
end
end
+ # GET /files/1/versions/1/suggestions
+ def suggestions
+ @suggestions = @version.suggestions
+ end
+
+ # POST /files/1/versions/1/process_suggestions
+ def process_suggestions
+
+ @version.revision_comments = params[:revision_comments]
+
+ success = @version.save
+
+ respond_to do |format|
+ format.html {
+ if success
+ flash[:notice] = 'File was successfully updated.'
+ redirect_to blob_version_path(@blob, @version.version)
+ else
+ render :action ="" "suggestions"
+ end
+ }
+ end
+ end
+
protected
def find_blob_auth
Modified: branches/versions/config/routes.rb (3056 => 3057)
--- branches/versions/config/routes.rb 2012-07-30 15:29:06 UTC (rev 3056)
+++ branches/versions/config/routes.rb 2012-07-31 10:28:25 UTC (rev 3057)
@@ -136,6 +136,9 @@
map.blob_version '/files/:id/versions/:version', :conditions => { :method => :get }, :controller => 'blobs', :action ="" 'show'
map.formatted_blob_version '/files/:id/versions/:version.:format', :conditions => { :method => :get }, :controller => 'blobs', :action ="" 'show'
+ map.blob_version_suggestions '/files/:id/versions/:version/suggestions', :conditions => { :method => :get }, :controller => 'blobs', :action ="" 'suggestions'
+ map.blob_version_process_suggestions '/files/:id/versions/:version/process_suggestions', :conditions => { :method => :post }, :controller => 'blobs', :action ="" 'process_suggestions'
+
# versioned preview images
['workflow'].each do |x|
@@ -167,6 +170,8 @@
:favourite => :post,
:favourite_delete => :delete,
:rate => :post,
+ :suggestions => :get,
+ :process_suggestions => :post,
:tag => :post } do |blob|
# Due to restrictions in the version of Rails used (v1.2.3),
# we cannot have reviews as nested resources in more than one top level resource.
Modified: branches/versions/lib/authorization.rb (3056 => 3057)
--- branches/versions/lib/authorization.rb 2012-07-30 15:29:06 UTC (rev 3056)
+++ branches/versions/lib/authorization.rb 2012-07-31 10:28:25 UTC (rev 3057)
@@ -602,9 +602,9 @@
def Authorization.categorize_action(action_name)
case action_name
- when 'show', 'index', 'view', 'search', 'favourite', 'favourite_delete', 'comment', 'comment_delete', 'comments', 'comments_timeline', 'rate', 'tag', 'items', 'statistics', 'curation', 'tag_suggestions', 'extra_metadata', 'read', 'verify'
+ when 'show', 'index', 'view', 'search', 'favourite', 'favourite_delete', 'comment', 'comment_delete', 'comments', 'comments_timeline', 'rate', 'tag', 'items', 'statistics', 'curation', 'suggestions', 'tag_suggestions', 'extra_metadata', 'read', 'verify'
action = ''
- when 'edit', 'new', 'create', 'update', 'new_version', 'create_version', 'destroy_version', 'edit_version', 'update_version', 'new_item', 'create_item', 'edit_item', 'update_item', 'quick_add', 'resolve_link', 'process_tag_suggestions', 'process_extra_metadata', 'edit_relationships'
+ when 'edit', 'new', 'create', 'update', 'new_version', 'create_version', 'destroy_version', 'edit_version', 'update_version', 'new_item', 'create_item', 'edit_item', 'update_item', 'quick_add', 'resolve_link', 'process_suggestions', 'process_tag_suggestions', 'process_extra_metadata', 'edit_relationships'
action = ''
when 'download', 'named_download', 'named_download_with_version', 'launch', 'submit_job', 'save_inputs', 'refresh_status', 'rerun', 'refresh_outputs', 'render_output', 'outputs_xml', 'outputs_package', 'galaxy_tool', 'galaxy_tool_download'
action = ''
Modified: branches/versions/vendor/plugins/versioning/lib/versioning.rb (3056 => 3057)
--- branches/versions/vendor/plugins/versioning/lib/versioning.rb 2012-07-30 15:29:06 UTC (rev 3056)
+++ branches/versions/vendor/plugins/versioning/lib/versioning.rb 2012-07-31 10:28:25 UTC (rev 3057)
@@ -12,6 +12,7 @@
cattr_accessor :version_class, :versioned_attributes, :mutable_attributes, :versioned_resource_column
attr_accessor :inhibit_version_check
+ attr_accessor :new_version_number
self.version_class = version_class.to_s.camelize.singularize.constantize
self.versioned_attributes = opts[:attributes] || []
@@ -62,9 +63,12 @@
resource.current_version = resource.current_version ? resource.current_version + 1 : 1
new_version[:version] = resource.current_version
+ resource.new_version_number = resource.current_version
resource.versioned_attributes.each do |attr|
- new_version.send("#{attr}=", resource.send(attr))
+ if new_version.respond_to?("#{attr}=") && resource.respond_to?(attr)
+ new_version.send("#{attr}=", resource.send(attr))
+ end
end
resource.versions << new_version
@@ -132,7 +136,9 @@
if version.version == versioned_resource.current_version
versioned_resource.versioned_attributes.each do |attr|
- versioned_resource[attr] = version[attr]
+ if versioned_resource.respond_to?("#{attr}=") && version.respond_to?(attr)
+ versioned_resource.send("#{attr}=", version.send(attr))
+ end
end
versioned_resource.inhibit_version_check = true