Added a method to delete maps

also split the maps into diffrent pages. all map pages urls are now
prefixed with .../exceptionhandler/maps...

closes #18
This commit is contained in:
2012-04-29 17:10:47 -04:00
parent 483dd95295
commit cbb37e750b
6 changed files with 47 additions and 35 deletions

View File

@@ -25,10 +25,7 @@ class MapsController < ApplicationController
before_filter :require_user
def index
if session[:uploadSuccess]
flash.now[:notice] = "File has been uploaded successfully"
session[:uploadSuccess] = false
end
end
def uploadFile
@@ -36,5 +33,24 @@ class MapsController < ApplicationController
session[:uploadSuccess] = post
redirect_to(:back)
end
def deleteMap
map = Map.find_by_map(params[:map])
if map != nil
map.destroy
directory = "public/maps"
File.delete("#{RAILS_ROOT}/public/maps/#{params[:map]}")
flash.now[:notice] = "Map deleted successfully"
else
flash.now[:error] = "No Map Found"
end
end
def new
if session[:uploadSuccess]
flash.now[:notice] = "File has been uploaded successfully"
session[:uploadSuccess] = false
end
end
end #EOF

View File

@@ -62,8 +62,4 @@ class Map < ActiveRecord::Base
map.map = sha1.hexdigest
map.save
end
def getMap()
end
end

View File

@@ -0,0 +1,2 @@
<strong>exterminate!</strong>
<%= params[:map] %>

View File

@@ -1,29 +1,9 @@
<h1>Exception Handler Maps</h1>
<br/>
<%= form_tag ({:action => 'uploadFile'}, :multipart => true) %>
<label for="package">Package:</label>
<br/>
<input name="package" id="package" type="text" maxlength="5555500" size=50%/>
<br/>
<label for="package">Build:</label>
<br/>
<input name="build" id="build" type="text" maxlength="5555500" size=50%/>
<br/>
<%= form_tag ({:action => 'uploadFile'}, :multipart => true) %>
<p><label for="upload_file">Select File</label> :
<br/>
<%= file_field 'upload', 'datafile' %></p>
<%= submit_tag "Upload" %>
<br/>
<strong>Current Maps:</strong>
<% Map.all.each do |map| %>
<br/>
<br/>
<strong>Current Maps:</strong>
<% Map.all.each do |map| %>
<br/>
<%= map[:package] %> <%= map[:build] %>
<% end %>
<%= form_tag %>
<%= map[:package] %> <%= map[:build] %> <%= link_to "Delete", "maps/delete/#{map[:map]}" %>
<% end %>

View File

@@ -0,0 +1,16 @@
<h1>Exception Handler Map Uploader</h1>
<%= form_tag ({:action => 'uploadFile'}, :multipart => true) %>
<label for="package">Package:</label>
<br/>
<input name="package" id="package" type="text" maxlength="5555500" size=50%/>
<br/>
<label for="package">Build:</label>
<br/>
<input name="build" id="build" type="text" maxlength="5555500" size=50%/>
<br/>
<%= form_tag ({:action => 'uploadFile'}, :multipart => true) %>
<p><label for="upload_file">Select File</label> :
<br/>
<%= file_field 'upload', 'datafile' %></p>
<%= submit_tag "Upload" %>
<%= form_tag %>