Manage Uploaded Files

Allow alternate sort-orders (by filename, by date).
Restrict to files in the given Web.
This commit is contained in:
Jacques Distler 2008-12-31 11:30:33 -06:00
parent 1d3f7007c6
commit b74d298196
4 changed files with 28 additions and 14 deletions

View file

@ -135,7 +135,7 @@ class AdminController < ApplicationController
else else
flash[:error] = password_error(params['system_password']) flash[:error] = password_error(params['system_password'])
end end
redirect_to :controller => 'wiki', :web => @web_name, :action => 'file_list' redirect_to :back
end end
private private

View file

@ -54,7 +54,16 @@ class WikiController < ApplicationController
end end
def file_list def file_list
@web.file_list sort_order = params['sort_order'] || 'file_name'
case sort_order
when 'file_name'
@alt_sort_order = 'created_at'
@alt_sort_name = 'date'
else
@alt_sort_order = 'file_name'
@alt_sort_name = 'filename'
end
@file_list = @web.file_list(sort_order)
end end
def export_html def export_html

View file

@ -47,8 +47,8 @@ class Web < ActiveRecord::Base
WikiFile.find_by_file_name(file_name) != nil WikiFile.find_by_file_name(file_name) != nil
end end
def file_list def file_list(sort_order = 'file_name')
WikiFile.find(:all, :order => 'file_name') WikiFile.all(:order => sort_order, :conditions => ['web_id = ?', id])
end end
def description(file_name) def description(file_name)

View file

@ -8,18 +8,23 @@
Uploaded Files in <%= @web.name %> Uploaded Files in <%= @web.name %>
</h2> </h2>
<p>Check the files you wish to delete.</p> <%- if @file_list.empty? -%>
<ul style="list-style-type:none"> <p>No uploaded files in this Web</p>
<%- for @file in @web.file_list -%> <%- else -%>
<p>Check the files you wish to delete (<%= link_to "sort by #{@alt_sort_name}", :controller => 'wiki',
:web => @web.address, :action => 'file_list', :sort_order => @alt_sort_order %>).</p>
<ul style="list-style-type:none">
<%- for file in @file_list -%>
<li> <li>
<input type="checkbox" name="<%= @file.file_name %>" value="delete"/> <input type="checkbox" name="<%= file.file_name %>" value="delete"/>
<a href="<%= url_for :web => @web.address, :action => 'file', <a href="<%= url_for :web => @web.address, :action => 'file',
:id => @file.file_name %>"><%= @file.file_name%></a> :id => file.file_name %>"><%= file.file_name%></a> (<%= file.created_at.asctime %>)
</li> </li>
<%- end -%> <%- end -%>
</ul> </ul>
<label for="system_password">Enter system password</label> <label for="system_password">Enter system password</label>
<%= password_field_tag "system_password", '', :class => "disableAutoComplete" %> <%= password_field_tag "system_password", '', :class => "disableAutoComplete" %>
and <%= submit_tag("Delete Files") %> and <%= submit_tag("Delete Files") %>
<%- end -%>
</div> </div>
<%- end %> <%- end -%>