aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
Commit message (Collapse)AuthorAgeLines
* InfoRequest#initial_request_text performanceGareth Rees2015-05-12-3/+9
| | | | | | | | Passes the InfoRequest's CensorRules directly to the OutgoingMessage. user system total real old 0.010000 0.010000 0.020000 ( 0.020827) new 0.010000 0.000000 0.010000 ( 0.016633)
* Allow optional censor rules to be passed to #bodyGareth Rees2015-05-12-5/+15
| | | | | | | If we’re in the context of an InfoRequest and want the OutgoingMessage#body, we can pass the rules in explicitly to avoid looking up the info request again. Otherwise it falls back to the existing behaviour.
* Add a non-mutating #apply_to_textGareth Rees2015-05-12-0/+5
| | | | | | Still need to `return nil if text_to_censor.nil?` because `gsub!` returns `nil` rather than the original text if it does not make a substitution.
* Use #raw_body sugar methodGareth Rees2015-05-12-1/+1
|
* Extract text cleaning from #body methodGareth Rees2015-05-12-9/+10
|
* InfoRequest#initial_request_text minor improvementGareth Rees2015-05-12-2/+1
| | | | | | system total real old 0.810000 0.300000 1.110000 ( 1.358172) new 0.970000 0.090000 1.060000 ( 1.292340)
* Merge branch 'version-dependent-caching' into rails-3-developLouise Crow2015-05-07-2/+12
|\
| * Force the encoding of values returned from YAML.Louise Crow2015-05-07-2/+12
| | | | | | | | | | | | | | | | | | This is a workaround for an issue where YAML in ruby 1.8 tags UTF-8 heavy strings as binary, resulting in them being retrieved under 1.9 as ASCII-8BIT which can't be concatenated with UTF-8. Described as "Deep deep YAML oddness" in https://www.zendesk.com/blog/upgrade-the-road-to-1-9/.
* | Minor tidy upGareth Rees2015-05-07-11/+8
| | | | | | | | | | | | | | Remove explicit returns Remove self Ternary for short conditional Moved #site_administration? to be nearer similar methods
* | Don't load PublicBody when initalizing InfoRequestGareth Rees2015-05-07-1/+2
| | | | | | | | | | Doesn't need to try to set the default law_used once it's persisted, so we save a query each time we find an InfoRequest
* | Add InfoRequest#move_to_public_bodyGareth Rees2015-05-07-0/+24
|/
* Merge branch 'hotfix/0.21.0.24' into rails-3-developGareth Rees2015-04-30-4/+8
|\
| * Rescue from Holidays::UnknownRegionErrorhotfix/0.21.0.24Gareth Rees2015-04-29-4/+8
| | | | | | | | | | If you run an Alaveteli in a region where we can’t show holiday suggestions the holiday import page breaks. This commit rescues from an unavailable region so that we display a friendly error message.
* | Merge branch 'add-widget' into rails-3-developLouise Crow2015-04-28-0/+20
|\ \
| * | Validate the uniqueness of cookies within the scope of info requests.Louise Crow2015-04-27-0/+1
| | |
| * | Add model to track "votes" for a requestJody McIntyre2015-04-27-0/+19
| | |
* | | Merge branch 'hotfix/0.21.0.23' into rails-3-developGareth Rees2015-04-27-6/+3
|\ \ \ | | |/ | |/|
| * | Tidy InfoRequest#initial_request_textGareth Rees2015-04-27-5/+2
| | |
| * | Only load the outgoing messages that will be usedGareth Rees2015-04-27-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prevents loading of all outgoing messages related to the info request. Before OutgoingMessage Load (1.5ms) SELECT "outgoing_messages".* FROM "outgoing_messages" WHERE "outgoing_messages"."info_request_id" = 137 ORDER BY created_at After OutgoingMessage Load (0.8ms) SELECT "outgoing_messages".* FROM "outgoing_messages" WHERE "outgoing_messages"."info_request_id" = 137 ORDER BY created_at LIMIT 1
| * | Improve performance initializing OutgoingMessageGareth Rees2015-04-27-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reduces the amount of queries to associated objects by directly checking the database before setting the default body content. Before > info_request.outgoing_messages OutgoingMessage Load (0.4ms) SELECT "outgoing_messages".* FROM "outgoing_messages" WHERE "outgoing_messages"."info_request_id" = 137 ORDER BY created_at InfoRequest Load (0.5ms) SELECT "info_requests".* FROM "info_requests" WHERE "info_requests"."id" = 137 LIMIT 1 PublicBody Load (0.5ms) SELECT "public_bodies".* FROM "public_bodies" WHERE "public_bodies"."id" = 16 LIMIT 1 HasTagString::HasTagStringTag Load (0.4ms) SELECT "has_tag_string_tags".* FROM "has_tag_string_tags" WHERE "has_tag_string_tags"."model_id" = 16 AND (model = 'PublicBody') CensorRule Load (0.4ms) SELECT "censor_rules".* FROM "censor_rules" WHERE "censor_rules"."info_request_id" IS NULL AND "censor_rules"."public_body_id" IS NULL AND "censor_rules"."user_id" IS NULL User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = 13 LIMIT 1 (0.5ms) SELECT COUNT(*) FROM "censor_rules" WHERE "censor_rules"."user_id" = 13 CensorRule Load (0.5ms) SELECT "censor_rules".* FROM "censor_rules" WHERE "censor_rules"."info_request_id" = 137 ORDER BY created_at desc CensorRule Load (0.5ms) SELECT "censor_rules".* FROM "censor_rules" WHERE "censor_rules"."public_body_id" = 16 ORDER BY created_at desc InfoRequest Load (0.5ms) SELECT "info_requests".* FROM "info_requests" WHERE "info_requests"."id" = 137 LIMIT 1 PublicBody Load (0.5ms) SELECT "public_bodies".* FROM "public_bodies" WHERE "public_bodies"."id" = 16 LIMIT 1 HasTagString::HasTagStringTag Load (0.6ms) SELECT "has_tag_string_tags".* FROM "has_tag_string_tags" WHERE "has_tag_string_tags"."model_id" = 16 AND (model = 'PublicBody') CensorRule Load (0.5ms) SELECT "censor_rules".* FROM "censor_rules" WHERE "censor_rules"."info_request_id" IS NULL AND "censor_rules"."public_body_id" IS NULL AND "censor_rules"."user_id" IS NULL User Load (0.6ms) SELECT "users".* FROM "users" WHERE "users"."id" = 13 LIMIT 1 (0.5ms) SELECT COUNT(*) FROM "censor_rules" WHERE "censor_rules"."user_id" = 13 CensorRule Load (0.4ms) SELECT "censor_rules".* FROM "censor_rules" WHERE "censor_rules"."info_request_id" = 137 ORDER BY created_at desc CensorRule Load (0.5ms) SELECT "censor_rules".* FROM "censor_rules" WHERE "censor_rules"."public_body_id" = 16 ORDER BY created_at desc => [#<OutgoingMessage id: 36, info_request_id: 137, body: "Some information please", status: "sent", message_type: "initial_request", created_at: "2015-04-17 10:50:21", updated_at: "2015-04-17 10:50:21", last_sent_at: "2015-04-17 10:50:21", incoming_message_followup_id: nil, what_doing: "normal_sort", prominence: "normal", prominence_reason: nil>, #<OutgoingMessage id: 37, info_request_id: 137, body: "Dear Example Public Body 6,\r\n\r\nc'mooooooonnnnnn\r\n\r\n...", status: "sent", message_type: "followup", created_at: "2015-04-20 12:18:30", updated_at: "2015-04-20 12:18:30", last_sent_at: "2015-04-20 12:18:30", incoming_message_followup_id: 30, what_doing: "normal_sort", prominence: "normal", prominence_reason: nil>] After > info_request.outgoing_messages OutgoingMessage Load (0.8ms) SELECT "outgoing_messages".* FROM "outgoing_messages" WHERE "outgoing_messages"."info_request_id" = 137 ORDER BY created_at => [#<OutgoingMessage id: 36, info_request_id: 137, body: "Some information please", status: "sent", message_type: "initial_request", created_at: "2015-04-17 10:50:21", updated_at: "2015-04-17 10:50:21", last_sent_at: "2015-04-17 10:50:21", incoming_message_followup_id: nil, what_doing: "normal_sort", prominence: "normal", prominence_reason: nil>, #<OutgoingMessage id: 37, info_request_id: 137, body: "Dear Example Public Body 6,\r\n\r\nc'mooooooonnnnnn\r\n\r\n...", status: "sent", message_type: "followup", created_at: "2015-04-20 12:18:30", updated_at: "2015-04-20 12:18:30", last_sent_at: "2015-04-20 12:18:30", incoming_message_followup_id: 30, what_doing: "normal_sort", prominence: "normal", prominence_reason: nil>]
* | | Merge branch 'request-classification-association' into rails-3-developGareth Rees2015-04-27-0/+1
|\ \ \ | |_|/ |/| |
| * | Add RequestClassification association to UserGareth Rees2015-04-22-0/+1
| | | | | | | | | | | | Both ends of the association should be defined
* | | Change PublicBody behaviour to not override blank request emailsHenare Degan2015-04-21-1/+1
| | | | | | | | | | | | | | | This is so if you're overriding the request email you can still observe how Alaveteli behaves when there's no request email set.
* | | Remove unnecessary methodHenare Degan2015-04-21-9/+3
|/ /
* | Merge branch 'issues/556-info_request_destroy' into rails-3-developLouise Crow2015-04-16-7/+10
|\ \
| * | Destroy associated censor rules and comments.Louise Crow2015-04-13-0/+3
| | |
| * | Remove unneeded references to self.Louise Crow2015-04-13-7/+7
| |/
* | Make method more conciseHenare Degan2015-04-11-4/+1
| |
* | Use symbolic operator - only use "and" for control-flowHenare Degan2015-04-11-1/+1
| |
* | Check for blank values, not just an empty stringHenare Degan2015-04-11-1/+1
|/ | | | | | | | | | | | | On my machine the integration test "Editing a Public Body can add a translation for multiple locales" (http://git.io/vvv9t) was failing because when it submitted the form to update one locale it created empty records for all locales resulting in the test (http://git.io/vvv93) for a nil locale to fail. It was doing this because when it submitted the form it included a notes field with a single newline character and so this method evaluated as false and therefore a largely blank translation was created.
* Don't translate validation messages yet.Louise Crow2015-03-24-3/+3
| | | | | | They're only visible in the admin interface. See https://github.com/mysociety/alaveteli/issues/1353 for details.
* Fix translating Public Body HeadingsGareth Rees2015-03-18-18/+25
| | | | | Fixes submission of form containing both existing and new translations
* Fix translating Public Body CategoriesGareth Rees2015-03-18-17/+43
|
* Fix translating Public BodiesGareth Rees2015-03-18-28/+17
|
* Merge branch '59-localised-authority-links' into rails-3-developLouise Crow2015-03-05-29/+0
|\ | | | | | | | | Conflicts: app/views/public_body/show.html.erb
| * Use routing helper to generate localised urls.Louise Crow2015-03-05-25/+0
| |
| * Remove 'html' param.Louise Crow2015-03-05-7/+3
| | | | | | | | | | There's only one call to this function in the rest of the code. That has 'html' set to true.
* | Merge branch 'remove-public-body-categories' into rails-3-developLouise Crow2015-03-05-5/+0
|\ \
| * | Remove deprecated code. Fixes #2015.Louise Crow2015-02-26-5/+0
| |/
* / WIP commit of public body page redesignMartin Wright2015-03-02-2/+1
|/
* Merge branch 'rails-3-develop' of ↵Louise Crow2015-02-24-2/+10
|\ | | | | | | ssh://git.mysociety.org/data/git/public/alaveteli into rails-3-develop
| * Add User#banned?Gareth Rees2015-02-24-2/+10
| | | | | | | | | | | | | | - Redefined User#public_banned? to User#banned? - Add specs for User#banned? - Deprecate User#public_banned? - Replace use of User#public_banned? with User#banned?
* | Merge branch 'allow-custom-state-testing' into rails-3-developLouise Crow2015-02-24-5/+3
|\ \ | |/ |/|
| * Allow custom states to be tested.Louise Crow2015-02-09-5/+3
| | | | | | | | | | | | Since https://github.com/mysociety/alaveteli/commit/80ad2d4c31075ffc994e8c48ea25e6e3c486c364 no themes have been loaded by tests unless explicitly specified, so I think it's safe to remove the code added in https://github.com/mysociety/alaveteli/commit/3dfc53f6b82b3c5da79a4c710d45b859f61f4f5f
* | Merge branch '2134-fix-same-attribute-value-across-locales' into rails-3-developLouise Crow2015-02-23-80/+99
|\ \
| * | Refactor massive import method into smaller instance level methodsLouise Crow2015-02-23-89/+83
| | |
| * | Use standard spacing for hashes, new lines for commentsLouise Crow2015-02-23-2/+3
| | |
| * | Test localised value for import against existing localised valueLouise Crow2015-02-23-2/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously the call to public_body.send would return the value for the default locale if no value was set in the current locale, meaning that translations for attributes that were the same as the attribute values in the default locale were not being loaded. Fixes #2134.
* | | Move logic to modelLouise Crow2015-02-20-0/+5
| | |
* | | Use correct method name in error.Louise Crow2015-02-20-1/+1
| | |