aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/info_request.rb
Commit message (Collapse)AuthorAgeLines
* Move special case to whatdotheyknow-themeLouise Crow2013-10-04-8/+2
| | | | | Apart from anything else, we don't want translators to have to worry about the special case text. See https://github.com/mysociety/whatdotheyknow-theme/commit/2078febca5181ce3b1a9c0fae0123ae5f6448718 for the corresponding change to whatdotheyknow-theme.
* Merge branch 'hotfix/0.13.0.3' into rails-3-developLouise Crow2013-09-18-1/+11
|\
| * Restrict old_unclassified methods to normal prominence.0.13.0.3hotfix/0.13.0.3Louise Crow2013-09-18-1/+11
| | | | | | | | Fixes #1082.
* | Merge branch 'feature/hide-individual-responses' into rails-3-developLouise Crow2013-09-17-43/+90
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: Gemfile app/views/admin_request/edit_outgoing.html.erb config/packages doc/CHANGES.md doc/INSTALL.md spec/models/info_request_spec.rb spec/models/public_body_spec.rb
| * | Exclude hidden responses when calculating old_unclassifiedLouise Crow2013-09-16-4/+14
| | | | | | | | | | | | | | | Make old_unclassified_params method consistent with last_public_response_event and associated methods.
| * | Only include public messages in who_can_followup_toLouise Crow2013-09-16-0/+2
| | |
| * | Add public criteria for message event access methodsLouise Crow2013-09-16-16/+18
| | | | | | | | | | | | | | | | | | | | | get_last_response_event and get_last_outgoing_event are used in various places to determine which events to link to, use in queries etc. Restrict them to refer to the last publicly visible event of the relevant type, and rename them to make that clear.
| * | Hide hidden outgoing messages in download.Louise Crow2013-09-16-1/+3
| | |
| * | Move some download methods to InfoRequest.Louise Crow2013-09-16-0/+34
| | | | | | | | | | | | | | | | | | Use send_file to send zips. Also adds 'all_can_view_all_correspondence?' - is this request completely cachable, or do we need to cache different versions for different levels of privilege?
| * | Extract calculation of last update hashLouise Crow2013-09-16-0/+4
| | |
| * | Refactor common logic about prominence and access.Louise Crow2013-09-16-7/+1
| | | | | | | | | | | | Move it into the Ability module.
| * | Rename method to make it a bit more genericLouise Crow2013-09-16-3/+3
| | | | | | | | | | | | A super user will be able to see all hidden things, not just requests.
| * | Re-annotate models with database fieldsLouise Crow2013-09-16-16/+15
| | |
* | | Allow a unicode-only title in validationLouise Crow2013-09-17-1/+5
| | |
* | | Save cached columns once updated.Louise Crow2013-09-05-0/+6
| | |
* | | Improve calculation of PublicBody statistics columnsMark Longair2013-08-20-0/+11
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | On PublicBody, we don't need to update info_requests_count because that's already done with :counter_cache. On the other hand, info_requests_successful_count and info_requests_not_held_count can't be updated easily with counter_cache (since they need conditions to be attached). Instead we update them in post_save and post_destroy, as suggested here: http://blog.douglasfshearer.com/post/17495285851/custom-counter-cache-with-conditions This also adds tests to ensure that the after_(save|destroy) callbacks are called and that they modify the counts correctly.
* | Comments on described_state and calculated_stateLouise Crow2013-08-15-3/+20
| | | | | | | | | | | | Add some notes on the logic and expectations around InfoRequest.described_state and calculate_status and InfoRequestEvent.described_state and calculated_state.
* | Make admin edits affect info_request_event described_states.Louise Crow2013-08-15-3/+4
| | | | | | | | | | | | | | Make sure that admin edits changing the described state of an info request are reflected in the latest_status and status values of info request events so that the info requests are retrieved correctly in status-based searches.
* | Allow 'edit' and 'status_update' calculated states to propagate.Louise Crow2013-08-15-4/+16
|/ | | | | | | | Update test expectations and add further test to explicitly show that we want the described status from a status update to be propagated to a preceding response, as well as being filled in in the status update itself (which is mostly to deal with the case where there isn't a preceding response). Make those changes to calculate_event_states
* Merge remote-tracking branch ↵Louise Crow2013-07-23-11/+1
|\ | | | | | | | | | | | | 'openaustralia_github/tests_set_described_state' into rails-3-develop Conflicts: spec/models/info_request_spec.rb
| * Now record a state_update event *whenever* a user classifies a requestMatthew Landauer2013-04-20-10/+0
| |
| * How we would handle event states if we added a state_update event whenever a ↵Matthew Landauer2013-04-20-1/+1
| | | | | | | | user classifies a request
| * Simple solution to bugs shown up in tests in last 2 commitsMatthew Landauer2013-04-18-1/+1
| |
* | Merge branch 'hotfix/0.11.0.7' into rails-3-developLouise Crow2013-06-10-1/+1
|\ \ | | | | | | | | | | | | Conflicts: spec/models/info_request_spec.rb
| * | Cope with replying to a message with a missing or empty SubjectMark Longair2013-06-07-1/+1
| | | | | | | | | | | | | | | | | | Conflicts: spec/models/info_request_spec.rb
* | | Handle request for json for an external request. Closes #973.Louise Crow2013-06-07-0/+4
| | |
* | | Merge remote-tracking branch ↵Louise Crow2013-06-04-0/+15
|\ \ \ | | | | | | | | | | | | 'openaustralia_github/more_info_on_report_request' into rails-3-develop
| * | | Reasons that request can be reported now stored in modelMatthew Landauer2013-03-22-0/+6
| | | |
| * | | Wrap in a transactionMatthew Landauer2013-03-22-3/+5
| | | |
| * | | Extract methodMatthew Landauer2013-03-22-0/+7
| | |/ | |/|
* | | Merge remote-tracking branch ↵Louise Crow2013-06-04-26/+0
|\ \ \ | | | | | | | | | | | | 'openaustralia_github/inline_search_method_refactor' into rails-3-develop
| * | | Remove unused methodMatthew Landauer2013-03-25-11/+0
| | | |
| * | | Inline method InfoRequest.full_searchMatthew Landauer2013-03-25-15/+0
| |/ /
* | | Merge remote-tracking branch ↵Louise Crow2013-06-04-19/+4
|\ \ \ | | | | | | | | | | | | 'openaustralia_github/small_email_hash_refactor' into rails-3-develop
| * | | Inline method and simplify logicMatthew Landauer2013-03-29-19/+4
| |/ /
* | | Merge remote-tracking branch ↵Louise Crow2013-05-30-19/+0
|\ \ \ | |_|/ |/| | | | | 'openaustralia_github/remove_random_request_action' into rails-3-develop
| * | Remove apparently unused action for showing random requestMatthew Landauer2013-03-22-19/+0
| |/
* | Merge branch 'release/0.9' into rails-3-developLouise Crow2013-04-24-0/+11
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: Gemfile.lock app/controllers/public_body_controller.rb app/mailers/track_mailer.rb app/views/request/_hidden_correspondence.html.erb app/views/request/_sidebar.html.erb app/views/request/hidden.html.erb app/views/request/new_please_describe.html.erb app/views/request/preview.html.erb app/views/user/show.html.erb config/environment.rb config/routes.rb spec/controllers/public_body_controller_spec.rb
| * Fix the deadlock on dealing with incoming emailMark Longair2013-04-18-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #336 There was an occasional deadlock when two emails for the same request came in near-simultaneously; two processes would be started via script/mailin, each to deal with one email which are both updating the same InfoRequest. The error would look like: 2013-04-07 09:19:03 BST [13398]: [2-1] DETAIL: Process 13398 waits for ShareLock on transaction 36193647; blocked by process 13397. Process 13397 waits for ExclusiveLock on tuple (390,35) of relation 32918788 of database 32918687; blocked by process 13398. Process 13398: UPDATE "info_requests" SET "updated_at" = '2013-04-07 08:19:02.139515', "awaiting_description" = 't' WHERE "id" = 156200 Process 13397: UPDATE "info_requests" SET "updated_at" = '2013-04-07 08:19:02.143624', "awaiting_description" = 't' WHERE "id" = 156200 This arose from the following section of code: ActiveRecord::Base.transaction do raw_email = RawEmail.new incoming_message.raw_email = raw_email incoming_message.info_request = self incoming_message.save! raw_email.data = raw_email_data raw_email.save! self.awaiting_description = true params = { :incoming_message_id => incoming_message.id } if !rejected_reason.empty? params[:rejected_reason] = rejected_reason.to_str end self.log_event("response", params) self.save! end Matthew Somerville explained what was happening here in the issue report; to repeat his explanation from the bug report, both processes enter the transaction block and acquire a ShareLock on self with: incoming_message.info_request = self incoming_message.save! However, in order to update the self.awaiting_description field of the InfoRequest, with: self.awaiting_description = true [...] self.save! ... the ShareLock needs to be upgraded to an ExclusiveLock, but both will wait until the other's ShareLock is released, which would only happen at the end of the transaction. We can avoid this deadlock by using SELECT ... FOR UPDATE for the row in info_requests. In Rails 3.2.0 there is ActiveRecord support for this (via with_lock and lock! on a model instance) but so as not to require upgrading rails, I'm just using raw SQL.
* | Fix up some merge action from f60ada47d4e7aabe0dce152109cb0d91865929daHenare Degan2013-03-15-1/+1
| |
* | Merge remote-tracking branch 'mysociety/develop' into rails-3-developHenare Degan2013-03-14-76/+80
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: Gemfile Gemfile.lock app/controllers/admin_request_controller.rb app/controllers/admin_track_controller.rb app/controllers/request_controller.rb app/controllers/services_controller.rb app/helpers/link_to_helper.rb app/mailers/request_mailer.rb app/models/application_mailer.rb app/models/info_request.rb app/views/admin_censor_rule/edit.html.erb app/views/admin_censor_rule/new.html.erb app/views/admin_public_body/_form.html.erb app/views/admin_public_body/_locale_selector.html.erb app/views/admin_public_body/_one_list.html.erb app/views/admin_public_body/edit.html.erb app/views/admin_public_body/list.html.erb app/views/admin_public_body/new.html.erb app/views/admin_request/_incoming_message_actions.html.erb app/views/admin_request/edit.html.erb app/views/admin_request/edit_comment.html.erb app/views/admin_request/edit_outgoing.html.erb app/views/admin_request/list.html.erb app/views/admin_request/list_old_unclassified.html.erb app/views/admin_request/show.html.erb app/views/admin_track/_some_tracks.html.erb app/views/admin_track/list.html.erb app/views/admin_user/edit.html.erb app/views/admin_user/list.html.erb app/views/admin_user/show.html.erb app/views/general/_footer.html.erb app/views/general/exception_caught.html.erb app/views/help/contact.html.erb app/views/layouts/default.html.erb app/views/public_body/_alphabet.html.erb app/views/request/_request_listing_single.html.erb app/views/request/_sidebar.html.erb app/views/request/new.html.erb app/views/request/show.html.erb app/views/request_mailer/external_response.rhtml app/views/request_mailer/fake_response.rhtml config/environment.rb config/environments/production.rb config/routes.rb spec/controllers/admin_censor_rule_controller_spec.rb spec/controllers/request_controller_spec.rb spec/controllers/track_controller_spec.rb spec/helpers/link_to_helper_spec.rb spec/mailers/request_mailer_spec.rb spec/models/info_request_spec.rb spec/spec_helper.rb spec/views/public_body/show.html.erb_spec.rb spec/views/request/show.html.erb_spec.rb vendor/plugins/rails_xss/lib/rails_xss/erubis.rb
| * Refactor functionality from controller to modelMatthew Landauer2013-03-04-0/+15
| |
| * When setting a state optionally pass a messsageMatthew Landauer2013-03-02-2/+2
| |
| * Simplify method by using array to store mappingMatthew Landauer2013-03-02-39/+24
| |
| * InfoRequestEvent should know about its event typesMatthew Landauer2013-03-02-2/+2
| |
| * Extract methodMatthew Landauer2013-03-02-6/+5
| |
| * Simplify methodsMatthew Landauer2013-03-02-19/+7
| |
| * Simplify logic in methodMatthew Landauer2013-03-02-7/+2
| |
| * Inline methodMatthew Landauer2013-03-02-11/+1
| |
| * Inline methodMatthew Landauer2013-03-02-6/+1
| |