mysociety / whatdotheyknow-theme

The Alaveteli theme for WhatDoTheyKnow (UK)
http://www.whatdotheyknow.com/
MIT License
31 stars 26 forks source link

Tone down public note on BIDS #1136

Closed RichardTaylor closed 2 years ago

RichardTaylor commented 2 years ago

This body may not be subject to Freedom of Information law, we list it here because it has the power to raise and spend taxes.

to

This body may not be subject to Freedom of Information law, we list it here because it is funded via business rates.

(The power to raise tax is subject to a referendum of business rate payers, and subject to a veto by the relevant local council)

RichardTaylor commented 2 years ago

Features which would make it easier to make this kind of edit:

At the moment I'd need to download the whole CSV, and write either a script or spreadsheet formula to identify relevant rows/bodies, make the edit, create a new CSV and re-upload.

Care would need to be taken not to overwrite any non-standard notes fields which had previously been tweaked/customised.

garethrees commented 2 years ago

Will do after https://github.com/mysociety/whatdotheyknow-theme/issues/1125 so that I can also link to it from the updated notes.

garethrees commented 2 years ago

https://github.com/mysociety/whatdotheyknow-theme/issues/1125 is done so we can do this now.

garethrees commented 2 years ago
PREVIOUS_LINE = %q(This body may not be subject to Freedom of Information law, 
  we list it here because it has the power to raise and spend taxes.).squish

UPDATED_LINE = %q(
  This body may not be subject to Freedom of Information law.
  We list it here
  <a href="https://www.mysociety.org/2022/04/27/business-improvement-districts-on-whatdotheyknow/" title="Business Improvement Districts on WhatDoTheyKnow">
  because it is funded via business rates
  </a>.
).squish

editor = User.find(60565) # me

PublicBody.with_tag('bid').each do |body|
  next unless body.notes =~ Regexp.new(PREVIOUS_LINE)
  body.last_edit_comment = %q(Automated update to tone down BID notes (https://github.com/mysociety/whatdotheyknow-theme/issues/1136).)
  body.last_edit_editor = editor.url_name
  body.notes = body.notes.gsub(PREVIOUS_LINE, UPDATED_LINE)
  body.save!
end
garethrees commented 2 years ago

Done, but ugh, had to make another edit to remove the spaces added to the link caused by squishing the string together:

PREVIOUS_LINE = %q(<a href="https://www.mysociety.org/2022/04/27/business-improvement-districts-on-whatdotheyknow/" title="Business Improvement Districts on WhatDoTheyKnow"> because it is funded via business rates </a>.)
UPDATED_LINE = %q(<a href="https://www.mysociety.org/2022/04/27/business-improvement-districts-on-whatdotheyknow/" title="Business Improvement Districts on WhatDoTheyKnow">because it is funded via business rates</a>.)

editor = User.find(60565) # me

PublicBody.with_tag('bid').each do |body|
  next unless body.notes =~ Regexp.new(PREVIOUS_LINE)
  body.last_edit_comment = %q(Fix spaces in notes URL)
  body.last_edit_editor = editor.url_name
  body.notes = body.notes.gsub(PREVIOUS_LINE, UPDATED_LINE)
  body.save!
end
garethrees commented 2 years ago

I've had a quick check through all the BIDs and they all have the link to the blog. I've manually scanned through a few there's been additional notes and looks like it's been inserted without any issue. One body didn't have notes, so I added them.

# Count of bids that *don't* include part of the blog URL
PublicBody.with_tag('bid').reject { |body| body.notes.include?('2022/04/27') }.size
# => 0