diff options
author | francis <francis> | 2008-03-25 17:25:08 +0000 |
---|---|---|
committer | francis <francis> | 2008-03-25 17:25:08 +0000 |
commit | 596ef551443f5916e5cbce8834b7fd708207b57f (patch) | |
tree | 8c0de727515f9662c5dccbe45f52e6465b6ee4e3 | |
parent | fcb843b5e42c20ccf25c86d11a256b62bcd52f95 (diff) |
requested_from: requested_by: and type: searches.
-rw-r--r-- | app/controllers/user_controller.rb | 6 | ||||
-rw-r--r-- | app/models/info_request.rb | 38 | ||||
-rw-r--r-- | app/models/public_body.rb | 8 | ||||
-rw-r--r-- | app/models/user.rb | 18 | ||||
-rw-r--r-- | app/views/general/search.rhtml | 34 | ||||
-rw-r--r-- | app/views/user/show.rhtml | 2 | ||||
-rw-r--r-- | public/stylesheets/main.css | 7 | ||||
-rw-r--r-- | todo.txt | 8 | ||||
-rw-r--r-- | vendor/plugins/acts_as_solr/lib/parser_methods.rb | 2 |
9 files changed, 80 insertions, 43 deletions
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 61ea74923..5e6d5ba3a 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -4,13 +4,13 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: user_controller.rb,v 1.44 2008-03-21 15:31:31 francis Exp $ +# $Id: user_controller.rb,v 1.45 2008-03-25 17:25:09 francis Exp $ class UserController < ApplicationController # Show page about a set of users with same url name def show - if MySociety::Format.simplify_url_part(params[:url_name]) != params[:url_name] - redirect_to :url_name => MySociety::Format.simplify_url_part(params[:url_name]) + if MySociety::Format.simplify_url_part(params[:url_name], 32) != params[:url_name] + redirect_to :url_name => MySociety::Format.simplify_url_part(params[:url_name], 32) return end diff --git a/app/models/info_request.rb b/app/models/info_request.rb index ef6f4bc4d..353c84105 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -22,7 +22,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: info_request.rb,v 1.72 2008-03-24 09:35:23 francis Exp $ +# $Id: info_request.rb,v 1.73 2008-03-25 17:25:09 francis Exp $ require 'digest/sha1' @@ -68,11 +68,29 @@ class InfoRequest < ActiveRecord::Base :title, :initial_request_text, { :status => :string }, - { :created_at => :date } + { :requested_by => :string }, + { :requested_from => :string }, + { :created_at => :date }, + { :type => :string} # see "def type" below ], :if => "$do_solr_index" def status # for name in Solr queries calculate_status end + def requested_by + self.user.url_name + end + def requested_from + self.public_body.url_name + end + # acts_on_solr indexes things with type: anyway but by default does text (full text) + # rather than string (flag) indexing for it. The entry in acts_on_solr above forces + # the type to be string, and this function returns the same value as acts_on_solr would + # anyway. Also, only needs to happen in this one model, as others are + # covered automatically by the multi solr search query command, which treats types same + # across all models. + def type + "InfoRequest" + end $do_solr_index = false $do_solr_index_marking = false @@ -141,15 +159,15 @@ public self.update_url_title end def update_url_title - url_title = MySociety::Format.simplify_url_part(self.title) - if url_title.size > 32 - url_title = url_title[0..31] - end - # For request with same name as others, tag on the request numeric id - while not InfoRequest.find_by_url_title(url_title, :conditions => self.id.nil? ? nil : ["id <> ?", self.id] ).nil? - url_title += "_" + self.id.to_s + url_title = MySociety::Format.simplify_url_part(self.title, 32) + # For request with same title as others, add on arbitary numeric identifier + unique_url_title = url_title + suffix_num = 2 # as there's already one without numeric suffix + while not InfoRequest.find_by_url_title(unique_url_title, :conditions => self.id.nil? ? nil : ["id <> ?", self.id] ).nil? + unique_url_title = url_title + "_" + suffix_num.to_s + suffix_num = suffix_num + 1 end - write_attribute(:url_title, url_title) + write_attribute(:url_title, unique_url_title) end # Email which public body should use to respond to request. This is in diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 066ca8200..2403a97d8 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -21,7 +21,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: public_body.rb,v 1.46 2008-03-24 20:17:01 francis Exp $ +# $Id: public_body.rb,v 1.47 2008-03-25 17:25:09 francis Exp $ require 'csv' require 'set' @@ -72,8 +72,12 @@ class PublicBody < ActiveRecord::Base acts_as_solr :fields => [ {:name => { :boost => 10.0 }}, {:short_name => { :boost => 10.0 }}, - { :created_at => :date } + { :created_at => :date }, + { :moo => :string } ] + def moo + "authority" + end # When name or short name is changed, also change the url name def short_name=(short_name) diff --git a/app/models/user.rb b/app/models/user.rb index bd2df8267..1bbbdb83a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -20,7 +20,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: user.rb,v 1.40 2008-03-21 14:45:38 francis Exp $ +# $Id: user.rb,v 1.41 2008-03-25 17:25:09 francis Exp $ require 'digest/sha1' @@ -87,15 +87,15 @@ class User < ActiveRecord::Base self.update_url_name end def update_url_name - url_name = MySociety::Format.simplify_url_part(self.name) - if url_name.size > 32 - url_name = url_name[0..31] + url_name = MySociety::Format.simplify_url_part(self.name, 32) + # For user with same name as others, add on arbitary numeric identifier + unique_url_name = url_name + suffix_num = 2 # as there's already one without numeric suffix + while not User.find_by_url_name(unique_url_name, :conditions => self.id.nil? ? nil : ["id <> ?", self.id] ).nil? + unique_url_name = url_name + "_" + suffix_num.to_s + suffix_num = suffix_num + 1 end - # For request with same name as others, tag on the request numeric id - while not User.find_by_url_name(url_name, :conditions => self.id.nil? ? nil : ["id <> ?", self.id] ).nil? - url_name += "_" + self.id.to_s - end - write_attribute(:url_name, url_name) + write_attribute(:url_name, unique_url_name) end # Virtual password attribute, which stores the hashed password, rather than plain text. diff --git a/app/views/general/search.rhtml b/app/views/general/search.rhtml index e41294a1f..3b5661ee3 100644 --- a/app/views/general/search.rhtml +++ b/app/views/general/search.rhtml @@ -50,21 +50,25 @@ <% if @search_results.nil? or @search_results.empty? %> <h2>Search tips</h2> <ul> - <li>Enter words that you want to find separated by spaces, e.g. climbing lane</li> - <li>Use OR (in capital letters) where you don't mind which word, e.g. commons OR lords - <li>Use quotes when you want to find an exact phrase, e.g. "Liverpool City Council" - <li>Type status: to select based on the status of the request. - <table> - <tr><td>status:waiting_response</td><td> Waiting for the public body to reply </td></tr> - <tr><td>status:waiting_response_overdue</td><td> Waiting for the public body to reply, they are late </td></tr> - <tr><td>status:not_held</td><td> The public body does not have the information requested </td></tr> - <tr><td>status:rejected</td><td> The request was rejected by the public body </td></tr> - <tr><td>status:partially_successful</td><td> Some of the information requested has been received </td></tr> - <tr><td>status:successful</td><td> All of the information requested has been received </td></tr> - <tr><td>status:waiting_clarification</td><td> The public body would like part of the request explained </td></tr> - <tr><td>status:waiting_classification</td><td> A new response has arrived, but it hasn't been categorised yet </td></tr> - <tr><td>status:requires_admin</td><td> A strange reponse, required attention by the WhatDoTheyKnow team </td></tr> - </table> + <li>Enter words that you want to find separated by spaces, e.g. <strong>climbing lane</strong></li> + <li>Use OR (in capital letters) where you don't mind which word, e.g. <strong>commons OR lords</strong> + <li>Use quotes when you want to find an exact phrase, e.g. <strong>"Liverpool City Council"</strong> + <li>Type <strong>status:</strong> to select based on the status of the request, see table below. + <li><strong>requested_from:home_office</strong>, typing the name as in the URL, to restrict to requests from the Home Office. + <li><strong>requested_by:francis_irving</strong>, typing the name as in the URL, to restrict to requests made by Francis Irving. + <li><strong>type:</strong> with value InfoRequest, OutgoingMessage, IncomingMessage, PubicBody or User to select type of thing being searched for <li>Read about <a href="http://lucene.apache.org/java/docs/queryparsersyntax.html">advanced search operators</a>, such as fuzziness and proximity. </ul> + + <table class="status_table"> + <tr><td><strong>status:waiting_response</strong></td><td> Waiting for the public body to reply </td></tr> + <tr><td><strong>status:waiting_response_overdue</strong></td><td> Waiting for the public body to reply, they are late </td></tr> + <tr><td><strong>status:not_held</strong></td><td> The public body does not have the information requested </td></tr> + <tr><td><strong>status:rejected</strong></td><td> The request was rejected by the public body </td></tr> + <tr><td><strong>status:partially_successful</strong></td><td> Some of the information requested has been received </td></tr> + <tr><td><strong>status:successful</strong></td><td> All of the information requested has been received </td></tr> + <tr><td><strong>status:waiting_clarification</strong></td><td> The public body would like part of the request explained </td></tr> + <tr><td><strong>status:waiting_classification</strong></td><td> A new response has arrived, but it hasn't been categorised yet </td></tr> + <tr><td><strong>status:requires_admin</strong></td><td> A strange reponse, required attention by the WhatDoTheyKnow team </td></tr> + </table> <% end %> diff --git a/app/views/user/show.rhtml b/app/views/user/show.rhtml index 367bf88d4..3585f345f 100644 --- a/app/views/user/show.rhtml +++ b/app/views/user/show.rhtml @@ -1,7 +1,7 @@ <% @title = h(@display_user.name) + (@is_you ? " (you)" : "") %> <% if (@same_name_users.size >= 1) %> - <p>This is <strong>one person</strong> who uses this site and has this name, you may + <p>This is <strong>just one person</strong> who uses this site and has this name, you may mean a different one: <% for @same_name_user in @same_name_users %> <%= user_link(@same_name_user) %> diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css index e2eafb173..b32aa27ba 100644 --- a/public/stylesheets/main.css +++ b/public/stylesheets/main.css @@ -385,6 +385,13 @@ table#list_requests .odd { color: #ff0000; } +.status_table { + border-collapse: collapse; + border: solid 1px #000000; +} +.status_table td { + border: solid 1px #000000; +} /* /body - listing bodies */ @@ -1,6 +1,8 @@ -Search: +CVS commit: + +Fix up url names for info requests and users so don't end in _ -Gah - test to see if it queries solr when new message arrives +Search: Search for successful requests now has bogus date order :( Doesn't fit in with paradigm of request / incoming message being separate objects. @@ -46,6 +48,8 @@ Now of course when ids go into requests/users for new ones it just adds an _ on Later ===== +Offer search on 404s + RDAs need their short names somehow in CSV import? Send email to remind people to clarify diff --git a/vendor/plugins/acts_as_solr/lib/parser_methods.rb b/vendor/plugins/acts_as_solr/lib/parser_methods.rb index 0f1288039..2a5223332 100644 --- a/vendor/plugins/acts_as_solr/lib/parser_methods.rb +++ b/vendor/plugins/acts_as_solr/lib/parser_methods.rb @@ -166,7 +166,7 @@ module ActsAsSolr #:nodoc: field_type = get_solr_field_type(:text) if solr_field.is_a?(Hash) solr_field.each do |name,value| - if value.respond_to?(:each_pair) + if value.respond_to?(:each_pair) field_type = get_solr_field_type(value[:type]) if value[:type] else field_type = get_solr_field_type(value) |