aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin_censor_rule_controller.rb2
-rw-r--r--app/controllers/admin_controller.rb10
-rw-r--r--app/controllers/admin_general_controller.rb4
-rw-r--r--app/controllers/admin_public_body_controller.rb11
-rw-r--r--app/controllers/admin_request_controller.rb22
-rw-r--r--app/controllers/admin_track_controller.rb12
-rw-r--r--app/controllers/admin_user_controller.rb12
-rw-r--r--app/controllers/api_controller.rb13
-rw-r--r--app/controllers/application_controller.rb121
-rw-r--r--app/controllers/comment_controller.rb2
-rw-r--r--app/controllers/general_controller.rb45
-rw-r--r--app/controllers/help_controller.rb8
-rw-r--r--app/controllers/holiday_controller.rb4
-rw-r--r--app/controllers/public_body_controller.rb12
-rw-r--r--app/controllers/reports_controller.rb31
-rw-r--r--app/controllers/request_controller.rb156
-rw-r--r--app/controllers/request_game_controller.rb2
-rw-r--r--app/controllers/services_controller.rb6
-rw-r--r--app/controllers/track_controller.rb14
-rw-r--r--app/controllers/user_controller.rb43
-rw-r--r--app/helpers/application_helper.rb2
-rw-r--r--app/helpers/config_helper.rb4
-rwxr-xr-xapp/helpers/link_to_helper.rb12
-rw-r--r--app/helpers/mailer_helper.rb2
-rw-r--r--app/mailers/application_mailer.rb30
-rw-r--r--app/mailers/contact_mailer.rb45
-rw-r--r--app/mailers/outgoing_mailer.rb (renamed from app/models/outgoing_mailer.rb)32
-rw-r--r--app/mailers/request_mailer.rb (renamed from app/models/request_mailer.rb)228
-rw-r--r--app/mailers/track_mailer.rb (renamed from app/models/track_mailer.rb)37
-rw-r--r--app/mailers/user_mailer.rb44
-rw-r--r--app/models/about_me_validator.rb22
-rw-r--r--app/models/application_mailer.rb164
-rw-r--r--app/models/censor_rule.rb12
-rw-r--r--app/models/change_email_validator.rb38
-rw-r--r--app/models/comment.rb2
-rw-r--r--app/models/contact_mailer.rb56
-rw-r--r--app/models/contact_validator.rb34
-rw-r--r--app/models/foi_attachment.rb29
-rw-r--r--app/models/holiday.rb2
-rw-r--r--app/models/incoming_message.rb109
-rw-r--r--app/models/info_request.rb180
-rw-r--r--app/models/info_request_event.rb6
-rw-r--r--app/models/mail_server_log.rb12
-rw-r--r--app/models/mail_server_log_done.rb2
-rw-r--r--app/models/outgoing_message.rb43
-rw-r--r--app/models/post_redirect.rb28
-rw-r--r--app/models/profile_photo.rb39
-rw-r--r--app/models/public_body.rb12
-rw-r--r--app/models/purge_request.rb2
-rw-r--r--app/models/raw_email.rb6
-rw-r--r--app/models/track_thing.rb4
-rw-r--r--app/models/track_things_sent_email.rb2
-rw-r--r--app/models/user.rb48
-rw-r--r--app/models/user_info_request_sent_alert.rb2
-rw-r--r--app/models/user_mailer.rb48
-rw-r--r--app/views/admin_censor_rule/_form.html.erb (renamed from app/views/admin_censor_rule/_form.rhtml)0
-rw-r--r--app/views/admin_censor_rule/_show.html.erb (renamed from app/views/admin_censor_rule/_show.rhtml)0
-rw-r--r--app/views/admin_censor_rule/edit.html.erb (renamed from app/views/admin_censor_rule/edit.rhtml)4
-rw-r--r--app/views/admin_censor_rule/new.html.erb (renamed from app/views/admin_censor_rule/new.rhtml)2
-rw-r--r--app/views/admin_general/_admin_navbar.html.erb (renamed from app/views/admin_general/_admin_navbar.rhtml)0
-rw-r--r--app/views/admin_general/debug.html.erb (renamed from app/views/admin_general/debug.rhtml)7
-rw-r--r--app/views/admin_general/index.html.erb (renamed from app/views/admin_general/index.rhtml)0
-rw-r--r--app/views/admin_general/stats.html.erb (renamed from app/views/admin_general/stats.rhtml)0
-rw-r--r--app/views/admin_general/timeline.html.erb (renamed from app/views/admin_general/timeline.rhtml)0
-rw-r--r--app/views/admin_public_body/_form.html.erb (renamed from app/views/admin_public_body/_form.rhtml)5
-rw-r--r--app/views/admin_public_body/_one_list.html.erb (renamed from app/views/admin_public_body/_one_list.rhtml)2
-rw-r--r--app/views/admin_public_body/_tag_help.html.erb (renamed from app/views/admin_public_body/_tag_help.rhtml)0
-rw-r--r--app/views/admin_public_body/_tags.html.erb (renamed from app/views/admin_public_body/_tags.rhtml)0
-rw-r--r--app/views/admin_public_body/edit.html.erb (renamed from app/views/admin_public_body/edit.rhtml)4
-rw-r--r--app/views/admin_public_body/import_csv.html.erb (renamed from app/views/admin_public_body/import_csv.rhtml)2
-rw-r--r--app/views/admin_public_body/list.html.erb (renamed from app/views/admin_public_body/list.rhtml)3
-rw-r--r--app/views/admin_public_body/missing_scheme.html.erb (renamed from app/views/admin_public_body/missing_scheme.rhtml)0
-rw-r--r--app/views/admin_public_body/new.html.erb (renamed from app/views/admin_public_body/new.rhtml)2
-rw-r--r--app/views/admin_public_body/show.html.erb (renamed from app/views/admin_public_body/show.rhtml)3
-rw-r--r--app/views/admin_request/_incoming_message_actions.html.erb (renamed from app/views/admin_request/_incoming_message_actions.rhtml)4
-rw-r--r--app/views/admin_request/_some_requests.html.erb (renamed from app/views/admin_request/_some_requests.rhtml)0
-rw-r--r--app/views/admin_request/_tags.html.erb (renamed from app/views/admin_request/_tags.rhtml)0
-rw-r--r--app/views/admin_request/edit.html.erb (renamed from app/views/admin_request/edit.rhtml)4
-rw-r--r--app/views/admin_request/edit_comment.html.erb (renamed from app/views/admin_request/edit_comment.rhtml)2
-rw-r--r--app/views/admin_request/edit_outgoing.html.erb (renamed from app/views/admin_request/edit_outgoing.rhtml)4
-rw-r--r--app/views/admin_request/hidden_user_explanation.html.erb10
-rw-r--r--app/views/admin_request/hidden_user_explanation.rhtml10
-rw-r--r--app/views/admin_request/list.html.erb (renamed from app/views/admin_request/list.rhtml)2
-rw-r--r--app/views/admin_request/show.html.erb (renamed from app/views/admin_request/show.rhtml)16
-rw-r--r--app/views/admin_request/show_raw_email.html.erb (renamed from app/views/admin_request/show_raw_email.rhtml)0
-rw-r--r--app/views/admin_track/_some_tracks.html.erb (renamed from app/views/admin_track/_some_tracks.rhtml)4
-rw-r--r--app/views/admin_track/list.html.erb (renamed from app/views/admin_track/list.rhtml)2
-rw-r--r--app/views/admin_user/_form.html.erb (renamed from app/views/admin_user/_form.rhtml)0
-rw-r--r--app/views/admin_user/_user_table.html.erb (renamed from app/views/admin_user/_user_table.rhtml)0
-rw-r--r--app/views/admin_user/edit.html.erb (renamed from app/views/admin_user/edit.rhtml)2
-rw-r--r--app/views/admin_user/list.html.erb (renamed from app/views/admin_user/list.rhtml)2
-rw-r--r--app/views/admin_user/list_banned.html.erb (renamed from app/views/admin_user/list_banned.rhtml)0
-rw-r--r--app/views/admin_user/show.html.erb (renamed from app/views/admin_user/show.rhtml)6
-rw-r--r--app/views/admin_user/show_bounce_message.html.erb (renamed from app/views/admin_user/show_bounce_message.rhtml)0
-rw-r--r--app/views/comment/_comment_form.html.erb (renamed from app/views/comment/_comment_form.rhtml)2
-rw-r--r--app/views/comment/_single_comment.html.erb (renamed from app/views/comment/_single_comment.rhtml)0
-rw-r--r--app/views/comment/new.html.erb (renamed from app/views/comment/new.rhtml)0
-rw-r--r--app/views/comment/preview.html.erb (renamed from app/views/comment/preview.rhtml)2
-rw-r--r--app/views/contact_mailer/from_admin_message.text.erb (renamed from app/views/contact_mailer/from_admin_message.rhtml)0
-rw-r--r--app/views/contact_mailer/to_admin_message.text.erb (renamed from app/views/contact_mailer/to_admin_message.rhtml)0
-rw-r--r--app/views/contact_mailer/user_message.text.erb (renamed from app/views/contact_mailer/user_message.rhtml)0
-rw-r--r--app/views/general/_advanced_search_tips.html.erb (renamed from app/views/general/_advanced_search_tips.rhtml)0
-rw-r--r--app/views/general/_before_body_end.html.erb (renamed from app/views/general/_before_body_end.rhtml)0
-rw-r--r--app/views/general/_before_head_end.html.erb (renamed from app/views/general/_before_head_end.rhtml)0
-rw-r--r--app/views/general/_credits.html.erb (renamed from app/views/general/_credits.rhtml)0
-rw-r--r--app/views/general/_custom_state_descriptions.html.erb (renamed from app/views/general/_custom_state_descriptions.rhtml)0
-rw-r--r--app/views/general/_custom_state_transitions_complete.html.erb (renamed from app/views/general/_custom_state_transitions_complete.rhtml)0
-rw-r--r--app/views/general/_custom_state_transitions_pending.html.erb (renamed from app/views/general/_custom_state_transitions_pending.rhtml)0
-rw-r--r--app/views/general/_footer.html.erb (renamed from app/views/general/_footer.rhtml)2
-rw-r--r--app/views/general/_frontpage_bodies_list.html.erb (renamed from app/views/general/_frontpage_bodies_list.rhtml)0
-rw-r--r--app/views/general/_frontpage_intro_sentence.html.erb (renamed from app/views/general/_frontpage_intro_sentence.rhtml)0
-rw-r--r--app/views/general/_frontpage_new_request.html.erb (renamed from app/views/general/_frontpage_new_request.rhtml)0
-rw-r--r--app/views/general/_frontpage_requests_list.html.erb (renamed from app/views/general/_frontpage_requests_list.rhtml)0
-rw-r--r--app/views/general/_frontpage_search_box.html.erb (renamed from app/views/general/_frontpage_search_box.rhtml)0
-rw-r--r--app/views/general/_locale_switcher.html.erb (renamed from app/views/general/_locale_switcher.rhtml)2
-rw-r--r--app/views/general/_localised_datepicker.html.erb (renamed from app/views/general/_localised_datepicker.rhtml)0
-rw-r--r--app/views/general/_orglink.html.erb (renamed from app/views/general/_orglink.rhtml)0
-rw-r--r--app/views/general/_popup_banner.html.erb (renamed from app/views/general/_popup_banner.rhtml)0
-rw-r--r--app/views/general/_stylesheet_includes.html.erb (renamed from app/views/general/_stylesheet_includes.rhtml)7
-rw-r--r--app/views/general/_topnav.html.erb (renamed from app/views/general/_topnav.rhtml)0
-rw-r--r--app/views/general/blog.html.erb (renamed from app/views/general/blog.rhtml)14
-rw-r--r--app/views/general/custom_css.rhtml1
-rw-r--r--app/views/general/exception_caught.html.erb (renamed from app/views/general/exception_caught.rhtml)2
-rw-r--r--app/views/general/frontpage.html.erb (renamed from app/views/general/frontpage.rhtml)2
-rw-r--r--app/views/general/search.html.erb (renamed from app/views/general/search.rhtml)29
-rw-r--r--app/views/help/_sidebar.html.erb (renamed from app/views/help/_sidebar.rhtml)0
-rw-r--r--app/views/help/_why_they_should_reply_by_email.html.erb (renamed from app/views/help/_why_they_should_reply_by_email.rhtml)0
-rw-r--r--app/views/help/about.html.erb (renamed from app/views/help/about.rhtml)0
-rw-r--r--app/views/help/alaveteli.html.erb (renamed from app/views/help/alaveteli.rhtml)0
-rw-r--r--app/views/help/api.html.erb (renamed from app/views/help/api.rhtml)0
-rw-r--r--app/views/help/contact.html.erb (renamed from app/views/help/contact.rhtml)4
-rw-r--r--app/views/help/credits.html.erb (renamed from app/views/help/credits.rhtml)0
-rw-r--r--app/views/help/officers.html.erb (renamed from app/views/help/officers.rhtml)0
-rw-r--r--app/views/help/privacy.html.erb (renamed from app/views/help/privacy.rhtml)0
-rw-r--r--app/views/help/requesting.html.erb (renamed from app/views/help/requesting.rhtml)0
-rw-r--r--app/views/help/unhappy.html.erb (renamed from app/views/help/unhappy.rhtml)0
-rw-r--r--app/views/holiday/due_date.html.erb (renamed from app/views/holiday/due_date.rhtml)0
-rw-r--r--app/views/layouts/admin.html.erb (renamed from app/views/layouts/admin.rhtml)0
-rw-r--r--app/views/layouts/contact_mailer.html.erb (renamed from app/views/layouts/contact_mailer.rhtml)0
-rw-r--r--app/views/layouts/default.html.erb (renamed from app/views/layouts/default.rhtml)20
-rw-r--r--app/views/layouts/no_chrome.html.erb (renamed from app/views/layouts/no_chrome.rhtml)17
-rw-r--r--app/views/layouts/outgoing_mailer.html.erb (renamed from app/views/layouts/outgoing_mailer.rhtml)0
-rw-r--r--app/views/layouts/request_mailer.html.erb (renamed from app/views/layouts/request_mailer.rhtml)0
-rw-r--r--app/views/layouts/user_mailer.html.erb (renamed from app/views/layouts/user_mailer.rhtml)0
-rw-r--r--app/views/outgoing_mailer/_followup_footer.text.erb (renamed from app/views/outgoing_mailer/_followup_footer.rhtml)0
-rw-r--r--app/views/outgoing_mailer/followup.text.erb (renamed from app/views/outgoing_mailer/followup.rhtml)0
-rw-r--r--app/views/outgoing_mailer/initial_request.text.erb (renamed from app/views/outgoing_mailer/initial_request.rhtml)0
-rw-r--r--app/views/public_body/_alphabet.html.erb (renamed from app/views/public_body/_alphabet.rhtml)2
-rw-r--r--app/views/public_body/_body_listing.html.erb (renamed from app/views/public_body/_body_listing.rhtml)0
-rw-r--r--app/views/public_body/_body_listing_single.html.erb (renamed from app/views/public_body/_body_listing_single.rhtml)10
-rw-r--r--app/views/public_body/_list_sidebar_extra.html.erb (renamed from app/views/public_body/_list_sidebar_extra.rhtml)0
-rw-r--r--app/views/public_body/_search_ahead.html.erb (renamed from app/views/public_body/_search_ahead.rhtml)7
-rw-r--r--app/views/public_body/list.html.erb (renamed from app/views/public_body/list.rhtml)2
-rw-r--r--app/views/public_body/show.html.erb (renamed from app/views/public_body/show.rhtml)50
-rw-r--r--app/views/public_body/view_email.html.erb (renamed from app/views/public_body/view_email.rhtml)0
-rw-r--r--app/views/public_body/view_email_captcha.html.erb (renamed from app/views/public_body/view_email_captcha.rhtml)2
-rw-r--r--app/views/reports/new.html.erb26
-rw-r--r--app/views/request/_after_actions.html.erb (renamed from app/views/request/_after_actions.rhtml)0
-rw-r--r--app/views/request/_bubble.html.erb (renamed from app/views/request/_bubble.rhtml)0
-rw-r--r--app/views/request/_correspondence.html.erb (renamed from app/views/request/_correspondence.rhtml)0
-rw-r--r--app/views/request/_describe_state.html.erb (renamed from app/views/request/_describe_state.rhtml)6
-rw-r--r--app/views/request/_followup.html.erb (renamed from app/views/request/_followup.rhtml)2
-rw-r--r--app/views/request/_hidden_correspondence.html.erb (renamed from app/views/request/_hidden_correspondence.rhtml)10
-rw-r--r--app/views/request/_next_actions.html.erb (renamed from app/views/request/_next_actions.rhtml)0
-rw-r--r--app/views/request/_other_describe_state.html.erb (renamed from app/views/request/_other_describe_state.rhtml)2
-rw-r--r--app/views/request/_request_filter_form.html.erb (renamed from app/views/request/_request_filter_form.rhtml)2
-rw-r--r--app/views/request/_request_listing.html.erb (renamed from app/views/request/_request_listing.rhtml)0
-rw-r--r--app/views/request/_request_listing_short_via_event.html.erb (renamed from app/views/request/_request_listing_short_via_event.rhtml)0
-rw-r--r--app/views/request/_request_listing_single.html.erb (renamed from app/views/request/_request_listing_single.rhtml)0
-rw-r--r--app/views/request/_request_listing_via_event.html.erb (renamed from app/views/request/_request_listing_via_event.rhtml)0
-rw-r--r--app/views/request/_search_ahead.html.erb (renamed from app/views/request/_search_ahead.rhtml)0
-rw-r--r--app/views/request/_sidebar.html.erb (renamed from app/views/request/_sidebar.rhtml)21
-rw-r--r--app/views/request/_sidebar_request_listing.html.erb (renamed from app/views/request/_sidebar_request_listing.rhtml)0
-rw-r--r--app/views/request/_summary_suggestion.html.erb (renamed from app/views/request/_summary_suggestion.rhtml)0
-rw-r--r--app/views/request/_view_html_prefix.html.erb (renamed from app/views/request/_view_html_prefix.rhtml)0
-rw-r--r--app/views/request/_view_html_stylesheet.html.erb (renamed from app/views/request/_view_html_stylesheet.rhtml)0
-rw-r--r--app/views/request/_wall_listing.html.erb (renamed from app/views/request/_wall_listing.rhtml)0
-rw-r--r--app/views/request/describe_state_message.html.erb (renamed from app/views/request/describe_state_message.rhtml)2
-rw-r--r--app/views/request/details.html.erb (renamed from app/views/request/details.rhtml)0
-rw-r--r--app/views/request/followup_bad.html.erb (renamed from app/views/request/followup_bad.rhtml)0
-rw-r--r--app/views/request/followup_preview.html.erb (renamed from app/views/request/followup_preview.rhtml)4
-rw-r--r--app/views/request/hidden.html.erb (renamed from app/views/request/hidden.rhtml)2
-rw-r--r--app/views/request/list.html.erb (renamed from app/views/request/list.rhtml)0
-rw-r--r--app/views/request/new.html.erb (renamed from app/views/request/new.rhtml)6
-rw-r--r--app/views/request/new_bad_contact.html.erb (renamed from app/views/request/new_bad_contact.rhtml)0
-rw-r--r--app/views/request/new_please_describe.html.erb (renamed from app/views/request/new_please_describe.rhtml)4
-rw-r--r--app/views/request/preview.html.erb (renamed from app/views/request/preview.rhtml)6
-rw-r--r--app/views/request/select_authority.html.erb (renamed from app/views/request/select_authority.rhtml)23
-rw-r--r--app/views/request/show.html.erb (renamed from app/views/request/show.rhtml)2
-rw-r--r--app/views/request/show_response.html.erb (renamed from app/views/request/show_response.rhtml)0
-rw-r--r--app/views/request/similar.html.erb (renamed from app/views/request/similar.rhtml)15
-rw-r--r--app/views/request/simple_correspondence.html.erb (renamed from app/views/request/simple_correspondence.rhtml)2
-rw-r--r--app/views/request/upload_response.html.erb (renamed from app/views/request/upload_response.rhtml)2
-rw-r--r--app/views/request_game/play.html.erb (renamed from app/views/request_game/play.rhtml)0
-rw-r--r--app/views/request_mailer/comment_on_alert.text.erb (renamed from app/views/request_mailer/comment_on_alert.rhtml)0
-rw-r--r--app/views/request_mailer/comment_on_alert_plural.text.erb (renamed from app/views/request_mailer/comment_on_alert_plural.rhtml)0
-rw-r--r--app/views/request_mailer/external_response.rhtml1
-rw-r--r--app/views/request_mailer/external_response.text.erb1
-rw-r--r--app/views/request_mailer/fake_response.rhtml1
-rw-r--r--app/views/request_mailer/fake_response.text.erb1
-rw-r--r--app/views/request_mailer/new_response.text.erb (renamed from app/views/request_mailer/new_response.rhtml)0
-rw-r--r--app/views/request_mailer/new_response_reminder_alert.text.erb (renamed from app/views/request_mailer/new_response_reminder_alert.rhtml)0
-rw-r--r--app/views/request_mailer/not_clarified_alert.text.erb (renamed from app/views/request_mailer/not_clarified_alert.rhtml)0
-rw-r--r--app/views/request_mailer/old_unclassified_updated.text.erb (renamed from app/views/request_mailer/old_unclassified_updated.rhtml)0
-rw-r--r--app/views/request_mailer/overdue_alert.text.erb (renamed from app/views/request_mailer/overdue_alert.rhtml)0
-rw-r--r--app/views/request_mailer/requires_admin.text.erb (renamed from app/views/request_mailer/requires_admin.rhtml)0
-rw-r--r--app/views/request_mailer/stopped_responses.text.erb (renamed from app/views/request_mailer/stopped_responses.rhtml)0
-rw-r--r--app/views/request_mailer/very_overdue_alert.text.erb (renamed from app/views/request_mailer/very_overdue_alert.rhtml)0
-rw-r--r--app/views/track/_tracking_links.html.erb (renamed from app/views/track/_tracking_links.rhtml)2
-rw-r--r--app/views/track/atom_feed.atom.erb2
-rw-r--r--app/views/track_mailer/event_digest.text.erb (renamed from app/views/track_mailer/event_digest.rhtml)0
-rw-r--r--app/views/user/_change_receive_email.html.erb (renamed from app/views/user/_change_receive_email.rhtml)2
-rw-r--r--app/views/user/_show_user_info.html.erb (renamed from app/views/user/_show_user_info.rhtml)0
-rw-r--r--app/views/user/_signin.html.erb (renamed from app/views/user/_signin.rhtml)2
-rw-r--r--app/views/user/_signup.html.erb (renamed from app/views/user/_signup.rhtml)2
-rw-r--r--app/views/user/_user_listing_single.html.erb (renamed from app/views/user/_user_listing_single.rhtml)0
-rw-r--r--app/views/user/bad_token.html.erb (renamed from app/views/user/bad_token.rhtml)0
-rw-r--r--app/views/user/banned.html.erb (renamed from app/views/user/banned.rhtml)0
-rw-r--r--app/views/user/confirm.html.erb (renamed from app/views/user/confirm.rhtml)0
-rw-r--r--app/views/user/contact.html.erb (renamed from app/views/user/contact.rhtml)2
-rw-r--r--app/views/user/no_cookies.html.erb (renamed from app/views/user/no_cookies.rhtml)0
-rw-r--r--app/views/user/rate_limited.html.erb (renamed from app/views/user/rate_limited.rhtml)2
-rw-r--r--app/views/user/river.html.erb (renamed from app/views/user/river.rhtml)0
-rw-r--r--app/views/user/set_crop_profile_photo.html.erb (renamed from app/views/user/set_crop_profile_photo.rhtml)4
-rw-r--r--app/views/user/set_draft_profile_photo.html.erb (renamed from app/views/user/set_draft_profile_photo.rhtml)4
-rw-r--r--app/views/user/set_profile_about_me.html.erb (renamed from app/views/user/set_profile_about_me.rhtml)4
-rw-r--r--app/views/user/show.html.erb (renamed from app/views/user/show.rhtml)16
-rw-r--r--app/views/user/sign.html.erb (renamed from app/views/user/sign.rhtml)2
-rw-r--r--app/views/user/signchangeemail.html.erb (renamed from app/views/user/signchangeemail.rhtml)2
-rw-r--r--app/views/user/signchangeemail_confirm.html.erb (renamed from app/views/user/signchangeemail_confirm.rhtml)0
-rw-r--r--app/views/user/signchangepassword.html.erb (renamed from app/views/user/signchangepassword.rhtml)2
-rw-r--r--app/views/user/signchangepassword_confirm.html.erb (renamed from app/views/user/signchangepassword_confirm.rhtml)0
-rw-r--r--app/views/user/signchangepassword_send_confirm.html.erb (renamed from app/views/user/signchangepassword_send_confirm.rhtml)2
-rw-r--r--app/views/user/signin_successful.html.erb (renamed from app/views/user/signin_successful.rhtml)0
-rw-r--r--app/views/user/wall.html.erb (renamed from app/views/user/wall.rhtml)0
-rw-r--r--app/views/user/wrong_user.html.erb (renamed from app/views/user/wrong_user.rhtml)0
-rw-r--r--app/views/user/wrong_user_unknown_email.html.erb (renamed from app/views/user/wrong_user_unknown_email.rhtml)0
-rw-r--r--app/views/user_mailer/already_registered.text.erb (renamed from app/views/user_mailer/already_registered.rhtml)0
-rw-r--r--app/views/user_mailer/changeemail_already_used.text.erb (renamed from app/views/user_mailer/changeemail_already_used.rhtml)0
-rw-r--r--app/views/user_mailer/changeemail_confirm.text.erb (renamed from app/views/user_mailer/changeemail_confirm.rhtml)0
-rw-r--r--app/views/user_mailer/confirm_login.text.erb (renamed from app/views/user_mailer/confirm_login.rhtml)0
241 files changed, 1140 insertions, 1198 deletions
diff --git a/app/controllers/admin_censor_rule_controller.rb b/app/controllers/admin_censor_rule_controller.rb
index d3e9e47d2..6f79b5ba1 100644
--- a/app/controllers/admin_censor_rule_controller.rb
+++ b/app/controllers/admin_censor_rule_controller.rb
@@ -2,7 +2,7 @@
# For modifying requests.
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class AdminCensorRuleController < AdminController
def new
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index e90f03187..0bccd3358 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -2,7 +2,7 @@
# All admin controllers are dervied from this.
#
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
require 'fileutils'
@@ -51,7 +51,7 @@ class AdminController < ApplicationController
# For administration interface, return display name of authenticated user
def admin_current_user
- if Configuration::skip_admin_auth
+ if AlaveteliConfiguration::skip_admin_auth
admin_http_auth_user
else
session[:admin_name]
@@ -74,12 +74,12 @@ class AdminController < ApplicationController
end
def authenticate
- if Configuration::skip_admin_auth
+ if AlaveteliConfiguration::skip_admin_auth
session[:using_admin] = 1
return
else
if session[:using_admin].nil? || session[:admin_name].nil?
- if params[:emergency].nil? || Configuration::disable_emergency_user
+ if params[:emergency].nil? || AlaveteliConfiguration::disable_emergency_user
if authenticated?(
:web => _("To log into the administrative interface"),
:email => _("Then you can log into the administrative interface"),
@@ -97,7 +97,7 @@ class AdminController < ApplicationController
end
else
authenticate_or_request_with_http_basic do |user_name, password|
- if user_name == Configuration::admin_username && password == Configuration::admin_password
+ if user_name == AlaveteliConfiguration::admin_username && password == AlaveteliConfiguration::admin_password
session[:using_admin] = 1
session[:admin_name] = user_name
else
diff --git a/app/controllers/admin_general_controller.rb b/app/controllers/admin_general_controller.rb
index 800678787..ec5f95eda 100644
--- a/app/controllers/admin_general_controller.rb
+++ b/app/controllers/admin_general_controller.rb
@@ -2,7 +2,7 @@
# Controller for main admin pages.
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class AdminGeneralController < AdminController
skip_before_filter :authenticate, :only => :admin_js
@@ -134,7 +134,7 @@ class AdminGeneralController < AdminController
def debug
@admin_current_user = admin_current_user
- @current_commit = `git log -1 --format="%H"`
+ @current_commit = alaveteli_git_commit
@current_branch = `git branch | perl -ne 'print $1 if /^\\* (.*)/'`
@current_version = `git describe --always --tags`
repo = `git remote show origin -n | perl -ne 'print $1 if m{Fetch URL: .*github\\.com[:/](.*)\\.git}'`
diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb
index 93715d364..078af12f4 100644
--- a/app/controllers/admin_public_body_controller.rb
+++ b/app/controllers/admin_public_body_controller.rb
@@ -2,7 +2,7 @@
# Controller for editing public bodies from the admin interface.
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
require "public_body_categories"
@@ -23,12 +23,10 @@ class AdminPublicBodyController < AdminController
if @page == ""
@page = nil
end
- @public_bodies = PublicBody.paginate :order => "public_body_translations.name", :page => @page, :per_page => 100,
- :conditions => @query.nil? ? "public_body_translations.locale = '#{@locale}'" :
+ @public_bodies = PublicBody.joins(:translations).where(@query.nil? ? "public_body_translations.locale = '#{@locale}'" :
["(lower(public_body_translations.name) like lower('%'||?||'%') or
lower(public_body_translations.short_name) like lower('%'||?||'%') or
- lower(public_body_translations.request_email) like lower('%'||?||'%' )) AND (public_body_translations.locale = '#{@locale}')", @query, @query, @query],
- :joins => :translations
+ lower(public_body_translations.request_email) like lower('%'||?||'%' )) AND (public_body_translations.locale = '#{@locale}')", @query, @query, @query]).paginate :order => "public_body_translations.name", :page => @page, :per_page => 100
end
@public_bodies_by_tag = PublicBody.find_by_tag(@query)
end
@@ -77,6 +75,9 @@ class AdminPublicBodyController < AdminController
@locale = self.locale_from_params()
I18n.with_locale(@locale) do
@public_body = PublicBody.find(params[:id])
+ @info_requests = @public_body.info_requests.paginate :order => "created_at desc",
+ :page => params[:page],
+ :per_page => 100
render
end
end
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb
index 53055ae32..66989ea93 100644
--- a/app/controllers/admin_request_controller.rb
+++ b/app/controllers/admin_request_controller.rb
@@ -2,7 +2,7 @@
# Controller for viewing FOI requests from the admin interface.
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
require 'ostruct'
@@ -14,10 +14,14 @@ class AdminRequestController < AdminController
def list
@query = params[:query]
- @info_requests = InfoRequest.paginate :order => "created_at desc",
+ if @query
+ info_requests = InfoRequest.where(["lower(title) like lower('%'||?||'%')", @query])
+ else
+ info_requests = InfoRequest
+ end
+ @info_requests = info_requests.paginate :order => "created_at desc",
:page => params[:page],
- :per_page => 100,
- :conditions => @query.nil? ? nil : ["lower(title) like lower('%'||?||'%')", @query]
+ :per_page => 100
end
def show
@@ -25,11 +29,11 @@ class AdminRequestController < AdminController
# XXX is this *really* the only way to render a template to a
# variable, rather than to the response?
vars = OpenStruct.new(:name_to => @info_request.user_name,
- :name_from => Configuration::contact_name,
+ :name_from => AlaveteliConfiguration::contact_name,
:info_request => @info_request, :reason => params[:reason],
- :info_request_url => 'http://' + Configuration::domain + request_path(@info_request),
+ :info_request_url => 'http://' + AlaveteliConfiguration::domain + request_url(@info_request),
:site_name => site_name)
- template = File.read(File.join(File.dirname(__FILE__), "..", "views", "admin_request", "hidden_user_explanation.rhtml"))
+ template = File.read(File.join(File.dirname(__FILE__), "..", "views", "admin_request", "hidden_user_explanation.html.erb"))
@request_hidden_user_explanation = ERB.new(template).result(vars.instance_eval { binding })
end
@@ -361,11 +365,11 @@ class AdminRequestController < AdminController
info_request.save!
if ! info_request.is_external?
- ContactMailer.deliver_from_admin_message(
+ ContactMailer.from_admin_message(
info_request.user,
subject,
params[:explanation].strip.html_safe
- )
+ ).deliver
flash[:notice] = _("Your message to {{recipient_user_name}} has been sent",:recipient_user_name=>CGI.escapeHTML(info_request.user.name))
else
flash[:notice] = _("This external request has been hidden")
diff --git a/app/controllers/admin_track_controller.rb b/app/controllers/admin_track_controller.rb
index 525c96782..085c9c6cc 100644
--- a/app/controllers/admin_track_controller.rb
+++ b/app/controllers/admin_track_controller.rb
@@ -2,14 +2,18 @@
# Show email alerts / RSS feeds from admin interface.
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class AdminTrackController < AdminController
def list
@query = params[:query]
- @admin_tracks = TrackThing.paginate :order => "created_at desc", :page => params[:page], :per_page => 100,
- :conditions => @query.nil? ? nil : ["lower(track_query) like lower('%'||?||'%')", @query ]
- @popular = ActiveRecord::Base.connection.select_all("select count(*) as count, title, info_request_id from track_things join info_requests on info_request_id = info_requests.id where info_request_id is not null group by info_request_id, title order by count desc limit 10;")
+ if @query
+ track_things = TrackThing.where(["lower(track_query) like lower('%'||?||'%')", @query])
+ else
+ track_things = TrackThing
+ end
+ @admin_tracks = track_things.paginate :order => "created_at desc", :page => params[:page], :per_page => 100
+ @popular = ActiveRecord::Base.connection.select_all("select count(*) as count, title, info_request_id from track_things join info_requests on info_request_id = info_requests.id where info_request_id is not null group by info_request_id, title order by count desc limit 10;")
end
private
diff --git a/app/controllers/admin_user_controller.rb b/app/controllers/admin_user_controller.rb
index feffa208e..929b93e0e 100644
--- a/app/controllers/admin_user_controller.rb
+++ b/app/controllers/admin_user_controller.rb
@@ -2,7 +2,7 @@
# Controller for viewing user accounts from the admin interface.
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class AdminUserController < AdminController
def index
@@ -12,9 +12,13 @@ class AdminUserController < AdminController
def list
@query = params[:query]
- @admin_users = User.paginate :order => "name", :page => params[:page], :per_page => 100,
- :conditions => @query.nil? ? nil : ["lower(name) like lower('%'||?||'%') or
- lower(email) like lower('%'||?||'%')", @query, @query]
+ if @query
+ users = User.where(["lower(name) like lower('%'||?||'%') or
+ lower(email) like lower('%'||?||'%')", @query, @query])
+ else
+ users = User
+ end
+ @admin_users = users.paginate :order => "name", :page => params[:page], :per_page => 100
end
def list_banned
diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb
index 5d8ceb888..49b226e4b 100644
--- a/app/controllers/api_controller.rb
+++ b/app/controllers/api_controller.rb
@@ -83,7 +83,7 @@ class ApiController < ApplicationController
direction = json["direction"]
body = json["body"]
- sent_at_str = json["sent_at"]
+ sent_at = json["sent_at"]
errors = []
@@ -107,12 +107,6 @@ class ApiController < ApplicationController
errors << "The 'body' is empty"
end
- begin
- sent_at = Time.iso8601(sent_at_str)
- rescue ArgumentError
- errors << "Failed to parse 'sent_at' field as ISO8601 time: #{sent_at_str}"
- end
-
if direction == "request" && !attachments.nil?
errors << "You cannot attach files to messages in the 'request' direction"
end
@@ -155,7 +149,8 @@ class ApiController < ApplicationController
)
end
- mail = RequestMailer.create_external_response(request, body, sent_at, attachment_hashes)
+ mail = RequestMailer.external_response(request, body, sent_at, attachment_hashes)
+
request.receive(mail, mail.encoded, true)
end
render :json => {
@@ -248,6 +243,6 @@ class ApiController < ApplicationController
private
def make_url(*args)
- "http://" + Configuration::domain + "/" + args.join("/")
+ "http://" + AlaveteliConfiguration::domain + "/" + args.join("/")
end
end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index f3deeb64a..88b107861 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -5,30 +5,28 @@
# will be available for all controllers.
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
require 'open-uri'
class ApplicationController < ActionController::Base
class PermissionDenied < StandardError
end
+ class RouteNotFound < StandardError
+ end
+ # assign our own handler method for non-local exceptions
+ rescue_from Exception, :with => :render_exception
+
# Standard headers, footers and navigation for whole site
layout "default"
include FastGettext::Translation # make functions like _, n_, N_ etc available)
- # Send notification email on exceptions
- include ExceptionNotification::Notifiable
-
# Note: a filter stops the chain if it redirects or renders something
before_filter :authentication_check
before_filter :set_gettext_locale
before_filter :check_in_post_redirect
before_filter :session_remember_me
before_filter :set_vary_header
- before_filter :set_popup_banner
-
- # scrub sensitive parameters from the logs
- filter_parameter_logging :password
def set_vary_header
response.headers['Vary'] = 'Cookie'
@@ -53,19 +51,22 @@ class ApplicationController < ActionController::Base
anonymous_cache(24.hours)
end
+ # This is an override of the method provided by gettext_i18n_rails - note the explicit
+ # setting of I18n.locale, required due to the I18nProxy used in Rails 3 to trigger the
+ # lookup_context and expire the template cache
def set_gettext_locale
- if Configuration::include_default_locale_in_urls == false
+ if AlaveteliConfiguration::include_default_locale_in_urls == false
params_locale = params[:locale] ? params[:locale] : I18n.default_locale
else
params_locale = params[:locale]
end
- if Configuration::use_default_browser_language
+ if AlaveteliConfiguration::use_default_browser_language
requested_locale = params_locale || session[:locale] || cookies[:locale] || request.env['HTTP_ACCEPT_LANGUAGE'] || I18n.default_locale
else
requested_locale = params_locale || session[:locale] || cookies[:locale] || I18n.default_locale
end
requested_locale = FastGettext.best_locale_in(requested_locale)
- session[:locale] = FastGettext.set_locale(requested_locale)
+ session[:locale] = I18n.locale = FastGettext.set_locale(requested_locale)
if !@user.nil?
if @user.locale != requested_locale
@user.locale = session[:locale]
@@ -74,9 +75,6 @@ class ApplicationController < ActionController::Base
end
end
- # scrub sensitive parameters from the logs
- filter_parameter_logging :password
-
helper_method :locale_from_params
# Help work out which request causes RAM spike.
@@ -92,7 +90,7 @@ class ApplicationController < ActionController::Base
# egrep "CONSUME MEMORY: [0-9]{7} KB" production.log
around_filter :record_memory
def record_memory
- record_memory = Configuration::debug_record_memory
+ record_memory = AlaveteliConfiguration::debug_record_memory
if record_memory
logger.info "Processing request for #{request.url} with Rails process #{Process.pid}"
File.read("/proc/#{Process.pid}/status").match(/VmRSS:\s+(\d+)/)
@@ -120,52 +118,36 @@ class ApplicationController < ActionController::Base
end
end
- # Override default error handler, for production sites.
- def rescue_action_in_public(exception)
- # Looks for before_filters called something like `set_view_paths_{themename}`. These
- # are set by the themes.
- # Normally, this is called by the theme itself in a
- # :before_filter, but when there's an error, this doesn't
- # happen. By calling it here, we can ensure error pages are
- # still styled according to the theme.
- ActionController::Base.before_filters.select{|f| f.to_s =~ /set_view_paths/}.each do |f|
- self.send(f)
- end
- # Make sure expiry time for session is set (before_filters are
- # otherwise missed by this override)
- session_remember_me
+ def render_exception(exception)
- # Make sure the locale is set correctly too
- set_gettext_locale
+ # In development, or the admin interface, or for a local request, let Rails handle the exception
+ # with its stack trace templates. Local requests in testing are a special case so that we can
+ # test this method - there we use consider_all_requests_local to control behaviour.
+ if Rails.application.config.consider_all_requests_local || local_request? ||
+ (request.local? && !Rails.env.test?)
+ raise exception
+ end
+ @exception_backtrace = exception.backtrace.join("\n")
+ @exception_class = exception.class.to_s
+ @exception_message = exception.message
case exception
- when ActiveRecord::RecordNotFound, ActionController::UnknownAction, ActionController::RoutingError
+ when ActiveRecord::RecordNotFound, RouteNotFound
@status = 404
when PermissionDenied
@status = 403
else
+ message = "\n#{@exception_class} (#{@exception_message}):\n"
+ backtrace = Rails.backtrace_cleaner.clean(exception.backtrace, :silent)
+ message << " " << backtrace.join("\n ")
+ Rails.logger.fatal("#{message}\n\n")
+ ExceptionNotifier::Notifier.exception_notification(request.env, exception).deliver
@status = 500
- notify_about_exception exception
end
- # Display user appropriate error message
- @exception_backtrace = exception.backtrace.join("\n")
- @exception_class = exception.class.to_s
- @exception_message = exception.message
- render :template => "general/exception_caught.rhtml", :status => @status
- end
-
- # For development sites.
- alias original_rescue_action_locally rescue_action_locally
- def rescue_action_locally(exception)
- # Make sure expiry time for session is set (before_filters are
- # otherwise missed by this override)
- session_remember_me
-
- # Make sure the locale is set correctly too
- set_gettext_locale
-
- # Display default, detailed error for developers
- original_rescue_action_locally(exception)
+ respond_to do |format|
+ format.html{ render :template => "general/exception_caught", :status => @status }
+ format.any{ render :nothing => true, :status => @status }
+ end
end
def local_request?
@@ -175,6 +157,7 @@ class ApplicationController < ActionController::Base
# Called from test code, is a mimic of UserController.confirm, for use in following email
# links when in controller tests (though we also have full integration tests that
# can work over multiple controllers)
+ # TODO: Move this to the tests. It shouldn't be here
def test_code_redirect_by_email_token(token, controller_example_group)
post_redirect = PostRedirect.find_by_email_token(token)
if post_redirect.nil?
@@ -182,7 +165,7 @@ class ApplicationController < ActionController::Base
end
session[:user_id] = post_redirect.user.id
session[:user_circumstance] = post_redirect.circumstance
- params = controller_example_group.params_from(:get, post_redirect.local_part_uri)
+ params = Rails.application.routes.recognize_path(post_redirect.local_part_uri)
params.merge(post_redirect.post_params)
controller_example_group.get params[:action], params
end
@@ -258,7 +241,7 @@ class ApplicationController < ActionController::Base
# Check the user is logged in
def authenticated?(reason_params)
unless session[:user_id]
- post_redirect = PostRedirect.new(:uri => request.request_uri, :post_params => params,
+ post_redirect = PostRedirect.new(:uri => request.fullpath, :post_params => params,
:reason_params => reason_params)
post_redirect.save!
# 'modal' controls whether the sign-in form will be displayed in the typical full-blown
@@ -346,10 +329,10 @@ class ApplicationController < ActionController::Base
#
def check_read_only
- if !Configuration::read_only.empty?
+ if !AlaveteliConfiguration::read_only.empty?
flash[:notice] = _("<p>{{site_name}} is currently in maintenance. You can only view existing requests. You cannot make new ones, add followups or annotations, or otherwise change the database.</p> <p>{{read_only}}</p>",
:site_name => site_name,
- :read_only => Configuration::read_only)
+ :read_only => AlaveteliConfiguration::read_only)
redirect_to frontpage_url
end
@@ -380,12 +363,15 @@ class ApplicationController < ActionController::Base
# Peform the search
@per_page = per_page
- if this_page.nil?
- @page = get_search_page_from_params
- else
- @page = this_page
- end
- result = InfoRequest.full_search(models, @query, order, ascending, collapse, @per_page, @page)
+ @page = this_page || get_search_page_from_params
+
+ result = ActsAsXapian::Search.new(models, @query,
+ :offset => (@page - 1) * @per_page,
+ :limit => @per_page,
+ :sort_by_prefix => order,
+ :sort_by_ascending => ascending,
+ :collapse_by_prefix => collapse
+ )
result.results # Touch the results to load them, otherwise accessing them from the view
# might fail later if the database has subsequently been reopened.
return result
@@ -552,16 +538,17 @@ class ApplicationController < ActionController::Base
def country_from_ip
country = ""
- if !Configuration::gaze_url.empty?
- country = quietly_try_to_open("#{Configuration::gaze_url}/gaze-rest?f=get_country_from_ip;ip=#{request.remote_ip}")
+ if !AlaveteliConfiguration::gaze_url.empty?
+ country = quietly_try_to_open("#{AlaveteliConfiguration::gaze_url}/gaze-rest?f=get_country_from_ip;ip=#{request.remote_ip}")
end
- country = Configuration::iso_country_code if country.empty?
+ country = AlaveteliConfiguration::iso_country_code if country.empty?
return country
end
- def set_popup_banner
- @popup_banner = render_to_string(:partial => "general/popup_banner").strip.html_safe
+ def alaveteli_git_commit
+ `git log -1 --format="%H"`.strip
end
+
# URL generating functions are needed by all controllers (for redirects),
# views (for links) and mailers (for use in emails), so include them into
# all of all.
diff --git a/app/controllers/comment_controller.rb b/app/controllers/comment_controller.rb
index ed249d6cc..d4b17e9d2 100644
--- a/app/controllers/comment_controller.rb
+++ b/app/controllers/comment_controller.rb
@@ -2,7 +2,7 @@
# Show annotations upon a request or other object.
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class CommentController < ApplicationController
before_filter :check_read_only, :only => [ :new ]
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index 0783fc579..540f67ec9 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -3,14 +3,7 @@
# particular model.
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
-
-begin
- require 'xmlsimple'
-rescue LoadError
- # Debian maintainers put their xmlsimple in a different location :(
- require 'lib/xmlsimple'
-end
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
require 'open-uri'
@@ -21,7 +14,7 @@ class GeneralController < ApplicationController
medium_cache
# get some example searches and public bodies to display
# either from config, or based on a (slow!) query if not set
- body_short_names = Configuration::frontpage_publicbody_examples.split(/\s*;\s*/).map{|s| "'%s'" % s.gsub(/'/, "''") }.join(", ")
+ body_short_names = AlaveteliConfiguration::frontpage_publicbody_examples.split(/\s*;\s*/).map{|s| "'%s'" % s.gsub(/'/, "''") }.join(", ")
@locale = self.locale_from_params()
locale_condition = 'public_body_translations.locale = ?'
conditions = [locale_condition, @locale]
@@ -71,7 +64,7 @@ class GeneralController < ApplicationController
def blog
medium_cache
@feed_autodetect = []
- @feed_url = Configuration::blog_feed
+ @feed_url = AlaveteliConfiguration::blog_feed
separator = @feed_url.include?('?') ? '&' : '?'
@feed_url = "#{@feed_url}#{separator}lang=#{self.locale_from_params()}"
@blog_items = []
@@ -84,7 +77,7 @@ class GeneralController < ApplicationController
@feed_autodetect = [{:url => @feed_url, :title => "#{site_name} blog"}]
end
end
- @twitter_user = Configuration::twitter_username
+ @twitter_user = AlaveteliConfiguration::twitter_username
end
# Just does a redirect from ?query= search to /query
@@ -109,7 +102,7 @@ class GeneralController < ApplicationController
def search
# XXX Why is this so complicated with arrays and stuff? Look at the route
# in config/routes.rb for comments.
- combined = params[:combined]
+ combined = params[:combined].split("/")
@sortby = nil
@bodies = @requests = @users = true
if combined.size > 0 && (['advanced'].include?(combined[-1]))
@@ -154,13 +147,12 @@ class GeneralController < ApplicationController
@query, _ = make_query_from_params(params)
end
@inputted_sortby = @sortby
- @common_query = get_tags_from_params(params)
if @sortby.nil?
# Parse query, so can work out if it has prefix terms only - if so then it is a
# structured query which should show newest first, rather than a free text search
# where we want most relevant as default.
begin
- dummy_query = ::ActsAsXapian::Search.new([InfoRequestEvent], @query, :limit => 1)
+ dummy_query = ActsAsXapian::Search.new([InfoRequestEvent], @query, :limit => 1)
rescue => e
flash[:error] = "Your query was not quite right. " + CGI.escapeHTML(e.to_str)
redirect_to search_url("")
@@ -176,10 +168,8 @@ class GeneralController < ApplicationController
# Query each type separately for separate display (XXX we are calling
# perform_search multiple times and it clobbers per_page for each one,
# so set as separate var)
- requests_per_page = 25
- if params[:requests_per_page]
- requests_per_page = params[:requests_per_page].to_i
- end
+ requests_per_page = params[:requests_per_page] ? params[:requests_per_page].to_i : 25
+
@this_page_hits = @total_hits = @xapian_requests_hits = @xapian_bodies_hits = @xapian_users_hits = 0
if @requests
@xapian_requests = perform_search([InfoRequestEvent], @query, @sortby, 'request_collapse', requests_per_page)
@@ -218,16 +208,19 @@ class GeneralController < ApplicationController
@feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss], :has_json => true } ]
end
- # Jump to a random request
- def random_request
- info_request = InfoRequest.random
- redirect_to request_url(info_request)
+ # Handle requests for non-existent URLs - will be handled by ApplicationController::render_exception
+ def not_found
+ raise RouteNotFound
end
- def custom_css
- long_cache
- @locale = self.locale_from_params()
- render(:layout => false, :content_type => 'text/css')
+ def version
+ respond_to do |format|
+ format.json { render :json => {
+ :alaveteli_git_commit => alaveteli_git_commit,
+ :alaveteli_version => ALAVETELI_VERSION,
+ :ruby_version => RUBY_VERSION
+ }}
+ end
end
end
diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb
index 573abac63..9959df6d8 100644
--- a/app/controllers/help_controller.rb
+++ b/app/controllers/help_controller.rb
@@ -2,7 +2,7 @@
# Show information about one particular request.
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class HelpController < ApplicationController
@@ -18,7 +18,7 @@ class HelpController < ApplicationController
end
def contact
- @contact_email = Configuration::contact_email
+ @contact_email = AlaveteliConfiguration::contact_email
# if they clicked remove for link to request/body, remove it
if params[:remove]
@@ -49,14 +49,14 @@ class HelpController < ApplicationController
end
@contact = ContactValidator.new(params[:contact])
if @contact.valid? && !params[:remove]
- ContactMailer.deliver_to_admin_message(
+ ContactMailer.to_admin_message(
params[:contact][:name],
params[:contact][:email],
params[:contact][:subject],
params[:contact][:message],
@user,
@last_request, @last_body
- )
+ ).deliver
flash[:notice] = _("Your message has been sent. Thank you for getting in touch! We'll get back to you soon.")
redirect_to frontpage_url
return
diff --git a/app/controllers/holiday_controller.rb b/app/controllers/holiday_controller.rb
index 3101c07e3..efc20701d 100644
--- a/app/controllers/holiday_controller.rb
+++ b/app/controllers/holiday_controller.rb
@@ -2,7 +2,7 @@
# Calculate dates
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class HolidayController < ApplicationController
@@ -12,7 +12,7 @@ class HolidayController < ApplicationController
def due_date
if params[:holiday]
@request_date = Date.strptime(params[:holiday]) or raise "Invalid date"
- @due_date = Holiday.due_date_from(@request_date, Configuration::reply_late_after_days, Configuration::working_or_calendar_days)
+ @due_date = Holiday.due_date_from(@request_date, AlaveteliConfiguration::reply_late_after_days, AlaveteliConfiguration::working_or_calendar_days)
@skipped = Holiday.all(
:conditions => [ 'day >= ? AND day <= ?',
@request_date.strftime("%F"), @due_date.strftime("%F")
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb
index 1821e6725..374866eda 100644
--- a/app/controllers/public_body_controller.rb
+++ b/app/controllers/public_body_controller.rb
@@ -3,7 +3,7 @@
# Show information about a public body.
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
require 'fastercsv'
@@ -128,12 +128,12 @@ class PublicBodyController < ApplicationController
end
end
I18n.with_locale(@locale) do
- @public_bodies = PublicBody.paginate(
- :order => "public_body_translations.name", :page => params[:page], :per_page => 100,
- :conditions => conditions,
- :joins => :translations
+ @public_bodies = PublicBody.where(conditions).joins(:translations).order("public_body_translations.name").paginate(
+ :page => params[:page], :per_page => 100
)
- render :template => "public_body/list"
+ respond_to do |format|
+ format.html { render :template => "public_body/list" }
+ end
end
end
diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb
new file mode 100644
index 000000000..a1dd53125
--- /dev/null
+++ b/app/controllers/reports_controller.rb
@@ -0,0 +1,31 @@
+class ReportsController < ApplicationController
+ def create
+ @info_request = InfoRequest.find_by_url_title!(params[:request_id])
+ @reason = params[:reason]
+ @message = params[:message]
+ if @reason.empty?
+ flash[:error] = _("Please choose a reason")
+ render "new"
+ return
+ end
+
+ if !authenticated_user
+ flash[:notice] = _("You need to be logged in to report a request for administrator attention")
+ elsif @info_request.attention_requested
+ flash[:notice] = _("This request has already been reported for administrator attention")
+ else
+ @info_request.report!(@reason, @message, @user)
+ flash[:notice] = _("This request has been reported for administrator attention")
+ end
+ redirect_to request_url(@info_request)
+ end
+
+ def new
+ @info_request = InfoRequest.find_by_url_title!(params[:request_id])
+ if authenticated?(
+ :web => _("To report this request"),
+ :email => _("Then you can report the request '{{title}}'", :title => @info_request.title),
+ :email_subject => _("Report an offensive or unsuitable request"))
+ end
+ end
+end
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index e82871d7b..0c1d9880c 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -1,10 +1,10 @@
+# encoding: UTF-8
# app/controllers/request_controller.rb:
# Show information about one particular request.
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
-require 'alaveteli_file_types'
require 'zip/zip'
require 'open-uri'
@@ -17,7 +17,7 @@ class RequestController < ApplicationController
@@custom_states_loaded = false
begin
- if ENV["RAILS_ENV"] != "test"
+ if !Rails.env.test?
require 'customstates'
include RequestControllerCustomStates
@@custom_states_loaded = true
@@ -28,7 +28,7 @@ class RequestController < ApplicationController
def select_authority
# Check whether we force the user to sign in right at the start, or we allow her
# to start filling the request anonymously
- if Configuration::force_registration_on_new_request && !authenticated?(
+ if AlaveteliConfiguration::force_registration_on_new_request && !authenticated?(
:web => _("To send your FOI request"),
:email => _("Then you'll be allowed to send FOI requests."),
:email_subject => _("Confirm your email address")
@@ -44,7 +44,7 @@ class RequestController < ApplicationController
end
def show
- if !Configuration::varnish_host.blank?
+ if !AlaveteliConfiguration::varnish_host.blank?
# If varnish is set up to accept PURGEs, then cache for a
# long time
long_cache
@@ -67,8 +67,7 @@ class RequestController < ApplicationController
# Test for whole request being hidden
if !@info_request.user_can_view?(authenticated_user)
- render :template => 'request/hidden', :status => 410 # gone
- return
+ return render_hidden
end
# Other parameters
@@ -101,7 +100,7 @@ class RequestController < ApplicationController
# ... requests that have similar imporant terms
begin
limit = 10
- @xapian_similar = ::ActsAsXapian::Similar.new([InfoRequestEvent], @info_request.info_request_events,
+ @xapian_similar = ActsAsXapian::Similar.new([InfoRequestEvent], @info_request.info_request_events,
:limit => limit, :collapse_by_prefix => 'request_collapse')
@xapian_similar_more = (@xapian_similar.matches_estimated > limit)
rescue
@@ -126,8 +125,7 @@ class RequestController < ApplicationController
long_cache
@info_request = InfoRequest.find_by_url_title!(params[:url_title])
if !@info_request.user_can_view?(authenticated_user)
- render :template => 'request/hidden', :status => 410 # gone
- return
+ return render_hidden
end
@columns = ['id', 'event_type', 'created_at', 'described_state', 'last_described_at', 'calculated_state' ]
end
@@ -146,19 +144,12 @@ class RequestController < ApplicationController
raise ActiveRecord::RecordNotFound.new("Request not found") if @info_request.nil?
if !@info_request.user_can_view?(authenticated_user)
- render :template => 'request/hidden', :status => 410 # gone
- return
+ return render_hidden
end
- @xapian_object = ::ActsAsXapian::Similar.new([InfoRequestEvent], @info_request.info_request_events,
+ @xapian_object = ActsAsXapian::Similar.new([InfoRequestEvent], @info_request.info_request_events,
:offset => (@page - 1) * @per_page, :limit => @per_page, :collapse_by_prefix => 'request_collapse')
@matches_estimated = @xapian_object.matches_estimated
@show_no_more_than = (@matches_estimated > MAX_RESULTS) ? MAX_RESULTS : @matches_estimated
-
- if (@page > 1)
- @page_desc = " (page " + @page.to_s + ")"
- else
- @page_desc = ""
- end
end
def list
@@ -242,16 +233,19 @@ class RequestController < ApplicationController
# Read parameters in - first the public body (by URL name or id)
if params[:url_name]
if params[:url_name].match(/^[0-9]+$/)
- params[:info_request][:public_body_id] = params[:url_name]
+ params[:info_request][:public_body] = PublicBody.find(params[:url_name])
else
public_body = PublicBody.find_by_url_name_with_historic(params[:url_name])
raise ActiveRecord::RecordNotFound.new("None found") if public_body.nil? # XXX proper 404
- params[:info_request][:public_body_id] = public_body.id
+ params[:info_request][:public_body] = public_body
end
elsif params[:public_body_id]
- params[:info_request][:public_body_id] = params[:public_body_id]
+ params[:info_request][:public_body] = PublicBody.find(params[:public_body_id])
+ # Explicitly load the association as this isn't done automatically in newer Rails versions
+ elsif params[:info_request][:public_body_id]
+ params[:info_request][:public_body] = PublicBody.find(params[:info_request][:public_body_id])
end
- if !params[:info_request][:public_body_id]
+ if !params[:info_request][:public_body]
# compulsory to have a body by here, or go to front page which is start of process
redirect_to frontpage_url
return
@@ -344,7 +338,7 @@ class RequestController < ApplicationController
end
if !authenticated?(
- :web => _("To send your FOI request"),
+ :web => _("To send your FOI request").to_str,
:email => _("Then your FOI request to {{public_body_name}} will be sent.",:public_body_name=>@info_request.public_body.name),
:email_subject => _("Confirm your FOI request to ") + @info_request.public_body.name
)
@@ -368,8 +362,8 @@ class RequestController < ApplicationController
replied by then.</p>
<p>If you write about this request (for example in a forum or a blog) please link to this page, and add an
annotation below telling people about your writing.</p>",:law_used_full=>@info_request.law_used_full,
- :late_number_of_days => Configuration::reply_late_after_days)
- redirect_to show_new_request_url(:url_title => @info_request.url_title)
+ :late_number_of_days => AlaveteliConfiguration::reply_late_after_days)
+ redirect_to show_new_request_path(:url_title => @info_request.url_title)
end
# Submitted to the describing state of messages form
@@ -417,12 +411,22 @@ class RequestController < ApplicationController
end
# Make the state change
+ event = info_request.log_event("status_update",
+ { :user_id => authenticated_user.id,
+ :old_described_state => info_request.described_state,
+ :described_state => described_state,
+ })
+
info_request.set_described_state(described_state, authenticated_user, message)
# If you're not the *actual* requester. e.g. you are playing the
# classification game, or you're doing this just because you are an
# admin user (not because you also own the request).
if !info_request.is_actual_owning_user?(authenticated_user)
+ # Create a classification event for league tables
+ RequestClassification.create!(:user_id => authenticated_user.id,
+ :info_request_event_id => event.id)
+
# Don't give advice on what to do next, as it isn't their request
if session[:request_game]
flash[:notice] = _('Thank you for updating the status of the request \'<a href="{{url}}">{{info_request_title}}</a>\'. There are some more requests below for you to classify.',:info_request_title=>CGI.escapeHTML(info_request.title), :url=>CGI.escapeHTML(request_path(info_request)))
@@ -434,6 +438,7 @@ class RequestController < ApplicationController
return
end
+ calculated_status = info_request.calculate_status
# Display advice for requester on what to do next, as appropriate
flash[:notice] = case info_request.calculate_status
when 'waiting_response'
@@ -442,7 +447,7 @@ class RequestController < ApplicationController
when 'waiting_response_overdue'
_("<p>Thank you! Hope you don't have to wait much longer.</p> <p>By law, you should have got a response promptly, and normally before the end of <strong>{{date_response_required_by}}</strong>.</p>",:date_response_required_by=>simple_date(info_request.date_response_required_by))
when 'waiting_response_very_overdue'
- _("<p>Thank you! Your request is long overdue, by more than {{very_late_number_of_days}} working days. Most requests should be answered within {{late_number_of_days}} working days. You might like to complain about this, see below.</p>", :very_late_number_of_days => Configuration::reply_very_late_after_days, :late_number_of_days => Configuration::reply_late_after_days)
+ _("<p>Thank you! Your request is long overdue, by more than {{very_late_number_of_days}} working days. Most requests should be answered within {{late_number_of_days}} working days. You might like to complain about this, see below.</p>", :very_late_number_of_days => AlaveteliConfiguration::reply_very_late_after_days, :late_number_of_days => AlaveteliConfiguration::reply_late_after_days)
when 'not_held'
_("<p>Thank you! Here are some ideas on what to do next:</p>
<ul>
@@ -460,15 +465,25 @@ class RequestController < ApplicationController
when 'rejected'
_("Oh no! Sorry to hear that your request was refused. Here is what to do now.")
when 'successful'
- _("<p>We're glad you got all the information that you wanted. If you write about or make use of the information, please come back and add an annotation below saying what you did.</p><p>If you found {{site_name}} useful, <a href=\"{{donation_url}}\">make a donation</a> to the charity which runs it.</p>", :site_name=>site_name, :donation_url => "http://www.mysociety.org/donate/")
+ if AlaveteliConfiguration::donation_url.blank?
+ _("<p>We're glad you got all the information that you wanted. If you write about or make use of the information, please come back and add an annotation below saying what you did.</p>")
+ else
+ _("<p>We're glad you got all the information that you wanted. If you write about or make use of the information, please come back and add an annotation below saying what you did.</p><p>If you found {{site_name}} useful, <a href=\"{{donation_url}}\">make a donation</a> to the charity which runs it.</p>",
+ :site_name => site_name, :donation_url => AlaveteliConfiguration::donation_url)
+ end
when 'partially_successful'
- _("<p>We're glad you got some of the information that you wanted. If you found {{site_name}} useful, <a href=\"{{donation_url}}\">make a donation</a> to the charity which runs it.</p><p>If you want to try and get the rest of the information, here's what to do now.</p>", :site_name=>site_name, :donation_url=>"http://www.mysociety.org/donate/")
+ if AlaveteliConfiguration::donation_url.blank?
+ _("<p>We're glad you got some of the information that you wanted.</p><p>If you want to try and get the rest of the information, here's what to do now.</p>")
+ else
+ _("<p>We're glad you got some of the information that you wanted. If you found {{site_name}} useful, <a href=\"{{donation_url}}\">make a donation</a> to the charity which runs it.</p><p>If you want to try and get the rest of the information, here's what to do now.</p>",
+ :site_name => site_name, :donation_url => AlaveteliConfiguration::donation_url)
+ end
when 'waiting_clarification'
_("Please write your follow up message containing the necessary clarifications below.")
when 'gone_postal'
nil
when 'internal_review'
- _("<p>Thank you! Hopefully your wait isn't too long.</p><p>You should get a response within {{late_number_of_days}} days, or be told if it will take longer (<a href=\"{{review_url}}\">details</a>).</p>",:late_number_of_days => Configuration.reply_late_after_days, :review_url => unhappy_url(info_request) + "#internal_review")
+ _("<p>Thank you! Hopefully your wait isn't too long.</p><p>You should get a response within {{late_number_of_days}} days, or be told if it will take longer (<a href=\"{{review_url}}\">details</a>).</p>",:late_number_of_days => AlaveteliConfiguration.reply_late_after_days, :review_url => unhappy_url(info_request) + "#internal_review")
when 'error_message', 'requires_admin'
_("Thank you! We'll look into what happened and try and fix it up.")
when 'user_withdrawn'
@@ -560,10 +575,7 @@ class RequestController < ApplicationController
end
- params_outgoing_message = params[:outgoing_message]
- if params_outgoing_message.nil?
- params_outgoing_message = {}
- end
+ params_outgoing_message = params[:outgoing_message] ? params[:outgoing_message].clone : {}
params_outgoing_message.merge!({
:status => 'ready',
:message_type => 'followup',
@@ -586,8 +598,7 @@ class RequestController < ApplicationController
# Test for hidden requests
if !authenticated_user.nil? && !@info_request.user_can_view?(authenticated_user)
- render :template => 'request/hidden', :status => 410 # gone
- return
+ return render_hidden
end
# Check address is good
@@ -670,7 +681,7 @@ class RequestController < ApplicationController
raise ActiveRecord::RecordNotFound.new("Message not found") if incoming_message.nil?
if !incoming_message.info_request.user_can_view?(authenticated_user)
@info_request = incoming_message.info_request # used by view
- render :template => 'request/hidden', :status => 410 # gone
+ return render_hidden
end
# Is this a completely public request that we can cache attachments for
# to be served up without authentication?
@@ -679,25 +690,6 @@ class RequestController < ApplicationController
end
end
- def report_request
- info_request = InfoRequest.find_by_url_title!(params[:url_title])
- return if !authenticated?(
- :web => _("To report this FOI request"),
- :email => _("Then you can report the request '{{title}}'", :title => info_request.title),
- :email_subject => _("Report an offensive or unsuitable request")
- )
-
- if !info_request.attention_requested
- info_request.set_described_state('attention_requested', @user)
- info_request.attention_requested = true # tells us if attention has ever been requested
- info_request.save!
- flash[:notice] = _("This request has been reported for administrator attention")
- else
- flash[:notice] = _("This request has already been reported for administrator attention")
- end
- redirect_to request_url(info_request)
- end
-
# special caching code so mime types are handled right
around_filter :cache_attachments, :only => [ :get_attachment, :get_attachment_as_html ]
def cache_attachments
@@ -708,16 +700,19 @@ class RequestController < ApplicationController
key_path = foi_fragment_cache_path(key)
if foi_fragment_cache_exists?(key_path)
logger.info("Reading cache for #{key_path}")
- raise PermissionDenied.new("Directory listing not allowed") if File.directory?(key_path)
- cached = foi_fragment_cache_read(key_path)
- response.content_type = AlaveteliFileTypes.filename_to_mimetype(params[:file_name].join("/")) || 'application/octet-stream'
- render_for_text(cached)
+
+ if File.directory?(key_path)
+ render :text => "Directory listing not allowed", :status => 403
+ else
+ render :text => foi_fragment_cache_read(key_path),
+ :content_type => (AlaveteliFileTypes.filename_to_mimetype(params[:file_name]) || 'application/octet-stream')
+ end
return
end
yield
- if params[:skip_cache].nil?
+ if params[:skip_cache].nil? && response.status == 200
# write it to the fileystem ourselves, so is just a plain file. (The
# various fragment cache functions using Ruby Marshall to write the file
# which adds a header, so isnt compatible with images that have been
@@ -732,13 +727,14 @@ class RequestController < ApplicationController
def get_attachment
get_attachment_internal(false)
+ return unless @attachment
# Prevent spam to magic request address. Note that the binary
# subsitution method used depends on the content type
@incoming_message.binary_mask_stuff!(@attachment.body, @attachment.content_type)
# we don't use @attachment.content_type here, as we want same mime type when cached in cache_attachments above
- response.content_type = AlaveteliFileTypes.filename_to_mimetype(params[:file_name].join("/")) || 'application/octet-stream'
+ response.content_type = AlaveteliFileTypes.filename_to_mimetype(params[:file_name]) || 'application/octet-stream'
render :text => @attachment.body
end
@@ -751,6 +747,7 @@ class RequestController < ApplicationController
raise ActiveRecord::RecordNotFound.new("Attachment HTML not found.")
end
get_attachment_internal(true)
+ return unless @attachment
# images made during conversion (e.g. images in PDF files) are put in the cache directory, so
# the same cache code in cache_attachments above will display them.
@@ -788,7 +785,7 @@ class RequestController < ApplicationController
raise ActiveRecord::RecordNotFound.new(message)
end
@part_number = params[:part].to_i
- @filename = params[:file_name].join("/")
+ @filename = params[:file_name]
if html_conversion
@original_filename = @filename.gsub(/\.html$/, "")
else
@@ -797,8 +794,11 @@ class RequestController < ApplicationController
# check permissions
raise "internal error, pre-auth filter should have caught this" if !@info_request.user_can_view?(authenticated_user)
- @attachment = IncomingMessage.get_attachment_by_url_part_number(@incoming_message.get_attachments_for_display, @part_number)
- raise ActiveRecord::RecordNotFound.new("attachment not found part number " + @part_number.to_s + " incoming_message " + @incoming_message.id.to_s) if @attachment.nil?
+ @attachment = IncomingMessage.get_attachment_by_url_part_number_and_filename(@incoming_message.get_attachments_for_display, @part_number, @original_filename)
+ # If we can't find the right attachment, redirect to the incoming message:
+ unless @attachment
+ return redirect_to incoming_message_url(@incoming_message), :status => 303
+ end
# check filename in URL matches that in database (use a censor rule if you want to change a filename)
raise ActiveRecord::RecordNotFound.new("please use same filename as original file has, display: '" + @attachment.display_filename + "' old_display: '" + @attachment.old_display_filename + "' original: '" + @original_filename + "'") if @attachment.display_filename != @original_filename && @attachment.old_display_filename != @original_filename
@@ -849,7 +849,8 @@ class RequestController < ApplicationController
return
end
- mail = RequestMailer.create_fake_response(@info_request, @user, body, file_name, file_content)
+ mail = RequestMailer.fake_response(@info_request, @user, body, file_name, file_content)
+
@info_request.receive(mail, mail.encoded, true)
flash[:notice] = _("Thank you for responding to this FOI request! Your response has been published below, and a link to your response has been emailed to ") + CGI.escapeHTML(@info_request.user.name) + "."
redirect_to request_url(@info_request)
@@ -863,7 +864,7 @@ class RequestController < ApplicationController
# by making the last work a wildcard, which is quite the same
query = params[:q]
@xapian_requests = perform_search_typeahead(query, InfoRequestEvent)
- render :partial => "request/search_ahead.rhtml"
+ render :partial => "request/search_ahead"
end
def download_entire_request
@@ -872,8 +873,7 @@ class RequestController < ApplicationController
@info_request = InfoRequest.find_by_url_title!(params[:url_title])
# Test for whole request being hidden or requester-only
if !@info_request.all_can_view?
- render :template => 'request/hidden', :status => 410 # gone
- return
+ return render_hidden
end
if authenticated?(
:web => _("To download the zip file"),
@@ -891,10 +891,10 @@ class RequestController < ApplicationController
if !File.exists?(file_path)
FileUtils.mkdir_p(File.dirname(file_path))
Zip::ZipFile.open(file_path, Zip::ZipFile::CREATE) { |zipfile|
- convert_command = Configuration::html_to_pdf_command
+ convert_command = AlaveteliConfiguration::html_to_pdf_command
done = false
if !convert_command.blank? && File.exists?(convert_command)
- url = "http://#{Configuration::domain}#{request_path(@info_request)}?print_stylesheet=1"
+ url = "http://#{AlaveteliConfiguration::domain}#{request_path(@info_request)}?print_stylesheet=1"
tempfile = Tempfile.new('foihtml2pdf')
output = AlaveteliExternalCommand.run(convert_command, url, tempfile.path)
if !output.nil?
@@ -911,7 +911,7 @@ class RequestController < ApplicationController
end
if !done
@info_request_events = @info_request.info_request_events
- template = File.read(File.join(File.dirname(__FILE__), "..", "views", "request", "simple_correspondence.rhtml"))
+ template = File.read(File.join(File.dirname(__FILE__), "..", "views", "request", "simple_correspondence.html.erb"))
output = ERB.new(template).result(binding)
zipfile.get_output_stream("correspondence.txt") { |f|
f.puts(output)
@@ -933,5 +933,17 @@ class RequestController < ApplicationController
end
end
end
+
+ private
+
+ def render_hidden
+ respond_to do |format|
+ response_code = 410 # gone
+ format.html{ render :template => 'request/hidden', :status => response_code }
+ format.any{ render :nothing => true, :status => response_code }
+ end
+ false
+ end
+
end
diff --git a/app/controllers/request_game_controller.rb b/app/controllers/request_game_controller.rb
index 4b6f02970..6eac399ac 100644
--- a/app/controllers/request_game_controller.rb
+++ b/app/controllers/request_game_controller.rb
@@ -2,7 +2,7 @@
# The 'categorise old requests' game
#
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class RequestGameController < ApplicationController
diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb
index e75dac903..11ed4ac8f 100644
--- a/app/controllers/services_controller.rb
+++ b/app/controllers/services_controller.rb
@@ -6,7 +6,7 @@ class ServicesController < ApplicationController
def other_country_message
text = ""
- iso_country_code = Configuration::iso_country_code.downcase
+ iso_country_code = AlaveteliConfiguration::iso_country_code.downcase
if country_from_ip.downcase != iso_country_code
found_country = WorldFOIWebsites.by_code(country_from_ip)
@@ -36,9 +36,9 @@ class ServicesController < ApplicationController
:content_type => "text/plain",
:layout => false,
:locals => {:name_to => info_request.user_name,
- :name_from => Configuration::contact_name,
+ :name_from => AlaveteliConfiguration::contact_name,
:info_request => info_request, :reason => params[:reason],
- :info_request_url => 'http://' + Configuration::domain + request_path(info_request),
+ :info_request_url => 'http://' + AlaveteliConfiguration::domain + request_path(info_request),
:site_name => site_name}
end
diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb
index 15da7f327..40fa69290 100644
--- a/app/controllers/track_controller.rb
+++ b/app/controllers/track_controller.rb
@@ -3,7 +3,7 @@
# social bookmarking.
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class TrackController < ApplicationController
@@ -80,10 +80,7 @@ class TrackController < ApplicationController
# Track a search term
def track_search_query
- # XXX should be better thing in rails routes than having to do this
- # join just to get / and . to work in a query.
- query_array = params[:query_array]
- @query = query_array.join("/")
+ @query = params[:query_array]
# XXX more hackery to make alternate formats still work with query_array
if /^(.*)\.json$/.match(@query)
@@ -156,11 +153,14 @@ class TrackController < ApplicationController
def atom_feed_internal
@xapian_object = perform_search([InfoRequestEvent], @track_thing.track_query, @track_thing.params[:feed_sortby], nil, 25, 1)
+ # We're assuming that a request to a feed url with no format suffix wants atom/xml
+ # so set that as the default, regardless of content negotiation
+ request.format = 'xml' unless params[:format]
respond_to do |format|
- format.atom { render :template => 'track/atom_feed', :content_type => "application/atom+xml" }
format.json { render :json => @xapian_object.results.map { |r| r[:model].json_for_api(true,
- lambda { |t| @template.highlight_and_excerpt(t, @xapian_object.words_to_highlight, 150) }
+ lambda { |t| view_context.highlight_and_excerpt(t, @xapian_object.words_to_highlight, 150) }
) } }
+ format.any { render :template => 'track/atom_feed.atom', :layout => false, :content_type => 'application/atom+xml' }
end
end
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index fc8b6e014..175425280 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -2,7 +2,7 @@
# Show information about a user.
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
require 'set'
@@ -19,8 +19,8 @@ class UserController < ApplicationController
# Show page about a user
def show
long_cache
- if MySociety::Format.simplify_url_part(params[:url_name], 'user', 32) != params[:url_name]
- redirect_to :url_name => MySociety::Format.simplify_url_part(params[:url_name], 'user', 32), :status => :moved_permanently
+ if MySociety::Format.simplify_url_part(params[:url_name], 'user') != params[:url_name]
+ redirect_to :url_name => MySociety::Format.simplify_url_part(params[:url_name], 'user'), :status => :moved_permanently
return
end
if params[:view].nil?
@@ -119,7 +119,11 @@ class UserController < ApplicationController
@track_things = TrackThing.find(:all, :conditions => ["tracking_user_id = ? and track_medium = ?", @display_user.id, 'email_daily'], :order => 'created_at desc')
for track_thing in @track_things
# XXX factor out of track_mailer.rb
- xapian_object = InfoRequest.full_search([InfoRequestEvent], track_thing.track_query, 'described_at', true, nil, 20, 1)
+ xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], track_thing.track_query,
+ :sort_by_prefix => 'described_at',
+ :sort_by_ascending => true,
+ :collapse_by_prefix => nil,
+ :limit => 20)
feed_results += xapian_object.results.map {|x| x[:model]}
end
end
@@ -136,7 +140,7 @@ class UserController < ApplicationController
# Login form
def signin
work_out_post_redirect
- @request_from_foreign_country = country_from_ip != Configuration::iso_country_code
+ @request_from_foreign_country = country_from_ip != AlaveteliConfiguration::iso_country_code
# make sure we have cookies
if session.instance_variable_get(:@dbman)
if not session.instance_variable_get(:@dbman).instance_variable_get(:@original)
@@ -190,7 +194,7 @@ class UserController < ApplicationController
# Create new account form
def signup
work_out_post_redirect
- @request_from_foreign_country = country_from_ip != Configuration::iso_country_code
+ @request_from_foreign_country = country_from_ip != AlaveteliConfiguration::iso_country_code
# Make the user and try to save it
@user_signup = User.new(params[:user_signup])
error = false
@@ -222,7 +226,7 @@ class UserController < ApplicationController
post_redirect = PostRedirect.find_by_email_token(params[:email_token])
if post_redirect.nil?
- render :template => 'user/bad_token.rhtml'
+ render :template => 'user/bad_token'
return
end
@@ -288,7 +292,7 @@ class UserController < ApplicationController
post_redirect.user = user_signchangepassword
post_redirect.save!
url = confirm_url(:email_token => post_redirect.email_token)
- UserMailer.deliver_confirm_login(user_signchangepassword, post_redirect.reason_params, url)
+ UserMailer.confirm_login(user_signchangepassword, post_redirect.reason_params, url).deliver
else
# User not found, but still show confirm page to not leak fact user exists
end
@@ -352,7 +356,7 @@ class UserController < ApplicationController
# if new email already in use, send email there saying what happened
user_alreadyexists = User.find_user_by_email(@signchangeemail.new_email)
if user_alreadyexists
- UserMailer.deliver_changeemail_already_used(@user.email, @signchangeemail.new_email)
+ UserMailer.changeemail_already_used(@user.email, @signchangeemail.new_email).deliver
# it is important this screen looks the same as the one below, so
# you can't change to someone's email in order to tell if they are
# registered with that email on the site
@@ -373,7 +377,7 @@ class UserController < ApplicationController
post_redirect.save!
url = confirm_url(:email_token => post_redirect.email_token)
- UserMailer.deliver_changeemail_confirm(@user, @signchangeemail.new_email, url)
+ UserMailer.changeemail_confirm(@user, @signchangeemail.new_email, url).deliver
# it is important this screen looks the same as the one above, so
# you can't change to someone's email in order to tell if they are
# registered with that email on the site
@@ -419,13 +423,13 @@ class UserController < ApplicationController
params[:contact][:email] = @user.email
@contact = ContactValidator.new(params[:contact])
if @contact.valid?
- ContactMailer.deliver_user_message(
+ ContactMailer.user_message(
@user,
@recipient_user,
user_url(@user),
params[:contact][:subject],
params[:contact][:message]
- )
+ ).deliver
flash[:notice] = _("Your message to {{recipient_user_name}} has been sent!",:recipient_user_name=>CGI.escapeHTML(@recipient_user.name))
redirect_to user_url(@recipient_user)
return
@@ -465,7 +469,7 @@ class UserController < ApplicationController
@draft_profile_photo = ProfilePhoto.new(:data => file_content, :draft => true)
if !@draft_profile_photo.valid?
# error page (uses @profile_photo's error fields in view to show errors)
- render :template => 'user/set_draft_profile_photo.rhtml'
+ render :template => 'user/set_draft_profile_photo'
return
end
@draft_profile_photo.save
@@ -480,7 +484,7 @@ class UserController < ApplicationController
return
end
- render :template => 'user/set_crop_profile_photo.rhtml'
+ render :template => 'user/set_crop_profile_photo'
return
elsif !params[:submitted_crop_profile_photo].nil?
# crop the draft photo according to jquery parameters and set it as the users photo
@@ -499,7 +503,7 @@ class UserController < ApplicationController
redirect_to set_profile_about_me_url()
end
else
- render :template => 'user/set_draft_profile_photo.rhtml'
+ render :template => 'user/set_draft_profile_photo'
end
end
@@ -527,11 +531,12 @@ class UserController < ApplicationController
def get_draft_profile_photo
profile_photo = ProfilePhoto.find(params[:id])
response.content_type = "image/png"
- render_for_text(profile_photo.data)
+ render :text => profile_photo.data
end
# actual profile photo of a user
def get_profile_photo
+ long_cache
@display_user = User.find(:first, :conditions => [ "url_name = ? and email_confirmed = ?", params[:url_name], true ])
if !@display_user
raise ActiveRecord::RecordNotFound.new("user not found, url_name=" + params[:url_name])
@@ -542,7 +547,7 @@ class UserController < ApplicationController
end
response.content_type = "image/png"
- render_for_text(@display_user.profile_photo.data)
+ render :text => @display_user.profile_photo.data
end
# Change about me text on your profile page
@@ -631,7 +636,7 @@ class UserController < ApplicationController
post_redirect.save!
url = confirm_url(:email_token => post_redirect.email_token)
- UserMailer.deliver_confirm_login(user, post_redirect.reason_params, url)
+ UserMailer.confirm_login(user, post_redirect.reason_params, url).deliver
render :action => 'confirm'
end
@@ -642,7 +647,7 @@ class UserController < ApplicationController
post_redirect.save!
url = confirm_url(:email_token => post_redirect.email_token)
- UserMailer.deliver_already_registered(user, post_redirect.reason_params, url)
+ UserMailer.already_registered(user, post_redirect.reason_params, url).deliver
render :action => 'confirm' # must be same as for send_confirmation_mail above to avoid leak of presence of email in db
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 42f9d30f1..e3b1e57ac 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -3,7 +3,7 @@
# in the application.
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
require 'languages'
diff --git a/app/helpers/config_helper.rb b/app/helpers/config_helper.rb
index 73e12172f..026600ff1 100644
--- a/app/helpers/config_helper.rb
+++ b/app/helpers/config_helper.rb
@@ -1,5 +1,5 @@
module ConfigHelper
def site_name
- Configuration::site_name
+ AlaveteliConfiguration::site_name
end
-end \ No newline at end of file
+end
diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb
index 3f59c55ca..5533402c5 100755
--- a/app/helpers/link_to_helper.rb
+++ b/app/helpers/link_to_helper.rb
@@ -3,7 +3,7 @@
# -
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
module LinkToHelper
@@ -238,7 +238,7 @@ module LinkToHelper
# TODO: Remove in next release
def main_url(relative_path, append = nil)
warn "[DEPRECATION] main_url is deprecated. Please remove it from your theme."
- url_prefix = "http://" + Configuration::domain
+ url_prefix = "http://" + AlaveteliConfiguration::domain
url = url_prefix + relative_path
if !append.nil?
begin
@@ -282,5 +282,13 @@ module LinkToHelper
def year_from_date(date)
return date.strftime("%Y").strip
end
+
+ #I18n locale switcher
+
+ def locale_switcher(locale, params)
+ params['locale'] = locale
+ return url_for(params)
+ end
+
end
diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb
index be2ce47aa..3d4bbac71 100644
--- a/app/helpers/mailer_helper.rb
+++ b/app/helpers/mailer_helper.rb
@@ -1,5 +1,5 @@
module MailerHelper
def contact_from_name_and_email
- "#{Configuration::contact_name} <#{Configuration::contact_email}>"
+ "#{AlaveteliConfiguration::contact_name} <#{AlaveteliConfiguration::contact_email}>"
end
end
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
new file mode 100644
index 000000000..d2230bb82
--- /dev/null
+++ b/app/mailers/application_mailer.rb
@@ -0,0 +1,30 @@
+# models/application_mailer.rb:
+# Shared code between different mailers.
+#
+# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
+
+require 'action_mailer/version'
+class ApplicationMailer < ActionMailer::Base
+ # Include all the functions views get, as emails call similar things.
+ helper :application
+ include MailerHelper
+
+ # This really should be the default - otherwise you lose any information
+ # about the errors, and have to do error checking on return codes.
+ self.raise_delivery_errors = true
+
+ def blackhole_email
+ AlaveteliConfiguration::blackhole_prefix+"@"+AlaveteliConfiguration::incoming_email_domain
+ end
+
+ # URL generating functions are needed by all controllers (for redirects),
+ # views (for links) and mailers (for use in emails), so include them into
+ # all of all.
+ include LinkToHelper
+
+ # Site-wide access to configuration settings
+ include ConfigHelper
+
+end
+
diff --git a/app/mailers/contact_mailer.rb b/app/mailers/contact_mailer.rb
new file mode 100644
index 000000000..4dc49bf8b
--- /dev/null
+++ b/app/mailers/contact_mailer.rb
@@ -0,0 +1,45 @@
+# models/contact_mailer.rb:
+# Sends contact form mails.
+#
+# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
+
+class ContactMailer < ApplicationMailer
+ # Send message to administrator
+ def to_admin_message(name, email, subject, message, logged_in_user, last_request, last_body)
+ @message, @logged_in_user, @last_request, @last_body = message, logged_in_user, last_request, last_body
+
+ mail(:from => "#{name} <#{email}>",
+ :to => contact_from_name_and_email,
+ :subject => subject)
+ end
+
+ # We always set Reply-To when we set Return-Path to be different from From,
+ # since some email clients seem to erroneously use the envelope from when
+ # they shouldn't, and this might help. (Have had mysterious cases of a
+ # reply coming in duplicate from a public body to both From and envelope
+ # from)
+
+ # Send message to another user
+ def user_message(from_user, recipient_user, from_user_url, subject, message)
+ @message, @from_user, @recipient_user, @from_user_url = message, from_user, recipient_user, from_user_url
+
+ # Do not set envelope from address to the from_user, so they can't get
+ # someone's email addresses from transitory bounce messages.
+ headers('Return-Path' => blackhole_email, 'Reply-To' => from_user.name_and_email)
+
+ mail(:from => from_user.name_and_email,
+ :to => recipient_user.name_and_email,
+ :subject => subject)
+ end
+
+ # Send message to a user from the administrator
+ def from_admin_message(recipient_user, subject, message)
+ @message, @from_user, @recipient_user = message, contact_from_name_and_email, recipient_user
+
+ mail(:from => contact_from_name_and_email,
+ :to => recipient_user.name_and_email,
+ :bcc => AlaveteliConfiguration::contact_email,
+ :subject => subject)
+ end
+end
diff --git a/app/models/outgoing_mailer.rb b/app/mailers/outgoing_mailer.rb
index 503166b8a..083c05a7c 100644
--- a/app/models/outgoing_mailer.rb
+++ b/app/mailers/outgoing_mailer.rb
@@ -2,7 +2,7 @@
# Emails which go to public bodies on behalf of users.
#
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
# Note: The layout for this wraps messages by lines rather than (blank line
# separated) paragraphs, as is the convention for all the other mailers. This
@@ -13,31 +13,29 @@
# throughout the application.
class OutgoingMailer < ApplicationMailer
-
# Email to public body requesting info
def initial_request(info_request, outgoing_message)
+ @info_request, @outgoing_message, @contact_email = info_request, outgoing_message, AlaveteliConfiguration::contact_email
@wrap_lines_as_paragraphs = true
- @from = info_request.incoming_name_and_email
- @recipients = info_request.recipient_name_and_email
- @subject = info_request.email_subject_request
- @headers["message-id"] = OutgoingMailer.id_for_message(outgoing_message)
- @body = {:info_request => info_request, :outgoing_message => outgoing_message,
- :contact_email => Configuration::contact_email }
+ headers["message-id"] = OutgoingMailer.id_for_message(outgoing_message)
+
+ mail(:from => info_request.incoming_name_and_email,
+ :to => info_request.recipient_name_and_email,
+ :subject => info_request.email_subject_request)
end
# Later message to public body regarding existing request
def followup(info_request, outgoing_message, incoming_message_followup)
+ @info_request, @outgoing_message, @incoming_message_followup, @contact_email = info_request, outgoing_message, incoming_message_followup, AlaveteliConfiguration::contact_email
@wrap_lines_as_paragraphs = true
- @from = info_request.incoming_name_and_email
- @recipients = OutgoingMailer.name_and_email_for_followup(info_request, incoming_message_followup)
- @subject = OutgoingMailer.subject_for_followup(info_request, outgoing_message)
- @headers["message-id"] = OutgoingMailer.id_for_message(outgoing_message)
- @body = {:info_request => info_request, :outgoing_message => outgoing_message,
- :incoming_message_followup => incoming_message_followup,
- :contact_email => Configuration::contact_email }
+ headers["message-id"] = OutgoingMailer.id_for_message(outgoing_message)
+
+ mail(:from => info_request.incoming_name_and_email,
+ :to => OutgoingMailer.name_and_email_for_followup(info_request, incoming_message_followup),
+ :subject => OutgoingMailer.subject_for_followup(info_request, outgoing_message))
end
- # XXX the condition checking valid_to_reply_to? also appears in views/request/_followup.rhtml,
+ # XXX the condition checking valid_to_reply_to? also appears in views/request/_followup.html.erb,
# it shouldn't really, should call something here.
# XXX also OutgoingMessage.get_salutation
# XXX these look like they should be members of IncomingMessage, but logically they
@@ -90,7 +88,7 @@ class OutgoingMailer < ApplicationMailer
message_id = "ogm-" + outgoing_message.id.to_s
t = Time.now
message_id += "+" + '%08x%05x-%04x' % [t.to_i, t.tv_usec, rand(0xffff)]
- message_id += "@" + Configuration::incoming_email_domain
+ message_id += "@" + AlaveteliConfiguration::incoming_email_domain
return "<" + message_id + ">"
end
diff --git a/app/models/request_mailer.rb b/app/mailers/request_mailer.rb
index 955f73ef4..4dbce6738 100644
--- a/app/models/request_mailer.rb
+++ b/app/mailers/request_mailer.rb
@@ -2,89 +2,87 @@
# Alerts relating to requests.
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
-require 'alaveteli_file_types'
-if Rails.env == 'test' && RUBY_VERSION.to_f >= 1.9
- # Avoid spec/script/mailin_spec.rb running script/runner as a test suite
- # http://stackoverflow.com/questions/1899009/why-are-tests-running-in-production-mode-and-causing-my-script-runners-to-fail
- Test::Unit.run = true
-end
class RequestMailer < ApplicationMailer
-
-
# Used when an FOI officer uploads a response from their web browser - this is
# the "fake" email used to store in the same format in the database as if they
# had emailed it.
- def fake_response(info_request, from_user, body, attachment_name, attachment_content)
- @from = from_user.name_and_email
- @recipients = info_request.incoming_name_and_email
- @body = {
- :body => body
- }
+ def fake_response(info_request, from_user, message_body, attachment_name, attachment_content)
+ @message_body = message_body
+
if !attachment_name.nil? && !attachment_content.nil?
content_type = AlaveteliFileTypes.filename_to_mimetype(attachment_name) || 'application/octet-stream'
- attachment :content_type => content_type,
- :body => attachment_content,
- :filename => attachment_name
+ attachments[attachment_name] = {:content => attachment_content,
+ :content_type => content_type}
end
+
+ mail(:from => from_user.name_and_email,
+ :to => info_request.incoming_name_and_email)
end
# Used when a response is uploaded using the API
- def external_response(info_request, body, sent_at, attachments)
- @from = blackhole_email
- @recipients = info_request.incoming_name_and_email
- @body = { :body => body }
-
- # ActionMailer only works properly when the time is in the local timezone:
- # see https://rails.lighthouseapp.com/projects/8994/tickets/3113-actionmailer-only-works-correctly-with-sent_on-times-that-are-in-the-local-time-zone
- @sent_on = sent_at.dup.localtime
+ def external_response(info_request, message_body, sent_at, attachment_hashes)
+ @message_body = message_body
- attachments.each do |attachment_hash|
- attachment attachment_hash
+ attachment_hashes.each do |attachment_hash|
+ attachments[attachment_hash[:filename]] = {:content => attachment_hash[:body],
+ :content_type => attachment_hash[:content_type]}
end
+
+ mail(:from => blackhole_email,
+ :to => info_request.incoming_name_and_email,
+ :date => sent_at)
end
# Incoming message arrived for a request, but new responses have been stopped.
def stopped_responses(info_request, email, raw_email_data)
- @from = contact_from_name_and_email
- headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # we don't care about bounces, likely from spammers
- 'Auto-Submitted' => 'auto-replied' # http://tools.ietf.org/html/rfc3834
- @recipients = email.from_addrs[0].to_s
- @subject = _("Your response to an FOI request was not delivered")
- attachment :content_type => 'message/rfc822', :body => raw_email_data,
- :filename => "original.eml", :transfer_encoding => '7bit', :content_disposition => 'inline'
- @body = {
- :info_request => info_request,
- :contact_email => Configuration::contact_email
- }
+ headers('Return-Path' => blackhole_email, # we don't care about bounces, likely from spammers
+ 'Auto-Submitted' => 'auto-replied') # http://tools.ietf.org/html/rfc3834
+
+ attachments.inline["original.eml"] = raw_email_data
+
+ @info_request = info_request
+ @contact_email = AlaveteliConfiguration::contact_email
+
+ mail(:to => email.from_addrs[0].to_s,
+ :from => contact_from_name_and_email,
+ :reply_to => contact_from_name_and_email,
+ :subject => _("Your response to an FOI request was not delivered"))
end
# An FOI response is outside the scope of the system, and needs admin attention
def requires_admin(info_request, set_by = nil, message = "")
user = set_by || info_request.user
- @from = user.name_and_email
- @recipients = contact_from_name_and_email
- @subject = _("FOI response requires admin ({{reason}}) - {{title}}", :reason => info_request.described_state, :title => info_request.title)
- url = request_url(info_request)
- admin_url = admin_request_show_url(info_request)
- @body = {:reported_by => user, :message => message, :info_request => info_request, :url => url, :admin_url => admin_url }
+ @reported_by = user
+ @url = request_url(info_request)
+ @admin_url = admin_request_show_url(info_request)
+ @info_request = info_request
+ @message = message
+
+ mail(:from => user.name_and_email,
+ :to => contact_from_name_and_email,
+ :subject => _("FOI response requires admin ({{reason}}) - {{title}}", :reason => info_request.described_state, :title => info_request.title))
end
# Tell the requester that a new response has arrived
def new_response(info_request, incoming_message)
# Don't use login link here, just send actual URL. This is
# because people tend to forward these emails amongst themselves.
- url = incoming_message_url(incoming_message)
+ @url = incoming_message_url(incoming_message)
+ @incoming_message, @info_request = incoming_message, info_request
- @from = contact_from_name_and_email
- headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # not much we can do if the user's email is broken
+ headers('Return-Path' => blackhole_email,
'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834
- 'X-Auto-Response-Suppress' => 'OOF'
- @recipients = info_request.user.name_and_email
- @subject = (_("New response to your FOI request - ") + info_request.title).html_safe
- @body = { :incoming_message => incoming_message, :info_request => info_request, :url => url }
+ 'X-Auto-Response-Suppress' => 'OOF')
+
+ mail(:from => contact_from_name_and_email,
+ :to => info_request.user.name_and_email,
+ :subject => _("New response to your FOI request - ") + info_request.title,
+ :charset => "UTF-8",
+ # not much we can do if the user's email is broken
+ :reply_to => contact_from_name_and_email)
end
# Tell the requester that the public body is late in replying
@@ -92,18 +90,21 @@ class RequestMailer < ApplicationMailer
respond_url = respond_to_last_url(info_request) + "#followup"
post_redirect = PostRedirect.new(
- :uri => respond_url,
+ :uri => respond_to_last_url(info_request) + "#followup",
:user_id => user.id)
post_redirect.save!
url = confirm_url(:email_token => post_redirect.email_token)
- @from = contact_from_name_and_email
- headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # not much we can do if the user's email is broken
+ @url = confirm_url(:email_token => post_redirect.email_token)
+ @info_request = info_request
+
+ headers('Return-Path' => blackhole_email, 'Reply-To' => contact_from_name_and_email, # not much we can do if the user's email is broken
'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834
- 'X-Auto-Response-Suppress' => 'OOF'
- @recipients = user.name_and_email
- @subject = (_("Delayed response to your FOI request - ") + info_request.title).html_safe
- @body = { :info_request => info_request, :url => url }
+ 'X-Auto-Response-Suppress' => 'OOF')
+
+ mail(:from => contact_from_name_and_email,
+ :to => user.name_and_email,
+ :subject => (_("Delayed response to your FOI request - ") + info_request.title).html_safe)
end
# Tell the requester that the public body is very late in replying
@@ -111,18 +112,19 @@ class RequestMailer < ApplicationMailer
respond_url = respond_to_last_url(info_request) + "#followup"
post_redirect = PostRedirect.new(
- :uri => respond_url,
+ :uri => respond_to_last_url(info_request) + "#followup",
:user_id => user.id)
post_redirect.save!
- url = confirm_url(:email_token => post_redirect.email_token)
+ @url = confirm_url(:email_token => post_redirect.email_token)
+ @info_request = info_request
- @from = contact_from_name_and_email
- headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # not much we can do if the user's email is broken
+ headers('Return-Path' => blackhole_email, 'Reply-To' => contact_from_name_and_email, # not much we can do if the user's email is broken
'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834
- 'X-Auto-Response-Suppress' => 'OOF'
- @recipients = user.name_and_email
- @subject = (_("You're long overdue a response to your FOI request - ") + info_request.title).html_safe
- @body = { :info_request => info_request, :url => url }
+ 'X-Auto-Response-Suppress' => 'OOF')
+
+ mail(:from => contact_from_name_and_email,
+ :to => user.name_and_email,
+ :subject => (_("You're long overdue a response to your FOI request - ") + info_request.title).html_safe)
end
# Tell the requester that they need to say if the new response
@@ -134,27 +136,31 @@ class RequestMailer < ApplicationMailer
:uri => request_url(info_request) + "#describe_state_form_1",
:user_id => info_request.user.id)
post_redirect.save!
- url = confirm_url(:email_token => post_redirect.email_token)
+ @url = confirm_url(:email_token => post_redirect.email_token)
+ @incoming_message = incoming_message
+ @info_request = info_request
- @from = contact_from_name_and_email
- headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # not much we can do if the user's email is broken
+ headers('Return-Path' => blackhole_email, 'Reply-To' => contact_from_name_and_email, # not much we can do if the user's email is broken
'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834
- 'X-Auto-Response-Suppress' => 'OOF'
- @recipients = info_request.user.name_and_email
- @subject = _("Was the response you got to your FOI request any good?")
- @body = { :incoming_message => incoming_message, :info_request => info_request, :url => url }
+ 'X-Auto-Response-Suppress' => 'OOF')
+
+ mail(:from => contact_from_name_and_email,
+ :to => info_request.user.name_and_email,
+ :subject => _("Was the response you got to your FOI request any good?"))
end
# Tell the requester that someone updated their old unclassified request
def old_unclassified_updated(info_request)
- @from = contact_from_name_and_email
- headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # not much we can do if the user's email is broken
+ @url = request_url(info_request)
+ @info_request = info_request
+
+ headers('Return-Path' => blackhole_email, 'Reply-To' => contact_from_name_and_email, # not much we can do if the user's email is broken
'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834
- 'X-Auto-Response-Suppress' => 'OOF'
- @recipients = info_request.user.name_and_email
- @subject = _("Someone has updated the status of your request")
- url = request_url(info_request)
- @body = {:info_request => info_request, :url => url}
+ 'X-Auto-Response-Suppress' => 'OOF')
+
+ mail(:from => contact_from_name_and_email,
+ :to => info_request.user.name_and_email,
+ :subject => _("Someone has updated the status of your request"))
end
# Tell the requester that they need to clarify their request
@@ -166,35 +172,43 @@ class RequestMailer < ApplicationMailer
:uri => respond_url,
:user_id => info_request.user.id)
post_redirect.save!
- url = confirm_url(:email_token => post_redirect.email_token)
+ @url = confirm_url(:email_token => post_redirect.email_token)
+ @incoming_message = incoming_message
+ @info_request = info_request
- @from = contact_from_name_and_email
- headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # not much we can do if the user's email is broken
+ headers('Return-Path' => blackhole_email, 'Reply-To' => contact_from_name_and_email, # not much we can do if the user's email is broken
'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834
- 'X-Auto-Response-Suppress' => 'OOF'
- @recipients = info_request.user.name_and_email
- @subject = (_("Clarify your FOI request - ") + info_request.title).html_safe
- @body = { :incoming_message => incoming_message, :info_request => info_request, :url => url }
+ 'X-Auto-Response-Suppress' => 'OOF')
+
+ mail(:from => contact_from_name_and_email,
+ :to => info_request.user.name_and_email,
+ :subject => _("Clarify your FOI request - ") + info_request.title)
end
# Tell requester that somebody add an annotation to their request
def comment_on_alert(info_request, comment)
- @from = contact_from_name_and_email
- headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # not much we can do if the user's email is broken
+ @comment, @info_request = comment, info_request
+ @url = comment_url(comment)
+
+ headers('Return-Path' => blackhole_email, 'Reply-To' => contact_from_name_and_email, # not much we can do if the user's email is broken
'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834
- 'X-Auto-Response-Suppress' => 'OOF'
- @recipients = info_request.user.name_and_email
- @subject = (_("Somebody added a note to your FOI request - ") + info_request.title).html_safe
- @body = { :comment => comment, :info_request => info_request, :url => comment_url(comment) }
+ 'X-Auto-Response-Suppress' => 'OOF')
+
+ mail(:from => contact_from_name_and_email,
+ :to => info_request.user.name_and_email,
+ :subject => (_("Somebody added a note to your FOI request - ") + info_request.title).html_safe)
end
def comment_on_alert_plural(info_request, count, earliest_unalerted_comment)
- @from = contact_from_name_and_email
- headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # not much we can do if the user's email is broken
+ @count, @info_request = count, info_request
+ @url = comment_url(earliest_unalerted_comment)
+
+ headers('Return-Path' => blackhole_email, 'Reply-To' => contact_from_name_and_email, # not much we can do if the user's email is broken
'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834
- 'X-Auto-Response-Suppress' => 'OOF'
- @recipients = info_request.user.name_and_email
- @subject = (_("Some notes have been added to your FOI request - ") + info_request.title).html_safe
- @body = { :count => count, :info_request => info_request, :url => comment_url(earliest_unalerted_comment) }
+ 'X-Auto-Response-Suppress' => 'OOF')
+
+ mail(:from => contact_from_name_and_email,
+ :to => info_request.user.name_and_email,
+ :subject => (_("Some notes have been added to your FOI request - ") + info_request.title).html_safe)
end
# Class function, called by script/mailin with all incoming responses.
@@ -307,9 +321,9 @@ class RequestMailer < ApplicationMailer
# (otherwise they are banned, and there is no point sending it)
if info_request.user.can_make_followup?
if calculated_status == 'waiting_response_overdue'
- RequestMailer.deliver_overdue_alert(info_request, info_request.user)
+ RequestMailer.overdue_alert(info_request, info_request.user).deliver
elsif calculated_status == 'waiting_response_very_overdue'
- RequestMailer.deliver_very_overdue_alert(info_request, info_request.user)
+ RequestMailer.very_overdue_alert(info_request, info_request.user).deliver
else
raise "unknown request status"
end
@@ -323,7 +337,7 @@ class RequestMailer < ApplicationMailer
# Send email alerts for new responses which haven't been classified. By default,
# it goes out 3 days after last update of event, then after 10, then after 24.
def self.alert_new_response_reminders
- Configuration::new_response_reminder_after_days.each_with_index do |days, i|
+ AlaveteliConfiguration::new_response_reminder_after_days.each_with_index do |days, i|
self.alert_new_response_reminders_internal(days, "new_response_reminder_#{i+1}")
end
end
@@ -348,7 +362,7 @@ class RequestMailer < ApplicationMailer
store_sent.alert_type = type_code
store_sent.info_request_event_id = alert_event_id
# XXX uses same template for reminder 1 and reminder 2 right now.
- RequestMailer.deliver_new_response_reminder_alert(info_request, last_response_message)
+ RequestMailer.new_response_reminder_alert(info_request, last_response_message).deliver
store_sent.save!
end
end
@@ -376,7 +390,7 @@ class RequestMailer < ApplicationMailer
# Only send the alert if the user can act on it by making a followup
# (otherwise they are banned, and there is no point sending it)
if info_request.user.can_make_followup?
- RequestMailer.deliver_not_clarified_alert(info_request, last_response_message)
+ RequestMailer.not_clarified_alert(info_request, last_response_message).deliver
end
store_sent.save!
end
@@ -440,9 +454,9 @@ class RequestMailer < ApplicationMailer
store_sent.alert_type = 'comment_1'
store_sent.info_request_event_id = last_comment_event.id
if count > 1
- RequestMailer.deliver_comment_on_alert_plural(info_request, count, earliest_unalerted_comment_event.comment)
+ RequestMailer.comment_on_alert_plural(info_request, count, earliest_unalerted_comment_event.comment).deliver
elsif count == 1
- RequestMailer.deliver_comment_on_alert(info_request, last_comment_event.comment)
+ RequestMailer.comment_on_alert(info_request, last_comment_event.comment).deliver
else
raise "internal error"
end
diff --git a/app/models/track_mailer.rb b/app/mailers/track_mailer.rb
index 7262c82f3..8e9beded6 100644
--- a/app/models/track_mailer.rb
+++ b/app/mailers/track_mailer.rb
@@ -2,30 +2,31 @@
# Emails which go to users who are tracking things.
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class TrackMailer < ApplicationMailer
def event_digest(user, email_about_things)
+ @user, @email_about_things = user, email_about_things
+
post_redirect = PostRedirect.new(
:uri => user_url(user) + "#email_subscriptions",
:user_id => user.id)
post_redirect.save!
- unsubscribe_url = confirm_url(:email_token => post_redirect.email_token)
+ @unsubscribe_url = confirm_url(:email_token => post_redirect.email_token)
- @from = contact_from_name_and_email
- headers 'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834
- 'Precedence' => 'bulk' # http://www.vbulletin.com/forum/project.php?issueid=27687 (Exchange hack)
+ headers('Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834
+ 'Precedence' => 'bulk')# http://www.vbulletin.com/forum/project.php?issueid=27687 (Exchange hack)
# 'Return-Path' => blackhole_email, 'Reply-To' => @from # we don't care about bounces for tracks
# (We let it return bounces for now, so we can manually kill the tracks that bounce so Yahoo
# etc. don't decide we are spammers.)
- @recipients = user.name_and_email
- @subject = _("Your {{site_name}} email alert", :site_name => site_name)
- @body = { :user => user, :email_about_things => email_about_things, :unsubscribe_url => unsubscribe_url }
+ mail(:from => contact_from_name_and_email,
+ :to => user.name_and_email,
+ :subject => _("Your {{site_name}} email alert", :site_name => site_name))
end
def contact_from_name_and_email
- "#{Configuration::track_sender_name} <#{Configuration::track_sender_email}>"
+ "#{AlaveteliConfiguration::track_sender_name} <#{AlaveteliConfiguration::track_sender_email}>"
end
# Send email alerts for tracked things. Never more than one email
@@ -38,11 +39,9 @@ class TrackMailer < ApplicationMailer
def self.alert_tracks
done_something = false
now = Time.now()
- users = User.find(:all, :conditions => [ "last_daily_track_email < ?", now - 1.day ])
- if users.empty?
- return done_something
- end
- for user in users
+ one_week_ago = now - 7.days
+ User.find_each(:conditions => [ "last_daily_track_email < ?",
+ now - 1.day ]) do |user|
next if !user.should_be_emailed? || !user.receive_email_alerts
email_about_things = []
@@ -66,7 +65,11 @@ class TrackMailer < ApplicationMailer
# Query for things in this track. We use described_at for the
# ordering, so we catch anything new (before described), or
# anything whose new status has been described.
- xapian_object = InfoRequest.full_search([InfoRequestEvent], track_thing.track_query, 'described_at', true, nil, 100, 1)
+ xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], track_thing.track_query,
+ :sort_by_prefix => 'described_at',
+ :sort_by_ascending => true,
+ :collapse_by_prefix => nil,
+ :limit => 100)
# Go through looking for unalerted things
alert_results = []
for result in xapian_object.results
@@ -75,7 +78,7 @@ class TrackMailer < ApplicationMailer
end
next if track_thing.created_at >= result[:model].described_at # made before the track was created
- next if result[:model].described_at < now - 7.days # older than 1 week (see 14 days / 7 days in comment above)
+ next if result[:model].described_at < one_week_ago # older than 1 week (see 14 days / 7 days in comment above)
next if done_info_request_events.include?(result[:model].id) # definitely already done
# OK alert this one
@@ -92,7 +95,7 @@ class TrackMailer < ApplicationMailer
# Send the email
I18n.with_locale(user.get_locale) do
- TrackMailer.deliver_event_digest(user, email_about_things)
+ TrackMailer.event_digest(user, email_about_things).deliver
end
end
diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb
new file mode 100644
index 000000000..a351147f9
--- /dev/null
+++ b/app/mailers/user_mailer.rb
@@ -0,0 +1,44 @@
+# models/user_mailer.rb:
+# Emails relating to user accounts. e.g. Confirming a new account
+#
+# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
+
+class UserMailer < ApplicationMailer
+ def confirm_login(user, reasons, url)
+ @reasons, @name, @url = reasons, user.name, url
+ headers('Return-Path' => blackhole_email, 'Reply-To' => contact_from_name_and_email) # we don't care about bounces when people are fiddling with their account
+
+ mail(:from => contact_from_name_and_email,
+ :to => user.name_and_email,
+ :subject => reasons[:email_subject])
+ end
+
+ def already_registered(user, reasons, url)
+ @reasons, @name, @url = reasons, user.name, url
+ headers('Return-Path' => blackhole_email, 'Reply-To' => contact_from_name_and_email) # we don't care about bounces when people are fiddling with their account
+
+ mail(:from => contact_from_name_and_email,
+ :to => user.name_and_email,
+ :subject => reasons[:email_subject])
+ end
+
+ def changeemail_confirm(user, new_email, url)
+ @name, @url, @old_email, @new_email = user.name, url, user.email, new_email
+ headers('Return-Path' => blackhole_email, 'Reply-To' => contact_from_name_and_email) # we don't care about bounces when people are fiddling with their account
+
+ mail(:from => contact_from_name_and_email,
+ :to => new_email,
+ :subject => _("Confirm your new email address on {{site_name}}", :site_name => site_name))
+ end
+
+ def changeemail_already_used(old_email, new_email)
+ @old_email, @new_email = old_email, new_email
+ headers('Return-Path' => blackhole_email, 'Reply-To' => contact_from_name_and_email) # we don't care about bounces when people are fiddling with their account
+
+ mail(:from => contact_from_name_and_email,
+ :to => new_email,
+ :subject => _("Unable to change email address on {{site_name}}", :site_name=>site_name))
+ end
+end
+
diff --git a/app/models/about_me_validator.rb b/app/models/about_me_validator.rb
index 8ee505ac8..7df70fb61 100644
--- a/app/models/about_me_validator.rb
+++ b/app/models/about_me_validator.rb
@@ -1,25 +1,23 @@
-# == Schema Information
-# Schema version: 114
-#
-# Table name: about_me_validators
-#
-# about_me :text default("I..."), not null
-#
-
# models/about_me_validator.rb:
# Validates editing about me text on user profile pages.
#
# Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
-class AboutMeValidator < ActiveRecord::BaseWithoutTable
- strip_attributes!
+class AboutMeValidator
+ include ActiveModel::Validations
- column :about_me, :text, "I...", false
+ attr_accessor :about_me
# TODO: Switch to built in validations
validate :length_of_about_me
+ def initialize(attributes = {})
+ attributes.each do |name, value|
+ send("#{name}=", value)
+ end
+ end
+
private
def length_of_about_me
diff --git a/app/models/application_mailer.rb b/app/models/application_mailer.rb
deleted file mode 100644
index 1a97a4bf9..000000000
--- a/app/models/application_mailer.rb
+++ /dev/null
@@ -1,164 +0,0 @@
-# models/application_mailer.rb:
-# Shared code between different mailers.
-#
-# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
-
-require 'action_mailer/version'
-class ApplicationMailer < ActionMailer::Base
- # Include all the functions views get, as emails call similar things.
- helper :application
- include MailerHelper
-
- # This really should be the default - otherwise you lose any information
- # about the errors, and have to do error checking on return codes.
- self.raise_delivery_errors = true
-
- def blackhole_email
- Configuration::blackhole_prefix+"@"+Configuration::incoming_email_domain
- end
-
- # URL generating functions are needed by all controllers (for redirects),
- # views (for links) and mailers (for use in emails), so include them into
- # all of all.
- include LinkToHelper
-
- # Site-wide access to configuration settings
- include ConfigHelper
-
- # Instantiate a new mailer object. If +method_name+ is not +nil+, the mailer
- # will be initialized according to the named method. If not, the mailer will
- # remain uninitialized (useful when you only need to invoke the "receive"
- # method, for instance).
- def initialize(method_name=nil, *parameters) #:nodoc:
- create!(method_name, *parameters) if method_name
- end
-
- # For each multipart template (e.g. "the_template_file.text.html.erb") available,
- # add the one from the view path with the highest priority as a part to the mail
- def render_multipart_templates
- added_content_types = {}
- self.view_paths.each do |view_path|
- Dir.glob("#{view_path}/#{mailer_name}/#{@template}.*").each do |path|
- template = view_path["#{mailer_name}/#{File.basename(path)}"]
-
- # Skip unless template has a multipart format
- next unless template && template.multipart?
- next if added_content_types[template.content_type] == true
- @parts << Part.new(
- :content_type => template.content_type,
- :disposition => "inline",
- :charset => charset,
- :body => render_message(template, @body)
- )
- added_content_types[template.content_type] = true
- end
- end
- end
-
- # Look for the current template in each element of view_paths in order,
- # return the first
- def find_template
- self.view_paths.each do |view_path|
- if template = view_path["#{mailer_name}/#{@template}"]
- return template
- end
- end
- return nil
- end
-
- if ActionMailer::VERSION::MAJOR == 2
-
- # This method is a customised version of ActionMailer::Base.create!
- # modified to allow templates to be selected correctly for multipart
- # mails when themes have added to the view_paths. The problem from our
- # point of view with ActionMailer::Base is that it sets template_root to
- # the first element of the view_paths array and then uses only that (directly
- # and via template_path, which is created from it) in the create! method when
- # looking for templates. Our modified version looks for templates in the view_paths
- # in order.
-
- # It also has a line converting the mail subject to a string. This is because we
- # use translated strings in the subject lines, sometimes in conjunction with
- # user input, like request titles. The _() function used for translation
- # returns an instance of SafeBuffer, which doesn't handle gsub calls in the block form
- # with $ variables - https://github.com/rails/rails/issues/1555.
- # Unfortunately ActionMailer uses that form in quoted_printable(), which will be
- # called if any part of the subject requires quoting. So we convert the subject
- # back to a string via to_str() before passing in to create_mail. There is a test
- # for this in spec/models/request_mailer_spec.rb
-
- # Changed lines marked with ***
-
- # Initialize the mailer via the given +method_name+. The body will be
- # rendered and a new TMail::Mail object created.
- def create!(method_name, *parameters) #:nodoc:
- initialize_defaults(method_name)
- __send__(method_name, *parameters)
-
- # If an explicit, textual body has not been set, we check assumptions.
- unless String === @body
- # First, we look to see if there are any likely templates that match,
- # which include the content-type in their file name (i.e.,
- # "the_template_file.text.html.erb", etc.). Only do this if parts
- # have not already been specified manually.
- if @parts.empty?
- # *** render_multipart_templates replaces the following code
- # Dir.glob("#{template_path}/#{@template}.*").each do |path|
- # template = template_root["#{mailer_name}/#{File.basename(path)}"]
- #
- # # Skip unless template has a multipart format
- # next unless template && template.multipart?
- #
- # @parts << Part.new(
- # :content_type => template.content_type,
- # :disposition => "inline",
- # :charset => charset,
- # :body => render_message(template, @body)
- # )
- # end
- render_multipart_templates
-
- unless @parts.empty?
- @content_type = "multipart/alternative" if @content_type !~ /^multipart/
- @parts = sort_parts(@parts, @implicit_parts_order)
- end
- end
-
- # Then, if there were such templates, we check to see if we ought to
- # also render a "normal" template (without the content type). If a
- # normal template exists (or if there were no implicit parts) we render
- # it.
- template_exists = @parts.empty?
-
- # *** find_template replaces template_root call
- # template_exists ||= template_root["#{mailer_name}/#{@template}"]
- template_exists ||= find_template
-
- @body = render_message(@template, @body) if template_exists
-
- # Finally, if there are other message parts and a textual body exists,
- # we shift it onto the front of the parts and set the body to nil (so
- # that create_mail doesn't try to render it in addition to the parts).
- if !@parts.empty? && String === @body
- @parts.unshift ActionMailer::Part.new(:charset => charset, :body => @body)
- @body = nil
- end
- end
-
- # If this is a multipart e-mail add the mime_version if it is not
- # already set.
- @mime_version ||= "1.0" if !@parts.empty?
-
- # *** Convert into a string
- @subject = @subject.to_str if @subject
-
- # build the mail object itself
- @mail = create_mail
- end
- else
- raise "ApplicationMailer.create! is obsolete - find another way to ensure that themes can override mail templates for multipart mails"
- end
-
-end
-
diff --git a/app/models/censor_rule.rb b/app/models/censor_rule.rb
index f40ab6fbb..f0d06e088 100644
--- a/app/models/censor_rule.rb
+++ b/app/models/censor_rule.rb
@@ -20,7 +20,7 @@
# Stores alterations to remove specific data from requests.
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class CensorRule < ActiveRecord::Base
belongs_to :info_request
@@ -33,13 +33,15 @@ class CensorRule < ActiveRecord::Base
validate :require_valid_regexp, :if => proc{ |rule| rule.regexp? == true }
validates_presence_of :text
- named_scope :global, {:conditions => {:info_request_id => nil,
- :user_id => nil,
- :public_body_id => nil}}
+ scope :global, {:conditions => {:info_request_id => nil,
+ :user_id => nil,
+ :public_body_id => nil}}
def require_user_request_or_public_body
if self.info_request.nil? && self.user.nil? && self.public_body.nil?
- errors.add("Censor must apply to an info request a user or a body; ")
+ [:info_request, :user, :public_body].each do |a|
+ errors.add(a, "Rule must apply to an info request, a user or a body")
+ end
end
end
diff --git a/app/models/change_email_validator.rb b/app/models/change_email_validator.rb
index 2ddebb177..5cc13d4c2 100644
--- a/app/models/change_email_validator.rb
+++ b/app/models/change_email_validator.rb
@@ -1,36 +1,27 @@
-# == Schema Information
-# Schema version: 114
-#
-# Table name: change_email_validators
-#
-# old_email :string
-# new_email :string
-# password :string
-# user_circumstance :string
-#
-
# models/changeemail_validator.rb:
# Validates email change form submissions.
#
# Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
-
-class ChangeEmailValidator < ActiveRecord::BaseWithoutTable
- strip_attributes!
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
- column :old_email, :string
- column :new_email, :string
- column :password, :string
- column :user_circumstance, :string
+class ChangeEmailValidator
+ include ActiveModel::Validations
- attr_accessor :logged_in_user
+ attr_accessor :old_email, :new_email, :password, :user_circumstance, :logged_in_user
validates_presence_of :old_email, :message => N_("Please enter your old email address")
validates_presence_of :new_email, :message => N_("Please enter your new email address")
validates_presence_of :password, :message => N_("Please enter your password"), :unless => :changing_email
validate :password_and_format_of_email
- def changing_email()
+ def initialize(attributes = {})
+ attributes.each do |name, value|
+ send("#{name}=", value)
+ end
+ end
+
+
+ def changing_email
self.user_circumstance == 'change_email'
end
@@ -41,11 +32,11 @@ class ChangeEmailValidator < ActiveRecord::BaseWithoutTable
errors.add(:old_email, _("Old email doesn't look like a valid address"))
end
- if !errors[:old_email]
+ if errors[:old_email].blank?
if self.old_email.downcase != self.logged_in_user.email.downcase
errors.add(:old_email, _("Old email address isn't the same as the address of the account you are logged in with"))
elsif (!self.changing_email) && (!self.logged_in_user.has_this_password?(self.password))
- if !errors[:password]
+ if errors[:password].blank?
errors.add(:password, _("Password is not correct"))
end
end
@@ -55,5 +46,4 @@ class ChangeEmailValidator < ActiveRecord::BaseWithoutTable
errors.add(:new_email, _("New email doesn't look like a valid address"))
end
end
-
end
diff --git a/app/models/comment.rb b/app/models/comment.rb
index 70f3ba00d..9527030a9 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -18,7 +18,7 @@
# A comment by a user upon something.
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class Comment < ActiveRecord::Base
strip_attributes!
diff --git a/app/models/contact_mailer.rb b/app/models/contact_mailer.rb
deleted file mode 100644
index abde64928..000000000
--- a/app/models/contact_mailer.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-# models/contact_mailer.rb:
-# Sends contact form mails.
-#
-# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
-
-class ContactMailer < ApplicationMailer
-
- # Send message to administrator
- def to_admin_message(name, email, subject, message, logged_in_user, last_request, last_body)
- @from = name + " <" + email + ">"
- @recipients = contact_from_name_and_email
- @subject = subject
- @body = { :message => message,
- :logged_in_user => logged_in_user ,
- :last_request => last_request,
- :last_body => last_body
- }
- end
-
- # We always set Reply-To when we set Return-Path to be different from From,
- # since some email clients seem to erroneously use the envelope from when
- # they shouldn't, and this might help. (Have had mysterious cases of a
- # reply coming in duplicate from a public body to both From and envelope
- # from)
-
- # Send message to another user
- def user_message(from_user, recipient_user, from_user_url, subject, message)
- @from = from_user.name_and_email
- # Do not set envelope from address to the from_user, so they can't get
- # someone's email addresses from transitory bounce messages.
- headers 'Return-Path' => blackhole_email, 'Reply-To' => @from
- @recipients = recipient_user.name_and_email
- @subject = subject
- @body = {
- :message => message,
- :from_user => from_user,
- :recipient_user => recipient_user,
- :from_user_url => from_user_url
- }
- end
-
- # Send message to a user from the administrator
- def from_admin_message(recipient_user, subject, message)
- @from = contact_from_name_and_email
- @recipients = recipient_user.name_and_email
- @subject = subject
- @body = {
- :message => message,
- :from_user => @from,
- :recipient_user => recipient_user,
- }
- bcc Configuration::contact_email
- end
-
-end
diff --git a/app/models/contact_validator.rb b/app/models/contact_validator.rb
index d277161f9..65e539669 100644
--- a/app/models/contact_validator.rb
+++ b/app/models/contact_validator.rb
@@ -1,35 +1,29 @@
-# == Schema Information
-# Schema version: 114
-#
-# Table name: contact_validators
-#
-# name :string
-# email :string
-# subject :text
-# message :text
-#
-
# models/contact_validator.rb:
# Validates contact form submissions.
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
-class ContactValidator < ActiveRecord::BaseWithoutTable
- strip_attributes!
+class ContactValidator
+ include ActiveModel::Validations
- column :name, :string
- column :email, :string
- column :subject, :text
- column :message, :text
+ attr_accessor :name, :email, :subject, :message
validates_presence_of :name, :message => N_("Please enter your name")
validates_presence_of :email, :message => N_("Please enter your email address")
validates_presence_of :subject, :message => N_("Please enter a subject")
validates_presence_of :message, :message => N_("Please enter the message you want to send")
+ validate :email_format
- def validate
- errors.add(:email, _("Email doesn't look like a valid address")) unless MySociety::Validate.is_valid_email(self.email)
+ def initialize(attributes = {})
+ attributes.each do |name, value|
+ send("#{name}=", value)
+ end
end
+ private
+
+ def email_format
+ errors.add(:email, _("Email doesn't look like a valid address")) unless MySociety::Validate.is_valid_email(self.email)
+ end
end
diff --git a/app/models/foi_attachment.rb b/app/models/foi_attachment.rb
index bba0b6a8d..0340f2b83 100644
--- a/app/models/foi_attachment.rb
+++ b/app/models/foi_attachment.rb
@@ -20,7 +20,7 @@
# An attachment to an email (IncomingMessage)
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
# This is the type which is used to send data about attachments to the view
require 'digest'
@@ -38,11 +38,7 @@ class FoiAttachment < ActiveRecord::Base
BODY_MAX_DELAY = 5
def directory
- rails_env = Rails.env
- if rails_env.nil? || rails_env.empty?
- raise "$RAILS_ENV is not set"
- end
- base_dir = File.expand_path(File.join(File.dirname(__FILE__), "../../cache", "attachments_#{rails_env}"))
+ base_dir = File.expand_path(File.join(File.dirname(__FILE__), "../../cache", "attachments_#{Rails.env}"))
return File.join(base_dir, self.hexdigest[0..2])
end
@@ -67,28 +63,20 @@ class FoiAttachment < ActiveRecord::Base
file.write d
}
update_display_size!
- encode_cached_body!
@cached_body = d
end
- # If the original mail part had a charset, it's some kind of string, so assume that
- # it should be handled as a string in the stated charset, not a bytearray, and then
- # convert it our default encoding. For ruby 1.8 this is a noop.
- def encode_cached_body!
- if RUBY_VERSION.to_f >= 1.9
- if charset
- @cached_body.force_encoding(charset)
- @cached_body = @cached_body.encode(Encoding.default_internal, charset)
- end
- end
- end
-
def body
if @cached_body.nil?
tries = 0
delay = 1
begin
- @cached_body = File.open(self.filepath, "rb" ).read
+ binary_data = File.open(self.filepath, "rb" ).read
+ if self.content_type =~ /^text/
+ @cached_body = convert_string_to_utf8_or_binary(binary_data, 'UTF-8')
+ else
+ @cached_body = binary_data
+ end
rescue Errno::ENOENT
# we've lost our cached attachments for some reason. Reparse them.
if tries > BODY_MAX_TRIES
@@ -103,7 +91,6 @@ class FoiAttachment < ActiveRecord::Base
self.incoming_message.parse_raw_email!(force)
retry
end
- encode_cached_body!
end
return @cached_body
end
diff --git a/app/models/holiday.rb b/app/models/holiday.rb
index 13258396a..98f73e963 100644
--- a/app/models/holiday.rb
+++ b/app/models/holiday.rb
@@ -19,7 +19,7 @@
# -- Freedom of Information Act 2000 section 10
#
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class Holiday < ActiveRecord::Base
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 5c845ead3..ae3c3b407 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -25,19 +25,16 @@
# response from the public body.
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
# TODO
# Move some of the (e.g. quoting) functions here into rblib, as they feel
# general not specific to IncomingMessage.
-require 'alaveteli_file_types'
require 'htmlentities'
require 'rexml/document'
require 'zip/zip'
-require 'mapi/msg'
-require 'mapi/convert'
-
+require 'iconv' unless RUBY_VERSION >= '1.9'
class IncomingMessage < ActiveRecord::Base
belongs_to :info_request
@@ -132,6 +129,7 @@ class IncomingMessage < ActiveRecord::Base
end
self.valid_to_reply_to = self._calculate_valid_to_reply_to
self.last_parsed = Time.now
+ self.foi_attachments reload=true
self.save!
end
end
@@ -173,15 +171,29 @@ class IncomingMessage < ActiveRecord::Base
super
end
- # And look up by URL part number to get an attachment
+ # And look up by URL part number and display filename to get an attachment
# XXX relies on extract_attachments calling MailHandler.ensure_parts_counted
- def self.get_attachment_by_url_part_number(attachments, found_url_part_number)
- attachments.each do |a|
- if a.url_part_number == found_url_part_number
- return a
+ # The filename here is passed from the URL parameter, so it's the
+ # display_filename rather than the real filename.
+ def self.get_attachment_by_url_part_number_and_filename(attachments, found_url_part_number, display_filename)
+ attachment_by_part_number = attachments.detect { |a| a.url_part_number == found_url_part_number }
+ if attachment_by_part_number && attachment_by_part_number.display_filename == display_filename
+ # Then the filename matches, which is fine:
+ attachment_by_part_number
+ else
+ # Otherwise if the URL part number and filename don't
+ # match - this is probably due to a reparsing of the
+ # email. In that case, try to find a unique matching
+ # filename from any attachment.
+ attachments_by_filename = attachments.select { |a|
+ a.display_filename == display_filename
+ }
+ if attachments_by_filename.length == 1
+ attachments_by_filename[0]
+ else
+ nil
end
end
- return nil
end
# Converts email addresses we know about into textual descriptions of them
@@ -193,7 +205,7 @@ class IncomingMessage < ActiveRecord::Base
text.gsub!(self.info_request.public_body.request_email, _("[{{public_body}} request email]", :public_body => self.info_request.public_body.short_or_long_name))
end
text.gsub!(self.info_request.incoming_email, _('[FOI #{{request}} email]', :request => self.info_request.id.to_s) )
- text.gsub!(Configuration::contact_email, _("[{{site_name}} contact email]", :site_name => Configuration::site_name) )
+ text.gsub!(AlaveteliConfiguration::contact_email, _("[{{site_name}} contact email]", :site_name => AlaveteliConfiguration::site_name) )
end
# Replaces all email addresses in (possibly binary data) with equal length alternative ones.
@@ -219,7 +231,7 @@ class IncomingMessage < ActiveRecord::Base
if censored_uncompressed_text != uncompressed_text
# then use the altered file (recompressed)
recompressed_text = nil
- if Configuration::use_ghostscript_compression == true
+ if AlaveteliConfiguration::use_ghostscript_compression == true
command = ["gs", "-sDEVICE=pdfwrite", "-dCompatibilityLevel=1.4", "-dPDFSETTINGS=/screen", "-dNOPAUSE", "-dQUIET", "-dBATCH", "-sOutputFile=-", "-"]
else
command = ["pdftk", "-", "output", "-", "compress"]
@@ -246,7 +258,7 @@ class IncomingMessage < ActiveRecord::Base
# Used by binary_mask_stuff - replace text in place
def _binary_mask_stuff_internal!(text)
# Keep original size, so can check haven't resized it
- orig_size = text.size
+ orig_size = text.mb_chars.size
# Replace ASCII email addresses...
text.gsub!(MySociety::Validate.email_find_regexp) do |email|
@@ -258,11 +270,21 @@ class IncomingMessage < ActiveRecord::Base
# equivalents to the UCS-2
ascii_chars = text.gsub(/\0/, "")
emails = ascii_chars.scan(MySociety::Validate.email_find_regexp)
+
# Convert back to UCS-2, making a mask at the same time
- emails.map! {|email| [
- Iconv.conv('ucs-2le', 'ascii', email[0]),
- Iconv.conv('ucs-2le', 'ascii', email[0].gsub(/[^@.]/, 'x'))
- ] }
+ if RUBY_VERSION >= '1.9'
+ emails.map! do |email|
+ # We want the ASCII representation of UCS-2
+ [email[0].encode('UTF-16LE').force_encoding('US-ASCII'),
+ email[0].gsub(/[^@.]/, 'x').encode('UTF-16LE').force_encoding('US-ASCII')]
+ end
+ else
+ emails.map! {|email| [
+ Iconv.conv('ucs-2le', 'ascii', email[0]),
+ Iconv.conv('ucs-2le', 'ascii', email[0].gsub(/[^@.]/, 'x'))
+ ] }
+ end
+
# Now search and replace the UCS-2 email with the UCS-2 mask
for email, mask in emails
text.gsub!(email, mask)
@@ -271,7 +293,7 @@ class IncomingMessage < ActiveRecord::Base
# Replace censor items
self.info_request.apply_censor_rules_to_binary!(text)
- raise "internal error in binary_mask_stuff" if text.size != orig_size
+ raise "internal error in binary_mask_stuff" if text.mb_chars.size != orig_size
return text
end
@@ -316,7 +338,7 @@ class IncomingMessage < ActiveRecord::Base
text.gsub!(/(Mobile|Mob)([\s\/]*(Fax|Tel))*\s*:?[\s\d]*\d/, "[mobile number]")
# Remove WhatDoTheyKnow signup links
- text.gsub!(/http:\/\/#{Configuration::domain}\/c\/[^\s]+/, "[WDTK login link]")
+ text.gsub!(/http:\/\/#{AlaveteliConfiguration::domain}\/c\/[^\s]+/, "[WDTK login link]")
# Remove things from censor rules
self.info_request.apply_censor_rules_to_text!(text)
@@ -534,7 +556,7 @@ class IncomingMessage < ActiveRecord::Base
source_charset = 'utf-8' if source_charset.nil?
text = Iconv.conv('utf-8//IGNORE', source_charset, text) +
_("\n\n[ {{site_name}} note: The above text was badly encoded, and has had strange characters removed. ]",
- :site_name => Configuration::site_name)
+ :site_name => AlaveteliConfiguration::site_name)
rescue Iconv::InvalidEncoding, Iconv::IllegalSequence, Iconv::InvalidCharacter
if source_charset != "utf-8"
source_charset = "utf-8"
@@ -546,9 +568,11 @@ class IncomingMessage < ActiveRecord::Base
text
end
- # Returns part which contains main body text, or nil if there isn't one
- def get_main_body_text_part
- leaves = self.foi_attachments
+ # Returns part which contains main body text, or nil if there isn't one,
+ # from a set of foi_attachments. If the leaves parameter is empty or not
+ # supplied, uses its own foi_attachments.
+ def get_main_body_text_part(leaves=[])
+ leaves = self.foi_attachments if leaves.empty?
# Find first part which is text/plain or text/html
# (We have to include HTML, as increasingly there are mail clients that
@@ -582,6 +606,7 @@ class IncomingMessage < ActiveRecord::Base
# nil in this case)
return p
end
+
# Returns attachments that are uuencoded in main body part
def _uudecode_and_save_attachments(text)
# Find any uudecoded things buried in it, yeuchly
@@ -605,7 +630,7 @@ class IncomingMessage < ActiveRecord::Base
content_type = 'application/octet-stream'
end
hexdigest = Digest::MD5.hexdigest(content)
- attachment = self.foi_attachments.find_or_create_by_hexdigest(:hexdigest => hexdigest)
+ attachment = self.foi_attachments.find_or_create_by_hexdigest(hexdigest)
attachment.update_attributes(:filename => filename,
:content_type => content_type,
:body => content,
@@ -632,15 +657,19 @@ class IncomingMessage < ActiveRecord::Base
attachment_attributes = MailHandler.get_attachment_attributes(self.mail(force))
attachments = []
attachment_attributes.each do |attrs|
- attachment = self.foi_attachments.find_or_create_by_hexdigest(:hexdigest => attrs[:hexdigest])
- body = attrs.delete(:body)
+ attachment = self.foi_attachments.find_or_create_by_hexdigest(attrs[:hexdigest])
attachment.update_attributes(attrs)
- # Set the body separately as its handling can depend on the value of charset
- attachment.body = body
attachment.save!
- attachments << attachment.id
+ attachments << attachment
end
- main_part = get_main_body_text_part
+
+ # Reload to refresh newly created foi_attachments
+ self.reload
+
+ # get the main body part from the set of attachments we just created,
+ # not from the self.foi_attachments association - some of the total set of
+ # self.foi_attachments may now be obsolete
+ main_part = get_main_body_text_part(attachments)
# we don't use get_main_body_text_internal, as we want to avoid charset
# conversions, since /usr/bin/uudecode needs to deal with those.
# e.g. for https://secure.mysociety.org/admin/foi/request/show_raw_email/24550
@@ -651,12 +680,14 @@ class IncomingMessage < ActiveRecord::Base
c += 1
uudecode_attachment.url_part_number = c
uudecode_attachment.save!
- attachments << uudecode_attachment.id
+ attachments << uudecode_attachment
end
end
+ attachment_ids = attachments.map{ |attachment| attachment.id }
# now get rid of any attachments we no longer have
- FoiAttachment.destroy_all("id NOT IN (#{attachments.join(',')}) AND incoming_message_id = #{self.id}")
+ FoiAttachment.destroy_all(["id NOT IN (?) AND incoming_message_id = ?",
+ attachment_ids, self.id])
end
# Returns body text as HTML with quotes flattened, and emails removed.
@@ -682,7 +713,7 @@ class IncomingMessage < ActiveRecord::Base
text.strip!
# if there is nothing but quoted stuff, then show the subject
if text == "FOLDED_QUOTED_SECTION"
- text = "[Subject only] " + CGI.escapeHTML(self.subject) + text
+ text = "[Subject only] " + CGI.escapeHTML(self.subject || '') + text
end
# and display link for quoted stuff
text = text.gsub(/FOLDED_QUOTED_SECTION/, "\n\n" + '<span class="unfold_link"><a href="?unfold=1#incoming-'+self.id.to_s+'">'+_("show quoted sections")+'</a></span>' + "\n\n")
@@ -748,9 +779,15 @@ class IncomingMessage < ActiveRecord::Base
attachment.body,
attachment.charset)
end
+
# Remove any bad characters
- text = Iconv.conv('utf-8//IGNORE', 'utf-8', text)
- return text
+ if RUBY_VERSION >= '1.9'
+ text.encode("utf-8", :invalid => :replace,
+ :undef => :replace,
+ :replace => "")
+ else
+ Iconv.conv('utf-8//IGNORE', 'utf-8', text)
+ end
end
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index eaed25a61..8f15a4ea4 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -26,8 +26,7 @@
require 'digest/sha1'
class InfoRequest < ActiveRecord::Base
- include ActionView::Helpers::UrlHelper
- include ActionController::UrlWriter
+ include Rails.application.routes.url_helpers
strip_attributes!
@@ -51,7 +50,7 @@ class InfoRequest < ActiveRecord::Base
has_tag_string
- named_scope :visible, :conditions => {:prominence => "normal"}
+ scope :visible, :conditions => {:prominence => "normal"}
# user described state (also update in info_request_event, admin_request/edit.rhtml)
validate :must_be_valid_state
@@ -81,6 +80,11 @@ class InfoRequest < ActiveRecord::Base
'blackhole' # just dump them
]
+ # only check on create, so existing models with mixed case are allowed
+ validate :title_formatting, :on => :create
+
+ after_initialize :set_defaults
+
def self.enumerate_states
states = [
'waiting_response',
@@ -104,6 +108,12 @@ class InfoRequest < ActiveRecord::Base
states
end
+ # Possible reasons that a request could be reported for administrator attention
+ def report_reasons
+ ["Contains defamatory material", "Not a valid request", "Request for personal information",
+ "Contains personal information", "Vexatious", "Other"]
+ end
+
def must_be_valid_state
errors.add(:described_state, "is not a valid state") if
!InfoRequest.enumerate_states.include? described_state
@@ -146,9 +156,13 @@ class InfoRequest < ActiveRecord::Base
end
end
+ def user_json_for_api
+ is_external? ? { :name => user_name || _("Anonymous user") } : user.json_for_api
+ end
+
@@custom_states_loaded = false
begin
- if ENV["RAILS_ENV"] != "test"
+ if !Rails.env.test?
require 'customstates'
include InfoRequestCustomStates
@@custom_states_loaded = true
@@ -185,21 +199,6 @@ class InfoRequest < ActiveRecord::Base
self.comments.find(:all, :conditions => 'visible')
end
- # Central function to do all searches
- # (Not really the right place to put it, but everything can get it here, and it
- # does *mainly* find info requests, via their events, so hey)
- def InfoRequest.full_search(models, query, order, ascending, collapse, per_page, page)
- offset = (page - 1) * per_page
-
- return ::ActsAsXapian::Search.new(
- models, query,
- :offset => offset, :limit => per_page,
- :sort_by_prefix => order,
- :sort_by_ascending => ascending,
- :collapse_by_prefix => collapse
- )
- end
-
# If the URL name has changed, then all request: queries will break unless
# we update index for every event. Also reindex if prominence changes.
after_update :reindex_some_request_events
@@ -228,17 +227,6 @@ class InfoRequest < ActiveRecord::Base
end
end
- # For debugging
- def InfoRequest.profile_search(query)
- t = Time.now.usec
- for i in (1..10)
- t = Time.now.usec - t
- secs = t / 1000000.0
- STDOUT.write secs.to_s + " query " + i.to_s + "\n"
- results = InfoRequest.full_search([InfoRequestEvent], query, "created_at", true, nil, 25, 1).results
- end
- end
-
public
# When name is changed, also change the url name
def title=(title)
@@ -290,7 +278,7 @@ public
end
end
def email_subject_followup(incoming_message = nil)
- if incoming_message.nil? || !incoming_message.valid_to_reply_to?
+ if incoming_message.nil? || !incoming_message.valid_to_reply_to? || !incoming_message.subject
'Re: ' + self.email_subject_request
else
if incoming_message.subject.match(/^Re:/i)
@@ -347,7 +335,10 @@ public
# copying an email, and that doesn't matter)
def InfoRequest.find_by_incoming_email(incoming_email)
id, hash = InfoRequest._extract_id_hash_from_email(incoming_email)
- return self.find_by_magic_email(id, hash)
+ if hash_from_id(id) == hash
+ # Not using find(id) because we don't exception raised if nothing found
+ find_by_id(id)
+ end
end
# Return list of info requests which *might* be right given email address
@@ -456,7 +447,7 @@ public
if !allow
if self.handle_rejected_responses == 'bounce'
- RequestMailer.deliver_stopped_responses(self, email, raw_email_data) if !is_external?
+ RequestMailer.stopped_responses(self, email, raw_email_data).deliver if !is_external?
elsif self.handle_rejected_responses == 'holding_pen'
InfoRequest.holding_pen_request.receive(email, raw_email_data, false, reason)
elsif self.handle_rejected_responses == 'blackhole'
@@ -495,13 +486,13 @@ public
self.awaiting_description = true
params = { :incoming_message_id => incoming_message.id }
if !rejected_reason.empty?
- params[:rejected_reason] = rejected_reason
+ params[:rejected_reason] = rejected_reason.to_str
end
self.log_event("response", params)
self.save!
end
self.info_request_events.each { |event| event.xapian_mark_needs_index } # for the "waiting_classification" index
- RequestMailer.deliver_new_response(self, incoming_message) if !is_external?
+ RequestMailer.new_response(self, incoming_message).deliver if !is_external?
end
@@ -554,10 +545,23 @@ public
# states which require administrator action (hence email administrators
# when they are entered, and offer state change dialog to them)
+ def InfoRequest.requires_admin_states
+ return ['requires_admin', 'error_message', 'attention_requested']
+ end
+
def requires_admin?
['requires_admin', 'error_message', 'attention_requested'].include?(described_state)
end
+ # Report this request for administrator attention
+ def report!(reason, message, user)
+ ActiveRecord::Base.transaction do
+ set_described_state('attention_requested', user, "Reason: #{reason}\n\n#{message}")
+ self.attention_requested = true # tells us if attention has ever been requested
+ save!
+ end
+ end
+
# change status, including for last event for later historical purposes
def set_described_state(new_state, set_by = nil, message = "")
old_described_state = described_state
@@ -575,22 +579,12 @@ public
if self.requires_admin?
# Check there is someone to send the message "from"
if !set_by.nil? || !self.user.nil?
- RequestMailer.deliver_requires_admin(self, set_by, message)
+ RequestMailer.requires_admin(self, set_by, message).deliver
end
end
unless set_by.nil? || is_actual_owning_user?(set_by) || described_state == 'attention_requested'
- # Log the status change by someone other than the requester
- event = log_event("status_update",
- { :user_id => set_by.id,
- :old_described_state => old_described_state,
- :described_state => described_state,
- })
- # Create a classification event for league tables
- RequestClassification.create!(:user_id => set_by.id,
- :info_request_event_id => event.id)
-
- RequestMailer.deliver_old_unclassified_updated(self) if !is_external?
+ RequestMailer.old_unclassified_updated(self).deliver if !is_external?
end
end
@@ -642,7 +636,7 @@ public
event.save!
end
curr_state = nil
- elsif !curr_state.nil? && (event.event_type == 'followup_sent' || event.event_type == 'sent') && !event.described_state.nil? && (event.described_state == 'waiting_response' || event.described_state == 'internal_review')
+ elsif !curr_state.nil? && (event.event_type == 'followup_sent' || event.event_type == 'sent' || event.event_type == "status_update")
# Followups can set the status to waiting response / internal
# review. Initial requests ('sent') set the status to waiting response.
@@ -705,7 +699,7 @@ public
# last_event_forming_initial_request. There may be more obscure
# things, e.g. fees, not properly covered.
def date_response_required_by
- Holiday.due_date_from(self.date_initial_request_last_sent_at, Configuration::reply_late_after_days, Configuration::working_or_calendar_days)
+ Holiday.due_date_from(self.date_initial_request_last_sent_at, AlaveteliConfiguration::reply_late_after_days, AlaveteliConfiguration::working_or_calendar_days)
end
# This is a long stop - even with UK public interest test extensions, 40
# days is a very long time.
@@ -713,10 +707,10 @@ public
last_sent = last_event_forming_initial_request
if self.public_body.is_school?
# schools have 60 working days maximum (even over a long holiday)
- Holiday.due_date_from(self.date_initial_request_last_sent_at, Configuration::special_reply_very_late_after_days, Configuration::working_or_calendar_days)
+ Holiday.due_date_from(self.date_initial_request_last_sent_at, AlaveteliConfiguration::special_reply_very_late_after_days, AlaveteliConfiguration::working_or_calendar_days)
else
# public interest test ICO guidance gives 40 working maximum
- Holiday.due_date_from(self.date_initial_request_last_sent_at, Configuration::reply_very_late_after_days, Configuration::working_or_calendar_days)
+ Holiday.due_date_from(self.date_initial_request_last_sent_at, AlaveteliConfiguration::reply_very_late_after_days, AlaveteliConfiguration::working_or_calendar_days)
end
end
@@ -802,6 +796,16 @@ public
end
end
+ # Returns last event
+ def get_last_event
+ events = self.info_request_events
+ if events.size == 0
+ return nil
+ else
+ return events[-1]
+ end
+ end
+
# Get previous email sent to
def get_previous_email_sent_to(info_request_event)
last_email = nil
@@ -878,10 +882,10 @@ public
end
def InfoRequest.magic_email_for_id(prefix_part, id)
- magic_email = Configuration::incoming_email_prefix
+ magic_email = AlaveteliConfiguration::incoming_email_prefix
magic_email += prefix_part + id.to_s
magic_email += "-" + InfoRequest.hash_from_id(id)
- magic_email += "@" + Configuration::incoming_email_domain
+ magic_email += "@" + AlaveteliConfiguration::incoming_email_domain
return magic_email
end
@@ -892,25 +896,7 @@ public
end
def InfoRequest.hash_from_id(id)
- return Digest::SHA1.hexdigest(id.to_s + Configuration::incoming_email_secret)[0,8]
- end
-
- # Called by find_by_incoming_email - and used to be called by separate
- # function for envelope from address, until we abandoned it.
- def InfoRequest.find_by_magic_email(id, hash)
- expected_hash = InfoRequest.hash_from_id(id)
- #print "expected: " + expected_hash + "\nhash: " + hash + "\n"
- if hash != expected_hash
- return nil
- else
- begin
- return self.find(id)
- rescue ActiveRecord::RecordNotFound
- # so error email is sent to admin, rather than the exception sending weird
- # error to the public body.
- return nil
- end
- end
+ return Digest::SHA1.hexdigest(id.to_s + AlaveteliConfiguration::incoming_email_secret)[0,8]
end
# Used to find when event last changed
@@ -1063,25 +1049,6 @@ public
InfoRequest.update_all "allow_new_responses_from = 'nobody' where updated_at < (now() - interval '1 year') and allow_new_responses_from in ('anybody', 'authority_only') and url_title <> 'holding_pen'"
end
- # Returns a random FOI request
- def InfoRequest.random
- max_id = InfoRequest.connection.select_value('select max(id) as a from info_requests').to_i
- info_request = nil
- count = 0
- while info_request.nil?
- if count > 100
- return nil
- end
- id = rand(max_id) + 1
- begin
- count += 1
- info_request = find(id, :conditions => ["prominence = 'normal'"])
- rescue ActiveRecord::RecordNotFound
- end
- end
- return info_request
- end
-
def json_for_api(deep)
ret = {
:id => self.id,
@@ -1115,7 +1082,7 @@ public
before_save :purge_in_cache
def purge_in_cache
- if !Configuration::varnish_host.blank? && !self.id.nil?
+ if !AlaveteliConfiguration::varnish_host.blank? && !self.id.nil?
# we only do this for existing info_requests (new ones have a nil id)
path = url_for(:controller => 'request', :action => 'show', :url_title => self.url_title, :only_path => true, :locale => :none)
req = PurgeRequest.find_by_url(path)
@@ -1133,5 +1100,34 @@ public
yield(column.human_name, self.send(column.name), column.type.to_s, column.name)
end
end
+
+ private
+
+ def set_defaults
+ begin
+ if self.described_state.nil?
+ self.described_state = 'waiting_response'
+ end
+ rescue ActiveModel::MissingAttributeError
+ # this should only happen on Model.exists?() call. It can be safely ignored.
+ # See http://www.tatvartha.com/2011/03/activerecordmissingattributeerror-missing-attribute-a-bug-or-a-features/
+ end
+ # FOI or EIR?
+ if !self.public_body.nil? && self.public_body.eir_only?
+ self.law_used = 'eir'
+ end
+ end
+
+ def title_formatting
+ if !self.title.nil? && !MySociety::Validate.uses_mixed_capitals(self.title, 10)
+ errors.add(:title, _('Please write the summary using a mixture of capital and lower case letters. This makes it easier for others to read.'))
+ end
+ if !self.title.nil? && title.size > 200
+ errors.add(:title, _('Please keep the summary short, like in the subject of an email. You can use a phrase, rather than a full sentence.'))
+ end
+ if !self.title.nil? && self.title =~ /^(FOI|Freedom of Information)\s*requests?$/i
+ errors.add(:title, _('Please describe more what the request is about in the subject. There is no need to say it is an FOI request, we add that on anyway.'))
+ end
+ end
end
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb
index 871b81b1f..0967e3940 100644
--- a/app/models/info_request_event.rb
+++ b/app/models/info_request_event.rb
@@ -20,7 +20,7 @@
# models/info_request_event.rb:
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class InfoRequestEvent < ActiveRecord::Base
belongs_to :info_request
@@ -405,7 +405,7 @@ class InfoRequestEvent < ActiveRecord::Base
:comment_id => self.comment_id,
# XXX would be nice to add links here, but alas the
- # code to make them is in views only. See views/request/details.rhtml
+ # code to make them is in views only. See views/request/details.html.erb
# perhaps can call with @template somehow
}
@@ -420,7 +420,7 @@ class InfoRequestEvent < ActiveRecord::Base
if deep
ret[:info_request] = self.info_request.json_for_api(false)
ret[:public_body] = self.info_request.public_body.json_for_api
- ret[:user] = self.info_request.user.json_for_api
+ ret[:user] = self.info_request.user_json_for_api
end
return ret
diff --git a/app/models/mail_server_log.rb b/app/models/mail_server_log.rb
index 755584b90..7f61377ce 100644
--- a/app/models/mail_server_log.rb
+++ b/app/models/mail_server_log.rb
@@ -15,9 +15,7 @@
# We load log file lines for requests in here, for display in the admin interface.
#
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
-#
-# $Id: exim_log.rb,v 1.14 2009-09-17 21:10:05 francis Exp $
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class MailServerLog < ActiveRecord::Base
belongs_to :info_request
@@ -53,7 +51,7 @@ class MailServerLog < ActiveRecord::Base
done.save!
f = is_gz ? Zlib::GzipReader.open(file_name) : File.open(file_name, 'r')
- case(Configuration::mta_log_type.to_sym)
+ case(AlaveteliConfiguration::mta_log_type.to_sym)
when :exim
load_exim_log_data(f, done)
when :postfix
@@ -123,13 +121,13 @@ class MailServerLog < ActiveRecord::Base
# We also check the email prefix so that we could, for instance, separately handle a staging and production
# instance running on the same server with different email prefixes.
def MailServerLog.email_addresses_on_line(line)
- prefix = Regexp::quote(Configuration::incoming_email_prefix)
- domain = Regexp::quote(Configuration::incoming_email_domain)
+ prefix = Regexp::quote(AlaveteliConfiguration::incoming_email_prefix)
+ domain = Regexp::quote(AlaveteliConfiguration::incoming_email_domain)
line.scan(/#{prefix}request-[^\s]+@#{domain}/).sort.uniq
end
def MailServerLog.request_sent?(ir)
- case(Configuration::mta_log_type.to_sym)
+ case(AlaveteliConfiguration::mta_log_type.to_sym)
when :exim
request_exim_sent?(ir)
when :postfix
diff --git a/app/models/mail_server_log_done.rb b/app/models/mail_server_log_done.rb
index 3fb20f0b3..0e7e9eec3 100644
--- a/app/models/mail_server_log_done.rb
+++ b/app/models/mail_server_log_done.rb
@@ -13,7 +13,7 @@
# Stores that a particular mail server log file has been loaded in, see mail_server_log.rb
#
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class MailServerLogDone < ActiveRecord::Base
has_many :mail_server_logs
diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb
index 248125808..aedfb9cad 100644
--- a/app/models/outgoing_message.rb
+++ b/app/models/outgoing_message.rb
@@ -20,9 +20,17 @@
# else. e.g. An initial request for information, or a complaint.
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class OutgoingMessage < ActiveRecord::Base
+ include Rails.application.routes.url_helpers
+ include LinkToHelper
+ self.default_url_options[:host] = AlaveteliConfiguration::domain
+ # https links in emails if forcing SSL
+ if AlaveteliConfiguration::force_ssl
+ self.default_url_options[:protocol] = "https"
+ end
+
strip_attributes!
belongs_to :info_request
@@ -51,6 +59,8 @@ class OutgoingMessage < ActiveRecord::Base
end
end
+ after_initialize :set_default_letter
+
# How the default letter starts and ends
def get_salutation
ret = ""
@@ -78,15 +88,15 @@ class OutgoingMessage < ActiveRecord::Base
end
if self.what_doing == 'internal_review'
- "Please pass this on to the person who conducts Freedom of Information reviews." +
+ _("Please pass this on to the person who conducts Freedom of Information reviews.") +
"\n\n" +
- "I am writing to request an internal review of " +
- self.info_request.public_body.name +
- "'s handling of my FOI request " +
- "'" + self.info_request.title + "'." +
+ _("I am writing to request an internal review of {{public_body_name}}'s handling of my FOI request '{{info_request_title}}'.",
+ :public_body_name => self.info_request.public_body.name,
+ :info_request_title => self.info_request.title) +
"\n\n\n\n [ " + self.get_internal_review_insert_here_note + " ] \n\n\n\n" +
- "A full history of my FOI request and all correspondence is available on the Internet at this address:\n" +
- "http://" + Configuration::domain + "/request/" + self.info_request.url_title
+ _("A full history of my FOI request and all correspondence is available on the Internet at this address: {{url}}",
+ :url => request_url(self.info_request)) +
+ "\n"
else
""
end
@@ -130,13 +140,6 @@ class OutgoingMessage < ActiveRecord::Base
MySociety::Validate.contains_postcode?(self.body)
end
- # Set default letter
- def after_initialize
- if self.body.nil?
- self.body = get_default_message
- end
- end
-
# Deliver outgoing message
# Note: You can test this from script/console with, say:
# InfoRequest.find(1).outgoing_messages[0].send_message
@@ -147,7 +150,7 @@ class OutgoingMessage < ActiveRecord::Base
self.status = 'sent'
self.save!
- mail_message = OutgoingMailer.deliver_initial_request(self.info_request, self)
+ mail_message = OutgoingMailer.initial_request(self.info_request, self).deliver
self.info_request.log_event(log_event_type, {
:email => mail_message.to_addrs.join(", "),
:outgoing_message_id => self.id,
@@ -159,7 +162,7 @@ class OutgoingMessage < ActiveRecord::Base
self.status = 'sent'
self.save!
- mail_message = OutgoingMailer.deliver_followup(self.info_request, self, self.incoming_message_followup)
+ mail_message = OutgoingMailer.followup(self.info_request, self, self.incoming_message_followup).deliver
self.info_request.log_event('followup_' + log_event_type, {
:email => mail_message.to_addrs.join(", "),
:outgoing_message_id => self.id,
@@ -253,6 +256,12 @@ class OutgoingMessage < ActiveRecord::Base
private
+ def set_default_letter
+ if self.body.nil?
+ self.body = get_default_message
+ end
+ end
+
def format_of_body
if self.body.empty? || self.body =~ /\A#{get_salutation}\s+#{get_signoff}/ || self.body =~ /#{get_internal_review_insert_here_note}/
if self.message_type == 'followup'
diff --git a/app/models/post_redirect.rb b/app/models/post_redirect.rb
index 31f08c21a..409069cb6 100644
--- a/app/models/post_redirect.rb
+++ b/app/models/post_redirect.rb
@@ -24,7 +24,7 @@
# fakes the redirect to include POST parameters in request later.
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
require 'openssl' # for random bytes function
@@ -32,6 +32,8 @@ class PostRedirect < ActiveRecord::Base
# Optional, does a login confirm before redirect for use in email links.
belongs_to :user
+ after_initialize :generate_token
+
# We store YAML version of POST parameters in the database
def post_params=(params)
self.post_params_yaml = params.to_yaml
@@ -62,18 +64,6 @@ class PostRedirect < ActiveRecord::Base
MySociety::Util.generate_token
end
- # Make the token
- def after_initialize
- # The token is used to return you to what you are doing after the login form.
- if not self.token
- self.token = PostRedirect.generate_random_token
- end
- # There is a separate token to use in the URL if we send a confirmation email.
- if not self.email_token
- self.email_token = PostRedirect.generate_random_token
- end
- end
-
# Used by (rspec) test code only
def self.get_last_post_redirect
# XXX yeuch - no other easy way of getting the token so we can check
@@ -89,6 +79,18 @@ class PostRedirect < ActiveRecord::Base
PostRedirect.delete_all "updated_at < (now() - interval '2 months')"
end
+ private
+
+ def generate_token
+ # The token is used to return you to what you are doing after the login form.
+ if not self.token
+ self.token = PostRedirect.generate_random_token
+ end
+ # There is a separate token to use in the URL if we send a confirmation email.
+ if not self.email_token
+ self.email_token = PostRedirect.generate_random_token
+ end
+ end
end
diff --git a/app/models/profile_photo.rb b/app/models/profile_photo.rb
index f6aec6338..5d542daf1 100644
--- a/app/models/profile_photo.rb
+++ b/app/models/profile_photo.rb
@@ -13,7 +13,7 @@
# Image of user that goes on their profile.
#
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class ProfilePhoto < ActiveRecord::Base
WIDTH = 96
@@ -29,25 +29,9 @@ class ProfilePhoto < ActiveRecord::Base
attr_accessor :x, :y, :w, :h
- # convert binary data blob into ImageMagick image when assigned
attr_accessor :image
- def after_initialize
- if data.nil?
- self.image = nil
- return
- end
-
- image_list = Magick::ImageList.new
- begin
- image_list.from_blob(data)
- rescue Magick::ImageMagickError
- self.image = nil
- return
- end
- self.image = image_list[0] # XXX perhaps take largest image or somesuch if there were multiple in the file?
- self.convert_image
- end
+ after_initialize :convert_data_to_image
# make image valid format and size
def convert_image
@@ -112,6 +96,25 @@ class ProfilePhoto < ActiveRecord::Base
raise "Internal error, real pictures must have a user"
end
end
+
+ # Convert binary data blob into ImageMagick image when assigned
+ def convert_data_to_image
+ if data.nil?
+ self.image = nil
+ return
+ end
+
+ image_list = Magick::ImageList.new
+ begin
+ image_list.from_blob(data)
+ rescue Magick::ImageMagickError
+ self.image = nil
+ return
+ end
+
+ self.image = image_list[0] # XXX perhaps take largest image or somesuch if there were multiple in the file?
+ self.convert_image
+ end
end
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index b4d36fe91..a76aeb189 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -45,7 +45,7 @@ class PublicBody < ActiveRecord::Base
before_save :set_api_key, :set_default_publication_scheme
# Every public body except for the internal admin one is visible
- named_scope :visible, lambda {
+ scope :visible, lambda {
{
:conditions => "public_bodies.id <> #{PublicBody.internal_admin_body.id}"
}
@@ -54,7 +54,7 @@ class PublicBody < ActiveRecord::Base
translates :name, :short_name, :request_email, :url_name, :notes, :first_letter, :publication_scheme
# Convenience methods for creating/editing translations via forms
- def translation(locale)
+ def find_translation_by_locale(locale)
self.translations.find_by_locale(locale)
end
@@ -79,7 +79,7 @@ class PublicBody < ActiveRecord::Base
if translation_attrs.respond_to? :each_value # Hash => updating
translation_attrs.each_value do |attrs|
next if skip?(attrs)
- t = translation(attrs[:locale]) || PublicBody::Translation.new
+ t = translation_for(attrs[:locale]) || PublicBody::Translation.new
t.attributes = attrs
calculate_cached_fields(t)
t.save!
@@ -332,7 +332,7 @@ class PublicBody < ActiveRecord::Base
pb = PublicBody.new(
:name => 'Internal admin authority',
:short_name => "",
- :request_email => Configuration::contact_email,
+ :request_email => AlaveteliConfiguration::contact_email,
:home_page => "",
:notes => "",
:publication_scheme => "",
@@ -548,7 +548,7 @@ class PublicBody < ActiveRecord::Base
# Returns nil if configuration variable not set
def override_request_email
- e = Configuration::override_all_public_body_request_emails
+ e = AlaveteliConfiguration::override_all_public_body_request_emails
e if e != ""
end
@@ -632,6 +632,8 @@ class PublicBody < ActiveRecord::Base
end
end
+ private
+
def request_email_if_requestable
# Request_email can be blank, meaning we don't have details
if self.is_requestable?
diff --git a/app/models/purge_request.rb b/app/models/purge_request.rb
index 48a16f9e6..e48f3cc6f 100644
--- a/app/models/purge_request.rb
+++ b/app/models/purge_request.rb
@@ -14,7 +14,7 @@
# A queue of URLs to purge
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
#
class PurgeRequest < ActiveRecord::Base
diff --git a/app/models/raw_email.rb b/app/models/raw_email.rb
index de7978b82..6bf01bc74 100644
--- a/app/models/raw_email.rb
+++ b/app/models/raw_email.rb
@@ -10,7 +10,7 @@
# The fat part of models/incoming_message.rb
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class RawEmail < ActiveRecord::Base
# deliberately don't strip_attributes, so keeps raw email properly
@@ -23,10 +23,10 @@ class RawEmail < ActiveRecord::Base
raise "Failed to find the id number of the associated request: has it been saved?"
end
- if ENV["RAILS_ENV"] == "test"
+ if Rails.env.test?
return File.join(Rails.root, 'files/raw_email_test')
else
- return File.join(Configuration::raw_emails_location,
+ return File.join(AlaveteliConfiguration::raw_emails_location,
request_id[0..2], request_id)
end
end
diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb
index a0c74bdb6..66b8a5c47 100644
--- a/app/models/track_thing.rb
+++ b/app/models/track_thing.rb
@@ -19,7 +19,7 @@
# When somebody is getting alerts for something.
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
require 'set'
@@ -260,7 +260,7 @@ class TrackThing < ActiveRecord::Base
:title_in_email => self.public_body.law_only_short + " requests to '" + self.public_body.name + "'",
:title_in_rss => self.public_body.law_only_short + " requests to '" + self.public_body.name + "'",
# Authentication
- :web => _("To follow requests made using {{site_name}} to the public authority '{{public_body_name}}'", :site_name=>Configuration::site_name, :public_body_name=>CGI.escapeHTML(self.public_body.name)),
+ :web => _("To follow requests made using {{site_name}} to the public authority '{{public_body_name}}'", :site_name=>AlaveteliConfiguration::site_name, :public_body_name=>CGI.escapeHTML(self.public_body.name)),
:email => _("Then you will be notified whenever someone requests something or gets a response from '{{public_body_name}}'.", :public_body_name=>CGI.escapeHTML(self.public_body.name)),
:email_subject => _("Confirm you want to follow requests to '{{public_body_name}}'", :public_body_name=>self.public_body.name),
# RSS sorting
diff --git a/app/models/track_things_sent_email.rb b/app/models/track_things_sent_email.rb
index a0a4c0f0c..a9ea2520e 100644
--- a/app/models/track_things_sent_email.rb
+++ b/app/models/track_things_sent_email.rb
@@ -16,7 +16,7 @@
# Record that alert has arrived.
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class TrackThingsSentEmail < ActiveRecord::Base
belongs_to :info_request_event
diff --git a/app/models/user.rb b/app/models/user.rb
index 6b66e1a8d..9da4ad743 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -58,6 +58,9 @@ class User < ActiveRecord::Base
],
:terms => [ [ :variety, 'V', "variety" ] ],
:if => :indexed_by_search?
+
+ after_initialize :set_defaults
+
def created_at_numeric
# format it here as no datetime support in Xapian's value ranges
return self.created_at.strftime("%Y%m%d%H%M%S")
@@ -67,17 +70,6 @@ class User < ActiveRecord::Base
"user"
end
- def after_initialize
- if self.admin_level.nil?
- self.admin_level = 'none'
- end
- if self.new_record?
- # make alert emails go out at a random time for each new user, so
- # overall they are spread out throughout the day.
- self.last_daily_track_email = User.random_time_in_last_day
- end
- end
-
# requested_by: and commented_by: search queries also need updating after save
after_update :reindex_referencing_models
def reindex_referencing_models
@@ -114,7 +106,12 @@ class User < ActiveRecord::Base
name.strip!
end
if self.public_banned?
- name = _("{{user_name}} (Account suspended)", :user_name=>name)
+ # Use interpolation to return a string rather than a SafeBuffer so that
+ # gsub can be called on it until we upgrade to Rails 3.2. The name returned
+ # is not marked as HTML safe so will be escaped automatically in views. We
+ # do this in two steps so the string still gets picked up for translation
+ name = _("{{user_name}} (Account suspended)", :user_name=> name.html_safe)
+ name = "#{name}"
end
name
end
@@ -136,14 +133,14 @@ class User < ActiveRecord::Base
if user
# There is user with email, check password
if !user.has_this_password?(params[:password])
- user.errors.add_to_base(auth_fail_message)
+ user.errors.add(:base, auth_fail_message)
end
else
# No user of same email, make one (that we don't save in the database)
# for the forms code to use.
user = User.new(params)
# deliberately same message as above so as not to leak whether registered
- user.errors.add_to_base(auth_fail_message)
+ user.errors.add(:base, auth_fail_message)
end
user
end
@@ -196,12 +193,12 @@ class User < ActiveRecord::Base
# The "internal admin" is a special user for internal use.
def User.internal_admin_user
- u = User.find_by_email(Configuration::contact_email)
+ u = User.find_by_email(AlaveteliConfiguration::contact_email)
if u.nil?
password = PostRedirect.generate_random_token
u = User.new(
:name => 'Internal admin user',
- :email => Configuration::contact_email,
+ :email => AlaveteliConfiguration::contact_email,
:password => password,
:password_confirmation => password
)
@@ -274,16 +271,16 @@ class User < ActiveRecord::Base
return false if self.no_limit
# Has the user issued as many as MAX_REQUESTS_PER_USER_PER_DAY requests in the past 24 hours?
- return false if Configuration::max_requests_per_user_per_day.blank?
+ return false if AlaveteliConfiguration::max_requests_per_user_per_day.blank?
recent_requests = InfoRequest.count(:conditions => ["user_id = ? and created_at > now() - '1 day'::interval", self.id])
- return (recent_requests >= Configuration::max_requests_per_user_per_day)
+ return (recent_requests >= AlaveteliConfiguration::max_requests_per_user_per_day)
end
def next_request_permitted_at
return nil if self.no_limit
- n_most_recent_requests = InfoRequest.all(:conditions => ["user_id = ? and created_at > now() - '1 day'::interval", self.id], :order => "created_at DESC", :limit => Configuration::max_requests_per_user_per_day)
- return nil if n_most_recent_requests.size < Configuration::max_requests_per_user_per_day
+ n_most_recent_requests = InfoRequest.all(:conditions => ["user_id = ? and created_at > now() - '1 day'::interval", self.id], :order => "created_at DESC", :limit => AlaveteliConfiguration::max_requests_per_user_per_day)
+ return nil if n_most_recent_requests.size < AlaveteliConfiguration::max_requests_per_user_per_day
nth_most_recent_request = n_most_recent_requests[-1]
return nth_most_recent_request.created_at + 1.day
@@ -402,6 +399,17 @@ class User < ActiveRecord::Base
self.salt = self.object_id.to_s + rand.to_s
end
+ def set_defaults
+ if self.admin_level.nil?
+ self.admin_level = 'none'
+ end
+ if self.new_record?
+ # make alert emails go out at a random time for each new user, so
+ # overall they are spread out throughout the day.
+ self.last_daily_track_email = User.random_time_in_last_day
+ end
+ end
+
def email_and_name_are_valid
if self.email != "" && !MySociety::Validate.is_valid_email(self.email)
errors.add(:email, _("Please enter a valid email address"))
diff --git a/app/models/user_info_request_sent_alert.rb b/app/models/user_info_request_sent_alert.rb
index cf20bcbf5..449a4c237 100644
--- a/app/models/user_info_request_sent_alert.rb
+++ b/app/models/user_info_request_sent_alert.rb
@@ -15,7 +15,7 @@
# given type of alert.
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class UserInfoRequestSentAlert < ActiveRecord::Base
belongs_to :user
diff --git a/app/models/user_mailer.rb b/app/models/user_mailer.rb
deleted file mode 100644
index 1be4f8aa3..000000000
--- a/app/models/user_mailer.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# models/user_mailer.rb:
-# Emails relating to user accounts. e.g. Confirming a new account
-#
-# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
-
-class UserMailer < ApplicationMailer
- def confirm_login(user, reasons, url)
- @from = contact_from_name_and_email
- headers 'Return-Path' => blackhole_email, 'Reply-To' => @from # we don't care about bounces when people are fiddling with their account
- @recipients = user.name_and_email
- @subject = reasons[:email_subject]
- @body[:reasons] = reasons
- @body[:name] = user.name
- @body[:url] = url
- end
-
- def already_registered(user, reasons, url)
- @from = contact_from_name_and_email
- headers 'Return-Path' => blackhole_email, 'Reply-To' => @from # we don't care about bounces when people are fiddling with their account
- @recipients = user.name_and_email
- @subject = reasons[:email_subject]
- @body[:reasons] = reasons
- @body[:name] = user.name
- @body[:url] = url
- end
-
- def changeemail_confirm(user, new_email, url)
- @from = contact_from_name_and_email
- headers 'Return-Path' => blackhole_email, 'Reply-To' => @from # we don't care about bounces when people are fiddling with their account
- @recipients = new_email
- @subject = _("Confirm your new email address on {{site_name}}", :site_name=>site_name)
- @body[:name] = user.name
- @body[:url] = url
- @body[:old_email] = user.email
- @body[:new_email] = new_email
- end
-
- def changeemail_already_used(old_email, new_email)
- @from = contact_from_name_and_email
- headers 'Return-Path' => blackhole_email, 'Reply-To' => @from # we don't care about bounces when people are fiddling with their account
- @recipients = new_email
- @subject = _("Unable to change email address on {{site_name}}", :site_name=>site_name)
- @body[:old_email] = old_email
- @body[:new_email] = new_email
- end
-end
-
diff --git a/app/views/admin_censor_rule/_form.rhtml b/app/views/admin_censor_rule/_form.html.erb
index 5035238d6..5035238d6 100644
--- a/app/views/admin_censor_rule/_form.rhtml
+++ b/app/views/admin_censor_rule/_form.html.erb
diff --git a/app/views/admin_censor_rule/_show.rhtml b/app/views/admin_censor_rule/_show.html.erb
index 0d4cece93..0d4cece93 100644
--- a/app/views/admin_censor_rule/_show.rhtml
+++ b/app/views/admin_censor_rule/_show.html.erb
diff --git a/app/views/admin_censor_rule/edit.rhtml b/app/views/admin_censor_rule/edit.html.erb
index 4eb99ce57..230446ed3 100644
--- a/app/views/admin_censor_rule/edit.rhtml
+++ b/app/views/admin_censor_rule/edit.html.erb
@@ -2,14 +2,14 @@
<h1><%=@title%></h1>
-<% form_tag admin_rule_update_path(@censor_rule), :class => "form form-horizontal" do %>
+<%= form_tag admin_rule_update_path(@censor_rule), :class => "form form-horizontal" do %>
<%= render :partial => 'form', :locals => { :info_request => @censor_rule.info_request, :user => @censor_rule.user } %>
<div class="form-actions">
<%= submit_tag 'Save', :accesskey => 's', :class => "btn btn-primary" %>
</div>
<% end %>
-<% form_tag admin_rule_destroy_path(@censor_rule), :class => "form form-horizontal" do %>
+<%= form_tag admin_rule_destroy_path(@censor_rule), :class => "form form-horizontal" do %>
<%= hidden_field_tag(:censor_rule_id, @censor_rule.id) %>
<div class="form-actions">
Permanent! --&gt; <%= submit_tag "Destroy rule", :class => "btn btn-primary" %>
diff --git a/app/views/admin_censor_rule/new.rhtml b/app/views/admin_censor_rule/new.html.erb
index f6978c07c..77d22990c 100644
--- a/app/views/admin_censor_rule/new.rhtml
+++ b/app/views/admin_censor_rule/new.html.erb
@@ -2,7 +2,7 @@
<h1><%=@title%></h1>
-<% form_tag admin_rule_create_path, :class => "form form-horizontal" do %>
+<%= form_tag admin_rule_create_path, :class => "form form-horizontal" do %>
<%= render :partial => 'form', :locals => { :info_request => @info_request, :user => @censor_user } %>
<div class="form-actions">
<%= submit_tag "Create", :class => "btn btn-primary" %>
diff --git a/app/views/admin_general/_admin_navbar.rhtml b/app/views/admin_general/_admin_navbar.html.erb
index 5cc740f70..5cc740f70 100644
--- a/app/views/admin_general/_admin_navbar.rhtml
+++ b/app/views/admin_general/_admin_navbar.html.erb
diff --git a/app/views/admin_general/debug.rhtml b/app/views/admin_general/debug.html.erb
index 7fd256025..bf984c2e1 100644
--- a/app/views/admin_general/debug.rhtml
+++ b/app/views/admin_general/debug.html.erb
@@ -21,16 +21,13 @@ RUBY_VERSION <%=h RUBY_VERSION %>
<br>
Rails::VERSION::STRING <%=h Rails::VERSION::STRING%>
<br>
-TMail::VERSION::STRING <%=h TMail::VERSION::STRING%>
-<br>
Xapian::version_string <%=h Xapian::version_string%>
</p>
<h2>Configuration</h2>
-<p>environment: <%=h Rails::configuration.environment %>
-<br>environment_path: <%=h Rails::configuration.environment_path %>
-<br>framework_paths: <%=h Rails::configuration.framework_paths.to_yaml %>
+<p>Rails env: <%=h Rails.env %>
+<br>Rails root: <%=h Rails.root %>
</p>
<h2>Environment variables</h2>
diff --git a/app/views/admin_general/index.rhtml b/app/views/admin_general/index.html.erb
index b239a2b3f..b239a2b3f 100644
--- a/app/views/admin_general/index.rhtml
+++ b/app/views/admin_general/index.html.erb
diff --git a/app/views/admin_general/stats.rhtml b/app/views/admin_general/stats.html.erb
index 27dc25ee0..27dc25ee0 100644
--- a/app/views/admin_general/stats.rhtml
+++ b/app/views/admin_general/stats.html.erb
diff --git a/app/views/admin_general/timeline.rhtml b/app/views/admin_general/timeline.html.erb
index 8fd8875b6..8fd8875b6 100644
--- a/app/views/admin_general/timeline.rhtml
+++ b/app/views/admin_general/timeline.html.erb
diff --git a/app/views/admin_public_body/_form.rhtml b/app/views/admin_public_body/_form.html.erb
index 3f346842c..c577d1e18 100644
--- a/app/views/admin_public_body/_form.rhtml
+++ b/app/views/admin_public_body/_form.html.erb
@@ -18,11 +18,10 @@
prefix = "public_body[translated_versions][]"
object = @public_body.new_record? ?
PublicBody::Translation.new :
- @public_body.translation(locale.to_s) || PublicBody::Translation.new
+ @public_body.find_translation_by_locale(locale.to_s) || PublicBody::Translation.new
end
-
- fields_for prefix, object do |t|
%>
+ <%= fields_for prefix, object do |t| %>
<div class="tab-pane" id="div-locale-<%=locale.to_s%>">
<div class="control-group">
<%= t.hidden_field :locale, :value => locale.to_s %>
diff --git a/app/views/admin_public_body/_one_list.rhtml b/app/views/admin_public_body/_one_list.html.erb
index d8746bae7..8f1d719ec 100644
--- a/app/views/admin_public_body/_one_list.rhtml
+++ b/app/views/admin_public_body/_one_list.html.erb
@@ -31,7 +31,7 @@
<% end %>
</div>
-<% form_tag(admin_body_mass_tag_add_url, :method => "post", :class => "form form-inline" ) do %>
+<%= form_tag(admin_body_mass_tag_add_url, :method => "post", :class => "form form-inline" ) do %>
<p>
<%= text_field_tag 'new_tag', params[:new_tag], { :size => 15, :id => "mass_add_tag_new_tag_" + table_name } %>
<%= hidden_field_tag(:query, params[:query], { :id => "mass_add_tag_query_" + table_name } ) %>
diff --git a/app/views/admin_public_body/_tag_help.rhtml b/app/views/admin_public_body/_tag_help.html.erb
index b64e65877..b64e65877 100644
--- a/app/views/admin_public_body/_tag_help.rhtml
+++ b/app/views/admin_public_body/_tag_help.html.erb
diff --git a/app/views/admin_public_body/_tags.rhtml b/app/views/admin_public_body/_tags.html.erb
index 26526f304..26526f304 100644
--- a/app/views/admin_public_body/_tags.rhtml
+++ b/app/views/admin_public_body/_tags.html.erb
diff --git a/app/views/admin_public_body/edit.rhtml b/app/views/admin_public_body/edit.html.erb
index eb0c45f19..11b7eec22 100644
--- a/app/views/admin_public_body/edit.rhtml
+++ b/app/views/admin_public_body/edit.html.erb
@@ -3,7 +3,7 @@
<div class="row">
<div class="span8">
<div id="public_body_form">
- <% form_for @public_body, :url => admin_body_update_path(@public_body), :html => { :class => "form form-horizontal" } do |f| %>
+ <%= form_for @public_body, :url => admin_body_update_path(@public_body), :html => { :class => "form form-horizontal" } do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<div class="form-actions">
<%= f.submit 'Save', :accesskey => 's', :class => "btn btn-success" %></p>
@@ -20,7 +20,7 @@
</div>
<% if @public_body.info_requests.empty? %>
- <% form_tag(admin_body_destroy_path(@public_body), :class => "form form-inline") do %>
+ <%= form_tag(admin_body_destroy_path(@public_body), :class => "form form-inline") do %>
<%= hidden_field_tag(:public_body_id, { :value => @public_body.id } ) %>
<%= submit_tag _("Destroy {{name}}", :name => @public_body.name), :class => "btn btn-danger" %> (this is permanent!)
<% end %>
diff --git a/app/views/admin_public_body/import_csv.rhtml b/app/views/admin_public_body/import_csv.html.erb
index bfe1b0c3b..afda5a468 100644
--- a/app/views/admin_public_body/import_csv.rhtml
+++ b/app/views/admin_public_body/import_csv.html.erb
@@ -9,7 +9,7 @@
<pre id="error"><%=@errors %></pre>
<% end %>
-<% form_tag 'import_csv', :multipart => true do %>
+<%= form_tag 'import_csv', :multipart => true do %>
<p>
<% if @original_csv_file && @temporary_csv_file %>
CSV file:
diff --git a/app/views/admin_public_body/list.rhtml b/app/views/admin_public_body/list.html.erb
index acc05f50d..3d7d9c4cd 100644
--- a/app/views/admin_public_body/list.rhtml
+++ b/app/views/admin_public_body/list.html.erb
@@ -15,7 +15,7 @@
</div>
</div>
-<% form_tag({}, :method => "get", :class => "form form-search") do %>
+<%= form_tag({}, :method => "get", :class => "form form-search") do %>
<%= text_field_tag 'query', params[:query], { :size => 30, :class => "input-large search-query" } %>
<%= submit_tag "Search", :class => "btn" %>
<% if !@query.nil? %>
@@ -35,7 +35,6 @@
<h2>All authorities</h2>
<% else %>
<h2>Substring search matches (<%= @public_bodies.total_entries %> total)</h2>
-
<% end %>
<%= render :partial => 'one_list', :locals => { :bodies => @public_bodies, :table_name => 'substring' } %>
<% end %>
diff --git a/app/views/admin_public_body/missing_scheme.rhtml b/app/views/admin_public_body/missing_scheme.html.erb
index 2ea55ae00..2ea55ae00 100644
--- a/app/views/admin_public_body/missing_scheme.rhtml
+++ b/app/views/admin_public_body/missing_scheme.html.erb
diff --git a/app/views/admin_public_body/new.rhtml b/app/views/admin_public_body/new.html.erb
index 6ead1810c..13e8238d6 100644
--- a/app/views/admin_public_body/new.rhtml
+++ b/app/views/admin_public_body/new.html.erb
@@ -4,7 +4,7 @@
<div class="row">
<div class="span8">
<div id="public_body_form">
- <% form_for :public_body, @public_body, :url => admin_body_create_path, :html => {:class => "form form-horizontal"} do |f| %>
+ <%= form_for @public_body, :as => :public_body, :url => admin_body_create_path, :html => {:class => "form form-horizontal"} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<div class="form-actions">
<%= f.submit "Create", :class => "btn btn-primary" %>
diff --git a/app/views/admin_public_body/show.rhtml b/app/views/admin_public_body/show.html.erb
index cfb10b24e..8262287d5 100644
--- a/app/views/admin_public_body/show.rhtml
+++ b/app/views/admin_public_body/show.html.erb
@@ -83,7 +83,8 @@
<% end %>
<hr>
<h2>Requests</h2>
-<%= render :partial => 'admin_request/some_requests', :locals => { :info_requests => @public_body.info_requests } %>
+<%= render :partial => 'admin_request/some_requests', :locals => { :info_requests => @info_requests } %>
+<%= will_paginate(@info_requests, :class => "paginator") %>
<hr>
<h2>Track things</h2>
<%= render :partial => 'admin_track/some_tracks', :locals => { :track_things => @public_body.track_things, :include_destroy => true } %>
diff --git a/app/views/admin_request/_incoming_message_actions.rhtml b/app/views/admin_request/_incoming_message_actions.html.erb
index 84c29dcc3..653e73337 100644
--- a/app/views/admin_request/_incoming_message_actions.rhtml
+++ b/app/views/admin_request/_incoming_message_actions.html.erb
@@ -1,6 +1,6 @@
<fieldset class="form-horizontal">
<legend>Actions</legend>
- <% form_tag admin_request_redeliver_incoming_path, :class => "form form-inline" do %>
+ <%= form_tag admin_request_redeliver_incoming_path, :class => "form form-inline" do %>
<div class="control-group">
<label class="control-label" for="url_title_<%= incoming_message.id %>">Redeliver message to one or more other requests</label>
<div class="controls">
@@ -22,7 +22,7 @@
</div>
</div>
- <% form_tag admin_request_destroy_incoming_path, :class => "form form-inline" do %>
+ <%= form_tag admin_request_destroy_incoming_path, :class => "form form-inline" do %>
<div class="control-group">
<label class="control-label" for="destroy_message_<%= incoming_message.id %>">Destroy message</label>
<div class="controls">
diff --git a/app/views/admin_request/_some_requests.rhtml b/app/views/admin_request/_some_requests.html.erb
index cff94956d..cff94956d 100644
--- a/app/views/admin_request/_some_requests.rhtml
+++ b/app/views/admin_request/_some_requests.html.erb
diff --git a/app/views/admin_request/_tags.rhtml b/app/views/admin_request/_tags.html.erb
index 22fbf13c8..22fbf13c8 100644
--- a/app/views/admin_request/_tags.rhtml
+++ b/app/views/admin_request/_tags.html.erb
diff --git a/app/views/admin_request/edit.rhtml b/app/views/admin_request/edit.html.erb
index 1cf5d4f12..0e9c68aea 100644
--- a/app/views/admin_request/edit.rhtml
+++ b/app/views/admin_request/edit.html.erb
@@ -2,7 +2,7 @@
<%= error_messages_for 'info_request' %>
-<% form_tag admin_request_update_path(@info_request) do %>
+<%= form_tag admin_request_update_path(@info_request) do %>
<p><label for="info_request_title"><strong>Title</strong></label> (warning: editing this will break URLs right now)<br/>
<%= text_field 'info_request', 'title', :size => 50 %></p>
@@ -49,7 +49,7 @@
<hr>
-<% form_tag admin_request_destroy_path(@info_request) do %>
+<%= form_tag admin_request_destroy_path(@info_request) do %>
<p>
<strong>This is permanent and irreversible!</strong> <%= submit_tag 'Destroy request entirely' %>
<br>Use it mainly if someone posts private information, e.g. made a Data Protection request. It
diff --git a/app/views/admin_request/edit_comment.rhtml b/app/views/admin_request/edit_comment.html.erb
index 07031f5f2..2cf49a4a8 100644
--- a/app/views/admin_request/edit_comment.rhtml
+++ b/app/views/admin_request/edit_comment.html.erb
@@ -2,7 +2,7 @@
<%= error_messages_for 'comment' %>
-<% form_tag admin_request_update_comment_path(@comment) do %>
+<%= form_tag admin_request_update_comment_path(@comment) do %>
<p><label for="comment_body">Body of annotation</label><br/>
<%= text_area 'comment', 'body', :rows => 10, :cols => 60 %></p>
diff --git a/app/views/admin_request/edit_outgoing.rhtml b/app/views/admin_request/edit_outgoing.html.erb
index ab209be0d..a0c60520a 100644
--- a/app/views/admin_request/edit_outgoing.rhtml
+++ b/app/views/admin_request/edit_outgoing.html.erb
@@ -2,7 +2,7 @@
<%= error_messages_for 'outgoing_message' %>
-<% form_tag admin_request_update_outgoing_path(@outgoing_message) do %>
+<%= form_tag admin_request_update_outgoing_path(@outgoing_message) do %>
<p><label for="outgoing_message_body">Body of message</label><br/>
<%= text_area 'outgoing_message', 'body', :rows => 10, :cols => 60 %></p>
@@ -22,7 +22,7 @@
<%= link_to 'List all', admin_request_list_path %>
</p>
-<% form_tag admin_request_destroy_outgoing_path do %>
+<%= form_tag admin_request_destroy_outgoing_path do %>
<div>
<%= hidden_field_tag 'outgoing_message_id', @outgoing_message.id %>
Warning, this is permanent! ---&gt;
diff --git a/app/views/admin_request/hidden_user_explanation.html.erb b/app/views/admin_request/hidden_user_explanation.html.erb
new file mode 100644
index 000000000..d0a5d727d
--- /dev/null
+++ b/app/views/admin_request/hidden_user_explanation.html.erb
@@ -0,0 +1,10 @@
+<%= _("Dear {{name}},", :name => name_to) %>
+
+<%= _("Your request '{{request}}' at {{url}} has been reviewed by moderators.", :request => info_request.title.html_safe, :url => info_request_url) %>
+
+<%= reason == 'not_foi' ? _("We consider it is not a valid FOI request, and have therefore hidden it from other users.") : _("We consider it to be vexatious, and have therefore hidden it from other users.") %> <%= _("You will still be able to view it while logged in to the site. Please reply to this email if you would like to discuss this decision further.") %>
+
+<%= _("Yours,") %>
+
+<%= _("The {{site_name}} team.", :site_name => site_name) %>
+
diff --git a/app/views/admin_request/hidden_user_explanation.rhtml b/app/views/admin_request/hidden_user_explanation.rhtml
deleted file mode 100644
index 7084e986f..000000000
--- a/app/views/admin_request/hidden_user_explanation.rhtml
+++ /dev/null
@@ -1,10 +0,0 @@
-Dear <%= name_to %>,
-
-Your request '<%= info_request.title.html_safe %>' at <%= info_request_url %> has been reviewed by moderators.
-
-We consider it <% if reason == 'not_foi' %>is not a valid FOI request<% else %>to be vexatious<% end%>, and have therefore hidden it from other users. You will still be able to view it while logged in to the site. Please reply to this email if you would like to discuss this decision further.
-
-Yours,
-
-The <%= site_name %> team.
-
diff --git a/app/views/admin_request/list.rhtml b/app/views/admin_request/list.html.erb
index 10b39d3a2..2bd3e3326 100644
--- a/app/views/admin_request/list.rhtml
+++ b/app/views/admin_request/list.html.erb
@@ -2,7 +2,7 @@
<h1><%=@title%></h1>
-<% form_tag({}, :method => "get", :class => "form form-search") do %>
+<%= form_tag({}, :method => "get", :class => "form form-search") do %>
<%= text_field_tag 'query', params[:query], { :size => 30, :class => "input-large search-query" } %>
<%= submit_tag "Search", :class => "btn" %> (substring search, titles only)
<% end %>
diff --git a/app/views/admin_request/show.rhtml b/app/views/admin_request/show.html.erb
index 2b37e8afb..e18e319be 100644
--- a/app/views/admin_request/show.rhtml
+++ b/app/views/admin_request/show.html.erb
@@ -2,7 +2,7 @@
<h1><%=@title%></h1>
-<% form_tag admin_request_move_request_path, { :class => "form form-horizontal" } do %>
+<%= form_tag admin_request_move_request_path, { :class => "form form-horizontal" } do %>
<%= hidden_field_tag 'info_request_id', @info_request.id %>
<div class="accordion" id="info_request">
<div class="accordion-group">
@@ -121,7 +121,7 @@
<p class="help-block">(see also option to general URLs for individual incoming messages below)</p>
</div>
</div>
- <% form_tag admin_request_hide_path(@info_request), :class => "form form-inline", :id => "hide_request_form", 'data-info-request-id' => @info_request.id.to_s do %>
+ <%= form_tag admin_request_hide_path(@info_request), :class => "form form-inline", :id => "hide_request_form", 'data-info-request-id' => @info_request.id.to_s do %>
<div class="control-group">
<% if @info_request.is_external? %>
<label class="control-label">Hide the request:</label>
@@ -149,7 +149,7 @@
<div class="control-group" id="request_hidden_user_subject">
<label for="request_hidden_user_subject_field" class="control-label">Subject of email:</label>
<div class="controls">
- <%= text_field_tag "subject", "Your request on WhatDoTheyKnow.com hidden", {:id => "request_hidden_user_subject_field", :cols => 100} %>
+ <%= text_field_tag "subject", _("Your request on {{site_name}} hidden", :site_name => site_name), {:id => "request_hidden_user_subject_field", :cols => 100} %>
</div>
</div>
@@ -191,7 +191,7 @@
<tr>
<td>
<% if info_request_event.described_state != 'waiting_clarification' and info_request_event.event_type == 'response' %>
- <% form_tag admin_request_clarification_path, :class => "form form-inline admin-table-form admin-inline-form" do %>
+ <%= form_tag admin_request_clarification_path, :class => "form form-inline admin-table-form admin-inline-form" do %>
<%= hidden_field_tag 'info_request_event_id', info_request_event.id, :id => nil %>
<%= submit_tag "Was clarification request", :class => "btn btn-mini btn-primary" %>
<% end %>
@@ -233,7 +233,7 @@
<div class="accordion-group">
<div class="accordion-heading">
<a href="#outgoing_<%=outgoing_message.id%>" data-toggle="collapse" data-parent="#outgoing_messages"><%= chevron_right %></a>
- <% link_to admin_request_edit_outgoing_path(outgoing_message) do %>
+ <%= link_to admin_request_edit_outgoing_path(outgoing_message) do %>
#<%= outgoing_message.id %> -- <%= outgoing_message.status.humanize %> <%= outgoing_message.message_type.humanize %>
<% end %>
<blockquote>
@@ -245,7 +245,7 @@
<tbody>
<tr>
<td colspan="2">
- <% form_tag admin_request_resend_path, :class => "admin-table-form" do %>
+ <%= form_tag admin_request_resend_path, :class => "admin-table-form" do %>
<%= hidden_field_tag 'outgoing_message_id', outgoing_message.id %>
<%= submit_tag "Resend", :class => "btn" %>
<% end %>
@@ -306,7 +306,7 @@
<%= simple_format( truncate(h(value), :length => 400, :omission => link_to("...", "#", :class => "toggle-hidden")).html_safe) %>
<div style="display:none;"><%= simple_format(value) %></div>
<% else %>
- <%= simple_format(value) %>
+ <%= simple_format(value.to_s) %>
<% end %>
</td>
</tr>
@@ -326,7 +326,7 @@
<div class="accordion-group">
<div class="accordion-heading">
<a href="#comment_<%=comment.id%>" data-toggle="collapse" data-parent="#comments"><%= chevron_right %></a>
- <% link_to admin_request_edit_comment_path(comment) do %>
+ <%= link_to admin_request_edit_comment_path(comment) do %>
#<%=comment.id%>
--
<%=h(comment.user.name)%>
diff --git a/app/views/admin_request/show_raw_email.rhtml b/app/views/admin_request/show_raw_email.html.erb
index 72c782ad6..72c782ad6 100644
--- a/app/views/admin_request/show_raw_email.rhtml
+++ b/app/views/admin_request/show_raw_email.html.erb
diff --git a/app/views/admin_track/_some_tracks.rhtml b/app/views/admin_track/_some_tracks.html.erb
index 95101cb55..e9facfb5d 100644
--- a/app/views/admin_track/_some_tracks.rhtml
+++ b/app/views/admin_track/_some_tracks.html.erb
@@ -32,7 +32,7 @@
<% if include_destroy %>
<tr>
<td colspan="2">
- <% form_tag admin_user_destroy_track_path, :class => "form form-inline admin-table-form" do %>
+ <%= form_tag admin_user_destroy_track_path, :class => "form form-inline admin-table-form" do %>
<div>
<%= hidden_field_tag 'track_id', track_thing.id %>
<%= submit_tag "Destroy track", :class => "btn btn-warning" %>
@@ -70,3 +70,5 @@
<% end %>
</div>
<% end %>
+</table>
+
diff --git a/app/views/admin_track/list.rhtml b/app/views/admin_track/list.html.erb
index 9cff5635b..5e967a926 100644
--- a/app/views/admin_track/list.rhtml
+++ b/app/views/admin_track/list.html.erb
@@ -2,7 +2,7 @@
<h1><%=@title%></h1>
-<% form_tag({}, :method => "get", :class => "form form-search") do %>
+<%= form_tag({}, :method => "get", :class => "form form-search") do %>
<%= text_field_tag 'query', params[:query], { :size => 30, :class => "input-large search-query" } %>
<%= submit_tag "Search", :class => "btn" %> (substring search the query – so use url_names_for_a_particular_request_or_authority_or_person)
<% end %>
diff --git a/app/views/admin_user/_form.rhtml b/app/views/admin_user/_form.html.erb
index e7175d09c..e7175d09c 100644
--- a/app/views/admin_user/_form.rhtml
+++ b/app/views/admin_user/_form.html.erb
diff --git a/app/views/admin_user/_user_table.rhtml b/app/views/admin_user/_user_table.html.erb
index 57066bf3f..57066bf3f 100644
--- a/app/views/admin_user/_user_table.rhtml
+++ b/app/views/admin_user/_user_table.html.erb
diff --git a/app/views/admin_user/edit.rhtml b/app/views/admin_user/edit.html.erb
index 3333a1e48..e641a13d6 100644
--- a/app/views/admin_user/edit.rhtml
+++ b/app/views/admin_user/edit.html.erb
@@ -1,6 +1,6 @@
<h1><%=@title%></h1>
-<% form_tag admin_user_update_path(@admin_user), :class => "form form-horizontal" do %>
+<%= form_tag admin_user_update_path(@admin_user), :class => "form form-horizontal" do %>
<%= render :partial => 'form' %>
<div class="form-actions">
<%= submit_tag 'Save', :accesskey => 's', :class => "btn btn-primary" %>
diff --git a/app/views/admin_user/list.rhtml b/app/views/admin_user/list.html.erb
index 23f75c159..b1238f87a 100644
--- a/app/views/admin_user/list.rhtml
+++ b/app/views/admin_user/list.html.erb
@@ -2,7 +2,7 @@
<h1><%=@title%></h1>
-<% form_tag({}, :method => "get", :class => "form form-search") do %>
+<%= form_tag({}, :method => "get", :class => "form form-search") do %>
<%= text_field_tag 'query', params[:query], { :size => 30, :class => "input-large search-query"} %>
<%= submit_tag "Search", :class => "btn" %> (substring search, names and emails)
<%= link_to 'Banned users', admin_user_list_banned_path, :class => "btn btn-info" %>
diff --git a/app/views/admin_user/list_banned.rhtml b/app/views/admin_user/list_banned.html.erb
index e535415e6..e535415e6 100644
--- a/app/views/admin_user/list_banned.rhtml
+++ b/app/views/admin_user/list_banned.html.erb
diff --git a/app/views/admin_user/show.rhtml b/app/views/admin_user/show.html.erb
index 279758f03..c93c08e50 100644
--- a/app/views/admin_user/show.rhtml
+++ b/app/views/admin_user/show.html.erb
@@ -4,7 +4,7 @@
<% if @admin_user.profile_photo %>
<div class="user_photo_on_admin">
- <% form_tag admin_clear_profile_photo_path(@admin_user), :multipart => true, :class => "form" do %>
+ <%= form_tag admin_clear_profile_photo_path(@admin_user), :multipart => true, :class => "form" do %>
<img src="<%= get_profile_photo_url(:url_name => @admin_user.url_name) %>">
<br>
<%= submit_tag "Clear photo", :class => "btn btn-info" %>
@@ -32,13 +32,13 @@
<%=link_to @admin_user.email, "mailto:#{h @admin_user.email}"%>
<% elsif column_name == 'email_bounce_message' %>
<% unless @admin_user.email_bounce_message.empty? %>
- <%= link_to _("See bounce message"), admin_user_show_bounce(@admin_user.id) %>
+ <%= link_to _("See bounce message"), admin_user_show_bounce_path(@admin_user.id) %>
<% end %>
<% else %>
<%=h admin_value(value)%>
<% end %>
<% if column_name == 'email_bounced_at' && !@admin_user.email_bounced_at.nil? %>
- <% form_tag admin_user_clear_bounce_path(@admin_user), :class => "form form-inline" do %>
+ <%= form_tag admin_user_clear_bounce_path(@admin_user), :class => "form form-inline" do %>
<input type="submit" name="action" value="Clear bounce" class="btn btn-info">
<% end %>
<% end %>
diff --git a/app/views/admin_user/show_bounce_message.rhtml b/app/views/admin_user/show_bounce_message.html.erb
index ad643a13e..ad643a13e 100644
--- a/app/views/admin_user/show_bounce_message.rhtml
+++ b/app/views/admin_user/show_bounce_message.html.erb
diff --git a/app/views/comment/_comment_form.rhtml b/app/views/comment/_comment_form.html.erb
index d834b5b90..b78532768 100644
--- a/app/views/comment/_comment_form.rhtml
+++ b/app/views/comment/_comment_form.html.erb
@@ -1,4 +1,4 @@
-<% form_for(:comment, @comment, :url => { :controller => "comment", :action => "new", :type => "request" }, :html => { :id => 'comment_form' } ) do |f| %>
+<%= form_for(@comment, :as => :comment, :url => { :controller => "comment", :action => "new", :type => "request" }, :html => { :id => 'comment_form' } ) do |f| %>
<p>
<%= f.text_area :body, :rows => 10, :cols => 55 %>
</p>
diff --git a/app/views/comment/_single_comment.rhtml b/app/views/comment/_single_comment.html.erb
index 421a9d4ba..421a9d4ba 100644
--- a/app/views/comment/_single_comment.rhtml
+++ b/app/views/comment/_single_comment.html.erb
diff --git a/app/views/comment/new.rhtml b/app/views/comment/new.html.erb
index 578732cdb..578732cdb 100644
--- a/app/views/comment/new.rhtml
+++ b/app/views/comment/new.html.erb
diff --git a/app/views/comment/preview.rhtml b/app/views/comment/preview.html.erb
index 702bd9a9b..cd966e6a5 100644
--- a/app/views/comment/preview.rhtml
+++ b/app/views/comment/preview.html.erb
@@ -1,6 +1,6 @@
<% @title = _("Preview new annotation on '{{info_request_title}}'",:info_request_title=>h(@info_request.title)) %>
-<% form_for(:comment, @comment, :html => { :id => 'preview_form' }, :url => { :controller => "comment", :action => "new", :type => "request" } ) do |f| %>
+<%= form_for(@comment, :html => { :id => 'preview_form' }, :url => { :controller => "comment", :action => "new", :type => "request" } ) do |f| %>
<h1><%= _('Now preview your annotation') %></h1>
diff --git a/app/views/contact_mailer/from_admin_message.rhtml b/app/views/contact_mailer/from_admin_message.text.erb
index 4169d8d3a..4169d8d3a 100644
--- a/app/views/contact_mailer/from_admin_message.rhtml
+++ b/app/views/contact_mailer/from_admin_message.text.erb
diff --git a/app/views/contact_mailer/to_admin_message.rhtml b/app/views/contact_mailer/to_admin_message.text.erb
index dc9b1090b..dc9b1090b 100644
--- a/app/views/contact_mailer/to_admin_message.rhtml
+++ b/app/views/contact_mailer/to_admin_message.text.erb
diff --git a/app/views/contact_mailer/user_message.rhtml b/app/views/contact_mailer/user_message.text.erb
index afa1494db..afa1494db 100644
--- a/app/views/contact_mailer/user_message.rhtml
+++ b/app/views/contact_mailer/user_message.text.erb
diff --git a/app/views/general/_advanced_search_tips.rhtml b/app/views/general/_advanced_search_tips.html.erb
index 08ce04439..08ce04439 100644
--- a/app/views/general/_advanced_search_tips.rhtml
+++ b/app/views/general/_advanced_search_tips.html.erb
diff --git a/app/views/general/_before_body_end.rhtml b/app/views/general/_before_body_end.html.erb
index 25fdf4684..25fdf4684 100644
--- a/app/views/general/_before_body_end.rhtml
+++ b/app/views/general/_before_body_end.html.erb
diff --git a/app/views/general/_before_head_end.rhtml b/app/views/general/_before_head_end.html.erb
index 8886745ab..8886745ab 100644
--- a/app/views/general/_before_head_end.rhtml
+++ b/app/views/general/_before_head_end.html.erb
diff --git a/app/views/general/_credits.rhtml b/app/views/general/_credits.html.erb
index b1a9ce05e..b1a9ce05e 100644
--- a/app/views/general/_credits.rhtml
+++ b/app/views/general/_credits.html.erb
diff --git a/app/views/general/_custom_state_descriptions.rhtml b/app/views/general/_custom_state_descriptions.html.erb
index 913a6d50a..913a6d50a 100644
--- a/app/views/general/_custom_state_descriptions.rhtml
+++ b/app/views/general/_custom_state_descriptions.html.erb
diff --git a/app/views/general/_custom_state_transitions_complete.rhtml b/app/views/general/_custom_state_transitions_complete.html.erb
index e69de29bb..e69de29bb 100644
--- a/app/views/general/_custom_state_transitions_complete.rhtml
+++ b/app/views/general/_custom_state_transitions_complete.html.erb
diff --git a/app/views/general/_custom_state_transitions_pending.rhtml b/app/views/general/_custom_state_transitions_pending.html.erb
index e69de29bb..e69de29bb 100644
--- a/app/views/general/_custom_state_transitions_pending.rhtml
+++ b/app/views/general/_custom_state_transitions_pending.html.erb
diff --git a/app/views/general/_footer.rhtml b/app/views/general/_footer.html.erb
index 36f3919f0..990093694 100644
--- a/app/views/general/_footer.rhtml
+++ b/app/views/general/_footer.html.erb
@@ -1,6 +1,6 @@
<div id="footer">
<%= link_to _("Contact {{site_name}}", :site_name => site_name), help_contact_path %>
-| <img src="/images/twitter-16.png" alt="twitter icon" class="twitter-icon"> <a href="https://twitter.com/<%= Configuration::twitter_username %>"><%= _("Follow us on twitter") %></a>
+| <img src="/images/twitter-16.png" alt="twitter icon" class="twitter-icon"> <a href="https://twitter.com/<%= AlaveteliConfiguration::twitter_username %>"><%= _("Follow us on twitter") %></a>
<%= render :partial => 'general/credits' %>
</div>
<div class="after-footer">&nbsp;</div>
diff --git a/app/views/general/_frontpage_bodies_list.rhtml b/app/views/general/_frontpage_bodies_list.html.erb
index 75daea41d..75daea41d 100644
--- a/app/views/general/_frontpage_bodies_list.rhtml
+++ b/app/views/general/_frontpage_bodies_list.html.erb
diff --git a/app/views/general/_frontpage_intro_sentence.rhtml b/app/views/general/_frontpage_intro_sentence.html.erb
index 74b849fc9..74b849fc9 100644
--- a/app/views/general/_frontpage_intro_sentence.rhtml
+++ b/app/views/general/_frontpage_intro_sentence.html.erb
diff --git a/app/views/general/_frontpage_new_request.rhtml b/app/views/general/_frontpage_new_request.html.erb
index 499b60eb5..499b60eb5 100644
--- a/app/views/general/_frontpage_new_request.rhtml
+++ b/app/views/general/_frontpage_new_request.html.erb
diff --git a/app/views/general/_frontpage_requests_list.rhtml b/app/views/general/_frontpage_requests_list.html.erb
index fa498dfa7..fa498dfa7 100644
--- a/app/views/general/_frontpage_requests_list.rhtml
+++ b/app/views/general/_frontpage_requests_list.html.erb
diff --git a/app/views/general/_frontpage_search_box.rhtml b/app/views/general/_frontpage_search_box.html.erb
index 890602416..890602416 100644
--- a/app/views/general/_frontpage_search_box.rhtml
+++ b/app/views/general/_frontpage_search_box.html.erb
diff --git a/app/views/general/_locale_switcher.rhtml b/app/views/general/_locale_switcher.html.erb
index d0040bb0d..a318f61f3 100644
--- a/app/views/general/_locale_switcher.rhtml
+++ b/app/views/general/_locale_switcher.html.erb
@@ -2,7 +2,7 @@
<div id="user_locale_switcher">
<div class="btn-group">
<% for possible_locale in FastGettext.default_available_locales %>
- <% if possible_locale == I18n.locale.to_s %>
+ <% if possible_locale == FastGettext.locale %>
<a href="#" class="btn disabled"><%= locale_name(possible_locale) %></a>
<% else %>
<a href="<%= url_for params.merge(:locale => possible_locale) %>" class="btn"><%= locale_name(possible_locale) %></a>
diff --git a/app/views/general/_localised_datepicker.rhtml b/app/views/general/_localised_datepicker.html.erb
index ec6593ea0..ec6593ea0 100644
--- a/app/views/general/_localised_datepicker.rhtml
+++ b/app/views/general/_localised_datepicker.html.erb
diff --git a/app/views/general/_orglink.rhtml b/app/views/general/_orglink.html.erb
index 66002c021..66002c021 100644
--- a/app/views/general/_orglink.rhtml
+++ b/app/views/general/_orglink.html.erb
diff --git a/app/views/general/_popup_banner.rhtml b/app/views/general/_popup_banner.html.erb
index 8b1378917..8b1378917 100644
--- a/app/views/general/_popup_banner.rhtml
+++ b/app/views/general/_popup_banner.html.erb
diff --git a/app/views/general/_stylesheet_includes.rhtml b/app/views/general/_stylesheet_includes.html.erb
index 7a03680f8..9dd1f357d 100644
--- a/app/views/general/_stylesheet_includes.rhtml
+++ b/app/views/general/_stylesheet_includes.html.erb
@@ -8,14 +8,9 @@
<!--[if LT IE 7]>
<style type="text/css">@import url("/stylesheets/ie6.css");</style>
<![endif]-->
- <!--[if LT IE 7]>
- <style type="text/css">@import url("/stylesheets/ie6-custom.css");</style>
- <![endif]-->
<!--[if LT IE 8]>
<style type="text/css">@import url("/stylesheets/ie7.css");</style>
<![endif]-->
- <!-- the following method for customising CSS is deprecated; see `doc/THEMES.md` for detail -->
- <%= stylesheet_link_tag 'custom', :title => "Main", :rel => "stylesheet" %>
- <% if Configuration::force_registration_on_new_request %>
+ <% if AlaveteliConfiguration::force_registration_on_new_request %>
<%= stylesheet_link_tag 'jquery.fancybox-1.3.4', :rel => "stylesheet" %>
<% end %>
diff --git a/app/views/general/_topnav.rhtml b/app/views/general/_topnav.html.erb
index c7f2cedea..c7f2cedea 100644
--- a/app/views/general/_topnav.rhtml
+++ b/app/views/general/_topnav.html.erb
diff --git a/app/views/general/blog.rhtml b/app/views/general/blog.html.erb
index d42b32282..ef587421e 100644
--- a/app/views/general/blog.rhtml
+++ b/app/views/general/blog.html.erb
@@ -7,9 +7,9 @@
<img src="/images/twitter-16.png" alt="twitter icon" class="twitter-icon"> <a href="https://twitter.com/<%= @twitter_user %>"><%= _("Follow us on twitter") %></a><br/><br/>
<img src="/images/feed-16.png" alt="RSS icon"> <a href="<%= @feed_url %>"><%= _("Subscribe to blog") %></a>
</div>
- <% if Configuration::twitter_widget_id %>
+ <% if AlaveteliConfiguration::twitter_widget_id %>
<div id="twitter">
- <a class="twitter-timeline" data-dnt=true href="https://twitter.com/<%= Configuration::twitter_username %>" data-widget-id="<%= Configuration::twitter_widget_id %>">Tweets by @<%= Configuration::twitter_username %></a>
+ <a class="twitter-timeline" data-dnt=true href="https://twitter.com/<%= AlaveteliConfiguration::twitter_username %>" data-widget-id="<%= AlaveteliConfiguration::twitter_widget_id %>">Tweets by @<%= AlaveteliConfiguration::twitter_username %></a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div>
<% end %>
@@ -20,15 +20,15 @@
<h1><%=@title %></h1>
<div id="blog">
- <% for item in @blog_items: %>
+ <% @blog_items.each do |item| %>
<div class="blog_post">
- <h2 id="<%= Time.parse(item['pubDate'][0]).to_i %>"><a href="<%=item['link']%>"><%=h item['title'] %></a></h2>
- <p class="subtitle"><%= _("Posted on {{date}} by {{author}}", :date=>simple_date(Time.parse(item['pubDate'][0])), :author=>item['creator']) %></p>
+ <h2 id="<%= Time.parse(item['pubDate'][0]).to_i %>"><a href="<%=item['link'][0]%>"><%=h item['title'][0] %></a></h2>
+ <p class="subtitle"><%= _("Posted on {{date}} by {{author}}", :date=>simple_date(Time.parse(item['pubDate'][0])), :author=> item['creator'] ? item['creator'][0] : item['author'][0]) %></p>
<div>
<% if item['encoded'] %>
- <%= raw item['encoded'] %>
+ <%= raw item['encoded'][0] %>
<% elsif item['description'] %>
- <%= raw item['description'] %>
+ <%= raw item['description'][0] %>
<% end %>
</div>
<p><em>
diff --git a/app/views/general/custom_css.rhtml b/app/views/general/custom_css.rhtml
deleted file mode 100644
index 0def82ed0..000000000
--- a/app/views/general/custom_css.rhtml
+++ /dev/null
@@ -1 +0,0 @@
-// this should be overridden in a local "theme" plugin
diff --git a/app/views/general/exception_caught.rhtml b/app/views/general/exception_caught.html.erb
index f8fe4343b..8d78e2e92 100644
--- a/app/views/general/exception_caught.rhtml
+++ b/app/views/general/exception_caught.html.erb
@@ -7,7 +7,7 @@
<ul>
<li><%= _("Check for mistakes if you typed or copied the address.")%></li>
<li><%= _("Search the site to find what you were looking for.")%>
- <% form_tag({:controller => "general", :action => "search_redirect"}, {:id => "search_form" }) do %>
+ <%= form_tag({:controller => "general", :action => "search_redirect"}, {:id => "search_form" }) do %>
<%= text_field_tag 'query', params[:query], { :size => 30, :title => "type your search term here" } %>
<%= submit_tag _("Search") %>
<% end %>
diff --git a/app/views/general/frontpage.rhtml b/app/views/general/frontpage.html.erb
index 6eceb3b28..bf5261d15 100644
--- a/app/views/general/frontpage.rhtml
+++ b/app/views/general/frontpage.html.erb
@@ -1,4 +1,4 @@
-<%# TODO: Cache for 5 minutes %>
+<% # TODO: Cache for 5 minutes %>
<div id="frontpage_splash">
<div id="left_column">
<%= render :partial => "frontpage_new_request" %>
diff --git a/app/views/general/search.rhtml b/app/views/general/search.html.erb
index df114782f..d526a93c0 100644
--- a/app/views/general/search.rhtml
+++ b/app/views/general/search.html.erb
@@ -22,7 +22,7 @@
<% if @advanced %>
<div id="advanced-search">
<p><%= _('To use the advanced search, combine phrases and labels as described in the search tips below.') %></p>
- <% form_tag(advanced_search_url, :method => "get") do %>
+ <%= form_tag(advanced_search_url, :method => "get") do %>
<p>
<%= text_field_tag :query, @query, { :size => 60 } %>
<%= hidden_field_tag 'sortby', @inputted_sortby %>
@@ -35,15 +35,23 @@
<% end %>
</div>
<% else %>
- <% form_tag(request.url, {:method => "get", :id => "search_form"}) do %>
+
+
+ <%= form_tag(search_redirect_path, {:method => "get", :id => "search_form"}) do %>
<p>
<%= text_field_tag 'query', params[:query], { :size => 40, :title => "type your search term here" } %>
+
+ <%= submit_tag _("Search") %>
+ <%= link_to(_("Advanced search"), advanced_search_path) %>
+ </p>
+ <% end %>
+ <%= form_tag(request.url, {:method => "get", :id => "filter_form"}) do %>
+ <p>
<%= hidden_field_tag 'sortby', @inputted_sortby %>
<% if @bodies %>
<%= hidden_field_tag 'bodies', 1 %>
<% end %>
- <%= submit_tag _("Search") %>
- <%= link_to(_("Advanced search"), advanced_search_path) %>
+
</p>
<div id="common-subfilters">
@@ -63,18 +71,6 @@
<%= "|" unless variety == labels.last[0]%>
<% end %>
</div>
-
- <% if false %>
- <%-# Commented out for now as tags are of limited use when users can't see them. This will change in the future! -%>
- <% if @variety_postfix != "users" %>
- <div>
- <%= label_tag(:query, _("Tags (separated by a space):")) %><%= text_field_tag(:tags, params[:tags], { :size => 20 }) %>
- <% for tag in InfoRequest.get_tags %>
- <%= tag.name_and_value %>
- <% end %>
- </div>
- <% end %>
- <% end %>
</div>
<% if @variety_postfix == "requests" %>
@@ -139,7 +135,6 @@
<% end %>
<div style="clear:both;"></div>
-
<% if @total_hits == 0 %>
<h2><%=@title %></h2>
<% end %>
diff --git a/app/views/help/_sidebar.rhtml b/app/views/help/_sidebar.html.erb
index 2b7ed5647..2b7ed5647 100644
--- a/app/views/help/_sidebar.rhtml
+++ b/app/views/help/_sidebar.html.erb
diff --git a/app/views/help/_why_they_should_reply_by_email.rhtml b/app/views/help/_why_they_should_reply_by_email.html.erb
index faaa2b2e2..faaa2b2e2 100644
--- a/app/views/help/_why_they_should_reply_by_email.rhtml
+++ b/app/views/help/_why_they_should_reply_by_email.html.erb
diff --git a/app/views/help/about.rhtml b/app/views/help/about.html.erb
index 477f0e750..477f0e750 100644
--- a/app/views/help/about.rhtml
+++ b/app/views/help/about.html.erb
diff --git a/app/views/help/alaveteli.rhtml b/app/views/help/alaveteli.html.erb
index 6210f9f24..6210f9f24 100644
--- a/app/views/help/alaveteli.rhtml
+++ b/app/views/help/alaveteli.html.erb
diff --git a/app/views/help/api.rhtml b/app/views/help/api.html.erb
index 57390d65a..57390d65a 100644
--- a/app/views/help/api.rhtml
+++ b/app/views/help/api.html.erb
diff --git a/app/views/help/contact.rhtml b/app/views/help/contact.html.erb
index b1b5d4f24..ad89db9ec 100644
--- a/app/views/help/contact.rhtml
+++ b/app/views/help/contact.html.erb
@@ -40,13 +40,13 @@
<% end %>
</div>
-<% form_for :contact do |f| %>
+<%= form_for :contact do |f| %>
<% if not @user %>
<p>
<label class="form_label" for="contact_name">Your name:</label>
<%= f.text_field :name, :size => 20 %>
- (or <%= link_to "sign in", signin_path(:r => request.request_uri) %>)
+ (or <%= link_to "sign in", signin_path(:r => request.fullpath) %>)
</p>
<p>
diff --git a/app/views/help/credits.rhtml b/app/views/help/credits.html.erb
index 02f1e40e8..02f1e40e8 100644
--- a/app/views/help/credits.rhtml
+++ b/app/views/help/credits.html.erb
diff --git a/app/views/help/officers.rhtml b/app/views/help/officers.html.erb
index 6db706f78..6db706f78 100644
--- a/app/views/help/officers.rhtml
+++ b/app/views/help/officers.html.erb
diff --git a/app/views/help/privacy.rhtml b/app/views/help/privacy.html.erb
index 8e5293892..8e5293892 100644
--- a/app/views/help/privacy.rhtml
+++ b/app/views/help/privacy.html.erb
diff --git a/app/views/help/requesting.rhtml b/app/views/help/requesting.html.erb
index e7cfdd199..e7cfdd199 100644
--- a/app/views/help/requesting.rhtml
+++ b/app/views/help/requesting.html.erb
diff --git a/app/views/help/unhappy.rhtml b/app/views/help/unhappy.html.erb
index 79e3f8273..79e3f8273 100644
--- a/app/views/help/unhappy.rhtml
+++ b/app/views/help/unhappy.html.erb
diff --git a/app/views/holiday/due_date.rhtml b/app/views/holiday/due_date.html.erb
index 6f8c2e51a..6f8c2e51a 100644
--- a/app/views/holiday/due_date.rhtml
+++ b/app/views/holiday/due_date.html.erb
diff --git a/app/views/layouts/admin.rhtml b/app/views/layouts/admin.html.erb
index a58913892..a58913892 100644
--- a/app/views/layouts/admin.rhtml
+++ b/app/views/layouts/admin.html.erb
diff --git a/app/views/layouts/contact_mailer.rhtml b/app/views/layouts/contact_mailer.html.erb
index 3cdc75009..3cdc75009 100644
--- a/app/views/layouts/contact_mailer.rhtml
+++ b/app/views/layouts/contact_mailer.html.erb
diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.html.erb
index a66b85e02..472fa8ec1 100644
--- a/app/views/layouts/default.rhtml
+++ b/app/views/layouts/default.html.erb
@@ -33,7 +33,7 @@
<% end %>
<% end %>
<% if @has_json %>
- <link rel="alternate" type="application/json" title="JSON version of this page" href="<%=h url_for(request.query_parameters.merge(:format => 'json')) %>">
+ <link rel="alternate" type="application/json" title="JSON version of this page" href="<%=h url_for(request.params.merge(:format => 'json')) %>">
<% end %>
<% if @no_crawl %>
@@ -43,7 +43,7 @@
<%= render :partial => 'general/before_head_end' %>
</head>
<body class="<%= 'front' if params[:action] == 'frontpage' %>">
- <% if Configuration::force_registration_on_new_request && !@user %>
+ <% if AlaveteliConfiguration::force_registration_on_new_request && !@user %>
<%= javascript_include_tag 'jquery.fancybox-1.3.4.pack' %>
<script type="text/javascript">
$(document).ready(function() {
@@ -52,7 +52,7 @@
'width': 920,
'height': 400,
'type': 'iframe',
- 'href': '/<%= I18n.locale %>/profile/sign_in?modal=1',
+ 'href': '/<%= FastGettext.locale %>/profile/sign_in?modal=1',
'onClosed': function() {
// modal_signin_successful variable set by modal dialog box
if (typeof modal_signin_successful != 'undefined' ) {
@@ -67,11 +67,11 @@
<% if is_admin? %>
<%= render :partial => 'admin_general/admin_navbar' %>
<% end %>
-
-<% if !@popup_banner.blank? %>
+<% popup_banner = render(:partial => "general/popup_banner").strip %>
+<% if popup_banner.present? %>
<div id="everypage" class="jshide">
<p class="popup-close"><a href="#top" onclick="$.cookie('seen_foi2', 1, { expires: 7, path: '/' }); $('#everypage').hide('slow'); return false;"><%= _('Close') %></a></p>
- <%= @popup_banner %>
+ <%= raw popup_banner %>
<p class="popup-close"><a href="#top" onclick="$.cookie('seen_foi2', 1, { expires: 7, path: '/' }); $('#everypage').hide('slow'); return false;"><%= _('Close') %></a></p>
</div>
<% end %>
@@ -93,9 +93,9 @@
<% end %>
- <%= link_to _("Sign out"), signout_path(:r => request.request_uri) %>
+ <%= link_to _("Sign out"), signout_path(:r => request.fullpath) %>
<% else %>
- <%= link_to _("Sign in or sign up"), signin_path(:r => request.request_uri) %>
+ <%= link_to _("Sign in or sign up"), signin_path(:r => request.fullpath) %>
<% end %>
</div>
<% end %>
@@ -140,13 +140,13 @@
<input type="text">
</div>
<%
- unless Configuration::ga_code.empty? || (@user && @user.super?) %>
+ unless AlaveteliConfiguration::ga_code.empty? || (@user && @user.super?) %>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
- var pageTracker = _gat._getTracker("<%= Configuration::ga_code %>");
+ var pageTracker = _gat._getTracker("<%= AlaveteliConfiguration::ga_code %>");
pageTracker._trackPageview();
</script>
diff --git a/app/views/layouts/no_chrome.rhtml b/app/views/layouts/no_chrome.html.erb
index 120ba6f28..d7918cffc 100644
--- a/app/views/layouts/no_chrome.rhtml
+++ b/app/views/layouts/no_chrome.html.erb
@@ -12,19 +12,16 @@
<script type="text/javascript" src="/javascripts/jquery.js"></script>
- <%= stylesheet_link_tag 'main', :title => "Main", :rel => "stylesheet" %>
- <%= stylesheet_link_tag 'fonts', :rel => "stylesheet" %>
- <%= stylesheet_link_tag 'theme', :rel => "stylesheet" %>
- <!--[if LT IE 7]>
- <style type="text/css">@import url("/stylesheets/ie6.css");</style>
- <![endif]-->
- <!--[if LT IE 7]>
- <style type="text/css">@import url("/stylesheets/ie6-custom.css");</style>
+ <%= stylesheet_link_tag 'main', :title => "Main", :rel => "stylesheet" %>
+ <%= stylesheet_link_tag 'fonts', :rel => "stylesheet" %>
+ <%= stylesheet_link_tag 'theme', :rel => "stylesheet" %>
+ <!--[if LT IE 7]>
+ <style type="text/css">@import url("/stylesheets/ie6.css");</style>
<![endif]-->
<%= stylesheet_link_tag 'custom', :title => "Main", :rel => "stylesheet" %>
</head>
<body>
- <div class="entirebody">
+ <div class="entirebody">
<div id="content">
<% if flash[:notice] %>
<div id="notice"><%= flash[:notice] %></div>
@@ -39,4 +36,4 @@
</div>
</div>
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/app/views/layouts/outgoing_mailer.rhtml b/app/views/layouts/outgoing_mailer.html.erb
index 8bf8ef216..8bf8ef216 100644
--- a/app/views/layouts/outgoing_mailer.rhtml
+++ b/app/views/layouts/outgoing_mailer.html.erb
diff --git a/app/views/layouts/request_mailer.rhtml b/app/views/layouts/request_mailer.html.erb
index 3cdc75009..3cdc75009 100644
--- a/app/views/layouts/request_mailer.rhtml
+++ b/app/views/layouts/request_mailer.html.erb
diff --git a/app/views/layouts/user_mailer.rhtml b/app/views/layouts/user_mailer.html.erb
index 3cdc75009..3cdc75009 100644
--- a/app/views/layouts/user_mailer.rhtml
+++ b/app/views/layouts/user_mailer.html.erb
diff --git a/app/views/outgoing_mailer/_followup_footer.rhtml b/app/views/outgoing_mailer/_followup_footer.text.erb
index d7bc7c5aa..d7bc7c5aa 100644
--- a/app/views/outgoing_mailer/_followup_footer.rhtml
+++ b/app/views/outgoing_mailer/_followup_footer.text.erb
diff --git a/app/views/outgoing_mailer/followup.rhtml b/app/views/outgoing_mailer/followup.text.erb
index 049ebc881..049ebc881 100644
--- a/app/views/outgoing_mailer/followup.rhtml
+++ b/app/views/outgoing_mailer/followup.text.erb
diff --git a/app/views/outgoing_mailer/initial_request.rhtml b/app/views/outgoing_mailer/initial_request.text.erb
index 5c418ecc7..5c418ecc7 100644
--- a/app/views/outgoing_mailer/initial_request.rhtml
+++ b/app/views/outgoing_mailer/initial_request.text.erb
diff --git a/app/views/public_body/_alphabet.rhtml b/app/views/public_body/_alphabet.html.erb
index 46b345c2a..63b24e0fb 100644
--- a/app/views/public_body/_alphabet.rhtml
+++ b/app/views/public_body/_alphabet.html.erb
@@ -1,3 +1,3 @@
-<% "A".upto("Z") do |l| -%>
+<%- "A".upto("Z") do |l| -%>
<%= link_to_unless (@tag == l), l, list_public_bodies_path(:tag => l.downcase) %>
<% end %>
diff --git a/app/views/public_body/_body_listing.rhtml b/app/views/public_body/_body_listing.html.erb
index 864ab8c9b..864ab8c9b 100644
--- a/app/views/public_body/_body_listing.rhtml
+++ b/app/views/public_body/_body_listing.html.erb
diff --git a/app/views/public_body/_body_listing_single.rhtml b/app/views/public_body/_body_listing_single.html.erb
index 8e0a64df7..91a07d09c 100644
--- a/app/views/public_body/_body_listing_single.rhtml
+++ b/app/views/public_body/_body_listing_single.html.erb
@@ -20,8 +20,14 @@
<span class="bottomline">
<%= n_('{{count}} request made.', '{{count}} requests made.', public_body.info_requests.size,
:count => public_body.info_requests.size) %>
- <% if !@include_request_link_in_authority_listing.nil? %>
- <%= link_to _("Make your own request"), public_body_path(public_body) %>.
+ <% if !public_body.is_requestable? && public_body.not_requestable_reason != 'bad_contact' %>
+ <% if public_body.not_requestable_reason == 'defunct' %>
+ <%= _('Defunct.') %>
+ <% end %>
+ <% else %>
+ <% if !@include_request_link_in_authority_listing.nil? %>
+ <%= link_to _("Make your own request"), public_body_path(public_body) %>.
+ <% end %>
<% end %>
<br>
<span class="date_added">
diff --git a/app/views/public_body/_list_sidebar_extra.rhtml b/app/views/public_body/_list_sidebar_extra.html.erb
index 290593d6a..290593d6a 100644
--- a/app/views/public_body/_list_sidebar_extra.rhtml
+++ b/app/views/public_body/_list_sidebar_extra.html.erb
diff --git a/app/views/public_body/_search_ahead.rhtml b/app/views/public_body/_search_ahead.html.erb
index 7ade89b8e..3d1dc8f93 100644
--- a/app/views/public_body/_search_ahead.rhtml
+++ b/app/views/public_body/_search_ahead.html.erb
@@ -1,4 +1,4 @@
-<div>
+
<% if !@xapian_requests.nil? %>
<% if @xapian_requests.results.size > 0 %>
<h3><%= _('Top search results:') %></h3>
@@ -10,12 +10,11 @@
<% end %>
<div id="authority_search_ahead_results">
<% for result in @xapian_requests.results %>
- <%= render :partial => 'body_listing_single', :locals => { :public_body => result[:model] } %>
+ <%= render :partial => 'public_body/body_listing_single', :locals => { :public_body => result[:model] } %>
<% end %>
</div>
- <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @xapian_requests.matches_estimated) %>
+ <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @xapian_requests.matches_estimated), :params => {:controller=>"request", :action => "select_authority"} %>
<% end %>
-</div>
diff --git a/app/views/public_body/list.rhtml b/app/views/public_body/list.html.erb
index 34b34d550..ce24daaf9 100644
--- a/app/views/public_body/list.rhtml
+++ b/app/views/public_body/list.html.erb
@@ -32,7 +32,7 @@
<div id="left_column_flip">
<h1><%= _('Public authorities') %></h1>
-<% form_tag(list_public_bodies_default_url, :method => "get", :id=>"search_form") do %>
+<%= form_tag(list_public_bodies_default_url, :method => "get", :id=>"search_form") do %>
<div>
<%= text_field_tag(:public_body_query, params[:public_body_query], { :title => "type your search term here" } ) %>
<%= submit_tag(_("Search")) %>
diff --git a/app/views/public_body/show.rhtml b/app/views/public_body/show.html.erb
index fa6243b47..b35e29eea 100644
--- a/app/views/public_body/show.rhtml
+++ b/app/views/public_body/show.html.erb
@@ -46,31 +46,29 @@
<% end %>
</p>
- <% if @public_body.has_notes? && (@public_body.is_requestable? || @public_body.not_requestable_reason == 'bad_contact') %>
- <p><%= @public_body.notes_as_html.html_safe %></p>
- <% end %>
-
- <% if @public_body.eir_only? %>
- <p><%= _('You can only request information about the environment from this authority.')%></p>
+ <% if @public_body.is_requestable? || @public_body.not_requestable_reason == 'bad_contact' %>
+ <% if @public_body.has_notes? %>
+ <p><%= @public_body.notes_as_html.html_safe %></p>
+ <% end %>
+ <% if @public_body.eir_only? %>
+ <p><%= _('You can only request information about the environment from this authority.')%></p>
+ <% end %>
+ <% else %>
+ <% if @public_body.not_requestable_reason == 'not_apply' %>
+ <p><%= _('Freedom of Information law does not apply to this authority, so you cannot make
+ a request to it.')%></p>
+ <% elsif @public_body.not_requestable_reason == 'defunct' %>
+ <p><%= _('This authority no longer exists, so you cannot make a request to it.')%></p>
+ <% else %>
+ <p><%= _('For an unknown reason, it is not possible to make a request to this authority.')%></p>
+ <% end %>
<% end %>
<div id="stepwise_make_request">
<% if @public_body.is_requestable? || @public_body.not_requestable_reason == 'bad_contact' %>
- <% if @public_body.eir_only? %>
- <%= _('Make a new <strong>Environmental Information</strong> request')%>
- <% else %>
- <%= _('Make a new <strong>Freedom of Information</strong> request to {{public_body}}', :public_body => h(@public_body.name))%>
- <% end %>
- &nbsp;<%= link_to _("Start"), new_request_to_body_url(:url_name => @public_body.url_name), :class => "link_button_green" %>
+ <%= link_to _("Make a request to this authority"), new_request_to_body_path(:url_name => @public_body.url_name), :class => "link_button_green" %>
<% elsif @public_body.has_notes? %>
<%= @public_body.notes_as_html.html_safe %>
- <% elsif @public_body.not_requestable_reason == 'not_apply' %>
- <%= _('Freedom of Information law does not apply to this authority, so you cannot make
- a request to it.')%>
- <% elsif @public_body.not_requestable_reason == 'defunct' %>
- <%= _('This authority no longer exists, so you cannot make a request to it.')%>
- <% else %>
- <%= _('For an unknown reason, it is not possible to make a request to this authority.')%>
<% end %>
<% if @public_body.override_request_email %>
@@ -83,12 +81,14 @@
<div id="foi_results_section">
<% if @public_body.info_requests.size == 0 %>
- <% if @public_body.eir_only? %>
- <h2><%= _('Environmental Information Regulations requests made using this site') %></h2>
- <p>Nobody has made any Environmental Information Regulations requests to <%=h(@public_body.name)%> using this site yet.</p>
- <% else %>
- <h2><%= _('Freedom of Information requests made using this site')%></h2>
- <p><%= _('Nobody has made any Freedom of Information requests to {{public_body_name}} using this site yet.', :public_body_name => h(@public_body.name))%></p>
+ <% if @public_body.is_requestable? or @public_body.not_requestable_reason != 'defunct' %>
+ <% if @public_body.eir_only? %>
+ <h2><%= _('Environmental Information Regulations requests made using this site') %></h2>
+ <p>Nobody has made any Environmental Information Regulations requests to <%=h(@public_body.name)%> using this site yet.</p>
+ <% else %>
+ <h2><%= _('Freedom of Information requests made using this site')%></h2>
+ <p><%= _('Nobody has made any Freedom of Information requests to {{public_body_name}} using this site yet.', :public_body_name => h(@public_body.name))%></p>
+ <% end %>
<% end %>
<% else %>
<h2 class="foi_results">
diff --git a/app/views/public_body/view_email.rhtml b/app/views/public_body/view_email.html.erb
index 3f0a558c7..3f0a558c7 100644
--- a/app/views/public_body/view_email.rhtml
+++ b/app/views/public_body/view_email.html.erb
diff --git a/app/views/public_body/view_email_captcha.rhtml b/app/views/public_body/view_email_captcha.html.erb
index 6f301e055..4f6db5b67 100644
--- a/app/views/public_body/view_email_captcha.rhtml
+++ b/app/views/public_body/view_email_captcha.html.erb
@@ -4,7 +4,7 @@
<p><%= _('To view the email address that we use to send FOI requests to {{public_body_name}}, please enter these words.', :public_body_name => h(@public_body.name))%></p>
-<% form_for :contact do |f| %>
+<%= form_for :contact do |f| %>
<%= recaptcha_tags %>
<%= hidden_field_tag(:submitted_view_email, { :value => 1 } ) %>
diff --git a/app/views/reports/new.html.erb b/app/views/reports/new.html.erb
new file mode 100644
index 000000000..7d558ab4e
--- /dev/null
+++ b/app/views/reports/new.html.erb
@@ -0,0 +1,26 @@
+<h1>Report request: <%= @info_request.title %></h1>
+
+<% if @info_request.attention_requested %>
+ <p><%= _("This request has already been reported for administrator attention") %></p>
+<% else %>
+ <p>
+ Reporting a request notifies the site administrators. They will respond as soon as possible.
+ </p>
+ <p>Why specifically do you consider this request unsuitable?</p>
+
+ <%= form_tag request_report_path(:request_id => @info_request.url_title) do %>
+ <p>
+ <label class="form_label" for="reason">Reason:</label>
+ <%= select_tag :reason, options_for_select(@info_request.report_reasons, @reason), :prompt => "Choose a reason" %>
+ </p>
+ <p>
+ <label class="form_label" for="message">Please tell us more:</label>
+ <%= text_area_tag :message, @message, :rows => 10, :cols => 60 %>
+ </p>
+
+ <div class="form_button">
+ <%= submit_tag _("Report request") %>
+ </div>
+
+ <% end %>
+<% end %>
diff --git a/app/views/request/_after_actions.rhtml b/app/views/request/_after_actions.html.erb
index b54a8f5fb..b54a8f5fb 100644
--- a/app/views/request/_after_actions.rhtml
+++ b/app/views/request/_after_actions.html.erb
diff --git a/app/views/request/_bubble.rhtml b/app/views/request/_bubble.html.erb
index 94498612a..94498612a 100644
--- a/app/views/request/_bubble.rhtml
+++ b/app/views/request/_bubble.html.erb
diff --git a/app/views/request/_correspondence.rhtml b/app/views/request/_correspondence.html.erb
index 68711b259..68711b259 100644
--- a/app/views/request/_correspondence.rhtml
+++ b/app/views/request/_correspondence.html.erb
diff --git a/app/views/request/_describe_state.rhtml b/app/views/request/_describe_state.html.erb
index 0b65024fd..05cce013e 100644
--- a/app/views/request/_describe_state.rhtml
+++ b/app/views/request/_describe_state.html.erb
@@ -1,6 +1,6 @@
<% if @is_owning_user %>
- <% form_for(:incoming_message, @info_request, :url => describe_state_url(:id => @info_request.id)) do |f| %>
+ <%= form_for(@info_request, :as => :incoming_message, :url => describe_state_url(:id => @info_request.id), :html => {:id => "describe_form_#{id_suffix}"}) do |f| %>
<h2><%= _('What best describes the status of this request now?') %></h2>
<hr>
@@ -101,13 +101,13 @@
</p>
<% end %>
<% elsif @old_unclassified %>
- <%= render :partial => 'other_describe_state', :locals => {:id_suffix => id_suffix } %>
+ <%= render :partial => 'request/other_describe_state', :locals => {:id_suffix => id_suffix } %>
<% else %>
<% if !@info_request.is_external? %>
<%= _('We don\'t know whether the most recent response to this request contains
information or not
&ndash;
- if you are {{user_link}} please <a href="{{url}}">sign in</a> and let everyone know.',:user_link=>user_link(@info_request.user), :url=>signin_url(:r => request.request_uri)) %>
+ if you are {{user_link}} please <a href="{{url}}">sign in</a> and let everyone know.',:user_link=>user_link(@info_request.user), :url=>signin_url(:r => request.fullpath)) %>
<% end %>
<% end %>
diff --git a/app/views/request/_followup.rhtml b/app/views/request/_followup.html.erb
index 3776980a0..bb099ff15 100644
--- a/app/views/request/_followup.rhtml
+++ b/app/views/request/_followup.html.erb
@@ -78,7 +78,7 @@
</p>
<% end %>
- <% form_for(:outgoing_message, @outgoing_message, :html => { :id => 'followup_form' }, :url => incoming_message.nil? ? show_response_no_followup_url(:id => @info_request.id) : show_response_url(:id => @info_request.id, :incoming_message_id => incoming_message.id)) do |o| %>
+ <%= form_for(@outgoing_message, :html => { :id => 'followup_form' }, :url => incoming_message.nil? ? show_response_no_followup_url(:id => @info_request.id) : show_response_url(:id => @info_request.id, :incoming_message_id => incoming_message.id)) do |o| %>
<p>
<%= o.text_area :body, :rows => 15, :cols => 55 %>
</p>
diff --git a/app/views/request/_hidden_correspondence.rhtml b/app/views/request/_hidden_correspondence.html.erb
index a08c1badf..4c06f1f48 100644
--- a/app/views/request/_hidden_correspondence.rhtml
+++ b/app/views/request/_hidden_correspondence.html.erb
@@ -7,21 +7,21 @@
%>
<div class="correspondence" id="incoming-<%=incoming_message.id.to_s%>">
<p>
- <%= _('This response has been hidden. See annotations to find out why.
- If you are the requester, then you may <a href="{{url}}">sign in</a> to view the response.', :url => signin_url(:r => request.request_uri).html_safe) %>
+ <%= _('This response has been hidden. See annotations to find out why.
+ If you are the requester, then you may <a href="{{url}}">sign in</a> to view the response.', :url => signin_url(:r => request.fullpath).html_safe) %>
</p>
</div>
<% elsif [ 'sent', 'followup_sent', 'resent', 'followup_resent' ].include?(info_request_event.event_type) %>
<div class="correspondence" id="outgoing-<%=outgoing_message.id.to_s%>">
<p>
- <%= _('This outgoing message has been hidden. See annotations to
- find out why. If you are the requester, then you may <a href="{{url}}">sign in</a> to view the response.', :url => signin_url(:r => request.request_uri).html_safe) %>
+ <%= _('This outgoing message has been hidden. See annotations to
+ find out why. If you are the requester, then you may <a href="{{url}}">sign in</a> to view the response.', :url => signin_url(:r => request.fullpath).html_safe) %>
</p>
</div>
<% elsif info_request_event.event_type == 'comment' %>
<div class="comment_in_request" id="comment-<%=comment.id.to_s%>">
<p><%= _('This comment has been hidden. See annotations to
- find out why. If you are the requester, then you may <a href="{{url}}">sign in</a> to view the response.', :url => signin_url(:r => request.request_uri).html_safe) %>
+ find out why. If you are the requester, then you may <a href="{{url}}">sign in</a> to view the response.', :url => signin_url(:r => request.fullpath).html_safe) %>
</p>
</div>
<% end %>
diff --git a/app/views/request/_next_actions.rhtml b/app/views/request/_next_actions.html.erb
index f318df6e4..f318df6e4 100644
--- a/app/views/request/_next_actions.rhtml
+++ b/app/views/request/_next_actions.html.erb
diff --git a/app/views/request/_other_describe_state.rhtml b/app/views/request/_other_describe_state.html.erb
index 3a80823c6..e49f9ecb3 100644
--- a/app/views/request/_other_describe_state.rhtml
+++ b/app/views/request/_other_describe_state.html.erb
@@ -1,6 +1,6 @@
-<% form_for(:incoming_message, @info_request, :url => describe_state_url(:id => @info_request.id)) do |f| %>
+<%= form_for(@info_request, :as => :incoming_message, :url => describe_state_url(:id => @info_request.id), :html => {:id => "describe_form_#{id_suffix}"}) do |f| %>
<h2><%= _('Hi! We need your help. The person who made the following request
hasn\'t told us whether or not it was successful. Would you mind taking
a moment to read it and help us keep the place tidy for everyone?
diff --git a/app/views/request/_request_filter_form.rhtml b/app/views/request/_request_filter_form.html.erb
index 0c215a9b6..090db01df 100644
--- a/app/views/request/_request_filter_form.rhtml
+++ b/app/views/request/_request_filter_form.html.erb
@@ -1,7 +1,7 @@
<%= render :partial => 'general/localised_datepicker' %>
<div id="list-filter">
- <% form_tag(request.path, :method => "get", :id=>"filter_requests_form") do %>
+ <%= form_tag(request.path, :method => "get", :id=>"filter_requests_form") do %>
<div class="list-filter-item">
<%= label_tag(:query, _("Keywords"), :class=>"form_label title") %>
<%= text_field_tag(:query, params[:query]) %>
diff --git a/app/views/request/_request_listing.rhtml b/app/views/request/_request_listing.html.erb
index 492f874f3..492f874f3 100644
--- a/app/views/request/_request_listing.rhtml
+++ b/app/views/request/_request_listing.html.erb
diff --git a/app/views/request/_request_listing_short_via_event.rhtml b/app/views/request/_request_listing_short_via_event.html.erb
index c2f6474a1..c2f6474a1 100644
--- a/app/views/request/_request_listing_short_via_event.rhtml
+++ b/app/views/request/_request_listing_short_via_event.html.erb
diff --git a/app/views/request/_request_listing_single.rhtml b/app/views/request/_request_listing_single.html.erb
index 56737fd3e..56737fd3e 100644
--- a/app/views/request/_request_listing_single.rhtml
+++ b/app/views/request/_request_listing_single.html.erb
diff --git a/app/views/request/_request_listing_via_event.rhtml b/app/views/request/_request_listing_via_event.html.erb
index cc8bae8a9..cc8bae8a9 100644
--- a/app/views/request/_request_listing_via_event.rhtml
+++ b/app/views/request/_request_listing_via_event.html.erb
diff --git a/app/views/request/_search_ahead.rhtml b/app/views/request/_search_ahead.html.erb
index 1e65a5458..1e65a5458 100644
--- a/app/views/request/_search_ahead.rhtml
+++ b/app/views/request/_search_ahead.html.erb
diff --git a/app/views/request/_sidebar.rhtml b/app/views/request/_sidebar.html.erb
index c7d21d867..e08f43eaa 100644
--- a/app/views/request/_sidebar.rhtml
+++ b/app/views/request/_sidebar.html.erb
@@ -16,12 +16,12 @@
<% if @info_request.attention_requested %>
<% if @info_request.prominence == 'hidden' %>
<%# The eccentric formatting of the following string is in order that it be identical
- to the corresponding string in request/show.rhtml %>
+ to the corresponding string in request/show.html.erb %>
<p><%= _('This request has prominence \'hidden\'. You can only see it because you are logged
in as a super user.') %></p>
<% elsif @info_request.prominence == 'requester_only' %>
<%# The eccentric formatting of the following string is in order that it be identical
- to the corresponding string in request/show.rhtml %>
+ to the corresponding string in request/show.html.erb %>
<p><%= _('This request is hidden, so that only you the requester can see it. Please
<a href="{{url}}">contact us</a> if you are not sure why.', :url => help_requesting_path.html_safe) %></p>
<% else %>
@@ -30,26 +30,23 @@
<% else %>
<p><%= _('Requests for personal information and vexatious requests are not considered valid for FOI purposes (<a href="/help/about">read more</a>).') %></p>
<p><%= _('If you believe this request is not suitable, you can report it for attention by the site administrators') %></p>
- <%= button_to _("Report this request"), report_path, :class => "link_button_green" %>
+ <%= link_to _("Report this request"), new_request_report_path(:request_id => @info_request.url_title) %>
<% end %>
<% end %>
<h2><%= _("Act on what you've learnt") %></h2>
<div class="act_link">
- <%
- # Cast "related" to normal string because html safe string (from rails_xss gem) and CGI::escape
- # interact badly with ':' character. Go figure! Might go away in rails 3
- %>
- <% link_to "https://twitter.com/share?" + {:url => request.url, :via => Configuration::twitter_username, :text => @info_request.title, :related => _('alaveteli_foi:The software that runs {{site_name}}', :site_name => site_name).to_str}.to_query do %>
+ <% tweet_link = "https://twitter.com/share?" + {:url => request.url, :via => AlaveteliConfiguration::twitter_username, :text => "'#{@info_request.title}'", :related => _('alaveteli_foi:The software that runs {{site_name}}', :site_name => site_name)}.to_query %>
+ <% link_to tweet_link do %>
<%= image_tag "twitter-16.png", :alt => "twitter icon" %>
- <%= _("Tweet this request") %>
<% end %>
+ <%= link_to _("Tweet this request"), tweet_link %>
</div>
<div class="act_link">
- <% link_to "http://wordpress.com/" do %>
+ <%= link_to "http://wordpress.com/" do %>
<%= image_tag "wordpress.png", :class => "rss" %>
- <%= _("Start your own blog") %>
<% end %>
+ <%= link_to _("Start your own blog"), "http://wordpress.com/"%>
</div>
<%= render :partial => 'request/next_actions' %>
@@ -61,7 +58,7 @@
<%= render :partial => 'request/request_listing_short_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
<% end %>
<% if @xapian_similar_more %>
- <p><%= link_to _("More similar requests"), similar_request_path(@info_request) %></p>
+ <p><%= link_to _("More similar requests"), similar_request_path(@info_request.url_title) %></p>
<% end %>
<!-- Important terms: <%= @xapian_similar.important_terms.join(" ") %> -->
<% end %>
diff --git a/app/views/request/_sidebar_request_listing.rhtml b/app/views/request/_sidebar_request_listing.html.erb
index ec5a5813d..ec5a5813d 100644
--- a/app/views/request/_sidebar_request_listing.rhtml
+++ b/app/views/request/_sidebar_request_listing.html.erb
diff --git a/app/views/request/_summary_suggestion.rhtml b/app/views/request/_summary_suggestion.html.erb
index a5da09cda..a5da09cda 100644
--- a/app/views/request/_summary_suggestion.rhtml
+++ b/app/views/request/_summary_suggestion.html.erb
diff --git a/app/views/request/_view_html_prefix.rhtml b/app/views/request/_view_html_prefix.html.erb
index 3a9946745..3a9946745 100644
--- a/app/views/request/_view_html_prefix.rhtml
+++ b/app/views/request/_view_html_prefix.html.erb
diff --git a/app/views/request/_view_html_stylesheet.rhtml b/app/views/request/_view_html_stylesheet.html.erb
index d6cb932a8..d6cb932a8 100644
--- a/app/views/request/_view_html_stylesheet.rhtml
+++ b/app/views/request/_view_html_stylesheet.html.erb
diff --git a/app/views/request/_wall_listing.rhtml b/app/views/request/_wall_listing.html.erb
index b6b4b38b1..b6b4b38b1 100644
--- a/app/views/request/_wall_listing.rhtml
+++ b/app/views/request/_wall_listing.html.erb
diff --git a/app/views/request/describe_state_message.rhtml b/app/views/request/describe_state_message.html.erb
index 1427fea22..73237759f 100644
--- a/app/views/request/describe_state_message.rhtml
+++ b/app/views/request/describe_state_message.html.erb
@@ -9,7 +9,7 @@
<% end %>
</p>
-<% form_for :incoming_message, :url => describe_state_url(:id => @info_request.id) do |f| %>
+<%= form_for :incoming_message, :url => describe_state_url(:id => @info_request.id) do |f| %>
<p>
<label class="form_label" for="incoming_message_message">Please tell us more:</label>
diff --git a/app/views/request/details.rhtml b/app/views/request/details.html.erb
index 3cb2f5afe..3cb2f5afe 100644
--- a/app/views/request/details.rhtml
+++ b/app/views/request/details.html.erb
diff --git a/app/views/request/followup_bad.rhtml b/app/views/request/followup_bad.html.erb
index ea2400c5d..ea2400c5d 100644
--- a/app/views/request/followup_bad.rhtml
+++ b/app/views/request/followup_bad.html.erb
diff --git a/app/views/request/followup_preview.rhtml b/app/views/request/followup_preview.html.erb
index 50c64138f..55afc0245 100644
--- a/app/views/request/followup_preview.rhtml
+++ b/app/views/request/followup_preview.html.erb
@@ -2,7 +2,7 @@
<div id="followup">
-<% form_for(:outgoing_message, @outgoing_message, :html => { :id => 'preview_form' }, :url => (@incoming_message.nil? ? show_response_no_followup_url(:id => @info_request.id) : show_response_url(:id => @info_request.id, :incoming_message_id => @incoming_message.id)) + "#followup" ) do |o| %>
+<%= form_for(@outgoing_message, :html => { :id => 'preview_form' }, :url => (@incoming_message.nil? ? show_response_no_followup_url(:id => @info_request.id) : show_response_url(:id => @info_request.id, :incoming_message_id => @incoming_message.id)) + "#followup" ) do |o| %>
<% if @internal_review %>
<h1><%= _('Now preview your message asking for an internal review') %></h1>
@@ -15,7 +15,7 @@
<li><%= _('Your message will appear in <strong>search engines</strong>') %></li>
</ul>
- <% fields_for :outgoing_message do |o| %>
+ <%= fields_for :outgoing_message do |o| %>
<div class="correspondence" id="outgoing-0">
<p class="preview_subject">
diff --git a/app/views/request/hidden.rhtml b/app/views/request/hidden.html.erb
index 4190fb47c..f2f76a817 100644
--- a/app/views/request/hidden.rhtml
+++ b/app/views/request/hidden.html.erb
@@ -12,7 +12,7 @@ various reasons why we might have done this, sorry we can\'t be more specific he
</p>
<% if @info_request.prominence == 'requester_only' %>
<p>
- <%= _('If you are the requester, then you may <a href="{{url}}">sign in</a> to view the request.', :url => signin_url(:r => request.request_uri).html_safe) %>
+ <%= _('If you are the requester, then you may <a href="{{url}}">sign in</a> to view the request.', :url => signin_url(:r => request.fullpath).html_safe) %>
</p>
<% end %>
diff --git a/app/views/request/list.rhtml b/app/views/request/list.html.erb
index 062b77c3e..062b77c3e 100644
--- a/app/views/request/list.rhtml
+++ b/app/views/request/list.html.erb
diff --git a/app/views/request/new.rhtml b/app/views/request/new.html.erb
index 0790bd0ac..f8b97ffe3 100644
--- a/app/views/request/new.rhtml
+++ b/app/views/request/new.html.erb
@@ -33,7 +33,7 @@
<%= foi_error_messages_for :info_request, :outgoing_message %>
- <% form_for(:info_request, @info_request, :html => { :id => 'write_form' } ) do |f| %>
+ <%= form_for(@info_request, :url => new_request_path, :html => { :id => 'write_form' } ) do |f| %>
<div id="request_header">
<div id="request_header_body">
@@ -103,7 +103,7 @@
</div>
<div id="request_form">
- <% fields_for :outgoing_message do |o| %>
+ <%= fields_for :outgoing_message do |o| %>
<p>
<label class="form_label" for="outgoing_message_body"><%= _('Your request:') %></label>
<%= o.text_area :body, :rows => 20, :cols => 60 %>
@@ -141,7 +141,7 @@
<% if !@info_request.tag_string.empty? %>
<p class="form_note">
- <!-- <label class="form_label" for="info_request_tag_string">Tags:</label>
+ <!-- <label class="form_label" for="info_request_tag_string"><%= _("Tags (separated by a space):") %></label>
<%= f.text_field :tag_string, :size => 50 %> -->
<%= f.hidden_field(:tag_string) %>
diff --git a/app/views/request/new_bad_contact.rhtml b/app/views/request/new_bad_contact.html.erb
index 56f3f4168..56f3f4168 100644
--- a/app/views/request/new_bad_contact.rhtml
+++ b/app/views/request/new_bad_contact.html.erb
diff --git a/app/views/request/new_please_describe.rhtml b/app/views/request/new_please_describe.html.erb
index 808fbb206..8da4eb555 100644
--- a/app/views/request/new_please_describe.rhtml
+++ b/app/views/request/new_please_describe.html.erb
@@ -1,4 +1,4 @@
-<% @title = "First, did your other requests succeed?" %>
+<% @title = _("First, did your other requests succeed?") %>
<h1><%=@title%></h1>
@@ -13,7 +13,7 @@ if they are successful yet or not.') %>
</ul>
<p>
- <%= _('When you\'re done, <strong>come back here</strong>, <a href="{{url}}">reload this page</a> and file your new request.', :url => request.request_uri.html_safe) %>
+ <%= _('When you\'re done, <strong>come back here</strong>, <a href="{{url}}">reload this page</a> and file your new request.', :url => request.fullpath.html_safe) %>
</p>
<p>
diff --git a/app/views/request/preview.rhtml b/app/views/request/preview.html.erb
index 424277b50..243dc90a9 100644
--- a/app/views/request/preview.rhtml
+++ b/app/views/request/preview.html.erb
@@ -1,6 +1,6 @@
<% @title = "Preview new " + h(@info_request.law_used_short) + " request to '" + h(@info_request.public_body.name) + "'" %>
-<% form_for(:info_request, @info_request, :html => { :id => 'preview_form' } ) do |f| %>
+<%= form_for(@info_request, :url => new_request_path, :html => { :id => 'preview_form' } ) do |f| %>
<h1><%= _('3. Now check your request') %></h1>
<ul>
@@ -10,7 +10,7 @@
</li>
</ul>
- <% fields_for :outgoing_message do |o| %>
+ <%= fields_for :outgoing_message do |o| %>
<div class="correspondence" id="outgoing-0">
<p class="preview_subject">
@@ -45,4 +45,4 @@
<p><strong><%= _('Tags:') %></strong> <%=h @info_request.tag_string %></p>
<% end %>
-<% end %> \ No newline at end of file
+<% end %>
diff --git a/app/views/request/select_authority.rhtml b/app/views/request/select_authority.html.erb
index 737541872..75c51fc57 100644
--- a/app/views/request/select_authority.rhtml
+++ b/app/views/request/select_authority.html.erb
@@ -30,7 +30,7 @@
<h1 style="clear: left"><%= _('1. Select an authority') %></h1>
<div id="authority_selection">
- <% form_tag({:controller => "request", :action => "select_authority"}, {:id => "search_form", :method => "get"}) do %>
+ <%= form_tag({:controller => "request", :action => "select_authority"}, {:id => "search_form", :method => "get"}) do %>
<div>
<p>
<%= _('First, type in the <strong>name of the UK public authority</strong> you\'d
@@ -42,26 +42,9 @@
<%= submit_tag _('Search') %>
</div>
<% end %>
- <div id="typeahead_response">
- <% if !@xapian_requests.nil? %>
- <% if @xapian_requests.results.size > 0 %>
- <h3><%= _('Top search results:') %></h3>
- <p>
- <%= _('Select one to see more information about the authority.')%>
- </p>
- <% else %>
- <h3><%= _('No results found.') %></h3>
- <% end %>
- <div id="authority_search_ahead_results">
- <% for result in @xapian_requests.results %>
- <%= render :partial => 'public_body/body_listing_single', :locals => { :public_body => result[:model] } %>
- <% end %>
- </div>
-
- <% end %>
-
-
+ <div id="typeahead_response">
+ <%= render :partial => 'public_body/search_ahead' %>
</div>
</div>
diff --git a/app/views/request/show.rhtml b/app/views/request/show.html.erb
index a33bc7037..4b0663f76 100644
--- a/app/views/request/show.rhtml
+++ b/app/views/request/show.html.erb
@@ -106,7 +106,7 @@
<%= _('The request is <strong>waiting for clarification</strong>.') %>
<% if !@info_request.is_external? %>
<%= _('If you are {{user_link}}, please',:user_link=>user_link_for_request(@info_request)) %>
- <%= link_to _("sign in"), signin_path(:r => request.request_uri) %> <%= _('to send a follow up message.') %>
+ <%= link_to _("sign in"), signin_path(:r => request.fullpath) %> <%= _('to send a follow up message.') %>
<% end %>
<% end %>
<% elsif @status == 'gone_postal' %>
diff --git a/app/views/request/show_response.rhtml b/app/views/request/show_response.html.erb
index a61359679..a61359679 100644
--- a/app/views/request/show_response.rhtml
+++ b/app/views/request/show_response.html.erb
diff --git a/app/views/request/similar.rhtml b/app/views/request/similar.html.erb
index 0d53f6919..eb7ff636d 100644
--- a/app/views/request/similar.rhtml
+++ b/app/views/request/similar.html.erb
@@ -1,5 +1,16 @@
-<% @title = "Requests similar to '" + h(@info_request.title) + "'" + @page_desc %>
-<h1><%="Requests similar to '" + request_link(@info_request) + "'" + @page_desc %></h1>
+<%- if @page > 1 %>
+ <%- @title = _("Requests similar to '{{request_title}}' (page {{page}})", {:page => @page, :request_title => @info_request.title}) %>
+<%- else %>
+<%- @title = _("Requests similar to '{{request_title}}'", {:request_title => @info_request.title}) %>
+<%- end %>
+
+<h1>
+ <%- if @page > 1 %>
+ <%= _("Requests similar to '{{request_title}}' (page {{page}})", {:page => @page, :request_title => request_link(@info_request)}) %>
+ <%- else %>
+ <%= _("Requests similar to '{{request_title}}'", {:request_title => request_link(@info_request)}) %>
+ <%- end %>
+</h1>
<!-- Important terms: <%= @xapian_object.important_terms.join(" ") %> -->
diff --git a/app/views/request/simple_correspondence.rhtml b/app/views/request/simple_correspondence.html.erb
index 0da9ef172..461fa3912 100644
--- a/app/views/request/simple_correspondence.rhtml
+++ b/app/views/request/simple_correspondence.html.erb
@@ -1,4 +1,4 @@
-<%= _('This is a plain-text version of the Freedom of Information request "{{request_title}}". The latest, full version is available online at {{full_url}}', :request_title => @info_request.title, :full_url => "http://#{Configuration::domain}#{show_request_path(:url_title=>@info_request.url_title)}") %>.
+<%= _('This is a plain-text version of the Freedom of Information request "{{request_title}}". The latest, full version is available online at {{full_url}}', :request_title => @info_request.title, :full_url => "http://#{AlaveteliConfiguration::domain}#{show_request_path(:url_title=>@info_request.url_title)}") %>.
<% for info_request_event in @info_request_events %>
<%
diff --git a/app/views/request/upload_response.rhtml b/app/views/request/upload_response.html.erb
index f9f818e86..f5fd6f000 100644
--- a/app/views/request/upload_response.rhtml
+++ b/app/views/request/upload_response.html.erb
@@ -30,7 +30,7 @@
<p><%= raw(_('Enter your response below. You may attach one file (use email, or
<a href="{{url}}">contact us</a> if you need more).', :url => help_contact_path.html_safe)) %></p>
- <% form_tag '', :id => 'upload_response_form', :multipart => true do %>
+ <%= form_tag '', :id => 'upload_response_form', :multipart => true do %>
<p>
<label class="form_label" for="body"><% _('Response:')%></label>
<%= text_area_tag :body, "", :rows => 10, :cols => 55 %>
diff --git a/app/views/request_game/play.rhtml b/app/views/request_game/play.html.erb
index d5aa0d00e..d5aa0d00e 100644
--- a/app/views/request_game/play.rhtml
+++ b/app/views/request_game/play.html.erb
diff --git a/app/views/request_mailer/comment_on_alert.rhtml b/app/views/request_mailer/comment_on_alert.text.erb
index 691e6f9bb..691e6f9bb 100644
--- a/app/views/request_mailer/comment_on_alert.rhtml
+++ b/app/views/request_mailer/comment_on_alert.text.erb
diff --git a/app/views/request_mailer/comment_on_alert_plural.rhtml b/app/views/request_mailer/comment_on_alert_plural.text.erb
index a495b8e08..a495b8e08 100644
--- a/app/views/request_mailer/comment_on_alert_plural.rhtml
+++ b/app/views/request_mailer/comment_on_alert_plural.text.erb
diff --git a/app/views/request_mailer/external_response.rhtml b/app/views/request_mailer/external_response.rhtml
deleted file mode 100644
index 896054a43..000000000
--- a/app/views/request_mailer/external_response.rhtml
+++ /dev/null
@@ -1 +0,0 @@
-<%= raw @body %>
diff --git a/app/views/request_mailer/external_response.text.erb b/app/views/request_mailer/external_response.text.erb
new file mode 100644
index 000000000..fab256adf
--- /dev/null
+++ b/app/views/request_mailer/external_response.text.erb
@@ -0,0 +1 @@
+<%= @message_body %>
diff --git a/app/views/request_mailer/fake_response.rhtml b/app/views/request_mailer/fake_response.rhtml
deleted file mode 100644
index 896054a43..000000000
--- a/app/views/request_mailer/fake_response.rhtml
+++ /dev/null
@@ -1 +0,0 @@
-<%= raw @body %>
diff --git a/app/views/request_mailer/fake_response.text.erb b/app/views/request_mailer/fake_response.text.erb
new file mode 100644
index 000000000..fab256adf
--- /dev/null
+++ b/app/views/request_mailer/fake_response.text.erb
@@ -0,0 +1 @@
+<%= @message_body %>
diff --git a/app/views/request_mailer/new_response.rhtml b/app/views/request_mailer/new_response.text.erb
index 672212f20..672212f20 100644
--- a/app/views/request_mailer/new_response.rhtml
+++ b/app/views/request_mailer/new_response.text.erb
diff --git a/app/views/request_mailer/new_response_reminder_alert.rhtml b/app/views/request_mailer/new_response_reminder_alert.text.erb
index c196dafe6..c196dafe6 100644
--- a/app/views/request_mailer/new_response_reminder_alert.rhtml
+++ b/app/views/request_mailer/new_response_reminder_alert.text.erb
diff --git a/app/views/request_mailer/not_clarified_alert.rhtml b/app/views/request_mailer/not_clarified_alert.text.erb
index 2408452b3..2408452b3 100644
--- a/app/views/request_mailer/not_clarified_alert.rhtml
+++ b/app/views/request_mailer/not_clarified_alert.text.erb
diff --git a/app/views/request_mailer/old_unclassified_updated.rhtml b/app/views/request_mailer/old_unclassified_updated.text.erb
index 5b8534832..5b8534832 100644
--- a/app/views/request_mailer/old_unclassified_updated.rhtml
+++ b/app/views/request_mailer/old_unclassified_updated.text.erb
diff --git a/app/views/request_mailer/overdue_alert.rhtml b/app/views/request_mailer/overdue_alert.text.erb
index 249bf6bb8..249bf6bb8 100644
--- a/app/views/request_mailer/overdue_alert.rhtml
+++ b/app/views/request_mailer/overdue_alert.text.erb
diff --git a/app/views/request_mailer/requires_admin.rhtml b/app/views/request_mailer/requires_admin.text.erb
index b2e58295e..b2e58295e 100644
--- a/app/views/request_mailer/requires_admin.rhtml
+++ b/app/views/request_mailer/requires_admin.text.erb
diff --git a/app/views/request_mailer/stopped_responses.rhtml b/app/views/request_mailer/stopped_responses.text.erb
index 9cd156860..9cd156860 100644
--- a/app/views/request_mailer/stopped_responses.rhtml
+++ b/app/views/request_mailer/stopped_responses.text.erb
diff --git a/app/views/request_mailer/very_overdue_alert.rhtml b/app/views/request_mailer/very_overdue_alert.text.erb
index 80597473c..80597473c 100644
--- a/app/views/request_mailer/very_overdue_alert.rhtml
+++ b/app/views/request_mailer/very_overdue_alert.text.erb
diff --git a/app/views/track/_tracking_links.rhtml b/app/views/track/_tracking_links.html.erb
index d89c0e4a9..a16dbc78f 100644
--- a/app/views/track/_tracking_links.rhtml
+++ b/app/views/track/_tracking_links.html.erb
@@ -9,7 +9,7 @@
<% elsif existing_track %>
<p><%= track_thing.params[:verb_on_page_already] %></p>
<div class="feed_link feed_link_<%=location%>">
- <%= link_to _("Unsubscribe"), {:controller => 'track', :action => 'update', :track_id => existing_track.id, :track_medium => "delete", :r => request.request_uri}, :class => "link_button_green" %>
+ <%= link_to _("Unsubscribe"), {:controller => 'track', :action => 'update', :track_id => existing_track.id, :track_medium => "delete", :r => request.fullpath}, :class => "link_button_green" %>
</div>
<% elsif track_thing %>
<div class="feed_link feed_link_<%=location%>">
diff --git a/app/views/track/atom_feed.atom.erb b/app/views/track/atom_feed.atom.erb
index 23c932308..a12b9eff0 100644
--- a/app/views/track/atom_feed.atom.erb
+++ b/app/views/track/atom_feed.atom.erb
@@ -9,7 +9,7 @@
# Get the HTML content from the same partial template as website search does
content = ''
if result[:model].class.to_s == 'InfoRequestEvent'
- content += render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request }
+ content += render :partial => 'request/request_listing_via_event.html', :locals => { :event => result[:model], :info_request => result[:model].info_request }
else
content = "<p><strong>Unknown search result type " + result[:model].class.to_s + "</strong></p>"
end
diff --git a/app/views/track_mailer/event_digest.rhtml b/app/views/track_mailer/event_digest.text.erb
index 8dbc7fe06..8dbc7fe06 100644
--- a/app/views/track_mailer/event_digest.rhtml
+++ b/app/views/track_mailer/event_digest.text.erb
diff --git a/app/views/user/_change_receive_email.rhtml b/app/views/user/_change_receive_email.html.erb
index 83e5d8601..12824f711 100644
--- a/app/views/user/_change_receive_email.rhtml
+++ b/app/views/user/_change_receive_email.html.erb
@@ -1,4 +1,4 @@
-<% form_tag(:controller=>"user", :action=>"set_receive_email_alerts") do %>
+<%= form_tag(:controller=>"user", :action=>"set_receive_email_alerts") do %>
<div>
<% if @user.receive_email_alerts %>
<%= _('You are currently receiving notification of new activity on your wall by email.', :wall_url => show_user_wall_path) %><br><br>
diff --git a/app/views/user/_show_user_info.rhtml b/app/views/user/_show_user_info.html.erb
index 305300236..305300236 100644
--- a/app/views/user/_show_user_info.rhtml
+++ b/app/views/user/_show_user_info.html.erb
diff --git a/app/views/user/_signin.rhtml b/app/views/user/_signin.html.erb
index 7db07e4b4..afc55d249 100644
--- a/app/views/user/_signin.rhtml
+++ b/app/views/user/_signin.html.erb
@@ -1,6 +1,6 @@
<div id="signin">
-<% form_tag({:action => "signin"}, {:id => "signin_form"}) do %>
+<%= form_tag({:action => "signin"}, {:id => "signin_form"}) do %>
<%= foi_error_messages_for :user_signin %>
<!--<% if not sign_in_as_existing_user %>
diff --git a/app/views/user/_signup.rhtml b/app/views/user/_signup.html.erb
index eba3b8522..ec6541881 100644
--- a/app/views/user/_signup.rhtml
+++ b/app/views/user/_signup.html.erb
@@ -1,6 +1,6 @@
<div id="signup">
-<% form_tag({:action => "signup"}, {:id => "signup_form"}) do %>
+<%= form_tag({:action => "signup"}, {:id => "signup_form"}) do %>
<%= foi_error_messages_for :user_signup %>
<!--<h2><%= _('If you\'re new to {{site_name}}', :site_name=>site_name)%></h2>-->
diff --git a/app/views/user/_user_listing_single.rhtml b/app/views/user/_user_listing_single.html.erb
index ed1b95718..ed1b95718 100644
--- a/app/views/user/_user_listing_single.rhtml
+++ b/app/views/user/_user_listing_single.html.erb
diff --git a/app/views/user/bad_token.rhtml b/app/views/user/bad_token.html.erb
index 538bc5606..538bc5606 100644
--- a/app/views/user/bad_token.rhtml
+++ b/app/views/user/bad_token.html.erb
diff --git a/app/views/user/banned.rhtml b/app/views/user/banned.html.erb
index 475c10977..475c10977 100644
--- a/app/views/user/banned.rhtml
+++ b/app/views/user/banned.html.erb
diff --git a/app/views/user/confirm.rhtml b/app/views/user/confirm.html.erb
index bc70a1f36..bc70a1f36 100644
--- a/app/views/user/confirm.rhtml
+++ b/app/views/user/confirm.html.erb
diff --git a/app/views/user/contact.rhtml b/app/views/user/contact.html.erb
index 333b72334..6d23dd1ed 100644
--- a/app/views/user/contact.rhtml
+++ b/app/views/user/contact.html.erb
@@ -6,7 +6,7 @@
<%= foi_error_messages_for :contact %>
-<% form_for :contact do |f| %>
+<%= form_for :contact do |f| %>
<div class="form_note">
<h1><%= _("Contact {{recipient}}", :recipient => h(@recipient_user.name)) %></h1>
diff --git a/app/views/user/no_cookies.rhtml b/app/views/user/no_cookies.html.erb
index 0a4a39b1b..0a4a39b1b 100644
--- a/app/views/user/no_cookies.rhtml
+++ b/app/views/user/no_cookies.html.erb
diff --git a/app/views/user/rate_limited.rhtml b/app/views/user/rate_limited.html.erb
index d52deebab..54a4e0461 100644
--- a/app/views/user/rate_limited.rhtml
+++ b/app/views/user/rate_limited.html.erb
@@ -2,7 +2,7 @@
<h1><%=@title%></h1>
-<p><%= _("You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}.", :max_requests_per_user_per_day => Configuration::max_requests_per_user_per_day, :can_make_another_request => distance_of_time_in_words(Time.now, @next_request_permitted_at))%></p>
+<p><%= _("You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}.", :max_requests_per_user_per_day => AlaveteliConfiguration::max_requests_per_user_per_day, :can_make_another_request => distance_of_time_in_words(Time.now, @next_request_permitted_at))%></p>
<p><%= _("There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please <a href='{{help_contact_path}}'>get in touch</a>.", :help_contact_path => help_contact_path) %></p>
diff --git a/app/views/user/river.rhtml b/app/views/user/river.html.erb
index 9618e0aa8..9618e0aa8 100644
--- a/app/views/user/river.rhtml
+++ b/app/views/user/river.html.erb
diff --git a/app/views/user/set_crop_profile_photo.rhtml b/app/views/user/set_crop_profile_photo.html.erb
index eed0304d2..0a22d36dc 100644
--- a/app/views/user/set_crop_profile_photo.rhtml
+++ b/app/views/user/set_crop_profile_photo.html.erb
@@ -9,7 +9,7 @@
<div id="set_crop_profile_photo">
-<% form_tag 'set_photo', :id => 'set_crop_profile_photo_form', :multipart => true do %>
+<%= form_tag 'set_photo', :id => 'set_crop_profile_photo_form', :multipart => true do %>
<table>
<tr>
@@ -37,7 +37,7 @@
<p>
<%= hidden_field_tag 'submitted_crop_profile_photo', 1 %>
- <%= submit_tag _("Done") + " &gt;&gt;" %>
+ <%= submit_tag _("Done &gt;&gt;") %>
</p>
<% end %>
diff --git a/app/views/user/set_draft_profile_photo.rhtml b/app/views/user/set_draft_profile_photo.html.erb
index 757498249..b4bdd80f3 100644
--- a/app/views/user/set_draft_profile_photo.rhtml
+++ b/app/views/user/set_draft_profile_photo.html.erb
@@ -8,7 +8,7 @@
<div id="set_draft_profile_photo">
-<% form_tag 'set_photo', :id => 'set_draft_profile_photo_form', :multipart => true do %>
+<%= form_tag 'set_photo', :id => 'set_draft_profile_photo_form', :multipart => true do %>
<p>
<label class="form_label" for="file_1"><%= _('Photo of you:')%></label>
<%= file_field_tag :file, :size => 35, :id => 'file_1' %>
@@ -45,7 +45,7 @@
<h2><%= _('OR remove the existing photo')%></h2>
- <% form_tag 'clear_photo', :id => 'clear_profile_photo_form', :multipart => true do %>
+ <%= form_tag 'clear_photo', :id => 'clear_profile_photo_form', :multipart => true do %>
<%= submit_tag _("Clear photo") %>
<% end %>
diff --git a/app/views/user/set_profile_about_me.rhtml b/app/views/user/set_profile_about_me.html.erb
index 4fe1047da..fb7de7e97 100644
--- a/app/views/user/set_profile_about_me.rhtml
+++ b/app/views/user/set_profile_about_me.html.erb
@@ -4,7 +4,7 @@
<%= foi_error_messages_for :about_me %>
-<% form_for :about_me do |f| %>
+<%= form_for :about_me do |f| %>
<div class="form_note">
<h1><%= _('Edit text about you')%></h1>
<p>
@@ -26,7 +26,7 @@
<%= _(' Include relevant links, such as to a campaign page, your blog or a
twitter account. They will be made clickable.
e.g.')%>
- <a href="https://twitter.com/<%= Configuration::twitter_username %>">https://twitter.com/<%= Configuration::twitter_username %></a>
+ <a href="https://twitter.com/<%= AlaveteliConfiguration::twitter_username %>">https://twitter.com/<%= AlaveteliConfiguration::twitter_username %></a>
</p>
</div>
diff --git a/app/views/user/show.rhtml b/app/views/user/show.html.erb
index c538426ce..c9862effe 100644
--- a/app/views/user/show.rhtml
+++ b/app/views/user/show.html.erb
@@ -97,7 +97,7 @@
<% if not @is_you %>
<p id="user_not_logged_in">
- <%= _('<a href="{{url}}">Sign in</a> to change password, subscriptions and more ({{user_name}} only)',:user_name=>h(@display_user.name), :url => signin_url(:r => request.request_uri).html_safe) %>
+ <%= _('<a href="{{url}}">Sign in</a> to change password, subscriptions and more ({{user_name}} only)',:user_name=>h(@display_user.name), :url => signin_url(:r => request.fullpath).html_safe) %>
</p>
<% end %>
</div>
@@ -107,7 +107,7 @@
<% if @show_requests %>
<div id="user_profile_search">
- <% form_tag(show_user_url, :method => "get", :id=>"search_form") do %>
+ <%= form_tag(show_user_url, :method => "get", :id=>"search_form") do %>
<div>
<%= text_field_tag(:user_query, params[:user_query], {:title => "type your search term here" }) %>
<% if @is_you %>
@@ -181,12 +181,12 @@
<p><%= _("You're not following anything.")%></p>
<% else %>
<% if @track_things_grouped.size == 1 %>
- <% form_tag({:controller => 'track', :action => 'delete_all_type'}, :class => "feed_form") do %>
+ <%= form_tag({:controller => 'track', :action => 'delete_all_type'}, :class => "feed_form") do %>
<h3>
<%=TrackThing.track_type_description(@track_things[0].track_type)%>
<%= hidden_field_tag 'track_type', @track_things[0].track_type %>
<%= hidden_field_tag 'user', @display_user.id %>
- <%= hidden_field_tag 'r', request.request_uri %>
+ <%= hidden_field_tag 'r', request.fullpath %>
<% if @track_things.size > 1 %>
<%= submit_tag _('unsubscribe all') %>
<% end %>
@@ -195,12 +195,12 @@
<% end %>
<% for track_type, track_things in @track_things_grouped %>
<% if @track_things_grouped.size > 1 %>
- <% form_tag({:controller => 'track', :action => 'delete_all_type'}, :class => "feed_form") do %>
+ <%= form_tag({:controller => 'track', :action => 'delete_all_type'}, :class => "feed_form") do %>
<h3>
<%=TrackThing.track_type_description(track_type)%>
<%= hidden_field_tag 'track_type', track_type %>
<%= hidden_field_tag 'user', @display_user.id %>
- <%= hidden_field_tag 'r', request.request_uri %>
+ <%= hidden_field_tag 'r', request.fullpath %>
<% if track_things.size > 1 %>
<%= submit_tag _('unsubscribe all')%>
<% end %>
@@ -211,11 +211,11 @@
<ul>
<% for track_thing in track_things %>
<li>
- <% form_tag({:controller => 'track', :action => 'update', :track_id => track_thing.id}, :class => "feed_form") do %>
+ <%= form_tag({:controller => 'track', :action => 'update', :track_id => track_thing.id}, :class => "feed_form") do %>
<div>
<%= track_thing.params[:list_description] %>
<%= hidden_field_tag 'track_medium', "delete", { :id => 'track_medium_' + track_thing.id.to_s } %>
- <%= hidden_field_tag 'r', request.request_uri, { :id => 'r_' + track_thing.id.to_s } %>
+ <%= hidden_field_tag 'r', request.fullpath, { :id => 'r_' + track_thing.id.to_s } %>
<%= submit_tag _('unsubscribe') %>
</div>
<% end %>
diff --git a/app/views/user/sign.rhtml b/app/views/user/sign.html.erb
index 5e8cced91..8291cdace 100644
--- a/app/views/user/sign.rhtml
+++ b/app/views/user/sign.html.erb
@@ -12,7 +12,7 @@
<% end %>
</p>
<% if @post_redirect.post_params["controller"] == "admin_general" %>
- <% unless Configuration::disable_emergency_user %>
+ <% unless AlaveteliConfiguration::disable_emergency_user %>
<p id="superuser_message">Don't have a superuser account yet? <%= link_to "Sign in as the emergency user", @post_redirect.uri + "?emergency=1" %></p>
<% end %>
<% end %>
diff --git a/app/views/user/signchangeemail.rhtml b/app/views/user/signchangeemail.html.erb
index 0f8b76bc5..7308179f4 100644
--- a/app/views/user/signchangeemail.rhtml
+++ b/app/views/user/signchangeemail.html.erb
@@ -4,7 +4,7 @@
<div id="change_email">
-<% form_tag({:action => "signchangeemail"}, {:id => "signchangeemail_form"}) do %>
+<%= form_tag({:action => "signchangeemail"}, {:id => "signchangeemail_form"}) do %>
<%= foi_error_messages_for :signchangeemail %>
<div class="form_note">
diff --git a/app/views/user/signchangeemail_confirm.rhtml b/app/views/user/signchangeemail_confirm.html.erb
index bfedbac2d..bfedbac2d 100644
--- a/app/views/user/signchangeemail_confirm.rhtml
+++ b/app/views/user/signchangeemail_confirm.html.erb
diff --git a/app/views/user/signchangepassword.rhtml b/app/views/user/signchangepassword.html.erb
index edb980b9f..51bcb466d 100644
--- a/app/views/user/signchangepassword.rhtml
+++ b/app/views/user/signchangepassword.html.erb
@@ -4,7 +4,7 @@
<div id="change_password">
-<% form_tag({:action => "signchangepassword"}, {:id => "signchangepassword_form"}) do %>
+<%= form_tag({:action => "signchangepassword"}, {:id => "signchangepassword_form"}) do %>
<%= foi_error_messages_for :user %>
<div class="form_note">
diff --git a/app/views/user/signchangepassword_confirm.rhtml b/app/views/user/signchangepassword_confirm.html.erb
index 63b6515cd..63b6515cd 100644
--- a/app/views/user/signchangepassword_confirm.rhtml
+++ b/app/views/user/signchangepassword_confirm.html.erb
diff --git a/app/views/user/signchangepassword_send_confirm.rhtml b/app/views/user/signchangepassword_send_confirm.html.erb
index 84ee28f07..850237c34 100644
--- a/app/views/user/signchangepassword_send_confirm.rhtml
+++ b/app/views/user/signchangepassword_send_confirm.html.erb
@@ -2,7 +2,7 @@
<div id="change_password">
-<% form_tag({:action => "signchangepassword"}, {:id => "signchangepassword_form"}) do %>
+<%= form_tag({:action => "signchangepassword"}, {:id => "signchangepassword_form"}) do %>
<%= foi_error_messages_for :signchangepassword %>
<div class="form_note">
diff --git a/app/views/user/signin_successful.rhtml b/app/views/user/signin_successful.html.erb
index 675701d74..675701d74 100644
--- a/app/views/user/signin_successful.rhtml
+++ b/app/views/user/signin_successful.html.erb
diff --git a/app/views/user/wall.rhtml b/app/views/user/wall.html.erb
index 190cc0a6d..190cc0a6d 100644
--- a/app/views/user/wall.rhtml
+++ b/app/views/user/wall.html.erb
diff --git a/app/views/user/wrong_user.rhtml b/app/views/user/wrong_user.html.erb
index 30256a639..30256a639 100644
--- a/app/views/user/wrong_user.rhtml
+++ b/app/views/user/wrong_user.html.erb
diff --git a/app/views/user/wrong_user_unknown_email.rhtml b/app/views/user/wrong_user_unknown_email.html.erb
index c1967fc1f..c1967fc1f 100644
--- a/app/views/user/wrong_user_unknown_email.rhtml
+++ b/app/views/user/wrong_user_unknown_email.html.erb
diff --git a/app/views/user_mailer/already_registered.rhtml b/app/views/user_mailer/already_registered.text.erb
index 32c2c7e63..32c2c7e63 100644
--- a/app/views/user_mailer/already_registered.rhtml
+++ b/app/views/user_mailer/already_registered.text.erb
diff --git a/app/views/user_mailer/changeemail_already_used.rhtml b/app/views/user_mailer/changeemail_already_used.text.erb
index 1d74dda35..1d74dda35 100644
--- a/app/views/user_mailer/changeemail_already_used.rhtml
+++ b/app/views/user_mailer/changeemail_already_used.text.erb
diff --git a/app/views/user_mailer/changeemail_confirm.rhtml b/app/views/user_mailer/changeemail_confirm.text.erb
index c73e9486b..c73e9486b 100644
--- a/app/views/user_mailer/changeemail_confirm.rhtml
+++ b/app/views/user_mailer/changeemail_confirm.text.erb
diff --git a/app/views/user_mailer/confirm_login.rhtml b/app/views/user_mailer/confirm_login.text.erb
index fa86dc2b1..fa86dc2b1 100644
--- a/app/views/user_mailer/confirm_login.rhtml
+++ b/app/views/user_mailer/confirm_login.text.erb