Manage Uploaded Files
Allow alternate sort-orders (by filename, by date). Restrict to files in the given Web.
This commit is contained in:
parent
1d3f7007c6
commit
b74d298196
4 changed files with 28 additions and 14 deletions
|
@ -135,7 +135,7 @@ class AdminController < ApplicationController
|
|||
else
|
||||
flash[:error] = password_error(params['system_password'])
|
||||
end
|
||||
redirect_to :controller => 'wiki', :web => @web_name, :action => 'file_list'
|
||||
redirect_to :back
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -54,7 +54,16 @@ class WikiController < ApplicationController
|
|||
end
|
||||
|
||||
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
|
||||
|
||||
def export_html
|
||||
|
|
|
@ -47,8 +47,8 @@ class Web < ActiveRecord::Base
|
|||
WikiFile.find_by_file_name(file_name) != nil
|
||||
end
|
||||
|
||||
def file_list
|
||||
WikiFile.find(:all, :order => 'file_name')
|
||||
def file_list(sort_order = 'file_name')
|
||||
WikiFile.all(:order => sort_order, :conditions => ['web_id = ?', id])
|
||||
end
|
||||
|
||||
def description(file_name)
|
||||
|
|
|
@ -8,18 +8,23 @@
|
|||
Uploaded Files in <%= @web.name %>
|
||||
</h2>
|
||||
|
||||
<p>Check the files you wish to delete.</p>
|
||||
<ul style="list-style-type:none">
|
||||
<%- for @file in @web.file_list -%>
|
||||
<%- if @file_list.empty? -%>
|
||||
<p>No uploaded files in this Web</p>
|
||||
<%- 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>
|
||||
<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',
|
||||
:id => @file.file_name %>"><%= @file.file_name%></a>
|
||||
:id => file.file_name %>"><%= file.file_name%></a> (<%= file.created_at.asctime %>)
|
||||
</li>
|
||||
<%- end -%>
|
||||
</ul>
|
||||
<label for="system_password">Enter system password</label>
|
||||
<%= password_field_tag "system_password", '', :class => "disableAutoComplete" %>
|
||||
</ul>
|
||||
<label for="system_password">Enter system password</label>
|
||||
<%= password_field_tag "system_password", '', :class => "disableAutoComplete" %>
|
||||
and <%= submit_tag("Delete Files") %>
|
||||
<%- end -%>
|
||||
</div>
|
||||
<%- end %>
|
||||
<%- end -%>
|
Loading…
Reference in a new issue