myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [3379] branches/wf4ever: added "upload new versio


From: noreply
Subject: [myexperiment-hackers] [3379] branches/wf4ever: added "upload new version" button for pack resources
Date: Wed, 30 Jan 2013 05:55:06 +0000 (UTC)

Revision
3379
Author
dgc
Date
2013-01-30 05:55:06 +0000 (Wed, 30 Jan 2013)

Log Message

added "upload new version" button for pack resources

Modified Paths

Diff

Modified: branches/wf4ever/app/controllers/packs_controller.rb (3378 => 3379)


--- branches/wf4ever/app/controllers/packs_controller.rb	2013-01-30 05:50:45 UTC (rev 3378)
+++ branches/wf4ever/app/controllers/packs_controller.rb	2013-01-30 05:55:06 UTC (rev 3379)
@@ -202,6 +202,50 @@
     
   end
 
+  def reupload_resource
+  end
+
+  def recreate_resource
+
+    session = ROSRS::Session.new(@pack.ro_uri, Conf.rodl_bearer_token)
+
+    # FIXME: There needs to be a check here to ensure that the resource path
+    # cannot be used to change another RO owned by the same user.  This is
+    # significant because you can share edit rights to specific workflows to
+    # other myexperiment users.
+
+    session.delete_resource(@pack.ro_uri + params[:resource_path])
+
+    if params[:file]
+
+      filename = File.basename(params[:file].original_filename)
+      ## FIXME: Content type should not always be text/plain!
+      c, r, puri, ruri = session.aggregate_internal_resource(@pack.ro_uri, filename, { :body => params[:file].read, :ctype=> 'text/plain' })
+      post_process_created_resource(session, ruri, params[:type])        
+
+    elsif params[:uri] and not params[:uri].empty?
+
+      c, r, puri, ruri = session.aggregate_external_resource(@pack.ro_uri, params[:uri])
+      post_process_created_resource(session, ruri, params[:type])
+
+    else
+
+      ## TODO: prettify error message, but don't use the broken error() function
+      # as it is not following HTTP standard error codes
+      return render :text => "Adding an item failed, either a URL or a file must be provided", :status => :bad_request
+    end
+    
+    respond_to do |format|
+      format.html {
+        redirect_to pack_url(@pack)
+      }    
+    end
+
+    # TODO: Since we are replacing a resource, we should update existing
+    # relationships to point towards the new resource.
+    
+  end
+
   def edit_resource_annotations
     @resource_uri = @pack.resolve_resource_uri(params[:resource_path])
     # FIXME: @annotations is really @annotations_graphs ()
@@ -591,7 +635,9 @@
       "new"                => "create",
       "new_item"           => "edit",
       "quick_add"          => "edit",
+      "recreate_resource"  => "edit",
       "resolve_link"       => "edit",
+      "reupload_resource"  => "edit",
       "search"             => "view",
       "show"               => "view",
       "wfrun"              => "view",

Modified: branches/wf4ever/app/views/packs/_breadcrumbs.rhtml (3378 => 3379)


--- branches/wf4ever/app/views/packs/_breadcrumbs.rhtml	2013-01-30 05:50:45 UTC (rev 3378)
+++ branches/wf4ever/app/views/packs/_breadcrumbs.rhtml	2013-01-30 05:55:06 UTC (rev 3379)
@@ -25,6 +25,10 @@
 <% when "resource_show" %>
   <li><%= link_to "#{h(title)}", pack_path(@pack) %></li>
   <li><%=h @manifest_name -%></li>
+<% when "reupload_resource" %>
+  <li><%= link_to "#{h(title)}", pack_path(@pack) %></li>
+  <li><%= link_to h(@manifest_name), pack_resource_path(@pack, params[:resource_path]) -%></li>
+  <li>Upload new version</li>
 <% when "edit_resource_annotations" %>
   <li><%= link_to "#{h(title)}", pack_path(@pack) %></li>
   <li><%= link_to h(@manifest_name), pack_resource_path(@pack, params[:resource_path]) -%></li>

Modified: branches/wf4ever/app/views/packs/resource_show.rhtml (3378 => 3379)


--- branches/wf4ever/app/views/packs/resource_show.rhtml	2013-01-30 05:50:45 UTC (rev 3378)
+++ branches/wf4ever/app/views/packs/resource_show.rhtml	2013-01-30 05:55:06 UTC (rev 3379)
@@ -12,7 +12,8 @@
   <ul class="sectionIcons" style="margin-top: 0.7em; margin-bottom: 0.6em;">
     <% if Authorization.check("edit", @pack, current_user) %>
       <% if @pack.ro_uri %>
-        <li style="margin-left: 0;"><%= icon('edit', pack_resource_edit_path(@pack, params[:resource_path]), nil, nil, "Edit Annotations") %></li>
+        <li><%= icon('edit', pack_resource_edit_path(@pack, params[:resource_path]), nil, nil, "Edit Annotations") %></li>
+        <li><%= icon('new', pack_resource_reupload_path(@pack, params[:resource_path]), nil, nil, "Upload New Version") %></li>
       <% end %>
     <% end %>
   </ul>

Modified: branches/wf4ever/config/routes.rb (3378 => 3379)


--- branches/wf4ever/config/routes.rb	2013-01-30 05:50:45 UTC (rev 3378)
+++ branches/wf4ever/config/routes.rb	2013-01-30 05:55:06 UTC (rev 3379)
@@ -113,7 +113,11 @@
   map.pack_resource_edit  '/packs/:id/resources/:resource_path;edit', :controller => 'packs', :action ="" 'edit_resource_annotations',  :conditions => { :method => :get }, :requirements => { :resource_path => /[^;]+/ }
 
   map.pack_resource_update  '/packs/:id/resources/:resource_path;update', :controller => 'packs', :action ="" 'update_resource_annotations',  :conditions => { :method => :post }, :requirements => { :resource_path => /[^;]+/ }
+  map.pack_resource_delete  '/packs/:id/resources/:resource_path', :controller => 'packs', :action ="" 'destroy_resource',  :conditions => { :method => :delete }, :requirements => { :resource_path => /[^;]+/ }
 
+  map.pack_resource_reupload  '/packs/:id/resources/:resource_path;new_version', :controller => 'packs', :action ="" 'reupload_resource',  :conditions => { :method => :get }, :requirements => { :resource_path => /[^;]+/ }
+  map.pack_resource_recreate  '/packs/:id/resources/:resource_path;recreate', :controller => 'packs', :action ="" 'recreate_resource',  :conditions => { :method => :post }, :requirements => { :resource_path => /[^;]+/ }
+
   map.pack_wfrun  '/packs/:id/wfrun/:resource_path', :controller => 'packs', :action ="" 'wfrun', :conditions => { :method => :get }, :requirements => { :resource_path => /[^;]+/ }
 
   

reply via email to

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