diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/info_request_event.rb | 4 | ||||
-rw-r--r-- | app/models/public_body.rb | 111 | ||||
-rw-r--r-- | app/models/track_thing.rb | 4 | ||||
-rw-r--r-- | app/views/help/about.rhtml | 8 | ||||
-rw-r--r-- | app/views/request/new.rhtml | 2 | ||||
-rw-r--r-- | app/views/request/preview.rhtml | 11 |
6 files changed, 85 insertions, 55 deletions
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 7682aff11..6e8ce0231 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -18,7 +18,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: info_request_event.rb,v 1.34 2008-04-04 01:44:41 francis Exp $ +# $Id: info_request_event.rb,v 1.35 2008-04-09 16:53:59 francis Exp $ class InfoRequestEvent < ActiveRecord::Base belongs_to :info_request @@ -152,7 +152,7 @@ class InfoRequestEvent < ActiveRecord::Base elsif status == 'not_held' "Information not held" elsif status == 'rejected' - "Rejection by" + "Rejection" elsif status == 'partially_successful' "Some information sent" elsif status == 'successful' diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 178b6f23b..68129d051 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.53 2008-04-09 02:51:46 francis Exp $ +# $Id: public_body.rb,v 1.54 2008-04-09 16:53:59 francis Exp $ require 'csv' require 'set' @@ -145,62 +145,85 @@ class PublicBody < ActiveRecord::Base end end - # Import from CSV - def self.import_csv(csv, tag) - ActiveRecord::Base.transaction do - existing_bodies = PublicBody.find_by_tag(tag) - - bodies_by_name = {} - set_of_existing = Set.new() - for existing_body in existing_bodies - bodies_by_name[existing_body.name] = existing_body - set_of_existing.add(existing_body.name) - end + class ImportCSVDryRun < StandardError + end - set_of_importing = Set.new() - CSV::Reader.parse(csv) do |row| - name = row[1] - email = row[2] - next if name.nil? - #or email.nil? - if email.nil? - email = '' # unknown/bad contact is empty string + # Import from CSV + def self.import_csv(csv, tag, dry_run = false) + errors = [] + notes = [] + + begin + ActiveRecord::Base.transaction do + existing_bodies = PublicBody.find_by_tag(tag) + + bodies_by_name = {} + set_of_existing = Set.new() + for existing_body in existing_bodies + bodies_by_name[existing_body.name] = existing_body + set_of_existing.add(existing_body.name) end - name.strip! - email.strip! + set_of_importing = Set.new() + line = 0 + CSV::Reader.parse(csv) do |row| + line = line + 1 + + name = row[1] + email = row[2] + next if name.nil? + #or email.nil? + if email.nil? + email = '' # unknown/bad contact is empty string + end - if email != "" && !MySociety::Validate.is_valid_email(email) - raise "invalid email:" + name + " " + email - end + name.strip! + email.strip! - if bodies_by_name[name] - # Already have the public body, just update email - public_body = bodies_by_name[name] - if public_body.request_email != email - public_body.request_email = email - public_body.last_edit_editor = 'import_csv' - public_body.last_edit_comment = 'Updated from spreadsheet' - public_body.save + if email != "" && !MySociety::Validate.is_valid_email(email) + errors.push "error: line " + line.to_s + ": invalid email " + email + " for authority '" + name + "'" + next end - else - # New public body - public_body = PublicBody.new(:name => name, :request_email => email, :short_name => "", :last_edit_editor => "import_csv", :last_edit_comment => 'Created from spreadsheet') - public_body.tag_string = tag - public_body.save! + if bodies_by_name[name] + # Already have the public body, just update email + public_body = bodies_by_name[name] + if public_body.request_email != email + notes.push "line " + line.to_s + ": updating email for '" + name + "' from " + public_body.request_email + " to " + email + public_body.request_email = email + public_body.last_edit_editor = 'import_csv' + public_body.last_edit_comment = 'Updated from spreadsheet' + public_body.save! + end + else + # New public body + notes.push "line " + line.to_s + ": new authority '" + name + "' with email " + email + public_body = PublicBody.new(:name => name, :request_email => email, :short_name => "", :last_edit_editor => "import_csv", :last_edit_comment => 'Created from spreadsheet') + public_body.tag_string = tag + public_body.save! + end + + set_of_importing.add(name) end - set_of_importing.add(name) - end + # Give an error listing ones that are to be deleted + deleted_ones = set_of_existing - set_of_importing + if deleted_ones.size > 0 + errors.push "error: Some " + tag + " bodies are in database, but not in CSV file: " + Array(deleted_ones).join(", ") + end - # Give an error listing ones that are to be deleted - deleted_ones = set_of_existing - set_of_importing - if deleted_ones.size > 0 - raise "Some " + tag + " bodies are in database, but not in CSV file:\n" + Array(deleted_ones).join(", ") + # Rollback if a dry run, or we had errors + if dry_run or errors.size > 0 + raise ImportCSVDryRun + end end + rescue ImportCSVDryRun + # Ignore end + + return errors.join("\n") + notes.join("\n") end + end diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb index 2ee494b9d..71ecedb82 100644 --- a/app/models/track_thing.rb +++ b/app/models/track_thing.rb @@ -21,7 +21,7 @@ # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: track_thing.rb,v 1.8 2008-04-09 01:32:53 francis Exp $ +# $Id: track_thing.rb,v 1.9 2008-04-09 16:53:59 francis Exp $ class TrackThing < ActiveRecord::Base belongs_to :tracking_user, :class_name => 'User' @@ -62,7 +62,7 @@ class TrackThing < ActiveRecord::Base :list_description => "'<a href=\"/request/" + CGI.escapeHTML(self.info_request.url_title) + "\">" + CGI.escapeHTML(self.info_request.title) + "</a>', a request", # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how # Email :title_in_email => "New updates for the request '" + self.info_request.title + "'", - :title_in_rss => "New updates for the request '" + CGI.escapeHTML(self.info_request.title) + "'", + :title_in_rss => "New updates for the request '" + self.info_request.title + "'", # Authentication :web => "To follow updates to the request '" + CGI.escapeHTML(self.info_request.title) + "'", :email => "Then you will be emailed whenever the request '" + CGI.escapeHTML(self.info_request.title) + "' is updated.", diff --git a/app/views/help/about.rhtml b/app/views/help/about.rhtml index 1f4e1df13..377703620 100644 --- a/app/views/help/about.rhtml +++ b/app/views/help/about.rhtml @@ -76,7 +76,7 @@ pages on the Information Commisioner's website. <dt id="data_protection">Can I request information about myself?</dt> -<dd>No. Requests made using WhatDoTheyKnow are public, made under the +<dd>Not using this site. Requests made using WhatDoTheyKnow are public, made under the Freedom of Information Act, and cannot help you find information about a private individual. If you would like to know what information a public authority holds about yourself, you should make a "Subject Access Request" in @@ -96,7 +96,7 @@ you manage FOI requests in secret, then <a href="/help/contact">contact us</a>. </dl> -<h1 id="privacy">Privacy Questions</h1> +<h1 id="privacy">Privacy policy</h1> <dl> @@ -115,14 +115,14 @@ about the site or related mySociety services. We will never give or sell your email addresses to anyone else, unless we are obliged to by law, or you ask us to.</dd> -<dt>Why will my name appear publically on the site?</dt> +<dt id="public_request">Why will my name appear publically on the site?</dt> <dd>It means that someone researching the same area can get in touch with you, and maybe give you more information or ideas relating to your request. Also, we're going to publish the response with the name of the civil servant who wrote it, so it seems only fair that your name should be public too! Therefore, we encourage you to use your real name, but you may use a pseudonym -if you would like to be anonymous. +if you would like to be anonymous. </dd> <dt id="tracking">Why does the list of things that I'm tracking appear publically on the site?</dt> diff --git a/app/views/request/new.rhtml b/app/views/request/new.rhtml index 5d2b85ddb..d36f1142a 100644 --- a/app/views/request/new.rhtml +++ b/app/views/request/new.rhtml @@ -72,7 +72,7 @@ </p> <p class="form_note"> - <Strong>Can I request information about myself?</strong> + <strong>Can I request information about myself?</strong> <a href="/help/about#data_protection">No! (Click here for details)</a> </p> diff --git a/app/views/request/preview.rhtml b/app/views/request/preview.rhtml index ef12f89ce..bac3a0a64 100644 --- a/app/views/request/preview.rhtml +++ b/app/views/request/preview.rhtml @@ -2,7 +2,14 @@ <% form_for(:info_request, @info_request, :html => { :id => 'preview_form' } ) do |f| %> + <h1>Now preview your request</h1> + <ul> + <li>Check you haven't included any <strong>personal information</strong>.</li> + <li>Your name, request and any responses will appear in <strong>search engines</strong> + (<a href="/help/about#public_request">details</a>). + </li> + </ul> <% fields_for :outgoing_message do |o| %> <p class="outgoing_message_preview"> @@ -14,8 +21,8 @@ </p> <% end %> - <p><strong>Note:</strong> Your request and any response will be - displayed publically on this website.</p> + <p><strong>Privacy note:</strong> If you want to request private information about + yourself then <a href="/help/about#data_protection">click here</a>. <p> <%= f.hidden_field(:title) %> |