myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [2298] trunk: removed old bulk upload code


From: noreply
Subject: [myexperiment-hackers] [2298] trunk: removed old bulk upload code
Date: Mon, 23 Nov 2009 11:26:17 -0500 (EST)

Revision
2298
Author
dgc
Date
2009-11-23 11:26:17 -0500 (Mon, 23 Nov 2009)

Log Message

removed old bulk upload code

Modified Paths

Removed Paths

Diff

Modified: trunk/app/controllers/workflows_controller.rb (2297 => 2298)


--- trunk/app/controllers/workflows_controller.rb	2009-11-23 16:16:25 UTC (rev 2297)
+++ trunk/app/controllers/workflows_controller.rb	2009-11-23 16:26:17 UTC (rev 2298)
@@ -3,17 +3,15 @@
 # Copyright (c) 2007 University of Manchester and the University of Southampton.
 # See license.txt for details.
 
-require 'zip/zip'
-
 class WorkflowsController < ApplicationController
   before_filter :login_required, :except => [:index, :show, :download, :named_download, :statistics, :launch, :search, :all]
   
   before_filter :find_workflows, : [:all]
   before_filter :find_workflows_rss, : [:index]
-  before_filter :find_workflow_auth, :except => [:search, :index, :new, :create, :all, :bulk_upload, :bulk_create, :bulk_summary]
+  before_filter :find_workflow_auth, :except => [:search, :index, :new, :create, :all]
   
-  before_filter :initiliase_empty_objects_for_new_pages, : [:new, :create, :new_version, :create_version, :bulk_upload]
-  before_filter :set_sharing_mode_variables, : [:show, :new, :create, :edit, :update, :bulk_upload]
+  before_filter :initiliase_empty_objects_for_new_pages, : [:new, :create, :new_version, :create_version]
+  before_filter :set_sharing_mode_variables, : [:show, :new, :create, :edit, :update]
   
   before_filter :check_file_size, : [:create, :create_version]
   before_filter :check_custom_workflow_type, : [:create, :create_version]
@@ -21,11 +19,11 @@
   before_filter :check_is_owner, : [:edit, :update]
   
   # declare sweepers and which actions should invoke them
-  cache_sweeper :workflow_sweeper, : [ :create, :bulk_create, :create_version, :launch, :update, :update_version, :destroy_version, :destroy ]
+  cache_sweeper :workflow_sweeper, : [ :create, :create_version, :launch, :update, :update_version, :destroy_version, :destroy ]
   cache_sweeper :download_viewing_sweeper, : [ :show, :download, :named_download, :launch ]
-  cache_sweeper :permission_sweeper, : [ :create, :bulk_create, :update, :destroy ]
+  cache_sweeper :permission_sweeper, : [ :create, :update, :destroy ]
   cache_sweeper :bookmark_sweeper, : [ :destroy, :favourite, :favourite_delete ]
-  cache_sweeper :tag_sweeper, : [ :create, :bulk_create, :update, :tag, :destroy ]
+  cache_sweeper :tag_sweeper, : [ :create, :update, :tag, :destroy ]
   cache_sweeper :comment_sweeper, : [ :comment, :comment_delete ]
   cache_sweeper :rating_sweeper, : [ :rate ]
   
@@ -246,14 +244,6 @@
   def new
   end
 
-  # GET /workflows/bulk_upload
-  def bulk_upload
-  end
-
-  # GET /workflows/bulk_summary
-  def bulk_summary
-  end
-
   # GET /workflows/1/new_version
   def new_version
   end
@@ -438,93 +428,6 @@
    	
   end
 
