diff options
Diffstat (limited to 'app')
36 files changed, 1299 insertions, 816 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index df89a372c..0520a8c77 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -113,5 +113,19 @@ module ApplicationHelper end end + def admin_value(v) + if v.nil? + nil + elsif v.instance_of?(Time) + admin_date(v) + else + h(v) + end + end + + def admin_date(date) + "#{I18n.l(date, :format => "%e %B %Y %H:%M:%S")} (#{_('{{length_of_time}} ago', :length_of_time => time_ago_in_words(date))})" + end + end diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb index 914b4dc12..f621721b6 100755 --- a/app/helpers/link_to_helper.rb +++ b/app/helpers/link_to_helper.rb @@ -17,14 +17,18 @@ module LinkToHelper return show_request_url(params.merge(extra_params)) end - def request_link(info_request) - link_to h(info_request.title), request_url(info_request) + def request_link(info_request, cls=nil ) + link_to h(info_request.title), request_url(info_request), :class => cls end def request_admin_url(info_request) return admin_url('request/show/' + info_request.id.to_s) end + def request_admin_link(info_request, name="admin", cls=nil) + link_to name, request_admin_url(info_request), :class => cls + end + def request_both_links(info_request) link_to(h(info_request.title), main_url(request_url(info_request))) + " (" + link_to("admin", request_admin_url(info_request)) + ")" end @@ -66,8 +70,8 @@ module LinkToHelper def public_body_link_short(public_body) link_to h(public_body.short_or_long_name), public_body_url(public_body) end - def public_body_link(public_body) - link_to h(public_body.name), public_body_url(public_body) + def public_body_link(public_body, cls=nil) + link_to h(public_body.name), public_body_url(public_body), :class => cls end def public_body_link_absolute(public_body) # e.g. for in RSS link_to h(public_body.name), main_url(public_body_url(public_body)) @@ -86,8 +90,8 @@ module LinkToHelper def user_url(user) return show_user_url(:url_name => user.url_name, :only_path => true) end - def user_link(user) - link_to h(user.name), user_url(user) + def user_link(user, cls=nil) + link_to h(user.name), user_url(user), :class => cls end def user_link_absolute(user) link_to h(user.name), main_url(user_url(user)) @@ -112,6 +116,9 @@ module LinkToHelper def user_admin_url(user) return admin_url('user/show/' + user.id.to_s) end + def user_admin_link(user, name="admin", cls=nil) + link_to name, user_admin_url(user), :class => cls + end def user_both_links(user) link_to(h(user.name), main_url(user_url(user))) + " (" + link_to("admin", user_admin_url(user)) + ")" end diff --git a/app/models/censor_rule.rb b/app/models/censor_rule.rb index 201e60746..72b92d462 100644 --- a/app/models/censor_rule.rb +++ b/app/models/censor_rule.rb @@ -51,7 +51,10 @@ class CensorRule < ActiveRecord::Base errors.add("Censor must apply to an info request a user or a body; ") end end -end - - + def for_admin_column + self.class.content_columns.each do |column| + yield(column.human_name, self.send(column.name), column.type.to_s, column.name) + end + end +end diff --git a/app/models/comment.rb b/app/models/comment.rb index 44a1079cd..b3d5ba640 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -84,7 +84,9 @@ class Comment < ActiveRecord::Base return Comment.find(:first, :conditions => [ "info_request_id = ? and body = ?", info_request_id, body ]) end end - + def for_admin_column + self.class.content_columns.each do |column| + yield(column.human_name, self.send(column.name), column.type.to_s, column.name) + end + end end - - diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 8de6e5ba8..9dcd8c1bc 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -674,7 +674,6 @@ class IncomingMessage < ActiveRecord::Base end end - # Fix DOS style linefeeds to Unix style ones (or other later regexps won't work) # Needed for e.g. http://www.whatdotheyknow.com/request/60/response/98 text = text.gsub(/\r\n/, "\n") @@ -1029,8 +1028,6 @@ class IncomingMessage < ActiveRecord::Base return get_body_for_quoting + "\n\n" + get_attachment_text_clipped end - - # Has message arrived "recently"? def recently_arrived (Time.now - self.created_at) <= 3.days @@ -1133,7 +1130,14 @@ class IncomingMessage < ActiveRecord::Base return content_type end - private :normalise_content_type + + def for_admin_column + self.class.content_columns.each do |column| + yield(column.human_name, self.send(column.name), column.type.to_s, column.name) + end + end + + private :normalise_content_type end diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 3b86f4cb3..1e55f92ae 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -1059,6 +1059,10 @@ public req.save() end end -end - + def for_admin_column + self.class.content_columns.map{|c| c unless %w(title url_title).include?(c.name) }.compact.each do |column| + yield(column.human_name, self.send(column.name), column.type.to_s, column.name) + end + end +end diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 9ce191f6b..c5ca5fedd 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -36,29 +36,25 @@ class InfoRequestEvent < ActiveRecord::Base has_many :track_things_sent_emails validates_presence_of :event_type - - def self.enumerate_event_types - [ - 'sent', - 'resent', - 'followup_sent', - 'followup_resent', - - 'edit', # title etc. edited (in admin interface) - 'edit_outgoing', # outgoing message edited (in admin interface) - 'edit_comment', # comment edited (in admin interface) - 'destroy_incoming', # deleted an incoming message (in admin interface) - 'destroy_outgoing', # deleted an outgoing message (in admin interface) - 'redeliver_incoming', # redelivered an incoming message elsewhere (in admin interface) - 'move_request', # changed user or public body (in admin interface) - 'manual', # you did something in the db by hand - - 'response', - 'comment', - 'status_update', - ] - end - validates_inclusion_of :event_type, :in => enumerate_event_types + validates_inclusion_of :event_type, :in => [ + 'sent', + 'resent', + 'followup_sent', + 'followup_resent', + + 'edit', # title etc. edited (in admin interface) + 'edit_outgoing', # outgoing message edited (in admin interface) + 'edit_comment', # comment edited (in admin interface) + 'destroy_incoming', # deleted an incoming message (in admin interface) + 'destroy_outgoing', # deleted an outgoing message (in admin interface) + 'redeliver_incoming', # redelivered an incoming message elsewhere (in admin interface) + 'move_request', # changed user or public body (in admin interface) + 'manual', # you did something in the db by hand + + 'response', + 'comment', + 'status_update' + ] # user described state (also update in info_request) validate :must_be_valid_state @@ -440,7 +436,9 @@ class InfoRequestEvent < ActiveRecord::Base return ret end - + def for_admin_column + self.class.content_columns.each do |column| + yield(column.human_name, self.send(column.name), column.type.to_s, column.name) + end + end end - - diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index 29445d587..c29cbb785 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -271,6 +271,12 @@ class OutgoingMessage < ActiveRecord::Base def purge_in_cache self.info_request.purge_in_cache end + + def for_admin_column + self.class.content_columns.each do |column| + yield(column.human_name, self.send(column.name), column.type.to_s, column.name) + end + end end diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 0e21037ef..ae902dac6 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -189,6 +189,25 @@ class PublicBody < ActiveRecord::Base text = text.gsub(/\n/, '<br>') return text end + + def compare(previous = nil) + if previous.nil? + yield([]) + else + v = self + changes = self.class.content_columns.inject([]) {|memo, c| + unless %w(version last_edit_editor last_edit_comment updated_at).include?(c.name) + from = previous.send(c.name) + to = self.send(c.name) + memo << { :name => c.human_name, :from => from, :to => to } if from != to + end + memo + } + changes.each do |change| + yield(change) + end + end + end end acts_as_xapian :texts => [ :name, :short_name, :notes ], @@ -552,6 +571,12 @@ class PublicBody < ActiveRecord::Base self.info_requests.each {|x| x.purge_in_cache} end + def for_admin_column + self.class.content_columns.map{|c| c unless %w(name last_edit_comment).include?(c.name)}.compact.each do |column| + yield(column.human_name, self.send(column.name), column.type.to_s, column.name) + end + end + end diff --git a/app/models/user.rb b/app/models/user.rb index cd8d3e721..4a7153b3f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -400,6 +400,17 @@ class User < ActiveRecord::Base return self.email_confirmed end + def for_admin_column(complete = false) + if complete + columns = self.class.content_columns + else + columns = self.class.content_columns.map{|c| c if %w(created_at updated_at admin_level email_confirmed).include?(c.name) }.compact + end + columns.each do |column| + yield(column.human_name, self.send(column.name), column.type.to_s) + end + end + ## Private instance methods private @@ -430,4 +441,3 @@ class User < ActiveRecord::Base end end - diff --git a/app/views/admin_censor_rule/_form.rhtml b/app/views/admin_censor_rule/_form.rhtml index d077afd9a..f3f6f4ddf 100644 --- a/app/views/admin_censor_rule/_form.rhtml +++ b/app/views/admin_censor_rule/_form.rhtml @@ -1,35 +1,63 @@ <%= error_messages_for 'censor_rule' %> -<p>Applies to: - <% if !info_request.nil? %> - <%=request_both_links(info_request)%> request - <%= hidden_field 'censor_rule', 'info_request_id', { :value => info_request.id } %> - <% end %> - <% if !user.nil? %> - <%=user_both_links(user)%> user - <%= hidden_field 'censor_rule', 'user_id', { :value => user.id } %> - <% end %> -</p> +<div class="well"> + <%=_("Applies to")%> + <% unless info_request.nil? %> + <%= request_link(info_request)%> + <%= request_admin_link(info_request, "btn btn-info")%> + <%= hidden_field 'censor_rule', 'info_request_id', { :value => info_request.id } %> + <% end %> + <% unless user.nil? %> + <%= user_link(user) %> + <%= user_admin_link(user, "admin", "btn btn-info") %> + <%= hidden_field 'censor_rule', 'user_id', { :value => user.id } %> +<% end %> +</div> +<div class="control-group"> + <label for="censor_rule_text" class="control-label">Text</label> + <div class="controls"> + <%= text_field 'censor_rule', 'text', :class => "span3" %> + <div class="help-block"> + that you want to remove, case sensitive + </div> + </div> +</div> -<p><label for="censor_rule_text">Text</label> (that you want to remove, case sensitive)<br/> -<%= text_field 'censor_rule', 'text', :size => 60 %></p> +<div class="control-group"> + <label for="censor_rule_replacement" class="control-label">Replacement</label> + <div class="controls"> + <%= text_field 'censor_rule', 'replacement', :class => "span3" %> + <div class="help-block"> + put it in <strong>[square brackets]</strong>, e.g. [personal information removed]. applies to text in emails and HTML conversions of binaries; binaries themselves must stay the same length and the replacement is just a bunch of 'x's + </div> + </div> +</div> -<p><label for="censor_rule_replacement">Replacement</label> (put it in <strong>[square brackets]</strong>, e.g. [personal information removed]. applies to text in emails and HTML conversions of binaries; binaries themselves must stay the same length and the replacement is just a bunch of 'x's)<br/> -<%= text_field 'censor_rule', 'replacement', :size => 60 %></p> - -<p><label for="censor_rule_last_edit_comment">Comment for this edit</label> (put purpose of the rule, and why the change)<br/> -<%= text_area 'censor_rule', 'last_edit_comment', :rows => 2, :cols => 60 %></p> - -<p><strong>Warning and notes:</strong> This does replace text in binary files, but for -most formats only in a naive way. It works well on surprisingly many Word documents. Notably -it doesn't even do UCS-2 (unicode sometimes used in Word). There is also special code -which works on some PDFs. Please <strong>carefully check</strong> all attachments have -changed in the way you expect, and haven't become corrupted. -</p> - -<p>You may need to manually rebuild the search index afterwards. You can redact -things by individual request or by user by adding the censor rule from the -appropriate page. If you need to redact across a whole -authority, it will be easy enough to make code changes to add it, so do ask. -</p> +<div class="control-group"> + <label for="censor_rule_last_edit_comment" class="control-label">Comment for this edit</label> + <div class="controls"> + <%= text_area 'censor_rule', 'last_edit_comment', :rows => 2, :class => "span6" %> + <div class="help-block"> + put purpose of the rule, and why the change + </div> + </div> +</div> +<div class="row"> + <div class="span10 offset2"> + <div class="alert alert-info"> + <h3>Warning and notes:</h3> + <p> This does replace text in binary files, but for + most formats only in a naive way. It works well on surprisingly many Word documents. Notably + it doesn't even do UCS-2 (unicode sometimes used in Word). There is also special code + which works on some PDFs. Please <strong>carefully check</strong> all attachments have + changed in the way you expect, and haven't become corrupted. + </p> + <p>You may need to manually rebuild the search index afterwards. You can redact + things by individual request or by user by adding the censor rule from the + appropriate page. If you need to redact across a whole + authority, it will be easy enough to make code changes to add it, so do ask. + </p> + </div> + </div> +</div> diff --git a/app/views/admin_censor_rule/_show.rhtml b/app/views/admin_censor_rule/_show.rhtml index 363c3fb6f..eed0571af 100644 --- a/app/views/admin_censor_rule/_show.rhtml +++ b/app/views/admin_censor_rule/_show.rhtml @@ -26,14 +26,10 @@ <% end %> <% if defined? info_request %> - <p> - <%= link_to "New censor rule", '../../censor/new?info_request_id=' + info_request.id.to_s %> (for this request only) - </p> + <%= link_to "New censor rule", "../../censor/new?info_request_id=#{info_request.id}", :class => "btn btn-info" %> <span class="label label-info">for this request only</span> <% end %> <% if defined? user %> - <p> - <%= link_to "New censor rule", '../../censor/new?user_id=' + user.id.to_s %> (for all requests by this user) - </p> + <%= link_to "New censor rule", "../../censor/new?user_id=#{user.id}", :class => "btn btn-info" %> <span class="label label-info">for all requests by this user</span> <% end %> diff --git a/app/views/admin_censor_rule/new.rhtml b/app/views/admin_censor_rule/new.rhtml index c6b8cea6a..6cac58b3b 100644 --- a/app/views/admin_censor_rule/new.rhtml +++ b/app/views/admin_censor_rule/new.rhtml @@ -1,9 +1,11 @@ -<% @title = 'New censor rule' %> +<% @title = _('New censor rule') %> <h1><%=@title%></h1> -<% form_tag 'create' do %> +<% form_tag 'create', :class => "form form-horizontal" do %> <%= render :partial => 'form', :locals => { :info_request => @info_request, :user => @user } %> - <p><%= submit_tag "Create" %></p> + <div class="form-actions"> + <%= submit_tag "Create", :class => "btn btn-primary" %> + </div> <% end %> diff --git a/app/views/admin_general/index.rhtml b/app/views/admin_general/index.rhtml index 1a4b8ba96..891f8b70d 100644 --- a/app/views/admin_general/index.rhtml +++ b/app/views/admin_general/index.rhtml @@ -1,95 +1,160 @@ <% @title = "Summary" %> - -<h1><%=@title%></h1> - -<ul> -<li><%=@public_body_count%> public authorities</li> -<li><%=@info_request_count%> requests, <%=@outgoing_message_count%> outgoing messages, - <%=@incoming_message_count%> incoming messages -</li> -<li><%=@user_count%> users, <%=@track_thing_count%> tracked things</li> -<li><%=@comment_count%> annotations</li> -</ul> - -<hr> - -<h1>Things to do</h1> - -<% if @holding_pen_messages.size > 0 %> - <h3>Put misdelivered responses with the right request (<%=@holding_pen_messages.size%> total)</h3> - - <ul> - <% for message in @holding_pen_messages %> - <li> - <% if message.get_body_for_quoting.strip.size == 0 %> - <%= link_to "(no body)", "request/show_raw_email/" + message.raw_email_id.to_s %> - <% else %> - <%= link_to excerpt(message.get_body_for_quoting, "", 60), "request/show_raw_email/" + message.raw_email_id.to_s %> +<div class="hero-unit"> + <h2><%=@public_body_count%> public authorities</h2> + <h2><%=@info_request_count%> requests, <%=@outgoing_message_count%> outgoing messages, <%=@incoming_message_count%> incoming messages</h2> + <h2><%=@user_count%> users, <%=@track_thing_count%> tracked things</h2> + <h2><%=@comment_count%> annotations</h2> +</div> + +<div class="row"> + <div class="span12"> + <h1>Things to do</h1> + </div> +</div> + +<div class="accordion" id="things-to-do"> + <% if @holding_pen_messages.size > 0 %> + <div class="accordion-group"> + <div class="accordion-heading"> + <a class="accordion-toggle" href="#holding-pen" data-toggle="collapse" data-parent="things-to-do"><span class="label label-important"><%=@holding_pen_messages.size%></span> Put misdelivered responses with the right request</a> + </div> + <div id="holding-pen" class="accordion-body collapse"> + <table class="table table-striped"> + <tbody> + <% for message in @holding_pen_messages %> + <tr> + <td> + <% if message.get_body_for_quoting.strip.size == 0 %> + <%= link_to "(no body)", "request/show_raw_email/" + message.raw_email_id.to_s %> + <% else %> + <%= link_to excerpt(message.get_body_for_quoting, "", 60), "request/show_raw_email/" + message.raw_email_id.to_s %> + <% end %> + </td> + <td class="span2"> + <%=simple_date(message.sent_at)%> + </td> + </tr> <% end %> - (<%=simple_date(message.sent_at)%>) - </li> - <% end %> - </ul> - -<% end %> - -<% if @error_message_requests.size > 0 %> - <h3>Fix these delivery and other errors (<%=@error_message_requests.size%> total)</h3> - - <ul> - <% for @request in @error_message_requests %> - <li> - <%= request_both_links(@request)%> - – <%=simple_date(@request.get_last_event.created_at)%> - </li> - <% end %> - </ul> -<% end %> - -<% if @requires_admin_requests.size > 0 %> - <h3>These require administrator attention (<%=@requires_admin_requests.size%> total)</h3> - - <ul> - <% for @request in @requires_admin_requests %> - <li> - <%= request_both_links(@request)%> - – <%=simple_date(@request.get_last_event.created_at)%> - </li> - <% end %> - </ul> -<% end %> - -<% if @blank_contacts.size > 0 %> - <h3>Find missing FOI email for these public authorities (try phoning!) (<%=@blank_contacts.size%> total)</h3> - <ul> - <% for @blank_contact in @blank_contacts %> - <li> - <%= public_body_both_links(@blank_contact)%> - – <%=simple_date(@blank_contact.updated_at)%> - </li> - <% end %> - </ul> -<% end %> - -<% if @old_unclassified.size > 0 %> - <h3>Classify responses that are still unclassified <%=InfoRequest::OLD_AGE_IN_DAYS.inspect %> after response</h3> + </tbody> + </table> + </div> + </div> + <% end %> + + <% if @error_message_requests.size > 0 %> + <div class="accordion-group"> + <div class="accordion-heading"> + <a class="accordion-toggle" href="#error-messages" data-toggle="collapse" data-parent="things-to-do"><span class="label label-important"><%=@error_message_requests.size%></span> Fix these delivery and other errors</a> + </div> + <div id="error-messages" class="accordion-body collapse"> + <table class="table table-striped"> + <tbody> + <% for @request in @error_message_requests %> + <tr> + <td> + <%= link_to("admin", request_admin_url(@request), :class => "btn btn-primary btn-mini")%> + </td> + <td class="link"> + <%= request_link(@request)%> + </td> + <td class="span2"> + <%=simple_date(@request.get_last_event.created_at)%> + </td> + </tr> + <% end %> + </tbody> + </table> + </div> + </div> + <% end %> + + <% if @requires_admin_requests.size > 0 %> + <div class="accordion-group"> + <div class="accordion-heading"> + <a class="accordion-toggle" href="#requires-admin" data-toggle="collapse" data-parent="things-to-do"><span class="label label-important"><%=@requires_admin_requests.size%></span> These require administrator attention</a> + </div> + <div id="requires-admin" class="accordion-body collapse"> + <table class="table table-striped"> + <tbody> + <% for @request in @requires_admin_requests %> + <tr> + <td> + <%= link_to("admin", request_admin_url(@request), :class => "btn btn-primary btn-mini")%> + </td> + <td class="link"> + <%= request_link(@request)%> + </td> + <td class="span2"> + <%=simple_date(@request.get_last_event.created_at)%> + </td> + </tr> + <% end %> + </tbody> + </table> + </div> + </div> + <% end %> + + <% if @blank_contacts.size > 0 %> + <div class="accordion-group"> + <div class="accordion-heading"> + <a class="accordion-toggle" href="#blank-contacts" data-toggle="collapse" data-parent="things-to-do"><span class="label label-important"><%=@blank_contacts.size%></span> Find missing FOI email for these public authorities (try phoning!)</a> + </div> + <div id="blank-contacts" class="accordion-body collapse"> + <table class="table table-striped"> + <tbody> + <% for @blank_contact in @blank_contacts %> + <tr> + <td> + <%= link_to("admin", public_body_admin_url(@blank_contact), :class => "btn btn-primary btn-mini")%> + </td> + <td class="link"> + <%= public_body_link(@blank_contact)%> + </td> + <td class="span2"> + <%=simple_date(@blank_contact.updated_at)%> + </td> + </tr> + <% end %> + </tbody> + </table> + </div> + </div> + <% end %> + + <% if @old_unclassified.size > 0 %> + <div class="accordion-group"> + <div class="accordion-heading"> + <a class="accordion-toggle" href="#unclassified" data-toggle="collapse" data-parent="things-to-do"><span class="label label-important"><%=@old_unclassified.size%></span> Classify responses that are still unclassified <%=InfoRequest::OLD_AGE_IN_DAYS.inspect %> after response</a> + </div> + <div id="unclassified" class="accordion-body collapse"> + <table class="table table-striped"> + <tbody> + <% for @request in @old_unclassified %> + <tr> + <td> + <%= link_to("admin", request_admin_url(@request), :class => "btn btn-primary btn-mini")%> + </td> + <td class="link"> + <%= request_link(@request)%> + </td> + <td class="span2"> + <%=simple_date(@request.get_last_response_event.created_at)%> + </td> + </tr> + <% end %> + </tbody> - <ul> - <% for @request in @old_unclassified %> - <li> - <%= request_both_links(@request) %> - – <%=simple_date(@request.get_last_response_event.created_at)%> - </li> - <% end %> - </ul> - - <p>(<%= link_to "Full list", admin_url("unclassified") %>, or play public - <%= link_to "Categorisation game", main_url(play_url(:only_path => true)) %>) - </p> -<% end %> + </table> + </div> + </div> + <% end %> +</div> <% if @holding_pen_messages.size == 0 && @old_unclassified.size == 0 && @requires_admin_requests.size == 0 && @blank_contacts.size == 0 %> - <p>No pending administration required.</p> + <div class="row"> + <div class="span12 alert alert-success"> + No pending administration required. + </div> + </div> <% end %> - - diff --git a/app/views/admin_general/stats.rhtml b/app/views/admin_general/stats.rhtml index b22adb581..023c08cf5 100644 --- a/app/views/admin_general/stats.rhtml +++ b/app/views/admin_general/stats.rhtml @@ -1,38 +1,54 @@ <% @title = "Statistics" %> - -<h1>Statistics</h1> - -<h2>Chart of requests (excluding backpaged)</h2> - -<p> +<div class="row"> + <div class="span12"> + <h1>Statistics</h1> + <h2>Chart of requests (excluding backpaged)</h2> <img src="<%= main_url("/foi-live-creation.png")%>"> -</p> - -<h2>State of requests (includes backpaged)</h2> - -<table> -<% for state, count in @request_by_state %> -<tr> <td><%=state %></td><td><%= count %></td> </tr> -<% end %> -</table> - -<h2>Chart of users</h2> - -<p> + </div> +</div> +<div class="row"> + <div class="span12"> + <h2>State of requests (includes backpaged)</h2> + <div class="container"> + <% for state, count in @request_by_state %> + <div class="row"> + <div class="span1"> + <span class="label label-info"><%=count%></span> + </div> + <div class="span4"> + <%=state%> + </div> + </div> + <% end %> + </div> + </div> +</div> +<div class="row"> + <div class="span12"> + <h2>Chart of users</h2> <img src="<%= main_url("/foi-user-use.png")%>"> -</p> - -<h2>Tracks by type</h2> - -<table> -<% for state, count in @tracks_by_type %> -<tr> <td><%=state %></td><td><%= count %></td> </tr> -<% end %> -</table> - -<h2>Web analytics</h2> - - -</p> - + </div> +</div> +<div class="row"> + <div class="span12"> + <h2>Tracks by type</h2> + <div class="container"> + <% for state, count in @tracks_by_type %> + <div class="row"> + <div class="span1"> + <span class="label label-info"><%=count%></span> + </div> + <div class="span4"> + <%=state%> + </div> + </div> + <% end %> + </div> + </div> +</div> +<div class="row"> + <div class="span12"> + <h2>Web analytics</h2> + </div> +</div> diff --git a/app/views/admin_general/timeline.rhtml b/app/views/admin_general/timeline.rhtml index 39a4b3e36..532f17f98 100644 --- a/app/views/admin_general/timeline.rhtml +++ b/app/views/admin_general/timeline.rhtml @@ -1,14 +1,19 @@ <% @title = "Timeline" %> - -<h1><%=h @events_title%></h1> - -<p> -<a href="?hour=1">Hour</a> -| <a href="?day=1">Day</a> -| <a href="?">2 days</a> -| <a href="?week=1">Week</a> -| <a href="?month=1">Month</a> -| <a href="?all=1">All time</a></p> +<div class="btn-toolbar"> + <div class="btn-group"> + <a class="btn" href="?hour=1">Hour</a> + <a class="btn" href="?day=1">Day</a> + <a class="btn" href="?">2 days</a> + <a class="btn" href="?week=1">Week</a> + <a class="btn" href="?month=1">Month</a> + <a class="btn" href="?all=1">All time</a> + </div> +</div> +<div class="row"> + <div class="span12"> + <h1><%=h @events_title%></h1> + </div> +</div> <% last_date = nil %> <% for event in @events %> @@ -22,14 +27,14 @@ <br> <% end %> <% last_date = event.created_at.to_date %> - + <%= simple_time(event.created_at) %> <% if event.class.to_s == 'InfoRequestEvent' %> <%= request_both_links(event.info_request) %> <% if event.event_type == 'edit' %> was edited by administrator <strong><%=h event.params[:editor] %></strong>. - <% for p in ['title', 'prominence', 'described_state', 'awaiting_description'] + <% for p in ['title', 'prominence', 'described_state', 'awaiting_description'] if event.params[p.to_sym] != event.params[('old_'+p).to_sym] %> Changed <%=p%> from '<%=h event.params[('old_'+p).to_sym]%>' to '<%=h event.params[p.to_sym] %>'. <% end @@ -38,8 +43,9 @@ <% elsif event.event_type == 'edit_outgoing' %> <% outgoing_message = OutgoingMessage.find(event.params[:outgoing_message_id].to_i) %> had outgoing message edited by administrator <strong><%=h event.params[:editor] %></strong>. - <% if outgoing_message %> - <% for p in ['body'] + <% if outgoing_messages.size > 0 %> + <% outgoing_message = outgoing_messages[0] %> + <% for p in ['body'] if event.params[p.to_sym] != event.params[('old_'+p).to_sym] %> Changed <%=p%> from '<%=h event.params[('old_'+p).to_sym]%>' to '<%=h event.params[p.to_sym] %>'. <% end @@ -51,8 +57,9 @@ <% elsif event.event_type == 'edit_comment' %> <% comment = Comment.find(event.params[:comment_id].to_i) %> had annotation edited by administrator <strong><%=h event.params[:editor] %></strong>. - <% if comment %> - <% for p in ['body'] + <% if comments.size > 0 %> + <% comment = comments[0] %> + <% for p in ['body'] if event.params[p.to_sym] != event.params[('old_'+p).to_sym] %> Changed <%=p%> from '<%=h event.params[('old_'+p).to_sym]%>' to '<%=h event.params[p.to_sym] %>'. <% end @@ -69,7 +76,7 @@ had incoming message redelivered to another request by administrator <strong><%=h event.params[:editor] %></strong>. <% elsif event.event_type == 'response' %> <% incoming_message = event.incoming_message %> - received + received <%= link_to 'a response', main_url(incoming_message_url(incoming_message)) %> from <%=h event.info_request.public_body.name %>. <% elsif event.event_type == 'sent' %> @@ -93,5 +100,3 @@ <% if not @events.empty? %> </p> <% end %> - - diff --git a/app/views/admin_public_body/_form.rhtml b/app/views/admin_public_body/_form.rhtml index d854b53f5..a02e60e38 100644 --- a/app/views/admin_public_body/_form.rhtml +++ b/app/views/admin_public_body/_form.rhtml @@ -3,60 +3,98 @@ <!--[form:public_body]--> <div id="div-locales"> - <ul> - <% for locale in I18n.available_locales do %> - <li><a href="#div-locale-<%=locale.to_s%>"><%=locale_name(locale.to_s)%></a></li> - <% end %> - </ul> - -<% + <ul class="locales nav nav-tabs"> + <% I18n.available_locales.each_with_index do |locale, i| %> + <li><a href="#div-locale-<%=locale.to_s%>" data-toggle="tab" ><%=locale_name(locale.to_s) || _("Default locale")%></a></li> + <% end %> + </ul> + <div class="tab-content"> +<% for locale in I18n.available_locales do if locale==I18n.default_locale # The default locale is submitted as part of the bigger object... prefix = 'public_body' object = @public_body else # ...but additional locales go "on the side" prefix = "public_body[translated_versions][]" - object = @public_body.new_record? ? - PublicBody::Translation.new : + object = @public_body.new_record? ? + PublicBody::Translation.new : @public_body.translation(locale.to_s) || PublicBody::Translation.new end fields_for prefix, object do |t| %> - <div id="div-locale-<%=locale.to_s%>"> + <div class="tab-pane" id="div-locale-<%=locale.to_s%>"> + <div class="control-group"> <%= t.hidden_field :locale, :value => locale.to_s %> - - <p><label for="<%= form_tag_id(t.object_name, :name, locale) %>">Name</label><br/> - <%= t.text_field :name, :size => 60, :id => form_tag_id(t.object_name, :name, locale) %></p> - - <p><label for="<%= form_tag_id(t.object_name, :short_name, locale) %>">Short name <small>(only put in abbreviations which are really used, otherwise leave blank. Short or long name is used in the URL - don't worry about breaking URLs through renaming, as the history is used to redirect)</small></label><br/> - <%= t.text_field :short_name, :size => 60, :id => form_tag_id(t.object_name, :short_name, locale) %></p> - - <p><label for="<%= form_tag_id(t.object_name, :request_email, locale) %>">Request email <small>(set to <strong>blank</strong> (empty string) if can't find an address; these emails are <strong>public</strong> as anyone can view with a CAPTCHA)</small></label><br/> - <%= t.text_field :request_email, :size => 40, :id => form_tag_id(t.object_name, :request_email, locale) %></p> - - <p><label for="<%= form_tag_id(t.object_name, :publication_scheme, locale) %>">Publication scheme URL</label><br/> - <%= t.text_field :publication_scheme, :size => 60, :id => form_tag_id(t.object_name, :publication_scheme, locale) %></p> - - <p><label for="<%= form_tag_id(t.object_name, :notes, locale) %>">Public notes</label> <small>(HTML, for users to consider when making FOI requests to the authority)</small><br/> - <%= t.text_area :notes, :rows => 3, :cols => 60, :id => form_tag_id(t.object_name, :notes, locale) %></p> + <label for="<%= form_tag_id(t.object_name, :name, locale) %>" class="control-label">Name</label> + <div class="controls"> + <%= t.text_field :name, :id => form_tag_id(t.object_name, :name, locale), :class => "span4" %> + </div> + </div> + <div class="control-group"> + <label for="<%= form_tag_id(t.object_name, :short_name, locale) %>", class="control-label"><%=_("Short name")%></label> + <div class="controls"> + <%= t.text_field :short_name, :id => form_tag_id(t.object_name, :short_name, locale), :class => "span2" %> + <p class="help-block"><%=_("Only put in abbreviations which are really used, otherwise leave blank. Short or long name is used in the URL - don't worry about breaking URLs through renaming, as the history is used to redirect")%></p> + </div> + </div> + <div class="control-group"> + <label for="<%= form_tag_id(t.object_name, :request_email, locale) %>" class="control-label"><%=_("Request email")%></label> + <div class="controls"> + <%= t.text_field :request_email, :id => form_tag_id(t.object_name, :request_email, locale), :class => "span3" %> + <p class="help-block"><%=_("set to <strong>blank</strong> (empty string) if can't find an address; these emails are <strong>public</strong> as anyone can view with a CAPTCHA")%></p> + </div> + </div> + <div class="control-group"> + <label for="<%= form_tag_id(t.object_name, :publication_scheme, locale) %>" class="control-label"><%=_("Publication scheme URL")%></label> + <div class="controls"> + <%= t.text_field :publication_scheme, :size => 60, :id => form_tag_id(t.object_name, :publication_scheme, locale), :class => "span3" %> + </div> + </div> + <div class="control-group"> + <label for="<%= form_tag_id(t.object_name, :notes, locale) %>" class="control-label"><%=_("Public notes")%></label> + <div class="controls"> + <%= t.text_area :notes, :rows => 3, :id => form_tag_id(t.object_name, :notes, locale), :class => "span6" %> + <p class="help-block"> + HTML, for users to consider when making FOI requests to the authority + </p> + </div> + </div> </div> -<% +<% end - end + end %> + </div> </div> <h3>Common Fields</h3> - -<p><label for="public_body_tag_string">Tags <small>(space separated; see list of tags on the right; also <strong>not_apply</strong> if FOI and EIR no longer apply to authority, <strong>eir_only</strong> if EIR but not FOI applies to authority, <strong>defunct</strong> if the authority no longer exists; charity:NUMBER if a registered charity)</small></label><br/> - -<%= text_field :public_body, :tag_string, :size => 60, :id => 'public_body_tag_string' %></p> - -<p><label for="public_body_home_page">Home page <small>(of whole authority, not just their FOI page; set to <strong>blank</strong> (empty string) to guess it from the email)</small></label><br/> -<%= text_field :public_body, :home_page, :size => 60, :id => 'public_body_home_page' %></p> - -<p><label for="public_body_last_edit_comment"><strong>Comment</strong> for this edit</label> <small>(put URL or other source of new info)</small><br/> -<%= text_area :public_body, :last_edit_comment, :rows => 3, :cols => 60, :id => 'public_body_last_edit_comment' %></p> - +<div class="control-group"> + <label for="public_body_tag_string" class="control-label"><%=_("Tags")%></label> + <div class="controls"> + <%= f.text_field :tag_string, :class => "span4" %> + <p class="help-block">space separated; see list of tags on the right; also <strong>not_apply</strong> if FOI and EIR no longer apply to authority, <strong>eir_only</strong> if EIR but not FOI applies to authority, <strong>defunct</strong> if the authority no longer exists; charity:NUMBER if a registered charity</p> + </div> +</div> +<div class="control-group"> + <label for="public_body_home_page"><%=_("Home page")%></label> + <div class="controls"> + <%= f.text_field :home_page, :class => "span4" %> + <p class="help-block">(of whole authority, not just their FOI page; set to <strong>blank</strong> (empty string) to guess it from the email)</p> + </div> +</div> +<div class="control-group"> + <label for="public_body_last_edit_comment" class="control-label"><strong>Comment</strong> for this edit</label> + <div class="controls"> + <%= f.text_area :last_edit_comment, :rows => 3, :class => "span6" %></p> + <p class="help-block">put URL or other source of new info</p> + </div> +</div> +<div class="control-group"> + <label for="public_body_last_edit_comment" class="control-label"><strong>Comment</strong> for this edit</label> + <div class="controls"> + <%= f.text_area :last_edit_comment, :rows => 3, :class => "span6" %></p> + <p class="help-block">put URL or other source of new info</p> + </div> +</div> <!--[eoform:public_body]--> diff --git a/app/views/admin_public_body/_one_list.rhtml b/app/views/admin_public_body/_one_list.rhtml index e0d2399d0..bd31305d4 100644 --- a/app/views/admin_public_body/_one_list.rhtml +++ b/app/views/admin_public_body/_one_list.rhtml @@ -1,29 +1,51 @@ -<table> - <tr> - <th>Name</th> - <th>Tags</th> - <% for column in PublicBody.content_columns.map { |c| c.human_name } - [ "Name", "Last edit comment" ] %> - <th><%= column %></th> - <% end %> - </tr> -<% for public_body in bodies %> - <tr class="<%= cycle('odd', 'even') %>"> - <td><%= public_body_both_links(public_body) %></td> - <td><%= render :partial => 'tags', :locals => { :body => public_body} %></td> - <% for column in PublicBody.content_columns.map { |c| c.name } - [ "name", "last_edit_comment" ] %> - <td><%=h public_body.send(column) %></td> +<div class="accordion" id="bodies"> + <% for public_body in bodies %> + <div class="accordion-group"> + <div class="accordion-heading"> + <%= link_to("admin", public_body_admin_url(public_body), :class => "btn btn-primary btn-mini")%> + <a class="accordion-toggle" href="#body_<%=public_body.id%>" data-toggle="collapse" data-parent="bodies"> + <%=public_body.name%> + </a> + </div> + <div id="body_<%=public_body.id%>" class="accordion-body collapse"> + <table class="table table-striped"> + <tbody> + <tr> + <td> + <b><%=_("Tags")%></b> + </td> + <td> + <%= render :partial => 'tags', :locals => { :body => public_body} %> + </td> + </tr> + <% public_body.for_admin_column do |name, value, type| %> + <tr> + <td> + <b><%=name%></b> + </td> + <td> + <% if type == 'datetime' %> + <%= I18n.l(value, :format => "%e %B %Y %H:%M:%S") %> + (<%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(value)) %>) + <% else %> + <%= h value %> + <% end %> + </td> + </tr> + <% end %> + </tbody> + </table> + </div> + </div> <% end %> - </tr> -<% end %> -</table> +</div> -<% form_tag(admin_url("body/mass_tag_add"), :method => "post", :class => "forms_on_one_line" ) do %> - <p> - <%= text_field_tag 'new_tag', params[:new_tag], { :size => 15, :id => "mass_add_tag_new_tag_" + table_name } %> - <%= hidden_field_tag(:query, params[:query], { :id => "mass_add_tag_query_" + table_name } ) %> - <%= hidden_field_tag(:page, params[:page], { :id => "mass_add_page_" + table_name } ) %> - <%= hidden_field_tag(:table_name, table_name, { :id => "mass_add_tag_table_name_" + table_name } ) %> - <%= submit_tag "Add tag to all" %> (in table just above) - </p> +<% form_tag(admin_url("body/mass_tag_add"), :method => "post", :class => "form form-inline" ) do %> + <%= hidden_field_tag(:query, params[:query], { :id => "mass_add_tag_query_" + table_name } ) %> + <%= hidden_field_tag(:page, params[:page], { :id => "mass_add_page_" + table_name } ) %> + <%= hidden_field_tag(:table_name, table_name, { :id => "mass_add_tag_table_name_" + table_name } ) %> + <%= text_field_tag 'new_tag', params[:new_tag], { :size => 15, :id => "mass_add_tag_new_tag_" + table_name } %> + <%= submit_tag "Add tag to all", :class => "btn btn-primary" %> + (in table just above) <% end %> diff --git a/app/views/admin_public_body/_tag_help.rhtml b/app/views/admin_public_body/_tag_help.rhtml index 0d0f84dda..b64e65877 100644 --- a/app/views/admin_public_body/_tag_help.rhtml +++ b/app/views/admin_public_body/_tag_help.rhtml @@ -1,18 +1,16 @@ -<div id="tag_help"> - <h2>List of tags</h2> - <% first_row = true %> - <% for row in PublicBodyCategories::get().with_headings() %> - <% if row.instance_of?(Array) %> - <% if row[0] != 'other' %> - <strong><%= row[0] %></strong>=<%= row[1] %> - <br/> - <% end %> - <% elsif row != 'Miscellaneous' %> - <% if not first_row %> - <% else %> - <% first_row = false %> - <% end %> - <h3><%=h row%></h3> +<h2>List of tags</h2> +<% first_row = true %> +<% for row in PublicBodyCategories::get().with_headings() %> + <% if row.instance_of?(Array) %> + <% if row[0] != 'other' %> + <strong><%= row[0] %></strong>=<%= row[1] %> + <br/> <% end %> + <% elsif row != 'Miscellaneous' %> + <% if not first_row %> + <% else %> + <% first_row = false %> + <% end %> + <h3><%=h row%></h3> <% end %> -</div>
\ No newline at end of file +<% end %> diff --git a/app/views/admin_public_body/edit.rhtml b/app/views/admin_public_body/edit.rhtml index b19477a6b..629f64257 100644 --- a/app/views/admin_public_body/edit.rhtml +++ b/app/views/admin_public_body/edit.rhtml @@ -1,30 +1,34 @@ <h1><%=@title%></h1> -<script type="text/javascript"> - $(function() { - $("#div-locales").tabs(); - }); -</script> - -<%= render :partial => 'tag_help' %> - -<div id="public_body_form"> - <% form_tag '../update/' + @public_body.id.to_s do %> - <%= render :partial => 'form' %> - <p><%= submit_tag 'Save', :accesskey => 's' %></p> - <% end %> +<div class="row"> + <div class="span8"> + <div id="public_body_form"> + <% form_for @public_body, :url => "../update/#{@public_body.id}", :html => { :class => "form form-horizontal" } do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> + <div class="form-actions"> + <%= f.submit 'Save', :accesskey => 's', :class => "btn btn-success" %></p> + </div> + <% end %> - <p> - <%= link_to 'Show', '../show/' + @public_body.id.to_s %> | - <%= link_to 'List all', '../list' %> - </p> + <div class="row"> + <div class="span8"> + <div class="well"> + <%= link_to 'Show', "../show/#{@public_body.id}", :class => "btn" %> + <%= link_to 'List all', '../list', :class => "btn" %> + </div> + </div> + </div> - <% if @public_body.info_requests.size == 0 %> - <% form_tag('../destroy/' + @public_body.id.to_s) do %> - <p> - <%= hidden_field_tag(:public_body_id, { :value => @public_body.id } ) %> - <%= submit_tag "Destroy " + @public_body.name %> (this is permanent!) - </p> + <% if @public_body.info_requests.empty? %> + <% form_tag("../destroy/#{@public_body.id}", :class => "form form-inline") do %> + <%= hidden_field_tag(:public_body_id, { :value => @public_body.id } ) %> + <%= submit_tag _("Destroy {{name}}", :name => @public_body.name), :class => "btn btn-danger" %> (this is permanent!) <% end %> - <% end %> + <% end %> + </div> + + </div> + <div class="span4"> + <%= render :partial => 'tag_help' %> + </div> </div> diff --git a/app/views/admin_public_body/list.rhtml b/app/views/admin_public_body/list.rhtml index c28060604..412585b9f 100644 --- a/app/views/admin_public_body/list.rhtml +++ b/app/views/admin_public_body/list.rhtml @@ -1,24 +1,29 @@ <% if @query.nil? %> - <% @title = 'Listing public authorities' %> + <% @title = _('Listing public authorities') %> <% else %> - <% @title = "Listing public authorities matching '" + @query + "'" %> + <% @title = _("Listing public authorities matching '{{query}}'", :query => @query ) %> <% end %> <h1><%=@title%></h1> -<p> +<div class="btn-toolbar"> <% if !@query.nil? %> - <%= link_to 'Show all', 'list' %> | + <div class="btn-group"> + <%= link_to 'Show all', 'list', :class => "btn" %> + </div> <% end %> - <%= link_to 'New public authority', 'new' %> - | <%= link_to 'Import from CSV file', 'import_csv' %> + <div class="btn-group"> + <%= link_to 'New public authority', 'new', :class => "btn btn-primary" %> + </div> + <div class="btn-group"> + <%= link_to 'Import from CSV file', 'import_csv', :class => "btn btn-warning" %> + </div> +</div> </p> -<% form_tag("", :method => "get") do %> - <p> - <%= text_field_tag 'query', params[:query], { :size => 30 } %> - <%= submit_tag "Search" %> (substring search in names and emails; exact match of tags) - </p> +<% form_tag("", :method => "get", :class => "form form-search") do %> + <%= text_field_tag 'query', params[:query], { :size => 30, :class => "input-large search-query" } %> + <%= submit_tag "Search", :class => "btn" %> (substring search in names and emails; exact match of tags) <% end %> @@ -36,5 +41,4 @@ <%= render :partial => 'one_list', :locals => { :bodies => @public_bodies, :table_name => 'substring' } %> <% end %> -<%= will_paginate(@public_bodies) %> - +<%= will_paginate(@public_bodies, :class => "paginator") %> diff --git a/app/views/admin_public_body/new.rhtml b/app/views/admin_public_body/new.rhtml index 047d5a5bb..dd6354522 100644 --- a/app/views/admin_public_body/new.rhtml +++ b/app/views/admin_public_body/new.rhtml @@ -1,22 +1,25 @@ <% @title = 'New public authority' %> <h1><%=@title%></h1> - -<script type="text/javascript"> - $(function() { - $("#div-locales").tabs(); - }); -</script> - -<%= render :partial => 'tag_help' %> - -<div id="public_body_form"> - <% form_tag './create/' + @public_body.id.to_s do %> - <%= render :partial => 'form' %> - <p><%= submit_tag "Create" %></p> - <% end %> - - <p> - <%= link_to 'List all', 'list' %> - </p> +<div class="row"> + <div class="span8"> + <div id="public_body_form"> + <% form_for :public_body, @public_body, :url => {:action => "create"}, :html => {:class => "form form-horizontal"} do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> + <div class="form-actions"> + <%= f.submit "Create", :class => "btn btn-primary" %> + </div> + <% end %> + <div class="row"> + <div class="span8 well"> + <div class="well"> + <%= link_to _('List all'), 'list' %> + </div> + </div> + </div> + </div> + </div> + <div class="span4"> + <%= render :partial => 'tag_help' %> + </div> </div> diff --git a/app/views/admin_public_body/show.rhtml b/app/views/admin_public_body/show.rhtml index 643ccf5e8..8ca62147d 100644 --- a/app/views/admin_public_body/show.rhtml +++ b/app/views/admin_public_body/show.rhtml @@ -1,76 +1,103 @@ -<% @title = "Public authority - " + h(@public_body.name) %> +<% @title = _("Public authority - {{name}}", :name => h(@public_body.name)) %> <h1><%=@title%></h1> -<p> -<% - columns = PublicBody.content_columns + [] # force dup - columns.delete_if {|c| ['last_edit_comment'].include?(c.name)} - - for column in columns %> - <b><%= column.human_name %>:</b> - <% if column.name == 'home_page' and !column.name.empty? %> - <%= link_to(h(@public_body.send(column.name)), @public_body.send(column.name)) %> - <% elsif column.name == 'request_email' and !column.name.empty? %> - <%= link_to(h(@public_body.send(column.name)), "mailto:#{@public_body.send(column.name)}") %> - <% if !@public_body.is_requestable? %> - (not requestable due to: <%=h @public_body.not_requestable_reason %><% if @public_body.is_followupable? %>; but followupable<% end %>) - <% end %> - <% else %> - <%=h @public_body.send(column.name) %> - <% end %> - <br/> -<% end %> -<b>Calculated home page:</b> -<% if !@public_body.calculated_home_page.nil? %> - <%= link_to(h(@public_body.calculated_home_page), @public_body.calculated_home_page) %> +<table class="table table-striped"> + <tbody> + <% @public_body.for_admin_column do |name, value, type, column_name| %> + <tr> + <td> + <b><%=name%></b> + </td> + <td> + <% if column_name == 'home_page' %> + <%= link_to(h(value), value) %> + <% elsif column_name == 'request_email' %> + <%= link_to(h(value), "mailto:#{value}") %> + <% unless @public_body.is_requestable? %> + <%=_("not requestable due to: {{reason}}", :reason => h(@public_body.not_requestable_reason))%><% if @public_body.is_followupable? %>; <%=_("but followupable")%><% end %> + <% end %> + <% else %> + <%=h value %> + <% end %> + </td> + </tr> + <% end %> + <tr> + <td> + <b><%=_("Calculated home page")%></b> + </td> + <td> + <% unless @public_body.calculated_home_page.nil? %> + <%= link_to(h(@public_body.calculated_home_page), @public_body.calculated_home_page) %> + <% else %> + <%=_("*unknown*")%> + <% end %> + </td> + </tr> + <tr> + <td> + <b><%=_("Tags")%></b> + </td> + <td> + <%= render :partial => 'tags', :locals => { :body => @public_body} %> + </td> + </tr> + </tbody> +</table> +<%= link_to _("Edit"), "../edit/#{@public_body.id}", :class => "btn btn-primary" %> +<% unless @public_body.url_name.nil? %> + <%=link_to _("Public page"), main_url(public_body_url(@public_body)), :class => "btn" %> <% else %> - *unknown* + <%=_("Public page not available")%> <% end %> -<br/><b>Tags:</b> <%= render :partial => 'tags', :locals => { :body => @public_body} %> -<br/> -</p> - -<p> - <%= - # url_name can be missing if the name hasn't been set for this locale - if !@public_body.url_name.nil? - link_to 'Public page', main_url(public_body_url(@public_body)) - else - 'Public page not available' - end - %> - | <%= link_to 'Edit', '../edit/' + @public_body.id.to_s %> -</p> <h2>History</h2> -<table border="1"> -<tr> -<th>Updated at</th> -<% - history_columns = PublicBody.content_columns + [] # force dup - history_columns.delete_if {|c| ['created_at', 'updated_at', 'first_letter'].include?(c.name)} - for column in history_columns %> - <th><%= column.human_name %></th> -<% end %> -</tr> <%# There may be an option to versions() to specify order, but I can't find it. TB 2009-03-09 %> -<% for historic_public_body in @public_body.reverse_sorted_versions %> - <tr class="<%= cycle('odd', 'even') %>"> - <td><%=h historic_public_body.updated_at %></td> - <% for column in history_columns %> - <% - value = h(historic_public_body.send(column.name)) - if column.name == 'last_edit_comment' - value = historic_public_body.last_edit_comment_for_html_display - end - # Highlight entries which have changed since previous version - changed = (!['version', 'last_edit_editor', 'last_edit_comment'].include?(column.name)) && ((historic_public_body.send(column.name) != @public_body.sorted_versions[historic_public_body.version - 2].send(column.name)) || (historic_public_body.version == 1)) %> - <td <%= changed ? ' class="entry_changed" ': '' %> > - <%=value%> - </td> - <% end %> - </tr> +<% versions = @public_body.reverse_sorted_versions; versions.each_with_index do |historic_public_body, i| %> + <div class="row"> + <div class="span2"> + <b> + <%= _("Version {{version}}", :version => historic_public_body.version)%> + </b> + </div> + <div class="span4"> + <%= I18n.l(historic_public_body.updated_at, :format => "%e %B %Y %H:%M:%S") %> + (<%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(historic_public_body.updated_at)) %>) + </div> + <div class="span6"> + <% if i == versions.length - 1 %> + <div class="row"> + <div class="span6"> + <%=_("This is the first version.")%> + </div> + </div> + <% else %> + <%historic_public_body.compare(versions[i+1]) do |change|%> + <div class="row"> + <div class="span6"> + <b><%=change[:name]%> <%=_("was updated:")%></b> + </div> + </div> + <div class="row"> + <div class="span5 offset1"> + <div class="row"> + <div class="span5"> + <span class="label label-warning"><%=_("From:")%></span> <%=change[:from]%> + </div> + </div> + <div class="row"> + <div class="span5"> + <span class="label label-info"><%=_("To:")%></span> <%=change[:to]%> + </div> + </div> + </div> + </div> + <%end%> + </ul> + <% end %> + </div> + </div> <% end %> </table> @@ -78,6 +105,4 @@ <%= render :partial => 'admin_request/some_requests', :locals => { :info_requests => @public_body.info_requests } %> <h2>Track things</h2> -<%= render :partial => 'admin_track/some_tracks', :locals => { :track_things => @public_body.track_things } %> - - +<%= render :partial => 'admin_track/some_tracks', :locals => { :track_things => @public_body.track_things, :include_destroy => true } %> diff --git a/app/views/admin_request/_incoming_message_actions.rhtml b/app/views/admin_request/_incoming_message_actions.rhtml index c23b4060a..c32cbdb54 100644 --- a/app/views/admin_request/_incoming_message_actions.rhtml +++ b/app/views/admin_request/_incoming_message_actions.rhtml @@ -1,4 +1,4 @@ -<% form_tag '../redeliver_incoming' do %> +<% form_tag '../redeliver_incoming', :class => "form form-inline" do %> <div> id or url_title of request: <% if @info_requests && @info_requests.size == 1 %> @@ -7,20 +7,18 @@ <%= text_field_tag 'url_title', "", { :size => 20 } %> <% end %> <%= hidden_field_tag 'redeliver_incoming_message_id', incoming_message.id %> - <%= submit_tag "Redeliver to another request" %> + <%= submit_tag "Redeliver to another request", :class => "btn btn-warning" %> </div> <% end %> <p> -<%= link_to 'FOI officer upload URL', '../generate_upload_url/' + incoming_message.info_request.id.to_s + "?incoming_message_id=" + incoming_message.id.to_s %> +<%= link_to 'FOI officer upload URL', "../generate_upload_url/#{incoming_message.info_request.id}?incoming_message_id=#{incoming_message.id}", :class => "btn" %> </p> -<% form_tag '../destroy_incoming' do %> - <div> - <%= hidden_field_tag 'incoming_message_id', incoming_message.id %> - Warning, this is permanent! ---> - <%= submit_tag "Destroy message" %> - </div> +<% form_tag '../destroy_incoming', :class => "form form-inline" do %> + <%= hidden_field_tag 'incoming_message_id', incoming_message.id %> + <span class="label label-important"> + Warning, this is permanent! + </span> + <%= submit_tag "Destroy message", :class => "btn btn-danger" %> <% end %> - - diff --git a/app/views/admin_request/_some_requests.rhtml b/app/views/admin_request/_some_requests.rhtml index f2b8e7bea..5e9b14641 100644 --- a/app/views/admin_request/_some_requests.rhtml +++ b/app/views/admin_request/_some_requests.rhtml @@ -1,23 +1,38 @@ -<table> - <tr> - <th>Title</th> - <th>Authority</th> - <th>User</th> - <% for column in InfoRequest.content_columns.map { |c| c.human_name } - [ "Url title", "Title" ] %> - <th><%= column %></th> +<div class="accordion" id="requests"> + <% for info_request in info_requests %> + <div class="accordion-group"> + <div class="accordion-heading"> + <%= link_to("admin", request_admin_url(info_request), :class => "btn btn-primary btn-mini") %> + <a class="accordion-toggle" href="#request_<%=info_request.id%>" data-toggle="collapse" data-parent="requests"> + <%=info_request.title%> + </a> + </div> + <div id="request_<%=info_request.id%>" class="accordion-body collapse"> + <table class="table table-striped"> + <tbody> + <tr> + <td colspan="2"> + <%= link_to("admin #{info_request.public_body.name}", public_body_admin_url(info_request.public_body), :class => "btn btn-mini") %> + <%= link_to("admin #{info_request.user.name}", user_admin_url(info_request.user), :class => "btn btn-mini") %> + </td> + </tr> + <% info_request.for_admin_column do | name, value, type | %> + <tr> + <td> + <b><%=h name %></b> + </td> + <td> + <% if type == 'datetime' %> + <%=I18n.l(value, :format => "%e %B %Y %H:%M:%S")%> + (<%=_('{{length_of_time}} ago', :length_of_time => time_ago_in_words(value))%>) + <% else %> + <%=h value %> + <% end %> + </tr> + <% end %> + </tbody> + </table> + </div> + </div> <% end %> - </tr> - -<% for info_request in info_requests %> - <tr class="<%= cycle('odd', 'even') %>"> - <td><%= request_both_links(info_request) %></td> - <td><%= public_body_both_links(info_request.public_body) %></td> - <td><%= user_both_links(info_request.user) %></td> - <% for column in InfoRequest.content_columns.map { |c| c.name } - [ "title", "url_title" ] %> - <td><%=h info_request.send(column) %></td> - <% end %> - </tr> -<% end %> -</table> - - +</div> diff --git a/app/views/admin_request/list.rhtml b/app/views/admin_request/list.rhtml index cb328543e..ff67dd843 100644 --- a/app/views/admin_request/list.rhtml +++ b/app/views/admin_request/list.rhtml @@ -1,15 +1,13 @@ -<% @title = 'Listing FOI/EIR requests' %> +<% @title = _("Listing FOI requests") %> <h1><%=@title%></h1> -<% form_tag("", :method => "get") do %> - <p> - <%= text_field_tag 'query', params[:query], { :size => 30 } %> - <%= submit_tag "Search" %> (substring search, titles only) - </p> +<% form_tag("", :method => "get", :class => "form form-search") do %> + <%= text_field_tag 'query', params[:query], { :size => 30, :class => "input-large search-query" } %> + <%= submit_tag "Search", :class => "btn" %> (substring search, titles only) <% end %> <%= render :partial => 'some_requests', :locals => { :info_requests => @info_requests } %> -<%= will_paginate(@info_requests) %> +<%= will_paginate(@info_requests, :class => "paginator") %> diff --git a/app/views/admin_request/show.rhtml b/app/views/admin_request/show.rhtml index aac68ad2e..a93ef5db1 100644 --- a/app/views/admin_request/show.rhtml +++ b/app/views/admin_request/show.rhtml @@ -1,212 +1,270 @@ -<% @title = "FOI request - " + h(@info_request.title) %> +<% @title = _("FOI request - {{title}}", :title => h(@info_request.title)) %> <%= javascript_include_tag :defaults %> <h1><%=@title%></h1> -<% form_tag '../move_request', { :class => "inline" } do %> -<p> -<%= hidden_field_tag 'info_request_id', @info_request.id %> -<% for column in InfoRequest.content_columns %> - <strong><%= column.human_name %>:</strong> <%=h @info_request.send(column.name) %> - <% if column.name == 'described_state' %> - <strong>Calculated status:</strong> <%= @info_request.calculate_status %> - <br/><strong>Initial request last sent at:</strong> <%=@info_request.date_initial_request_last_sent_at.to_date %> - <strong>Date response required by:</strong> <%= @info_request.date_response_required_by %> - <strong>Very overdue after:</strong> <%= @info_request.date_very_overdue_after %> - <% end %> - <% if ![ 'allow_new_responses_from' ].include?(column.name) %> - <br/> - <% end %> -<% end %> - <strong>Created by:</strong> <%= user_both_links(@info_request.user) %> - <span> - <span> - (<%= link_to_function("move...", "$(this).up(1).childElements().invoke('toggle')") %>) - </span> - <span style="display:none;"> - <strong>url_name of new user:</strong> - <%= text_field_tag 'user_url_name', "", { :size => 20 } %> - <%= submit_tag "Move request to user" %> - </span> - </span> - <br> -<strong>Public authority:</strong> <%= public_body_both_links(@info_request.public_body) %> - <span> - <span> - (<%= link_to_function("move...", "$(this).up(1).childElements().invoke('toggle')") %>) - </span> - <span style="display:none;"> - <strong>url_name of new authority:</strong> - <%= text_field_tag 'public_body_url_name', "", { :size => 20 } %> - <%= submit_tag "Move request to authority" %> - </span> - </span> - <br> -<strong>Incoming email address:</strong> <%= link_to h(@info_request.incoming_email), "mailto:" + @info_request.incoming_email %> <br> -<b>Tags:</b> <%= render :partial => 'tags', :locals => { :info_request => @info_request} %> <br> -</p> +<% form_tag '../move_request', { :class => "form form-horizontal" } do %> + <%= hidden_field_tag 'info_request_id', @info_request.id %> + <table class="table table-striped"> + <tbody> + <% @info_request.for_admin_column do |name, value, type, column_name|%> + <tr> + <td> + <b><%= name %>:</b> + </td> + <td> + <% if type == 'datetime' %> + <%= I18n.l(value, :format => "%e %B %Y %H:%M:%S") %> + (<%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(value)) %>) + <% else %> + <%= h value %> + <% end %> + <% if column_name == 'described_state' %> + <ul> + <li><strong>Initial request last sent at:</strong> <%= @info_request.calculate_status %> + <li><strong>Initial request last sent at:</strong> <%=@info_request.date_initial_request_last_sent_at.to_date %> + <li><strong>Date response required by:</strong> <%= @info_request.date_response_required_by %> + <li><strong>Very overdue after:</strong> <%= @info_request.date_very_overdue_after %> + </ul> + <% end %> + </td> + </tr> + <% end %> + <tr> + <td> + <b>Created by</b> + </td> + <td> + <%= user_link(@info_request.user, "btn btn-mini") %> + <%= link_to _("admin"), user_admin_url(@info_request.user), :class => "btn btn-mini btn-warning" %> + <%= link_to _("move..."), "#", :class => "btn btn-mini btn-warning toggle-hidden" %> + <div style="display:none;"> + <strong>url_name of new user:</strong> + <%= text_field_tag 'user_url_name', "", { :size => 20 } %> + <%= submit_tag "Move request to user", :class => "btn btn-info" %> + </div> + </td> + </tr> + <tr> + <td> + <b>Public authority:</b> + </td> + <td> + <%= public_body_link(@info_request.public_body, "btn btn-mini") %> + <%= link_to _("admin"), public_body_admin_url(@info_request.public_body), :class => "btn btn-mini btn-warning" %> + <%= link_to "move...", "#", :class => "btn btn-mini btn-warning toggle-hidden" %> + <div style="display:none;"> + <strong>url_name of new authority:</strong> + <%= text_field_tag 'public_body_url_name', "", { :size => 20 } %> + <%= submit_tag "Move request to authority", :class => "btn btn-info" %> + </div> + </td> + </tr> + <tr> + <td> + <b><%=_("Incoming email address")%></b> + </td> + <td> + <%= link_to h(@info_request.incoming_email), "mailto:#{@info_request.incoming_email}" %> + </td> + </tr> + <tr> + <td> + <b><%=_("Tags")%></b> + </td> + <td> + <%= render :partial => 'tags', :locals => { :info_request => @info_request} %> + </td> + </tr> + </tbody> + </table> <% end %> -<p> - <%= link_to 'Public page', main_url(request_url(@info_request)) %> - | <%= link_to 'Edit', '../edit/' + @info_request.id.to_s %> - | <%= link_to 'FOI officer upload URL', '../generate_upload_url/' + @info_request.id.to_s %> (see also links on incoming messages below) -</p> +<%= link_to 'Public page', main_url(request_url(@info_request)), :class => "btn" %> +<%= link_to 'Edit', '../edit/' + @info_request.id.to_s, :class => "btn" %> +<%= link_to 'FOI officer upload URL', '../generate_upload_url/' + @info_request.id.to_s, :class => "btn btn-warning" %> (see also links on incoming messages below) <h2>Events</h2> - -<table> - <tr> - <th>Id</th> - <% for column in InfoRequestEvent.content_columns %> - <th><%= column.human_name %></th> - <% end %> - <th>Actions</th> - </tr> - -<% for info_request_event in @info_request.info_request_events.find(:all, :order => "created_at, id") %> - <tr class="<%= cycle('odd', 'even') %>"> - <td><%=h info_request_event.id %></td> - <% for column in InfoRequestEvent.content_columns %> - <td> - <% if column.name == 'params_yaml' %> - <%= info_request_event.params_yaml_as_html %> - <% elsif column.text? %> - <%=h (info_request_event.send(column.name) || '').gsub(/_/,' ') %> - <% else %> - <%=h info_request_event.send(column.name) %> - <% end %> - </td> - <% end %> - <td> - <% if info_request_event.described_state != 'waiting_clarification' and info_request_event.event_type == 'response' %> - <% form_tag '../mark_event_as_clarification' do %> - <div> +<div class="accordion" id="events"> + <% for info_request_event in @info_request.info_request_events.find(:all, :order => "created_at, id") %> + <div class="accordion-group"> + <div class="accordion-heading"> + <a class="accordion-toggle" href="#event_<%=info_request_event.id%>" data-toggle="collapse" data-parent="events"> + <%= _("Event {{id}}", :id => info_request_event.id) %> + -- + <%=h info_request_event.event_type.humanize %> + <%= admin_date info_request_event.created_at%> + <% if info_request_event.described_state != 'waiting_clarification' and info_request_event.event_type == 'response' %> + <% form_tag '../mark_event_as_clarification', :class => "form form-inline admin-table-form admin-inline-form pull-right" do %> <%= hidden_field_tag 'info_request_event_id', info_request_event.id %> - <%= submit_tag "Was clarification request" %> - </div> - <% end %> - <% end %> - </td> - </tr> -<% end %> -</table> + <%= submit_tag "Was clarification request", :class => "btn btn-mini btn-primary" %> + <% end %> + <% end %> + </a> + </div> + <div id="event_<%=info_request_event.id%>" class="accordion-body collapse"> + <table class="table table-striped"> + <tbody> + <% info_request_event.for_admin_column do |name, value, type, column_name| %> + <tr> + <td> + <b><%=h name%></b> + </td> + <td> + <% if column_name == 'params_yaml' %> + <%= info_request_event.params_yaml_as_html %> + <% elsif value.nil? %> + nil + <% elsif %w(text string).include?(type) %> + <%=h value.humanize %> + <% elsif type == 'datetime' %> + <%= admin_date value %> + <% else %> + <%=h value %> + <% end %> + </td> + </tr> + <% end %> + </tbody> + </table> + </div> + </div> + <% end %> +</div> <h2>Outgoing messages</h2> - -<table> - <tr> - <th>Id</th> - <% for column in OutgoingMessage.content_columns %> - <th><%= column.human_name %></th> - <% end %> - <th>Actions</th> - </tr> - -<% for outgoing_message in @info_request.outgoing_messages.find(:all, :order => 'created_at') %> - <tr class="<%= cycle('odd', 'even') %>"> - <td><%=h outgoing_message.id %></td> - <% for column in OutgoingMessage.content_columns.map { |c| c.name } %> - - <% if column == 'body' %> - <td> - <div><%= simple_format( truncate(outgoing_message.body, :length => 400, - :omission => link_to_function("...", "$(this).up('td').childElements().invoke('toggle')") - )) %></div> - <div style="display:none;"><%= simple_format( outgoing_message.body ) %></div> - </td> - <% else %> - <td><%= simple_format( outgoing_message.send(column) ) %></td> - <% end %> - - <% end %> - <td> - <% form_tag '../resend' do %> - <div> - <%= hidden_field_tag 'outgoing_message_id', outgoing_message.id %> - <%= submit_tag "Resend" %> +<div class="accordion" id="outgoing_messages"> + <% for outgoing_message in @info_request.outgoing_messages.find(:all, :order => 'created_at') %> + <div class="accordion-group"> + <div class="accordion-heading"> + <a class="accordion-toggle" href="#outgoing_<%=outgoing_message.id%>" data-toggle="collapse" data-parent="outgoing_messages"> + #<%= outgoing_message.id %> -- <%= outgoing_message.status.humanize %> <%= outgoing_message.message_type.humanize %> + </a> + </div> + <div id="outgoing_<%=outgoing_message.id%>" class="accordion-body collapse"> + <table class="table table-striped"> + <tbody> + <tr> + <td colspan="2"> + <% form_tag '../resend', :class => "admin-table-form" do %> + <%= hidden_field_tag 'outgoing_message_id', outgoing_message.id %> + <%= submit_tag "Resend", :class => "btn btn-warning" %> + <% end %> + <%= link_to "Edit", "../edit_outgoing/#{outgoing_message.id}", :class => "btn btn-warning" %> + </td> + </tr> + <% outgoing_message.for_admin_column do |name, value, type, column_name| %> + <tr> + <td class="span3"> + <b><%=name%></b> + </td> + <td> + <% if column_name == 'body' %> + <%= simple_format(truncate(outgoing_message.body, :length => 400, :omission => link_to("...", "#", :class => "toggle-hidden" ))) %> + <div style="display:none;"><%= simple_format( outgoing_message.body ) %></div> + <% else %> + <%= admin_value(value) %> + <% end %> + </td> + </tr> + <% end %> + </tbody> + </table> </div> + </div> <% end %> - <%= link_to "Edit", '../edit_outgoing/' + outgoing_message.id.to_s %> - </td> - </tr> -<% end %> -</table> +</div> <h2>Incoming messages</h2> - -<table> - <tr> - <th>Id</th> - <% for column in IncomingMessage.content_columns %> - <th><%= column.human_name %></th> - <% end %> - <th>Actions</th> - </tr> - -<% for incoming_message in @info_request.incoming_messages.find(:all, :order => 'created_at') %> - <tr class="<%= cycle('odd', 'even') %>" id="incoming-<%=incoming_message.id.to_s%>"> - <td><%=h incoming_message.id %></td> - <% for column in IncomingMessage.content_columns.map { |c| c.name } %> - <% if column =~ /^cached_.*?$/ %> - <td> - <div><%= simple_format( truncate(incoming_message.send(column), :length => 400, - :omission => link_to_function("...", "$(this).up('td').childElements().invoke('toggle')") - )) %></div> - <div style="display:none;"><%= simple_format( incoming_message.send(column) ) %></div> - </td> - <% else %> - <td><%= simple_format( incoming_message.send(column) ) %></td> - <% end %> +<div class="accordion"> + <% for incoming_message in @info_request.incoming_messages.find(:all, :order => 'created_at') %> + <div class="accordion-group"> + <div class="accordion-heading"> + <a class="accordion-toggle" href="#incoming_<%=incoming_message.id%>" data-toggle="collapse" data-parent="incoming_messages"> + <%=incoming_message.id%> -- <%=incoming_message.mail_from%> <%=_("at")%> <%=admin_value(incoming_message.sent_at)%> + </a> + </div> + <div id="incoming_<%=incoming_message.id%>" class="accordion-body collapse"> + <table class="table table-striped"> + <tbody> + <% incoming_message.for_admin_column do |name, value, type, column_name| %> + <tr> + <td> + <b><%=name%></b> + </td> + <td> + <% if column_name =~ /^cached_.*?$/ %> + <%= simple_format( truncate(value, :length => 400, :omission => link_to("...", "#", :class => "toggle-hidden"))) %> + <div style="display:none;"><%= simple_format(value) %></div> + <% else %> + <%= simple_format(value) %> + <% end %> + </td> + </tr> + <% end %> + <tr> + <td colspan="2"> + <% unless incoming_message.raw_email_id.nil? %> + <%= link_to "View raw email", "../show_raw_email/#{incoming_message.raw_email_id}", :class => "btn btn-mini" %> + <% end %> + <%= render :partial => 'incoming_message_actions', :locals => { :incoming_message => incoming_message } %> + </td> + </tr> + </tbody> + </table> + </div> + </div> <% end %> - <td> - <% if !incoming_message.raw_email_id.nil? %> - <p> - <%= link_to "View raw email", "../show_raw_email/" + incoming_message.raw_email_id.to_s %> - </p> - <% end %> - <%= render :partial => 'incoming_message_actions', :locals => { :incoming_message => incoming_message } %> - </td> - </tr> -<% end %> -</table> +</div> <h2>Annotations</h2> <% if @info_request.comments.size > 0 %> - <table> - <tr> - <th>Id</th> - <th>Posted by</th> - <% for column in Comment.content_columns %> - <th><%= column.human_name %></th> - <% end %> - <th>Actions</th> - </tr> - - <% for comment in @info_request.comments %> - <tr class="<%= cycle('odd', 'even') %>"> - <td><%=h comment.id %></td> - <td><%= user_both_links(comment.user) %></td> - <% for column in Comment.content_columns.map { |c| c.name } %> - <% if column == 'body' && !comment.visible %> - <td><s><%=h comment.send(column) %></s></td> - <% else %> - <td><%=h comment.send(column) %></td> - <% end %> + <div class="accordion" id="comments"> + <% for comment in @info_request.comments %> + <div class="accordion-group"> + <div class="accordion-heading"> + <a class="accordion-toggle" href="#comment_<%=comment.id%>" data-toggle="collapse" data-parent="comments"> + #<%=comment.id%> + -- + <%=comment.user.name%> + <%=admin_value(comment.created_at)%> + </a> + </div> + <div id="comment_<%=comment.id%>" class="accordion-body collapse"> + <table class="table table-striped"> + <tbody> + <tr> + <td colspan="2"> + <%= user_link(comment.user, "btn btn-mini")%> + <%= link_to("admin #{comment.user.name}", user_admin_url(comment.user), :class => "btn btn-mini") %> + <%= link_to "Edit", "../edit_comment/#{comment.id}", :class => "btn btn-warning btn-mini" %> + </td> + </tr> + <% comment.for_admin_column do |name, value, type, column_name |%> + <tr> + <td> + <b><%=name%></b> + </td> + <td> + <% if column_name == 'body' && !comment.visible %> + <s><%=h comment.send(column) %></s> + <% else %> + <%=h comment.send(column) %> + <% end %> + </td> + </tr> + <% end %> + </tbody> + </table> + </div> + </div> <% end %> - <td> - <%= link_to "Edit", '../edit_comment/' + comment.id.to_s %> - </td> - </tr> - <% end %> - </table> + </div> <% else %> <p>None yet.</p> <% end %> - - <h2>Exim delivery logs</h2> <p><i>(Lines containing the request incoming email address, updated hourly.)</i></p> diff --git a/app/views/admin_track/_some_tracks.rhtml b/app/views/admin_track/_some_tracks.rhtml index 72ee5fd95..83bda05e8 100644 --- a/app/views/admin_track/_some_tracks.rhtml +++ b/app/views/admin_track/_some_tracks.rhtml @@ -1,31 +1,65 @@ -<table> - <tr> - <th>Id</th> - <th>User</th> - <% for column in TrackThing.content_columns %> - <th><%= column.human_name %></th> - <% end %> - <th>Items sent by email (in last month)</th> - <th>Actions</th> - </tr> - -<% for track_thing in track_things %> - <tr class="<%= cycle('odd', 'even') %>"> - <td><%=h track_thing.id %></td> - <td><%=user_both_links(track_thing.tracking_user) %></td> - <% for column in TrackThing.content_columns.map { |c| c.name } %> - <td><%=h track_thing.send(column) %></td> - <% end %> - <td><%= track_thing.track_things_sent_emails.size %></td> - <td> - <% form_tag '../../user/destroy_track' do %> - <div> - <%= hidden_field_tag 'track_id', track_thing.id %> - <%= submit_tag "Destroy track" %> - </div> - <% end %> - </td> - </tr> -<% end %> -</table> +<% include_destroy = include_destroy || false %> +<% if track_things.empty? %> + <div class="row"> + <div class="span12"> + <%=_("No tracked things found.")%> + </div> + </div> +<% else %> + <div class="accordion" id="tracks"> + <% for track_thing in track_things %> + <div class="accordion-group"> + <div class="accordion-heading"> + <a class="accordion-toggle" href="#track_<%=track_thing.id%>" data-toggle="collapse" data-parent="tracks"> + <b><%=track_thing.id%>: <%=track_thing.tracking_user.email%> (<%=track_thing.tracking_user.name%>)</b> <%=track_thing.track_query%> <%=track_thing.track_medium%> + </a> + </div> + <div id="track_<%=track_thing.id%>" class="accordion-body collapse"> + <table class="table table-striped"> + <tbody> + <tr> + <td colspan="2"> + <%=link_to h(track_thing.tracking_user.name), main_url(user_url(track_thing.tracking_user)), :class => "btn" %> <%=link_to _("admin") + " " + h(track_thing.tracking_user.name), user_admin_url(track_thing.tracking_user), :class => "btn btn-success" %> + </td> + </tr> + <% if include_destroy %> + <tr> + <td colspan="2"> + <% form_tag '../../user/destroy_track', :class => "form form-inline admin-table-form" do %> + <div> + <%= hidden_field_tag 'track_id', track_thing.id %> + <%= submit_tag "Destroy track", :class => "btn btn-warning" %> + </div> + <% end %> + </td> + </tr> + <% end %> + <% TrackThing.content_columns.each do |column| %> + <tr> + <td> + <b><%=column.human_name%></b> + </td> + <td> + <% if column.type.to_s == 'datetime' %> + <%= I18n.l(track_thing.send(column.name), :format => "%e %B %Y %H:%M:%S") %> + (<%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(track_thing.send(column.name))) %>) + <% elsif column.name == 'track_medium' and track_thing.track_medium == 'feed' %> + <%= link_to track_thing.track_medium, atom_feed_url(:track_id => track_thing.id) %> + <% else %> + <%= h track_thing.send(column.name)%> + <% end %> + </td> + </tr> + <% end %> + <tr> + <td><b><%=_("Items sent in last month")%></b></td> + <td><%= track_thing.track_things_sent_emails.size %></td> + </tr> + </tbody> + </table> + </div> + </div> + <% end %> + </div> +<% end %> diff --git a/app/views/admin_track/list.rhtml b/app/views/admin_track/list.rhtml index 58c87ddba..0f69e2c4e 100644 --- a/app/views/admin_track/list.rhtml +++ b/app/views/admin_track/list.rhtml @@ -1,39 +1,12 @@ -<% @title = 'Listing tracks' %> +<% @title = _('Listing tracks') %> <h1><%=@title%></h1> -<% form_tag("", :method => "get") do %> - <p> - <%= text_field_tag 'query', params[:query], { :size => 30 } %> - <%= submit_tag "Search" %> (substring search the query - so use url_names_for_a_particular_request_or_authority_or_person) - </p> +<% form_tag("", :method => "get", :class => "form form-search") do %> + <%= text_field_tag 'query', params[:query], { :size => 30, :class => "input-large search-query" } %> + <%= submit_tag "Search", :class => "btn" %> (substring search the query - so use url_names_for_a_particular_request_or_authority_or_person) <% end %> -<table> - <tr> - <th>Id</th> - <th>Tracked by</th> - <% for column in TrackThing.content_columns %> - <th><%= column.human_name %></th> - <% end %> - <th>Items sent by email (in last month)</th> - </tr> - -<% for track_thing in @admin_tracks %> - <tr class="<%= cycle('odd', 'even') %>"> - <td><%=h track_thing.id %></td> - <td><%= user_both_links(track_thing.tracking_user) %></td> - <% for column in TrackThing.content_columns.map { |c| c.name } %> - <% if column == 'track_medium' and track_thing.track_medium == 'feed'%> - <td><%= link_to track_thing.track_medium, atom_feed_url(:track_id => track_thing.id) %></td> - <% else %> - <td><%=h track_thing.send(column) %></td> - <% end %> - <% end %> - <td><%= track_thing.track_things_sent_emails.size %></td> - </tr> -<% end %> -</table> - -<%= will_paginate(@admin_tracks) %> +<%= render :partial => 'some_tracks', :locals => { :track_things => @admin_tracks } %> +<%= will_paginate(@admin_tracks, :class => "paginator" ) %> diff --git a/app/views/admin_user/_form.rhtml b/app/views/admin_user/_form.rhtml index be69d9a80..bb74ae38f 100644 --- a/app/views/admin_user/_form.rhtml +++ b/app/views/admin_user/_form.rhtml @@ -2,6 +2,7 @@ <!--[form:admin_user]--> +<<<<<<< HEAD <p><label for="admin_user_name">Name</label> (will change URL name and break URLs; unlike authorities, there is no history; you will need to rebuild the search index afterwards)<br/> <%= text_field 'admin_user', 'name', :size => 60 %></p> @@ -25,3 +26,66 @@ <p><%= check_box 'admin_user', 'no_limit' %> <label for="admin_user_no_limit">No rate limit</label> (disable the limit on daily requests)</p> +======= +<div class="control-group"> + <label for="admin_user_name" class="control-label">Name</label> + <div class="controls"> + <%= text_field 'admin_user', 'name', :class => "span3" %> + <div class="help-block"> + will change URL name and break URLs; unlike authorities, there is no history; you will need to rebuild the search index afterwards + </div> + </div> +</div> + +<div class="control-group"> + <label for="admin_user_email" class="control-label">Email</label> + <div class="controls"> + <%= text_field 'admin_user', 'email', :class => "span3" %> + <div class="help-block"> + <strong>you must</strong> first validate this + </div> + </div> +</div> + +<div class="control-group"> + <label for="admin_level" class="control-label">Admin level</label> + <div class="controls"> + <%= text_field 'admin_user', 'admin_level', :class => "span3" %> + <div class="help-block"> + <strong>none</strong> or <strong>super</strong>; this is for admin features and links which are in the site proper + </div> + </div> +</div> + +<div class="control-group"> + <label for="ban_text" class="control-label">Ban text</label> + <div class="controls"> + <%= text_area 'admin_user', 'ban_text', :class => "span6", :rows => 3 %> + <div class="help-block"> + if not blank will stop the + user from filing new requests, making annotations or messaging other users; + the text is shown in public on the user's page and when they try to do a + forbidden action; write in the second person (you); see + <%= link_to 'banned users', '../banned' %> for examples</small> + </div> + </div> +</div> + +<div class="control-group"> + <label for="about_me" class="control-label">About me</label> + <div class="controls"> + <%= text_area 'admin_user', 'about_me', :class => "span6", :rows => 3 %> + <div class="help-block"> + user's own text on their profile, format like comments + </div> + </div> +</div> +<div class="control-group"> + <label for="admin_user_no_limit" class="control-label">No rate limit</label> + <div class="controls"> + <%= check_box 'admin_user', 'no_limit' %> + <div class="help-block"> + disable the limit on daily requests + </div> + </div> +</div> diff --git a/app/views/admin_user/_user_table.rhtml b/app/views/admin_user/_user_table.rhtml index d35c78594..16431b7ae 100644 --- a/app/views/admin_user/_user_table.rhtml +++ b/app/views/admin_user/_user_table.rhtml @@ -1,22 +1,36 @@ -<table> - <tr> - <th>Id</th> - <% for column in ['Name', 'Email', 'Created at', 'Updated at', 'Email confirmed', 'Admin'] + (banned_column ? ['Ban text'] : []) %> - <th><%= column %></th> +<div class="accordion" id="users"> + <% for user in users %> + <div class="accordion-group"> + <div class="accordion-heading"> + <%= link_to("admin", user_admin_url(user), :class => "btn btn-primary btn-mini")%> + <a class="accordion-toggle" href="#user_<%=user.id%>" data-toggle="collapse" data-parent="users"> + <%=h user.name%> (<%=user.email%>) + </a> + </div> + <div id="user_<%=user.id%>" class="accordion-body collapse"> + <table class="table table-striped"> + <tbody> + <% user.for_admin_column do |name, value, type|%> + <tr> + <td> + <b><%=h name%></b> + </td> + <td> + <% if type == 'datetime' %> + <%= I18n.l(value, :format => "%e %B %Y %H:%M:%S") %> + (<%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(value)) %>) + <% else %> + <%= h value %> + <% end %> + </td> + </tr> + <% end %> + </tbody> + </table> + </div> + </div> <% end %> - </tr> - -<% for user in users %> - <tr class="<%= cycle('odd', 'even') %>"> - <td><%= user.id.to_s %></td> - <td><%= user_both_links(user) %></td> - <td><a href="mailto:<%=h user.email %>"><%=h user.email%></a></td> - <% for column in ['created_at', 'updated_at', 'email_confirmed', 'admin_level'] + (banned_column ? ['ban_text'] : []) %> - <td><%=h user.send(column) %></td> - <% end %> - </tr> -<% end %> -</table> +</div> -<%= will_paginate(users) %> +<%= will_paginate(users, :class => "paginator") %> diff --git a/app/views/admin_user/edit.rhtml b/app/views/admin_user/edit.rhtml index 06ddc57d3..c3ee3012b 100644 --- a/app/views/admin_user/edit.rhtml +++ b/app/views/admin_user/edit.rhtml @@ -1,16 +1,14 @@ - - <h1><%=@title%></h1> -<% form_tag '../update/' + @admin_user.id.to_s do %> +<% form_tag "../update/#{@admin_user.id}", :class => "form form-horizontal" do %> <%= render :partial => 'form' %> - <p><%= submit_tag 'Save', :accesskey => 's' %></p> + <div class="form-actions"> + <%= submit_tag 'Save', :accesskey => 's', :class => "btn btn-primary" %> + </div> <% end %> -<p> -<%= link_to 'Show', '../show/' + @admin_user.id.to_s %> | -<%= link_to 'List all', '../list' %> -</p> +<%= link_to 'Show', "../show/#{@admin_user.id}", :class => "btn" %> +<%= link_to 'List all', '../list', :class => "btn" %> <% if false #@admin_user.info_requests.size == 0 %> <% form_tag('../destroy/' + @admin_user.id.to_s) do %> diff --git a/app/views/admin_user/list.rhtml b/app/views/admin_user/list.rhtml index 9de381ecc..df3a1b276 100644 --- a/app/views/admin_user/list.rhtml +++ b/app/views/admin_user/list.rhtml @@ -1,13 +1,11 @@ -<% @title = 'Listing users' %> +<% @title = _('Listing users') %> <h1><%=@title%></h1> -<% form_tag("", :method => "get") do %> - <p> - <%= text_field_tag 'query', params[:query], { :size => 30 } %> - <%= submit_tag "Search" %> (substring search, names and emails) - <%= link_to 'Banned users', 'banned' %> - </p> +<% form_tag("", :method => "get", :class => "form form-search") do %> + <%= text_field_tag 'query', params[:query], { :size => 30, :class => "input-large search-query"} %> + <%= submit_tag "Search", :class => "btn" %> (substring search, names and emails) + <%= link_to 'Banned users', 'banned', :class => "btn btn-info" %> <% end %> <%= render :partial => 'user_table', :locals => { :users => @admin_users, :banned_column => false } %> diff --git a/app/views/admin_user/show.rhtml b/app/views/admin_user/show.rhtml index 4af79e45a..372fe23f2 100644 --- a/app/views/admin_user/show.rhtml +++ b/app/views/admin_user/show.rhtml @@ -1,42 +1,56 @@ -<% @title = "User - " + h(@admin_user.name) %> +<% @title = _("User - {{name}}", :name => h(@admin_user.name)) %> <h1><%=@title%></h1> <% if @admin_user.profile_photo %> - <div class="user_photo_on_admin"> - <% form_tag '../clear_profile_photo/' + @admin_user.id.to_s, :multipart => true do %> - <img src="<%= main_url(get_profile_photo_url(:url_name => @admin_user.url_name, :only_path => true)) %>"> - <br> - <%= submit_tag "Clear photo" %> - <% end %> - </div> + <div class="user_photo_on_admin"> + <% form_tag "../clear_profile_photo/#{@admin_user.id}", :multipart => true, :class => "form" do %> + <img src="<%= main_url(get_profile_photo_url(:url_name => @admin_user.url_name, :only_path => true)) %>"> + <br> + <%= submit_tag "Clear photo", :class => "btn btn-info" %> + <% end %> + </div> <% end %> - -<div> -<strong>Id:</strong> <%= @admin_user.id%> <br> -<% for column in User.content_columns %> - <strong><%= column.human_name %>:</strong> - <% if column.name == 'email' %> - <a href="mailto:<%=h @admin_user.email %>"><%=h @admin_user.email%></a> - <% elsif column.name == 'email_bounce_message' %> - <% if !@admin_user.email_bounce_message.empty? %> - <a href="../show_bounce_message/<%= @admin_user.id.to_s %>">See bounce message</a> - <% end %> - <% else %> - <%=h @admin_user.send(column.name) %> - <% end %> - <% if column.name == 'email_bounced_at' && !@admin_user.email_bounced_at.nil? %> - <form action="../clear_bounce/<%= @admin_user.id.to_s %>" style="display: inline;"><input type="submit" name="action" value="Clear bounce"></form> +<table class="table table-striped"> + <tbody> + <tr> + <td> + <b><%=_("Id")%></b> + </td> + <td> + <%=@admin_user.id%> + </td> + </tr> + <% @admin_user.for_admin_column(:complete => true) do |name, value, type, column_name| %> + <tr> + <td> + <b><%=_(name)%></b> + </td> + <td> + <% if column_name == 'email' %> + <%=link_to @admin_user.email, "mailto:#{h @admin_user.email}"%> + <% elsif column_name == 'email_bounce_message' %> + <% unless @admin_user.email_bounce_message.empty? %> + <%= link_to _("See bounce message"), "../show_bounce_message/#{@admin_user.id}"%> + <% end %> + <% else %> + <%=h admin_value(value)%> + <% end %> + <% if column_name == 'email_bounced_at' && !@admin_user.email_bounced_at.nil? %> + <% form_tag "../clear_bounce/#{@admin_user.id}", :class => "form form-inline" do %> + <input type="submit" name="action" value="Clear bounce" class="btn btn-info"> + <% end %> + <% end %> + </td> + </tr> <% end %> - <br> -<% end %> -</div> + </tbody> +</table> -<p> - <%= link_to 'Public page', main_url(user_url(@admin_user)) %> - | <%= link_to 'Edit', '../edit/' + @admin_user.id.to_s %> - | <%= link_to 'Log in as this user', '../login_as/' + @admin_user.id.to_s %> (also confirms their email) +<%= link_to 'Edit', '../edit/' + @admin_user.id.to_s, :class => "btn btn-primary" %> +<%= link_to 'Public page', main_url(user_url(@admin_user)), :class => "btn" %> +<%= link_to "Log in as #{@admin_user.name}", "../login_as/#{@admin_user.id}", :class => "btn btn-info" %> <span class="label label-warning">also confirms their email</span> </p> <h2>Track things</h2> @@ -51,7 +65,7 @@ <th><%= column.human_name %></th> <% end %> </tr> - + <% for post_redirect in @admin_user.post_redirects.find(:all, :order => 'created_at desc') %> <tr class="<%= cycle('odd', 'even') %>"> <td><%=h post_redirect.id %></td> diff --git a/app/views/general/_locale_switcher.rhtml b/app/views/general/_locale_switcher.rhtml index 27e492e84..6d1d5fad3 100644 --- a/app/views/general/_locale_switcher.rhtml +++ b/app/views/general/_locale_switcher.rhtml @@ -1,11 +1,13 @@ - <% if FastGettext.default_available_locales.length > 1 && !params.empty? %> - <div id="user_locale_switcher"> - <% for possible_locale in FastGettext.default_available_locales %> - <% if possible_locale == I18n.locale.to_s %> - <span class="active"><%= locale_name(possible_locale) %></span> - <% else %> - <a href="<%= locale_switcher(possible_locale, params) %>"><%= locale_name(possible_locale) %></a> - <% end %> - <% end %> + <% if FastGettext.default_available_locales.length > 1 && !params.empty? %> + <div id="user_locale_switcher" class="well btn-toolbar"> + <div class="btn-group"> + <% for possible_locale in FastGettext.default_available_locales %> + <% if possible_locale == I18n.locale.to_s %> + <a href="#" class="btn disabled"><%= locale_name(possible_locale) %></a> + <% else %> + <a href="<%= locale_switcher(possible_locale, params) %>" class="btn"><%= locale_name(possible_locale) %></a> + <% end %> + <% end %> </div> - <% end %> + </div> + <% end %> diff --git a/app/views/layouts/admin.rhtml b/app/views/layouts/admin.rhtml index 42ca5dbbb..623972c2e 100644 --- a/app/views/layouts/admin.rhtml +++ b/app/views/layouts/admin.rhtml @@ -3,37 +3,75 @@ <head> <meta http-equiv="content-type" content="text/html;charset=UTF-8" > <title><%= site_name %> admin<%= @title ? ":" : "" %> <%=@title%></title> - - <%= javascript_include_tag 'jquery.js', 'jquery-ui.min' %> + + <%= javascript_include_tag 'jquery.js', 'jquery-ui.min', 'bootstrap-collapse', 'bootstrap-tab', 'admin' %> <%= stylesheet_link_tag 'admin-theme/jquery-ui-1.8.15.custom.css', :rel => 'stylesheet'%> <%= stylesheet_link_tag 'admin', :title => "Main", :rel => "stylesheet" %> </head> <body> + <div id="main" class="container"> + <div class="navbar navbar-fixed-top"> + <div class="navbar-inner"> + <div class="container"> + <%= link_to 'Alaveteli', main_url('/'), :class => "brand" %> + <div class="nav-collapse"> + <ul class="nav"> + <li> + <%= link_to 'Summary', admin_general_index_path %> + </li> + <li> + <%= link_to 'Timeline', admin_timeline_path %> + </li> + <li> + <%= link_to 'Stats', admin_stats_path %> + </li> + <li> + <%= link_to 'Debug', admin_debug_path %> + </li> + <li> + <%= link_to 'Authorities', admin_body_list_path %> + </li> + <li> + <%= link_to 'Requests', admin_request_list_path %> + </li> + <li> + <%= link_to 'Users', admin_user_list_path %> + </li> + <li> + <%= link_to 'Tracks', admin_track_list_path %> + </li> + </ul> + </div> + </div> + </div> + </div> + <div class="row"> + <div class="span12"> + <%= render :partial => 'general/locale_switcher' %> + </div> + </div> + <% if flash[:error] %> + <div class="row"> + <div class="span12"> + <div class="alert alert-error"> + <%= flash[:error] %> + </div> + </div> + </div> + <% end %> - <p> - <strong><%= link_to 'Alaveteli', main_url('/') %> admin:</strong> - <%= link_to 'Summary', admin_general_index_path %> - | <%= link_to 'Timeline', admin_timeline_path %> - | <%= link_to 'Stats', admin_stats_path %> - | <%= link_to 'Debug', admin_debug_path %> - <strong>View:</strong> - <%= link_to 'Authorities', admin_body_list_path %> - | <%= link_to 'Requests', admin_request_list_path %> - | <%= link_to 'Users', admin_user_list_path %> - | <%= link_to 'Tracks', admin_track_list_path %> - </p> - <%= render :partial => 'general/locale_switcher' %> - - <% if flash[:error] %> - <p id="error"><%= flash[:error] %></p> - <% end %> - - <% if flash[:notice] %> - <p id="notice"><%= flash[:notice] %></p> - <% end %> + <% if flash[:notice] %> + <div class="row"> + <div class="span12"> + <div class="alert alert-info"> + <%= flash[:notice] %> + </div> + </div> + </div> + <% end %> - <%= yield %> - + <%= yield %> + </div> </body> </html> |