-  # POST /workflows/bulk_create
-
-  def bulk_create
-
-    def aux(file)
-      
-      @workflow = Workflow.new
-      @workflow.contributor = current_user
-      @workflow.last_edited_by = current_user.id
-      @workflow.license_id = params[:workflow][:license_id]
-      @workflow.content_blob = ContentBlob.new(:data ="" file.read)
-      @workflow.file_ext = file.original_filename.split(".").last.downcase
-      
-      # Check that the file uploaded is recognised and can be parsed...
-      
-      if infer_metadata(@workflow, file) == false
-        flash.now[:error] = "Couldn't recognise a workflow during bulk"
-          " upload.  Currently, only workflows that can be automatically"
-          " recognised can be bulk uploaded."
-        return false
-      end
-        
-      return false unless @workflow.save
-
-      if params[:workflow][:tag_list]
-        @workflow.refresh_tags(convert_tags_to_gem_format(params[:workflow][:tag_list]), current_user)
-      end
-      
-      update_policy(@workflow, params)
-      update_credits(@workflow, params)
-      update_attributions(@workflow, params)
-
-      @titles.push(@workflow.title)
-      
-      return true
-    end
-
-    # Unpack multiple workflows from the zip file
-
-    @results         = []
-    @titles          = []
-    @failures        = []
-    @overall_success = true
-
-    file = params[:workflow][:file]
-
-    Tempfile.open("bulk", "tmp") { |zip_file|
-
-      zip_file.write(file.read)
-      zip_file.open
-
-      begin
-        Workflow.transaction do
-
-          Zip::ZipFile.foreach(zip_file.path) { |entry|
-            if entry.file?
-              stream = entry.get_input_stream
-              stream.extend FileUpload
-              stream.original_filename = entry.name
-
-              if aux(stream) == false
-                @overall_success = false
-                @results.push([entry.name, false])
-              else
-                @results.push([entry.name, true])
-              end
-
-            end
-          }
-
-         raise BulkUploadError unless @overall_success
-
-        end
-      rescue BulkUploadError
-        # Here so that the transaction will rollback upon failure
-      end
-    }
-
-    if @overall_success
-      flash[:notice] = "Bulk upload successful."
-    else
-      flash[:error] = "Failed to process all entries."
-    end
-
-    render(:action ="" :bulk_summary)
-  end
-
   # PUT /workflows/1
   def update
     # remove protected columns
@@ -769,7 +672,7 @@
   end
   
   def initiliase_empty_objects_for_new_pages
-    if ["new", "create", "bulk_upload"].include?(action_name)
+    if ["new", "create"].include?(action_name)
       @workflow = Workflow.new
     end
     
@@ -799,7 +702,7 @@
   
   def set_sharing_mode_variables
     case action_name
-      when "new", "bulk_upload"
+      when "new"
         @sharing_mode  = 0
         @updating_mode = 6
       when "create", "update"

Deleted: trunk/app/views/workflows/bulk_summary.rhtml (2297 => 2298)


--- trunk/app/views/workflows/bulk_summary.rhtml	2009-11-23 16:16:25 UTC (rev 2297)
+++ trunk/app/views/workflows/bulk_summary.rhtml	2009-11-23 16:26:17 UTC (rev 2298)
@@ -1,57 +0,0 @@
-<% t "Bulk upload" -%>
-
-<center><%= error_messages_for :workflow -%></center>
-
-<h1>Bulk upload summary</h1>
-
-<div class="clearer">&nbsp;</div>
-
-<center>
-  <table class="simple">
-    <tr><th>Entry</th><th>Status</th></tr>
-    <% @results.each do |result| %>
-      <tr>
-        <td><%= result[0] %></td>
-        <% if result[1] %>
-          <td><img src="" /></td>
-        <% else %>
-          <td><img src="" /></td>
-        <% end %>
-      </tr>
-    <% end %>
-  </table>
-</center>
-
-<div class="clearer">&nbsp;</div>
-<div class="clearer">&nbsp;</div>
-
-<% if @overall_success %>
-  <center>
-    <ul class="sectionIcons">
-      <li style="margin-left: 0;">
-        <%= icon 'new',
-          "/workflows/bulk_upload",
-          "Bulk upload",
-          nil,
-          "Upload more" -%>
-      </li>
-      <li style="margin-left: 0;">
-        <%= icon 'home',
-          "/home",
-          "Return to the home page",
-          nil,
-          "Finished" -%>
-      </li>
-    </ul>
-  </center>
-
-<% else %>
-  <div class="box_infotext">
-    <p>
-      Nothing was uploaded to <%= Conf.sitename %>.  To try the bulk upload
-      again, use your browser's back button to return to the bulk upload page
-      and select to new Zip file.
-    </p>
-  </div>
-<% end %>
-

Deleted: trunk/app/views/workflows/bulk_upload.rhtml (2297 => 2298)


--- trunk/app/views/workflows/bulk_upload.rhtml	2009-11-23 16:16:25 UTC (rev 2297)
+++ trunk/app/views/workflows/bulk_upload.rhtml	2009-11-23 16:26:17 UTC (rev 2298)
@@ -1,68 +0,0 @@
-<% t "Bulk upload" -%>
-
-<%= _javascript__include_tag :fckeditor %>
-<%= _javascript__include_tag "osp.js" %>
-
-<h1>Bulk upload</h1>
-
-<center>
-	<%= error_messages_for :workflow %>
-</center>
-
-<% form_tag({:action ="" :bulk_create}, :multipart => true) do %>
-
-  <!-- Workflow File -->
-	
-	<p class="step_text">1. Zip file containing Workflow files/scripts</p>
-
-  <div class="box_infotext">
-    <p>Select a Zip file containing multiple Workflow files.  Note that
-    <%= Conf.sitename %> must be able to automatically recognise and extract
-    metadata from your Workflows to use this feature.</p>
-  </div>
-
-  <br />
-  <br />
-
-  <center>
-    <%= render :partial => 'workflow_file_selection_form' %>
-  </center>
-
-  <br />
-	
-	<!-- Other metadata and settings -->
-	
-	<p class="step_text" style="text-align: center;">2. Other metadata and settings</p>
-	
-	<!-- Tags -->
-  <%= render :partial => "tags/tags_form", :locals => { :edit => false, :taggable => @workflow } -%>
-                
-  <!-- Credit and Attribution -->
-  <%= render :partial => "contributions/credit_attribution_form", :locals => { :edit => false, :contributable => @workflow } -%>
-                
-  <!-- Sharing -->              
-  <%= render :partial => "contributions/sharing_form", :locals => { :edit => false, :contributable => @workflow, :update_perms => true } -%>
-                
-  <!-- License/Rights -->
-  <%= render :partial => "workflows/license_form", :locals => { :edit => false } -%>
-  
-	
-	<!-- Terms and conditions -->
-	
-	<p class="step_text">3. Terms and conditions</p>
-	
-  <%= render :partial => 'contributions/terms_and_conditions' %>
-	
-	<br/>
-
-	<!-- Upload and save -->
-	
-	<p class="step_text">4. Upload and save</p>
-
-  <p style="text-align: center;">
-    <%= submit_tag "Upload and Save", :disable_with => "Uploading and saving..." %>
-  </p>
-  
-<% end %>
-
-

Modified: trunk/app/views/workflows/index.rhtml (2297 => 2298)


--- trunk/app/views/workflows/index.rhtml	2009-11-23 16:16:25 UTC (rev 2297)
+++ trunk/app/views/workflows/index.rhtml	2009-11-23 16:26:17 UTC (rev 2298)
@@ -7,7 +7,6 @@
 
 <ul class="sectionIcons">
 	<li><%= icon "workflow", new_workflow_path, nil, nil, "Upload New Workflow" %></li>
-	<li><%= icon "workflow", bulk_upload_workflows_path, nil, nil, "Bulk Upload" %></li>
 	<li><%= icon "view-all", all_workflows_path, nil, nil, "View All Workflows" %></li>
 </ul>
 

Modified: trunk/app/views/workflows/new.rhtml (2297 => 2298)


--- trunk/app/views/workflows/new.rhtml	2009-11-23 16:16:25 UTC (rev 2297)
+++ trunk/app/views/workflows/new.rhtml	2009-11-23 16:26:17 UTC (rev 2298)
@@ -3,14 +3,6 @@
 <%= _javascript__include_tag :fckeditor %>
 <%= _javascript__include_tag "osp.js" %>
 
-<div class="box_standout" style="margin: 1.5em 3em; padding: 0.7em 1.5em;">
-	<p>
-    Do you have many Workflows to upload?  Use the <a
-    href="" upload</a> page to upload multiple
-    Workflows at the same time.
-  </p>
-</div>
-
 <h1>Upload Workflow</h1>
 
 <center>

Modified: trunk/config/routes.rb (2297 => 2298)


--- trunk/config/routes.rb	2009-11-23 16:16:25 UTC (rev 2297)
+++ trunk/config/routes.rb	2009-11-23 16:26:17 UTC (rev 2298)
@@ -62,11 +62,7 @@
 
   # workflows (downloadable)
   map.resources :workflows, 
-    :collection => { :all => :get,
-                     :search => :get,
-                     :bulk_upload => :get,
-                     :bulk_create => :post,
-                     :bulk_summary => :get }, 
+    :collection => { :all => :get, :search => :get }, 
     :member => { :new_version => :get, 
                  :download => :get, 
                  :launch => :get,

Deleted: trunk/lib/bulk_upload_error.rb (2297 => 2298)


--- trunk/lib/bulk_upload_error.rb	2009-11-23 16:16:25 UTC (rev 2297)
+++ trunk/lib/bulk_upload_error.rb	2009-11-23 16:26:17 UTC (rev 2298)
@@ -1,8 +0,0 @@
-# myExperiment: lib/bulk_upload_error.rb
-# 
-# Copyright (c) 2009 University of Manchester and the University of Southampton.
-# See license.txt for details.
-
-class BulkUploadError < StandardError
-end
-

reply via email to

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