diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/admin_censor_rule_controller.rb | 16 | ||||
-rw-r--r-- | app/controllers/admin_controller.rb | 11 | ||||
-rw-r--r-- | app/controllers/admin_general_controller.rb | 20 | ||||
-rw-r--r-- | app/controllers/admin_public_body_controller.rb | 22 | ||||
-rw-r--r-- | app/controllers/admin_request_controller.rb | 77 | ||||
-rw-r--r-- | app/controllers/admin_track_controller.rb | 11 | ||||
-rw-r--r-- | app/controllers/admin_user_controller.rb | 24 | ||||
-rw-r--r-- | app/controllers/api_controller.rb | 17 | ||||
-rw-r--r-- | app/controllers/application_controller.rb | 120 | ||||
-rw-r--r-- | app/controllers/comment_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/general_controller.rb | 40 | ||||
-rw-r--r-- | app/controllers/help_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/holiday_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/public_body_controller.rb | 16 | ||||
-rw-r--r-- | app/controllers/reports_controller.rb | 31 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 314 | ||||
-rw-r--r-- | app/controllers/request_game_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/services_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/track_controller.rb | 14 | ||||
-rw-r--r-- | app/controllers/user_controller.rb | 41 | ||||
-rw-r--r-- | app/helpers/admin_helper.rb | 37 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/config_helper.rb | 4 | ||||
-rwxr-xr-x | app/helpers/link_to_helper.rb | 194 | ||||
-rw-r--r-- | app/helpers/mailer_helper.rb | 2 | ||||
-rw-r--r-- | app/mailers/application_mailer.rb | 30 | ||||
-rw-r--r-- | app/mailers/contact_mailer.rb | 45 | ||||
-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) | 238 | ||||
-rw-r--r-- | app/mailers/track_mailer.rb (renamed from app/models/track_mailer.rb) | 44 | ||||
-rw-r--r-- | app/mailers/user_mailer.rb | 44 | ||||
-rw-r--r-- | app/models/about_me_validator.rb | 22 | ||||
-rw-r--r-- | app/models/application_mailer.rb | 164 | ||||
-rw-r--r-- | app/models/censor_rule.rb | 12 | ||||
-rw-r--r-- | app/models/change_email_validator.rb | 38 | ||||
-rw-r--r-- | app/models/comment.rb | 2 | ||||
-rw-r--r-- | app/models/contact_mailer.rb | 56 | ||||
-rw-r--r-- | app/models/contact_validator.rb | 34 | ||||
-rw-r--r-- | app/models/foi_attachment.rb | 32 | ||||
-rw-r--r-- | app/models/holiday.rb | 2 | ||||
-rw-r--r-- | app/models/incoming_message.rb | 103 | ||||
-rw-r--r-- | app/models/info_request.rb | 294 | ||||
-rw-r--r-- | app/models/info_request_event.rb | 40 | ||||
-rw-r--r-- | app/models/mail_server_log.rb | 12 | ||||
-rw-r--r-- | app/models/mail_server_log_done.rb | 2 | ||||
-rw-r--r-- | app/models/outgoing_message.rb | 45 | ||||
-rw-r--r-- | app/models/post_redirect.rb | 28 | ||||
-rw-r--r-- | app/models/profile_photo.rb | 41 | ||||
-rw-r--r-- | app/models/public_body.rb | 65 | ||||
-rw-r--r-- | app/models/purge_request.rb | 2 | ||||
-rw-r--r-- | app/models/raw_email.rb | 6 | ||||
-rw-r--r-- | app/models/track_thing.rb | 6 | ||||
-rw-r--r-- | app/models/track_things_sent_email.rb | 2 | ||||
-rw-r--r-- | app/models/user.rb | 54 | ||||
-rw-r--r-- | app/models/user_info_request_sent_alert.rb | 2 | ||||
-rw-r--r-- | app/models/user_mailer.rb | 48 | ||||
-rw-r--r-- | app/sass/admin.scss | 112 | ||||
-rw-r--r-- | app/views/admin_censor_rule/_form.html.erb | 75 | ||||
-rw-r--r-- | app/views/admin_censor_rule/_form.rhtml | 40 | ||||
-rw-r--r-- | app/views/admin_censor_rule/_show.html.erb (renamed from app/views/admin_censor_rule/_show.rhtml) | 12 | ||||
-rw-r--r-- | app/views/admin_censor_rule/edit.html.erb | 18 | ||||
-rw-r--r-- | app/views/admin_censor_rule/edit.rhtml | 16 | ||||
-rw-r--r-- | app/views/admin_censor_rule/new.html.erb | 11 | ||||
-rw-r--r-- | app/views/admin_censor_rule/new.rhtml | 9 | ||||
-rw-r--r-- | app/views/admin_general/_admin_navbar.html.erb | 22 | ||||
-rw-r--r-- | app/views/admin_general/admin.coffee | 24 | ||||
-rw-r--r-- | app/views/admin_general/admin.js | 32 | ||||
-rw-r--r-- | app/views/admin_general/admin_js.erb | 34 | ||||
-rw-r--r-- | app/views/admin_general/debug.html.erb (renamed from app/views/admin_general/debug.rhtml) | 15 | ||||
-rw-r--r-- | app/views/admin_general/index.html.erb | 185 | ||||
-rw-r--r-- | app/views/admin_general/index.rhtml | 109 | ||||
-rw-r--r-- | app/views/admin_general/stats.html.erb | 60 | ||||
-rw-r--r-- | app/views/admin_general/stats.rhtml | 38 | ||||
-rw-r--r-- | app/views/admin_general/timeline.html.erb (renamed from app/views/admin_general/timeline.rhtml) | 30 | ||||
-rw-r--r-- | app/views/admin_public_body/_form.html.erb | 98 | ||||
-rw-r--r-- | app/views/admin_public_body/_form.rhtml | 65 | ||||
-rw-r--r-- | app/views/admin_public_body/_locale_selector.rhtml | 10 | ||||
-rw-r--r-- | app/views/admin_public_body/_one_list.html.erb | 44 | ||||
-rw-r--r-- | app/views/admin_public_body/_one_list.rhtml | 29 | ||||
-rw-r--r-- | app/views/admin_public_body/_tag_help.html.erb | 16 | ||||
-rw-r--r-- | app/views/admin_public_body/_tag_help.rhtml | 18 | ||||
-rw-r--r-- | app/views/admin_public_body/_tags.html.erb | 12 | ||||
-rw-r--r-- | app/views/admin_public_body/_tags.rhtml | 11 | ||||
-rw-r--r-- | app/views/admin_public_body/edit.html.erb | 34 | ||||
-rw-r--r-- | app/views/admin_public_body/edit.rhtml | 30 | ||||
-rw-r--r-- | app/views/admin_public_body/import_csv.html.erb (renamed from app/views/admin_public_body/import_csv.rhtml) | 35 | ||||
-rw-r--r-- | app/views/admin_public_body/list.html.erb | 42 | ||||
-rw-r--r-- | app/views/admin_public_body/list.rhtml | 40 | ||||
-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 | 23 | ||||
-rw-r--r-- | app/views/admin_public_body/new.rhtml | 22 | ||||
-rw-r--r-- | app/views/admin_public_body/show.html.erb | 89 | ||||
-rw-r--r-- | app/views/admin_public_body/show.rhtml | 83 | ||||
-rw-r--r-- | app/views/admin_request/_incoming_message_actions.html.erb | 45 | ||||
-rw-r--r-- | app/views/admin_request/_incoming_message_actions.rhtml | 26 | ||||
-rw-r--r-- | app/views/admin_request/_some_requests.html.erb | 32 | ||||
-rw-r--r-- | app/views/admin_request/_some_requests.rhtml | 31 | ||||
-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) | 20 | ||||
-rw-r--r-- | app/views/admin_request/edit_comment.html.erb (renamed from app/views/admin_request/edit_comment.rhtml) | 8 | ||||
-rw-r--r-- | app/views/admin_request/edit_outgoing.html.erb (renamed from app/views/admin_request/edit_outgoing.rhtml) | 8 | ||||
-rw-r--r-- | app/views/admin_request/hidden_user_explanation.html.erb | 10 | ||||
-rw-r--r-- | app/views/admin_request/hidden_user_explanation.rhtml | 10 | ||||
-rw-r--r-- | app/views/admin_request/list.html.erb | 13 | ||||
-rw-r--r-- | app/views/admin_request/list.rhtml | 15 | ||||
-rw-r--r-- | app/views/admin_request/list_old_unclassified.rhtml | 16 | ||||
-rw-r--r-- | app/views/admin_request/show.html.erb | 386 | ||||
-rw-r--r-- | app/views/admin_request/show.rhtml | 230 | ||||
-rw-r--r-- | app/views/admin_request/show_raw_email.html.erb | 67 | ||||
-rw-r--r-- | app/views/admin_request/show_raw_email.rhtml | 37 | ||||
-rw-r--r-- | app/views/admin_track/_some_tracks.html.erb | 74 | ||||
-rw-r--r-- | app/views/admin_track/_some_tracks.rhtml | 31 | ||||
-rw-r--r-- | app/views/admin_track/list.html.erb | 20 | ||||
-rw-r--r-- | app/views/admin_track/list.rhtml | 39 | ||||
-rw-r--r-- | app/views/admin_user/_form.html.erb | 66 | ||||
-rw-r--r-- | app/views/admin_user/_form.rhtml | 27 | ||||
-rw-r--r-- | app/views/admin_user/_user_table.html.erb | 47 | ||||
-rw-r--r-- | app/views/admin_user/_user_table.rhtml | 22 | ||||
-rw-r--r-- | app/views/admin_user/edit.html.erb | 11 | ||||
-rw-r--r-- | app/views/admin_user/edit.rhtml | 23 | ||||
-rw-r--r-- | app/views/admin_user/list.html.erb | 13 | ||||
-rw-r--r-- | app/views/admin_user/list.rhtml | 15 | ||||
-rw-r--r-- | app/views/admin_user/list_banned.html.erb (renamed from app/views/admin_user/list_banned.rhtml) | 2 | ||||
-rw-r--r-- | app/views/admin_user/show.html.erb | 96 | ||||
-rw-r--r-- | app/views/admin_user/show.rhtml | 74 | ||||
-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/api/request_events.atom.builder | 4 | ||||
-rw-r--r-- | app/views/comment/_comment_form.html.erb (renamed from app/views/comment/_comment_form.rhtml) | 4 | ||||
-rw-r--r-- | app/views/comment/_single_comment.html.erb (renamed from app/views/comment/_single_comment.rhtml) | 6 | ||||
-rw-r--r-- | app/views/comment/new.html.erb (renamed from app/views/comment/new.rhtml) | 6 | ||||
-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.rhtml | 2 | ||||
-rw-r--r-- | app/views/contact_mailer/from_admin_message.text.erb | 2 | ||||
-rw-r--r-- | app/views/contact_mailer/to_admin_message.rhtml | 11 | ||||
-rw-r--r-- | app/views/contact_mailer/to_admin_message.text.erb | 11 | ||||
-rw-r--r-- | app/views/contact_mailer/user_message.text.erb (renamed from app/views/contact_mailer/user_message.rhtml) | 2 | ||||
-rw-r--r-- | app/views/general/_advanced_search_tips.html.erb (renamed from app/views/general/_advanced_search_tips.rhtml) | 34 | ||||
-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) | 4 | ||||
-rw-r--r-- | app/views/general/_frontpage_bodies_list.html.erb (renamed from app/views/general/_frontpage_bodies_list.rhtml) | 4 | ||||
-rw-r--r-- | app/views/general/_frontpage_intro_sentence.html.erb (renamed from app/views/general/_frontpage_intro_sentence.rhtml) | 2 | ||||
-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) | 8 | ||||
-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) | 0 | ||||
-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 | 2 | ||||
-rw-r--r-- | app/views/general/_orglink.rhtml | 2 | ||||
-rw-r--r-- | app/views/general/_popup_banner.html.erb (renamed from app/views/admin_general/_admin_navbar.rhtml) | 0 | ||||
-rw-r--r-- | app/views/general/_popup_banner.rhtml | 1 | ||||
-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) | 12 | ||||
-rw-r--r-- | app/views/general/blog.html.erb (renamed from app/views/general/blog.rhtml) | 16 | ||||
-rw-r--r-- | app/views/general/custom_css.rhtml | 1 | ||||
-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) | 26 | ||||
-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) | 14 | ||||
-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) | 5 | ||||
-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) | 4 | ||||
-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 | 38 | ||||
-rw-r--r-- | app/views/layouts/admin.rhtml | 39 | ||||
-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) | 23 | ||||
-rw-r--r-- | app/views/layouts/no_chrome.html.erb (renamed from app/views/layouts/no_chrome.rhtml) | 20 | ||||
-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) | 4 | ||||
-rw-r--r-- | app/views/outgoing_mailer/initial_request.text.erb (renamed from app/views/outgoing_mailer/initial_request.rhtml) | 2 | ||||
-rw-r--r-- | app/views/public_body/_alphabet.html.erb | 3 | ||||
-rw-r--r-- | app/views/public_body/_alphabet.rhtml | 3 | ||||
-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) | 7 | ||||
-rw-r--r-- | app/views/public_body/_list_sidebar_extra.html.erb | 6 | ||||
-rw-r--r-- | app/views/public_body/_list_sidebar_extra.rhtml | 6 | ||||
-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) | 18 | ||||
-rw-r--r-- | app/views/public_body/show.html.erb (renamed from app/views/public_body/show.rhtml) | 26 | ||||
-rw-r--r-- | app/views/public_body/view_email.html.erb (renamed from app/views/public_body/view_email.rhtml) | 10 | ||||
-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.erb | 26 | ||||
-rw-r--r-- | app/views/request/_after_actions.html.erb (renamed from app/views/request/_after_actions.rhtml) | 14 | ||||
-rw-r--r-- | app/views/request/_bubble.html.erb (renamed from app/views/request/_bubble.rhtml) | 12 | ||||
-rw-r--r-- | app/views/request/_correspondence.html.erb (renamed from app/views/request/_correspondence.rhtml) | 6 | ||||
-rw-r--r-- | app/views/request/_describe_state.html.erb (renamed from app/views/request/_describe_state.rhtml) | 13 | ||||
-rw-r--r-- | app/views/request/_followup.html.erb (renamed from app/views/request/_followup.rhtml) | 25 | ||||
-rw-r--r-- | app/views/request/_hidden_correspondence.html.erb (renamed from app/views/request/_hidden_correspondence.rhtml) | 12 | ||||
-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) | 3 | ||||
-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) | 6 | ||||
-rw-r--r-- | app/views/request/_request_listing_single.html.erb (renamed from app/views/request/_request_listing_single.rhtml) | 2 | ||||
-rw-r--r-- | app/views/request/_request_listing_via_event.html.erb (renamed from app/views/request/_request_listing_via_event.rhtml) | 8 | ||||
-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) | 30 | ||||
-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) | 2 | ||||
-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) | 6 | ||||
-rw-r--r-- | app/views/request/describe_state_message.html.erb | 30 | ||||
-rw-r--r-- | app/views/request/details.html.erb (renamed from app/views/request/details.rhtml) | 4 | ||||
-rw-r--r-- | app/views/request/followup_bad.html.erb (renamed from app/views/request/followup_bad.rhtml) | 12 | ||||
-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 | 19 | ||||
-rw-r--r-- | app/views/request/hidden.rhtml | 19 | ||||
-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) | 21 | ||||
-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) | 18 | ||||
-rw-r--r-- | app/views/request/select_authority.html.erb (renamed from app/views/request/select_authority.rhtml) | 39 | ||||
-rw-r--r-- | app/views/request/show.html.erb (renamed from app/views/request/show.rhtml) | 18 | ||||
-rw-r--r-- | app/views/request/show_response.html.erb (renamed from app/views/request/show_response.rhtml) | 4 | ||||
-rw-r--r-- | app/views/request/similar.html.erb (renamed from app/views/request/similar.rhtml) | 0 | ||||
-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) | 6 | ||||
-rw-r--r-- | app/views/request_game/play.html.erb (renamed from app/views/request_game/play.rhtml) | 4 | ||||
-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.rhtml | 1 | ||||
-rw-r--r-- | app/views/request_mailer/external_response.text.erb | 1 | ||||
-rw-r--r-- | app/views/request_mailer/fake_response.rhtml | 1 | ||||
-rw-r--r-- | app/views/request_mailer/fake_response.text.erb | 1 | ||||
-rw-r--r-- | app/views/request_mailer/new_response.text.erb (renamed from app/views/request_mailer/new_response.rhtml) | 4 | ||||
-rw-r--r-- | app/views/request_mailer/new_response_reminder_alert.text.erb (renamed from app/views/request_mailer/new_response_reminder_alert.rhtml) | 2 | ||||
-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) | 2 | ||||
-rw-r--r-- | app/views/request_mailer/requires_admin.text.erb (renamed from app/views/request_mailer/requires_admin.rhtml) | 6 | ||||
-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) | 2 | ||||
-rw-r--r-- | app/views/track/_tracking_links.html.erb (renamed from app/views/track/_tracking_links.rhtml) | 10 | ||||
-rw-r--r-- | app/views/track/atom_feed.atom.erb | 2 | ||||
-rw-r--r-- | app/views/track_mailer/event_digest.text.erb (renamed from app/views/track_mailer/event_digest.rhtml) | 8 | ||||
-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) | 8 | ||||
-rw-r--r-- | app/views/user/_signin.html.erb (renamed from app/views/user/_signin.rhtml) | 4 | ||||
-rw-r--r-- | app/views/user/_signup.html.erb (renamed from app/views/user/_signup.rhtml) | 20 | ||||
-rw-r--r-- | app/views/user/_user_listing_single.html.erb (renamed from app/views/user/_user_listing_single.rhtml) | 4 | ||||
-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) | 4 | ||||
-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) | 6 | ||||
-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) | 26 | ||||
-rw-r--r-- | app/views/user/sign.html.erb (renamed from app/views/user/sign.rhtml) | 4 | ||||
-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 | 8 | ||||
-rw-r--r-- | app/views/user/wrong_user_unknown_email.rhtml | 8 | ||||
-rw-r--r-- | app/views/user_mailer/already_registered.text.erb (renamed from app/views/user_mailer/already_registered.rhtml) | 4 | ||||
-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) | 2 | ||||
-rw-r--r-- | app/views/user_mailer/confirm_login.text.erb (renamed from app/views/user_mailer/confirm_login.rhtml) | 4 |
283 files changed, 3634 insertions, 2950 deletions
diff --git a/app/controllers/admin_censor_rule_controller.rb b/app/controllers/admin_censor_rule_controller.rb index 5381921bf..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 @@ -10,7 +10,7 @@ class AdminCensorRuleController < AdminController @info_request = InfoRequest.find(params[:info_request_id]) end if params[:user_id] - @user = User.find(params[:user_id]) + @censor_user = User.find(params[:user_id]) end end @@ -26,9 +26,9 @@ class AdminCensorRuleController < AdminController end flash[:notice] = 'CensorRule was successfully created.' if !@censor_rule.info_request.nil? - redirect_to admin_url('request/show/' + @censor_rule.info_request.id.to_s) + redirect_to admin_request_show_url(@censor_rule.info_request) elsif !@censor_rule.user.nil? - redirect_to admin_url('user/show/' + @censor_rule.user.id.to_s) + redirect_to admin_user_show_url(@censor_rule.user) else raise "internal error" end @@ -53,9 +53,9 @@ class AdminCensorRuleController < AdminController end flash[:notice] = 'CensorRule was successfully updated.' if !@censor_rule.info_request.nil? - redirect_to admin_url('request/show/' + @censor_rule.info_request.id.to_s) + redirect_to admin_request_show_url(@censor_rule.info_request) elsif !@censor_rule.user.nil? - redirect_to admin_url('user/show/' + @censor_rule.user.id.to_s) + redirect_to admin_user_show_url(@censor_rule.user) else raise "internal error" end @@ -79,9 +79,9 @@ class AdminCensorRuleController < AdminController flash[:notice] = "CensorRule was successfully destroyed." if !info_request.nil? - redirect_to admin_url('request/show/' + info_request.id.to_s) + redirect_to admin_request_show_url(info_request) elsif !user.nil? - redirect_to admin_url('user/show/' + user.id.to_s) + redirect_to admin_user_show_url(user) else raise "internal error" end diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index d93e68dab..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? + 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"), @@ -89,7 +89,6 @@ class AdminController < ApplicationController session[:using_admin] = 1 session[:admin_name] = @user.url_name else - session[:using_admin] = nil session[:user_id] = nil session[:admin_name] = nil @@ -98,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 96b67d389..ec5f95eda 100644 --- a/app/controllers/admin_general_controller.rb +++ b/app/controllers/admin_general_controller.rb @@ -2,9 +2,11 @@ # 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 + def index # ensure we have a trailing slash current_uri = request.env['REQUEST_URI'] @@ -115,6 +117,17 @@ class AdminGeneralController < AdminController end def stats + # Overview counts of things + @public_body_count = PublicBody.count + + @info_request_count = InfoRequest.count + @outgoing_message_count = OutgoingMessage.count + @incoming_message_count = IncomingMessage.count + + @user_count = User.count + @track_thing_count = TrackThing.count + + @comment_count = Comment.count @request_by_state = InfoRequest.count(:group => 'described_state') @tracks_by_type = TrackThing.count(:group => 'track_type') end @@ -128,5 +141,10 @@ class AdminGeneralController < AdminController @github_origin = "https://github.com/#{repo}/tree/" @request_env = request.env end + + # TODO: Remove this when support for proxy admin interface is removed + def admin_js + render :layout => false, :content_type => "application/javascript" + end end diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb index ac12e97b2..52b56eda2 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" @@ -14,7 +14,7 @@ class AdminPublicBodyController < AdminController def _lookup_query_internal @locale = self.locale_from_params() - PublicBody.with_locale(@locale) do + I18n.with_locale(@locale) do @query = params[:query] if @query == "" @query = nil @@ -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 @@ -75,7 +73,7 @@ class AdminPublicBodyController < AdminController def show @locale = self.locale_from_params() - PublicBody.with_locale(@locale) do + I18n.with_locale(@locale) do @public_body = PublicBody.find(params[:id]) render end @@ -87,12 +85,12 @@ class AdminPublicBodyController < AdminController end def create - PublicBody.with_locale(I18n.default_locale) do + I18n.with_locale(I18n.default_locale) do params[:public_body][:last_edit_editor] = admin_current_user() @public_body = PublicBody.new(params[:public_body]) if @public_body.save flash[:notice] = 'PublicBody was successfully created.' - redirect_to admin_url('body/show/' + @public_body.id.to_s) + redirect_to admin_body_show_url(@public_body) else render :action => 'new' end @@ -106,12 +104,12 @@ class AdminPublicBodyController < AdminController end def update - PublicBody.with_locale(I18n.default_locale) do + I18n.with_locale(I18n.default_locale) do params[:public_body][:last_edit_editor] = admin_current_user() @public_body = PublicBody.find(params[:id]) if @public_body.update_attributes(params[:public_body]) flash[:notice] = 'PublicBody was successfully updated.' - redirect_to admin_url('body/show/' + @public_body.id.to_s) + redirect_to admin_body_show_url(@public_body) else render :action => 'edit' end @@ -120,7 +118,7 @@ class AdminPublicBodyController < AdminController def destroy @locale = self.locale_from_params() - PublicBody.with_locale(@locale) do + I18n.with_locale(@locale) do public_body = PublicBody.find(params[:id]) if public_body.info_requests.size > 0 diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb index ed8de7755..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,25 +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] - end - - def list_old_unclassified - @info_requests = WillPaginate::Collection.create((params[:page] or 1), 50) do |pager| - info_requests = InfoRequest.find_old_unclassified(:conditions => ["prominence = 'normal'"], - :limit => pager.per_page, - :offset => pager.offset) - # inject the result array into the paginated collection: - pager.replace(info_requests) - - unless pager.total_entries - # the pager didn't manage to guess the total count, do it manually - pager.total_entries = InfoRequest.count_old_unclassified(:conditions => ["prominence = 'normal'"]) - end - end + :per_page => 100 end def show @@ -40,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_url(@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 @@ -52,7 +41,7 @@ class AdminRequestController < AdminController @outgoing_message = OutgoingMessage.find(params[:outgoing_message_id]) @outgoing_message.resend_message flash[:notice] = "Outgoing message resent" - redirect_to request_admin_url(@outgoing_message.info_request) + redirect_to admin_request_show_url(@outgoing_message.info_request) end def edit @@ -98,7 +87,7 @@ class AdminRequestController < AdminController # expire cached files expire_for_request(@info_request) flash[:notice] = 'Request successfully updated.' - redirect_to request_admin_url(@info_request) + redirect_to admin_request_show_url(@info_request) else render :action => 'edit' end @@ -114,7 +103,7 @@ class AdminRequestController < AdminController # expire cached files expire_for_request(@info_request) flash[:notice] = "Request #{url_title} has been completely destroyed. Email of user who made request: " + user.email - redirect_to admin_url('request/list') + redirect_to admin_request_list_url end def edit_outgoing @@ -131,7 +120,7 @@ class AdminRequestController < AdminController { :editor => admin_current_user(), :deleted_outgoing_message_id => outgoing_message_id }) flash[:notice] = 'Outgoing message successfully destroyed.' - redirect_to request_admin_url(@info_request) + redirect_to admin_request_show_url(@info_request) end def update_outgoing @@ -144,7 +133,7 @@ class AdminRequestController < AdminController { :outgoing_message_id => @outgoing_message.id, :editor => admin_current_user(), :old_body => old_body, :body => @outgoing_message.body }) flash[:notice] = 'Outgoing message successfully updated.' - redirect_to request_admin_url(@outgoing_message.info_request) + redirect_to admin_request_show_url(@outgoing_message.info_request) else render :action => 'edit_outgoing' end @@ -168,7 +157,7 @@ class AdminRequestController < AdminController :old_visible => old_visible, :visible => @comment.visible, }) flash[:notice] = 'Comment successfully updated.' - redirect_to request_admin_url(@comment.info_request) + redirect_to admin_request_show_url(@comment.info_request) else render :action => 'edit_comment' end @@ -186,7 +175,7 @@ class AdminRequestController < AdminController # expire cached files expire_for_request(@info_request) flash[:notice] = 'Incoming message successfully destroyed.' - redirect_to request_admin_url(@info_request) + redirect_to admin_request_show_url(@info_request) end def redeliver_incoming @@ -203,7 +192,7 @@ class AdminRequestController < AdminController end if destination_request.nil? flash[:error] = "Failed to find destination request '" + m + "'" - return redirect_to request_admin_url(previous_request) + return redirect_to admin_request_show_url(previous_request) end raw_email_data = incoming_message.raw_email.data @@ -223,7 +212,7 @@ class AdminRequestController < AdminController expire_for_request(previous_request) incoming_message.fully_destroy end - redirect_to request_admin_url(destination_request) + redirect_to admin_request_show_url(destination_request) end # change user or public body of a request magically @@ -246,7 +235,7 @@ class AdminRequestController < AdminController info_request.reindex_request_events flash[:notice] = "Message has been moved to new user" end - redirect_to request_admin_url(info_request) + redirect_to admin_request_show_url(info_request) elsif params[:commit] == 'Move request to authority' && !params[:public_body_url_name].blank? old_public_body = info_request.public_body destination_public_body = PublicBody.find_by_url_name(params[:public_body_url_name]) @@ -265,10 +254,10 @@ class AdminRequestController < AdminController flash[:notice] = "Request has been moved to new body" end - redirect_to request_admin_url(info_request) + redirect_to admin_request_show_url(info_request) else flash[:error] = "Please enter the user or authority to move the request to" - redirect_to request_admin_url(info_request) + redirect_to admin_request_show_url(info_request) end end @@ -292,20 +281,20 @@ class AdminRequestController < AdminController if !info_request.public_body.is_foi_officer?(user) flash[:notice] = user.email + " is not an email at the domain @" + info_request.public_body.foi_officer_domain_required + ", so won't be able to upload." - redirect_to request_admin_url(info_request) + redirect_to admin_request_show_url(info_request) return end # Bejeeps, look, sometimes a URL is something that belongs in a controller, jesus. - # XXX hammer this square peg into the round MVC hole - should be calling main_url(upload_response_url()) + # XXX hammer this square peg into the round MVC hole post_redirect = PostRedirect.new( - :uri => main_url(upload_response_url(:url_title => info_request.url_title, :only_path => true)), + :uri => upload_response_url(:url_title => info_request.url_title), :user_id => user.id) post_redirect.save! - url = main_url(confirm_url(:email_token => post_redirect.email_token, :only_path => true)) + url = confirm_url(:email_token => post_redirect.email_token) - flash[:notice] = 'Send "' + name + '" <<a href="mailto:' + email + '">' + email + '</a>> this URL: <a href="' + url + '">' + url + "</a> - it will log them in and let them upload a response to this request.".html_safe - redirect_to request_admin_url(info_request) + flash[:notice] = ("Send \"#{name}\" <<a href=\"mailto:#{email}\">#{email}</a>> this URL: <a href=\"#{url}\">#{url}</a> - it will log them in and let them upload a response to this request.").html_safe + redirect_to admin_request_show_url(info_request) end def show_raw_email @@ -355,7 +344,7 @@ class AdminRequestController < AdminController info_request_event.save! flash[:notice] = "Old response marked as having been a clarification" - redirect_to request_admin_url(info_request_event.info_request) + redirect_to admin_request_show_url(info_request_event.info_request) end def hide_request @@ -376,18 +365,18 @@ 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") end # expire cached files expire_for_request(info_request) - redirect_to request_admin_url(info_request) + redirect_to admin_request_show_url(info_request) end end diff --git a/app/controllers/admin_track_controller.rb b/app/controllers/admin_track_controller.rb index 03217da45..085c9c6cc 100644 --- a/app/controllers/admin_track_controller.rb +++ b/app/controllers/admin_track_controller.rb @@ -2,13 +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 ] + 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 ed20ddcf4..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 @@ -48,7 +52,7 @@ class AdminUserController < AdminController if @admin_user.valid? @admin_user.save! flash[:notice] = 'User successfully updated.' - redirect_to user_admin_url(@admin_user) + redirect_to admin_user_show_url(@admin_user) else render :action => 'edit' end @@ -58,7 +62,7 @@ class AdminUserController < AdminController track_thing = TrackThing.find(params[:track_id].to_i) track_thing.destroy flash[:notice] = 'Track destroyed' - redirect_to user_admin_url(track_thing.tracking_user) + redirect_to admin_user_show_url(track_thing.tracking_user) end def clear_bounce @@ -66,15 +70,15 @@ class AdminUserController < AdminController user.email_bounced_at = nil user.email_bounce_message = "" user.save! - redirect_to user_admin_url(user) + redirect_to admin_user_show_url(user) end def login_as @admin_user = User.find(params[:id]) # check user does exist - post_redirect = PostRedirect.new( :uri => main_url(user_url(@admin_user)), :user_id => @admin_user.id, :circumstance => "login_as" ) + post_redirect = PostRedirect.new( :uri => user_url(@admin_user), :user_id => @admin_user.id, :circumstance => "login_as" ) post_redirect.save! - url = main_url(confirm_url(:email_token => post_redirect.email_token, :only_path => true)) + url = confirm_url(:email_token => post_redirect.email_token) redirect_to url end @@ -91,7 +95,7 @@ class AdminUserController < AdminController end flash[:notice] = "Profile photo cleared" - redirect_to user_admin_url(@admin_user) + redirect_to admin_user_show_url(@admin_user) end private diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 15fb4f5f9..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 => { @@ -220,7 +215,7 @@ class ApiController < ApplicationController :event_id => event.id, :created_at => event.created_at.iso8601, :event_type => event.event_type, - :request_url => main_url(request_url(request)), + :request_url => request_url(request), :request_email => request.incoming_email, :title => request.title, :body => event.outgoing_message.body, @@ -228,7 +223,7 @@ class ApiController < ApplicationController :user_name => request.user_name, } if request.user - this_event[:user_url] = main_url(user_url(request.user)) + this_event[:user_url] = user_url(request.user) end @event_data.push(this_event) @@ -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 f5d6cbf18..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,17 +538,13 @@ 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 - end - def alaveteli_git_commit `git log -1 --format="%H"`.strip end 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 626c4ad87..939dd1739 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,11 +14,11 @@ 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] - PublicBody.with_locale(@locale) do + I18n.with_locale(@locale) do if body_short_names.empty? # This is too slow @popular_bodies = PublicBody.visible.find(:all, @@ -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])) @@ -160,7 +153,7 @@ class GeneralController < ApplicationController # 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 +169,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 +209,9 @@ 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) - end - - def custom_css - long_cache - @locale = self.locale_from_params() - render(:layout => false, :content_type => 'text/css') + # Handle requests for non-existent URLs - will be handled by ApplicationController::render_exception + def not_found + raise RouteNotFound end def version 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 1bcc0145c..74ea043bb 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' @@ -16,7 +16,7 @@ class PublicBodyController < ApplicationController return end @locale = self.locale_from_params() - PublicBody.with_locale(@locale) do + I18n.with_locale(@locale) do @public_body = PublicBody.find_by_url_name_with_historic(params[:url_name]) raise ActiveRecord::RecordNotFound.new("None found") if @public_body.nil? if @public_body.url_name.nil? @@ -31,7 +31,7 @@ class PublicBodyController < ApplicationController set_last_body(@public_body) - top_url = main_url("/") + top_url = frontpage_url @searched_to_send_request = false referrer = request.env['HTTP_REFERER'] if !referrer.nil? && referrer.match(%r{^#{top_url}search/.*/bodies$}) @@ -69,7 +69,7 @@ class PublicBodyController < ApplicationController @public_body = PublicBody.find_by_url_name_with_historic(params[:url_name]) raise ActiveRecord::RecordNotFound.new("None found") if @public_body.nil? - PublicBody.with_locale(self.locale_from_params()) do + I18n.with_locale(self.locale_from_params()) do if params[:submitted_view_email] if verify_recaptcha flash.discard(:error) @@ -127,11 +127,9 @@ class PublicBodyController < ApplicationController @description = _("in the category ‘{{category_name}}’", :category_name=>category_name) end end - PublicBody.with_locale(@locale) do - @public_bodies = PublicBody.paginate( - :order => "public_body_translations.name", :page => params[:page], :per_page => 100, - :conditions => conditions, - :joins => :translations + I18n.with_locale(@locale) do + @public_bodies = PublicBody.where(conditions).joins(:translations).order("public_body_translations.name").paginate( + :page => params[:page], :per_page => 100 ) render :template => "public_body/list" 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 6b8444f90..42693f867 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 @@ -52,7 +52,7 @@ class RequestController < ApplicationController medium_cache end @locale = self.locale_from_params() - PublicBody.with_locale(@locale) do + I18n.with_locale(@locale) do # Look up by old style numeric identifiers if params[:url_title].match(/^[0-9]+$/) @@ -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,10 +144,9 @@ 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 @@ -166,7 +163,7 @@ class RequestController < ApplicationController @view = params[:view] @page = get_search_page_from_params if !@page # used in cache case, as perform_search sets @page as side effect if @view == "recent" - return redirect_to request_list_all_path(:action => "list", :view => "all", :page => @page), :status => :moved_permanently + return redirect_to request_list_all_url(:action => "list", :view => "all", :page => @page), :status => :moved_permanently end # Later pages are very expensive to load @@ -242,16 +239,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 @@ -321,9 +321,9 @@ class RequestController < ApplicationController message = "" if @outgoing_message.contains_email? if @user.nil? - message += (_("<p>You do not need to include your email in the request in order to get a reply, as we will ask for it on the next screen (<a href=\"%s\">details</a>).</p>") % [help_privacy_path+"#email_address"]).html_safe; + message += _("<p>You do not need to include your email in the request in order to get a reply, as we will ask for it on the next screen (<a href=\"{{url}}\">details</a>).</p>", :url => (help_privacy_path+"#email_address").html_safe); else - message += (_("<p>You do not need to include your email in the request in order to get a reply (<a href=\"%s\">details</a>).</p>") % [help_privacy_path+"#email_address"]).html_safe; + message += _("<p>You do not need to include your email in the request in order to get a reply (<a href=\"{{url}}\">details</a>).</p>", :url => (help_privacy_path+"#email_address").html_safe); end message += _("<p>We recommend that you edit your request and remove the email address. If you leave it, the email address will be sent to the authority, but will not be displayed on the site.</p>") @@ -344,7 +344,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,99 +368,84 @@ 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) + :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 def describe_state - @info_request = InfoRequest.find(params[:id].to_i) - set_last_request(@info_request) - - # If this isn't a form submit, go to the request page - if params[:submitted_describe_state].nil? - redirect_to request_url(@info_request) - return - end + info_request = InfoRequest.find(params[:id].to_i) + set_last_request(info_request) # If this is an external request, go to the request page - we don't allow # state change from the front end interface. - if @info_request.is_external? - redirect_to request_url(@info_request) + if info_request.is_external? + redirect_to request_url(info_request) return end - @is_owning_user = @info_request.is_owning_user?(authenticated_user) - @last_info_request_event_id = @info_request.last_event_id_needing_description - @old_unclassified = @info_request.is_old_unclassified? && !authenticated_user.nil? - - # Check authenticated, and parameters set. We check is_owning_user - # to get admin overrides (see is_owning_user? above) - if !@old_unclassified && !@is_owning_user && !authenticated_as_user?(@info_request.user, + # Check authenticated, and parameters set. + unless Ability::can_update_request_state?(authenticated_user, info_request) + authenticated_as_user?(info_request.user, :web => _("To classify the response to this FOI request"), - :email => _("Then you can classify the FOI response you have got from ") + @info_request.public_body.name + ".", - :email_subject => _("Classify an FOI response from ") + @info_request.public_body.name - ) + :email => _("Then you can classify the FOI response you have got from ") + info_request.public_body.name + ".", + :email_subject => _("Classify an FOI response from ") + info_request.public_body.name) # do nothing - as "authenticated?" has done the redirect to signin page for us return end if !params[:incoming_message] flash[:error] = _("Please choose whether or not you got some of the information that you wanted.") - redirect_to request_url(@info_request) + redirect_to request_url(info_request) return end - if params[:last_info_request_event_id].to_i != @last_info_request_event_id + if params[:last_info_request_event_id].to_i != info_request.last_event_id_needing_description flash[:error] = _("The request has been updated since you originally loaded this page. Please check for any new incoming messages below, and try again.") - redirect_to request_url(@info_request) + redirect_to request_url(info_request) + return + end + + described_state = params[:incoming_message][:described_state] + message = params[:incoming_message][:message] + # For requires_admin and error_message states we ask for an extra message to send to + # the administrators. + # If this message hasn't been included then ask for it + if ["error_message", "requires_admin"].include?(described_state) && message.nil? + redirect_to describe_state_message_url(:url_title => info_request.url_title, :described_state => described_state) return end # Make the state change - old_described_state = @info_request.described_state - @info_request.set_described_state(params[:incoming_message][: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) - # Log the status change by someone other than the requester - event = @info_request.log_event("status_update", - { :user_id => authenticated_user.id, - :old_described_state => old_described_state, - :described_state => @info_request.described_state, - }) - # Create a classification event for league tables - RequestClassification.create!(:user_id => authenticated_user.id, - :info_request_event_id => event.id) - + if !info_request.is_actual_owning_user?(authenticated_user) # Don't give advice on what to do next, as it isn't their request - RequestMailer.deliver_old_unclassified_updated(@info_request) if !@info_request.is_external? 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_url(@info_request))) - redirect_to play_url + 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))) + redirect_to categorise_play_url else flash[:notice] = _('Thank you for updating this request!') - redirect_to request_url(@info_request) + redirect_to request_url(info_request) end return end - calculated_status = @info_request.calculate_status + calculated_status = info_request.calculate_status # Display advice for requester on what to do next, as appropriate - if calculated_status == 'waiting_response' - flash[:notice] = _("<p>Thank you! Hopefully your wait isn't too long.</p> <p>By law, you should get 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)) - redirect_to request_url(@info_request) - elsif calculated_status == 'waiting_response_overdue' - flash[:notice] = _("<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)) - redirect_to request_url(@info_request) - elsif calculated_status == 'waiting_response_very_overdue' - flash[:notice] = _("<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) - redirect_to unhappy_url(@info_request) - elsif calculated_status == 'not_held' - flash[:notice] = _("<p>Thank you! Here are some ideas on what to do next:</p> + flash[:notice] = case info_request.calculate_status + when 'waiting_response' + _("<p>Thank you! Hopefully your wait isn't too long.</p> <p>By law, you should get 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_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 => 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> <li>To send your request to another authority, first copy the text of your request below, then <a href=\"{{find_authority_url}}\">find the other authority</a>.</li> <li>If you would like to contest the authority's claim that they do not hold the information, here is @@ -471,44 +456,70 @@ class RequestController < ApplicationController </li> </ul>", :find_authority_url => "/new", - :complain_url => CGI.escapeHTML(unhappy_url(@info_request)), - :other_means_url => CGI.escapeHTML(unhappy_url(@info_request)) + "#other_means") - redirect_to request_url(@info_request) - elsif calculated_status == 'rejected' - flash[:notice] = _("Oh no! Sorry to hear that your request was refused. Here is what to do now.") - redirect_to unhappy_url(@info_request) - elsif calculated_status == 'successful' - flash[:notice] = _("<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/") - redirect_to request_url(@info_request) - elsif calculated_status == 'partially_successful' - flash[:notice] = _("<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/") - redirect_to unhappy_url(@info_request) - elsif calculated_status == 'waiting_clarification' - flash[:notice] = _("Please write your follow up message containing the necessary clarifications below.") - redirect_to respond_to_last_url(@info_request) - elsif calculated_status == 'gone_postal' - redirect_to respond_to_last_url(@info_request) + "?gone_postal=1" - elsif calculated_status == 'internal_review' - flash[:notice] = _("<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") - redirect_to request_url(@info_request) - elsif calculated_status == 'error_message' - flash[:notice] = _("<p>Thank you! We'll look into what happened and try and fix it up.</p><p>If the error was a delivery failure, and you can find an up to date FOI email address for the authority, please tell us using the form below.</p>") - redirect_to help_general_url(:action => 'contact') - elsif calculated_status == 'requires_admin' - flash[:notice] = _("Please use the form below to tell us more.") - redirect_to help_general_url(:action => 'contact') - elsif calculated_status == 'user_withdrawn' - flash[:notice] = _("If you have not done so already, please write a message below telling the authority that you have withdrawn your request. Otherwise they will not know it has been withdrawn.") - redirect_to respond_to_last_url(@info_request) + :complain_url => CGI.escapeHTML(unhappy_url(info_request)), + :other_means_url => CGI.escapeHTML(unhappy_url(info_request)) + "#other_means") + when 'rejected' + _("Oh no! Sorry to hear that your request was refused. Here is what to do now.") + when 'successful' + 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' + 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 => 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' + _("If you have not done so already, please write a message below telling the authority that you have withdrawn your request. Otherwise they will not know it has been withdrawn.") + end + + case info_request.calculate_status + when 'waiting_response', 'waiting_response_overdue', 'not_held', 'successful', + 'internal_review', 'error_message', 'requires_admin' + redirect_to request_url(info_request) + when 'waiting_response_very_overdue', 'rejected', 'partially_successful' + redirect_to unhappy_url(info_request) + when 'waiting_clarification', 'user_withdrawn' + redirect_to respond_to_last_url(info_request) + when 'gone_postal' + redirect_to respond_to_last_url(info_request) + "?gone_postal=1" else if @@custom_states_loaded - return self.theme_describe_state(@info_request) + return self.theme_describe_state(info_request) else - raise "unknown calculate_status " + calculated_status + raise "unknown calculate_status #{info_request.calculate_status}" end end end + # Collect a message to include with the change of state + def describe_state_message + @info_request = InfoRequest.find_by_url_title!(params[:url_title]) + @described_state = params[:described_state] + @last_info_request_event_id = @info_request.last_event_id_needing_description + @title = case @described_state + when "error_message" + _("I've received an error message") + when "requires_admin" + _("This request requires administrator attention") + else + raise "Unsupported state" + end + end + # Used for links from polymorphic URLs e.g. in Atom feeds - just redirect to # proper URL for the message the event refers to def show_request_event @@ -560,10 +571,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 +594,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 @@ -624,7 +631,7 @@ class RequestController < ApplicationController if !params[:submitted_followup].nil? && !params[:reedit] if @info_request.allow_new_responses_from == 'nobody' - flash[:error] = (_('Your follow up has not been sent because this request has been stopped to prevent spam. Please <a href="%s">contact us</a> if you really want to send a follow up message.') % [help_contact_path]).html_safe + flash[:error] = _('Your follow up has not been sent because this request has been stopped to prevent spam. Please <a href="{{url}}">contact us</a> if you really want to send a follow up message.', :url => help_contact_path.html_safe) else if @info_request.find_existing_outgoing_message(params[:outgoing_message][:body]) flash[:error] = _('You previously submitted that exact follow up message for this request.') @@ -670,7 +677,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 +686,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 +696,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 +723,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 +743,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 +781,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 +790,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 @@ -811,7 +807,7 @@ class RequestController < ApplicationController # FOI officers can upload a response def upload_response @locale = self.locale_from_params() - PublicBody.with_locale(@locale) do + I18n.with_locale(@locale) do @info_request = InfoRequest.find_by_url_title!(params[:url_title]) @reason_params = { @@ -849,7 +845,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,17 +860,16 @@ 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 @locale = self.locale_from_params() - PublicBody.with_locale(@locale) do + I18n.with_locale(@locale) do @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"), @@ -882,7 +878,7 @@ class RequestController < ApplicationController :email_subject => _("Log in to download a zip file of {{info_request_title}}", :info_request_title=>@info_request.title) ) - updated = Digest::SHA1.hexdigest(@info_request.get_last_event.created_at.to_i.to_s + @info_request.updated_at.to_i.to_s) + updated = Digest::SHA1.hexdigest(@info_request.info_request_events.last.created_at.to_i.to_s + @info_request.updated_at.to_i.to_s) @url_path = File.join("/download", request_dirs(@info_request), updated, @@ -891,10 +887,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_url(@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 +907,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 +929,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 a27e71264..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_url(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 4ee527bae..1bf5a5316 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' @@ -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, - main_url(user_url(@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/admin_helper.rb b/app/helpers/admin_helper.rb new file mode 100644 index 000000000..059cebdfa --- /dev/null +++ b/app/helpers/admin_helper.rb @@ -0,0 +1,37 @@ +module AdminHelper + def icon(name) + content_tag(:i, "", :class => "icon-#{name}") + end + + def eye + icon("eye-open") + end + + def chevron_right + icon("chevron-right") + end + + def chevron_down + icon("chevron-down") + end + + def arrow_right + icon("arrow-right") + end + + def request_both_links(info_request) + link_to(eye, request_path(info_request), :title => "view request on public website") + " " + + link_to(info_request.title, admin_request_show_path(info_request), :title => "view full details") + end + + def public_body_both_links(public_body) + link_to(eye, public_body_path(public_body), :title => "view authority on public website") + " " + + link_to(h(public_body.name), admin_body_show_path(public_body), :title => "view full details") + end + + def user_both_links(user) + link_to(eye, user_path(user), :title => "view user's page on public website") + " " + + link_to(h(user.name), admin_user_show_path(user), :title => "view full details") + end +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 42c1e0549..238a36ce4 100755 --- a/app/helpers/link_to_helper.rb +++ b/app/helpers/link_to_helper.rb @@ -3,102 +3,100 @@ # - # # 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 # Links to various models # Requests - def request_url(info_request, extra_params={}) - params = {:url_title => info_request.url_title, :only_path => true} - return show_request_url(params.merge(extra_params)) + def request_url(info_request, options = {}) + show_request_url({:url_title => info_request.url_title}.merge(options)) end - def request_link(info_request, cls=nil ) - link_to h(info_request.title), request_url(info_request), :class => cls + def request_path(info_request, options = {}) + request_url(info_request, {:only_path => true}.merge(options)) end - def request_admin_url(info_request) - return admin_url('request/show/' + info_request.id.to_s) + def request_link(info_request, cls=nil ) + link_to h(info_request.title), request_path(info_request), :class => cls end - def request_admin_link(info_request, name="admin", cls=nil) - link_to name, request_admin_url(info_request), :class => cls + def request_details_path(info_request) + details_request_path(:url_title => info_request.url_title) end - def request_both_links(info_request) - link_to(h(info_request.title), main_url(request_url(info_request))) + " (" + link_to("admin", request_admin_url(info_request)) + ")" + # Incoming / outgoing messages + def incoming_message_url(incoming_message, options = {}) + return request_url(incoming_message.info_request, options.merge(:anchor => "incoming-#{incoming_message.id}")) end - def request_similar_url(info_request) - return similar_request_url(:url_title => info_request.url_title, :only_path => true) + def incoming_message_path(incoming_message) + incoming_message_url(incoming_message, :only_path => true) end - def request_details_url(info_request) - return details_request_url(:url_title => info_request.url_title, :only_path => true) + def outgoing_message_url(outgoing_message, options = {}) + request_url(outgoing_message.info_request, options.merge(:anchor => "outgoing-#{outgoing_message.id}")) end - # Incoming / outgoing messages - def incoming_message_url(incoming_message) - return request_url(incoming_message.info_request)+"#incoming-"+incoming_message.id.to_s + def outgoing_message_path(outgoing_message) + outgoing_message_url(outgoing_message, :only_path => true) end - def outgoing_message_url(outgoing_message) - return request_url(outgoing_message.info_request)+"#outgoing-"+outgoing_message.id.to_s + def comment_url(comment, options = {}) + request_url(comment.info_request, options.merge(:anchor => "comment-#{comment.id}")) end - def comment_url(comment) - return request_url(comment.info_request)+"#comment-"+comment.id.to_s + def comment_path(comment) + comment_url(comment, :only_path => true) end # Respond to request - def respond_to_last_url(info_request) + def respond_to_last_url(info_request, options = {}) last_response = info_request.get_last_response if last_response.nil? - respond_url = show_response_no_followup_url(:id => info_request.id) + show_response_no_followup_url(options.merge(:id => info_request.id)) else - respond_url = show_response_url(:id => info_request.id, :incoming_message_id => last_response.id) + show_response_url(options.merge(:id => info_request.id, :incoming_message_id => last_response.id)) end - return respond_url end - # Public bodies - def public_body_url(public_body) - public_body.url_name.nil? ? '' : show_public_body_url(:url_name => public_body.url_name, :only_path => true) + def respond_to_last_path(info_request) + respond_to_last_url(info_request, :only_path => true) end - def public_body_link_short(public_body) - link_to h(public_body.short_or_long_name), public_body_url(public_body) + # Public bodies + def public_body_url(public_body, options = {}) + public_body.url_name.nil? ? '' : show_public_body_url(options.merge(:url_name => public_body.url_name)) end - def public_body_link(public_body, cls=nil) - link_to h(public_body.name), public_body_url(public_body), :class => cls + def public_body_path(public_body) + public_body_url(public_body, :only_path => true) end - def public_body_link_absolute(public_body) # e.g. for in RSS - link_to h(public_body.name), main_url(public_body_url(public_body)) + def public_body_link_short(public_body) + link_to h(public_body.short_or_long_name), public_body_path(public_body) end - def public_body_admin_url(public_body) - return admin_url('body/show/' + public_body.id.to_s) + def public_body_link(public_body, cls=nil) + link_to h(public_body.name), public_body_path(public_body), :class => cls end - def public_body_both_links(public_body) - link_to(h(public_body.name), main_url(public_body_url(public_body))) + " (" + link_to("admin", public_body_admin_url(public_body)) + ")" + def public_body_link_absolute(public_body) # e.g. for in RSS + link_to h(public_body.name), public_body_url(public_body) end - def list_public_bodies_default - list_public_bodies_url(:tag => 'all') + # Users + def user_url(user, options = {}) + show_user_url(options.merge(:url_name => user.url_name)) end - # Users - def user_url(user) - return show_user_url(:url_name => user.url_name, :only_path => true) + def user_path(user) + user_url(user, :only_path => true) end def user_link(user, cls=nil) - link_to h(user.name), user_url(user), :class => cls + link_to h(user.name), user_path(user), :class => cls end def user_link_for_request(request, cls=nil) @@ -110,21 +108,24 @@ module LinkToHelper user_name end else - link_to h(request.user.name), user_url(request.user), :class => cls + link_to h(request.user.name), user_path(request.user), :class => cls end end def user_admin_link_for_request(request, external_text=nil, internal_text=nil) if request.is_external? - text = external_text ? external_text : (request.external_user_name || _("Anonymous user")) + " (external)" + external_text || (request.external_user_name || _("Anonymous user")) + " (external)" else - text = internal_text ? internal_text : request.user.name - link_to(h(text), user_admin_url(request.user)) + link_to(h(internal_text || request.user.name), admin_user_show_url(request.user)) end end def user_link_absolute(user) - link_to h(user.name), main_url(user_url(user)) + link_to h(user.name), user_url(user) + end + + def user_link(user) + link_to h(user.name), user_path(user) end def request_user_link_absolute(request) @@ -135,11 +136,19 @@ module LinkToHelper end end + def request_user_link(request) + if request.is_external? + request.external_user_name || _("Anonymous user") + else + user_link(request.user) + end + end + def user_or_you_link(user) if @user && user == @user - link_to h("you"), user_url(user) + link_to h("you"), user_path(user) else - link_to h(user.name), user_url(user) + link_to h(user.name), user_path(user) end end @@ -152,40 +161,36 @@ module LinkToHelper end def user_or_you_capital_link(user) - link_to user_or_you_capital(user), user_url(user) - end - - def user_admin_url(user) - return admin_url('user/show/' + user.id.to_s) + link_to user_or_you_capital(user), user_path(user) end def user_admin_link(user, name="admin", cls=nil) - link_to name, user_admin_url(user), :class => cls - end - - def user_both_links(user) - link_to(h(user.name), main_url(user_url(user))) + " (" + link_to("admin", user_admin_url(user)) + ")" + link_to name, admin_user_show_url(user), :class => cls end # Tracks. feed can be 'track' or 'feed' - def do_track_url(track_thing, feed = 'track') + def do_track_url(track_thing, feed = 'track', options = {}) if track_thing.track_type == 'request_updates' - track_request_url(:url_title => track_thing.info_request.url_title, :feed => feed) + track_request_url(options.merge(:url_title => track_thing.info_request.url_title, :feed => feed)) elsif track_thing.track_type == 'all_new_requests' - track_list_url(:view => 'recent', :feed => feed) + track_list_url(options.merge(:view => 'recent', :feed => feed)) elsif track_thing.track_type == 'all_successful_requests' - track_list_url(:view => 'successful', :feed => feed) + track_list_url(options.merge(:view => 'successful', :feed => feed)) elsif track_thing.track_type == 'public_body_updates' - track_public_body_url(:url_name => track_thing.public_body.url_name, :feed => feed) + track_public_body_url(options.merge(:url_name => track_thing.public_body.url_name, :feed => feed)) elsif track_thing.track_type == 'user_updates' - track_user_url(:url_name => track_thing.tracked_user.url_name, :feed => feed) + track_user_url(options.merge(:url_name => track_thing.tracked_user.url_name, :feed => feed)) elsif track_thing.track_type == 'search_query' - track_search_url(:query_array => track_thing.track_query, :feed => feed) + track_search_url(options.merge(:query_array => track_thing.track_query, :feed => feed)) else raise "unknown tracking type " + track_thing.track_type end end + def do_track_path(track_thing, feed = 'track') + do_track_url(track_thing, feed, :only_path => true) + end + # General pages. def search_url(query, params = nil) if query.kind_of?(Array) @@ -217,28 +222,26 @@ module LinkToHelper link_to h(query), search_url(query) end - # Admin pages - def admin_url(relative_path) - admin_url_prefix = Configuration::admin_base_url - (admin_url_prefix.empty? ? admin_general_index_url + '/' : admin_url_prefix) + relative_path + def search_path(query, options = {}) + search_url(query, options.merge(:only_path => true)) end - # About page URLs - def about_url - return help_general_url(:action => 'about') + def search_link(query) + link_to h(query), search_url(query) end - def unhappy_url(info_request = nil) - if info_request.nil? - return help_general_url(:action => 'unhappy') - else - return help_unhappy_url(:url_title => info_request.url_title) - end + # Deprecated helper + # TODO: Remove in next release + def admin_url(relative_path) + warn "[DEPRECATION] admin_url is deprecated. Please remove it from your theme." + relative_path end - + # Deprecated helper + # TODO: Remove in next release def main_url(relative_path, append = nil) - url_prefix = "http://" + Configuration::domain + warn "[DEPRECATION] main_url is deprecated. Please remove it from your theme." + url_prefix = "http://" + AlaveteliConfiguration::domain url = url_prefix + relative_path if !append.nil? begin @@ -253,6 +256,19 @@ module LinkToHelper return url end + # About page URLs + def about_url + return help_general_url(:action => 'about') + end + + def unhappy_url(info_request = nil) + if info_request.nil? + return help_general_url(:action => 'unhappy') + else + return help_unhappy_url(:url_title => info_request.url_title) + end + end + # Basic date format def simple_date(date) date = date.in_time_zone.to_date unless date.is_a? Date @@ -269,5 +285,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 dc2c5fe21..4dbce6738 100644 --- a/app/models/request_mailer.rb +++ b/app/mailers/request_mailer.rb @@ -2,93 +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) - if !set_by.nil? - user = set_by - else - user = info_request.user - end - @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 = main_url(request_url(info_request)) - admin_url = request_admin_url(info_request) - @body = {:reported_by => user, :info_request => info_request, :url => url, :admin_url => admin_url } + def requires_admin(info_request, set_by = nil, message = "") + user = set_by || info_request.user + @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 = main_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 - @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 @@ -96,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 - @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 @@ -115,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 - @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 @@ -135,30 +133,34 @@ class RequestMailer < ApplicationMailer # Make a link going to the form to describe state, and which logs the # user in. post_redirect = PostRedirect.new( - :uri => main_url(request_url(info_request)) + "#describe_state_form_1", + :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 = main_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 @@ -170,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 - @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 - @body = { :comment => comment, :info_request => info_request, :url => main_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 - @body = { :count => count, :info_request => info_request, :url => main_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. @@ -311,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 @@ -327,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 @@ -352,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 @@ -380,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 @@ -444,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 7dfa87f52..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 => main_url(user_url(user)) + "#email_subscriptions", + :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 @@ -91,10 +94,9 @@ class TrackMailer < ApplicationMailer if email_about_things.size > 0 # Send the email - previous_locale = I18n.locale - I18n.locale = user.get_locale - TrackMailer.deliver_event_digest(user, email_about_things) - I18n.locale = previous_locale + I18n.with_locale(user.get_locale) do + TrackMailer.event_digest(user, email_about_things).deliver + end end # Record that we've now sent those alerts to that user 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 723bc4abb..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 @@ -317,8 +304,7 @@ class FoiAttachment < ActiveRecord::Base text = CGI.escapeHTML(text) text = MySociety::Format.make_clickable(text) html = text.gsub(/\n/, '<br>') - return '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" - "http://www.w3.org/TR/html4/loose.dtd"><html><head><title></title></head><body>' + html + "</body></html>", wrapper_id + return '<!DOCTYPE html><html><head><title></title></head><body>' + html + "</body></html>", wrapper_id end # the extractions will also produce image files, which go in the 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..f959a8799 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"] @@ -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) @@ -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. @@ -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 cee9eb959..46c247fa9 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' @@ -474,6 +465,17 @@ public incoming_message = IncomingMessage.new ActiveRecord::Base.transaction do + + # To avoid a deadlock when simultaneously dealing with two + # incoming emails that refer to the same InfoRequest, we + # lock the row for update. In Rails 3.2.0 and later this + # can be done with info_request.with_lock or + # info_request.lock!, but upgrading to that version of + # Rails creates many other problems at the moment. In the + # interim, just use raw SQL to do the SELECT ... FOR UPDATE + raw_sql = "SELECT * FROM info_requests WHERE id = #{self.id} LIMIT 1 FOR UPDATE" + ActiveRecord::Base.connection.execute(raw_sql) + raw_email = RawEmail.new incoming_message.raw_email = raw_email incoming_message.info_request = self @@ -484,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 @@ -548,15 +550,24 @@ public end def requires_admin? - return true if InfoRequest.requires_admin_states.include?(described_state) - return false + ['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) + def set_described_state(new_state, set_by = nil, message = "") + old_described_state = described_state ActiveRecord::Base.transaction do self.awaiting_description = false - last_event = self.get_last_event + last_event = self.info_request_events.last last_event.described_state = new_state self.described_state = new_state last_event.save! @@ -568,9 +579,23 @@ 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) + 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.old_unclassified_updated(self).deliver if !is_external? + end end # Work out what the situation of the request is. In addition to values of @@ -684,7 +709,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. @@ -692,10 +717,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 @@ -719,41 +744,28 @@ public self.info_request_events.create!(:event_type => type, :params => params) end + def response_events + self.info_request_events.select{|e| e.response?} + end + # The last response is the default one people might want to reply to def get_last_response_event_id - for e in self.info_request_events.reverse - if e.event_type == 'response' - return e.id - end - end - return nil - + get_last_response_event.id if get_last_response_event end def get_last_response_event - for e in self.info_request_events.reverse - if e.event_type == 'response' - return e - end - end - return nil + response_events.last end def get_last_response - last_response_event = self.get_last_response_event - if last_response_event.nil? - return nil - else - return last_response_event.incoming_message - end + get_last_response_event.incoming_message if get_last_response_event + end + + def outgoing_events + info_request_events.select{|e| e.outgoing? } end # The last outgoing message def get_last_outgoing_event - for e in self.info_request_events.reverse - if [ 'sent', 'followup_sent' ].include?(e.event_type) - return e - end - end - return nil + outgoing_events.last end # Text from the the initial request, for use in summary display @@ -821,46 +833,31 @@ public # Display version of status def InfoRequest.get_status_description(status) - if status == 'waiting_classification' - _("Awaiting classification.") - elsif status == 'waiting_response' - _("Awaiting response.") - elsif status == 'waiting_response_overdue' - _("Delayed.") - elsif status == 'waiting_response_very_overdue' - _("Long overdue.") - elsif status == 'not_held' - _("Information not held.") - elsif status == 'rejected' - _("Refused.") - elsif status == 'partially_successful' - _("Partially successful.") - elsif status == 'successful' - _("Successful.") - elsif status == 'waiting_clarification' - _("Waiting clarification.") - elsif status == 'gone_postal' - _("Handled by post.") - elsif status == 'internal_review' - _("Awaiting internal review.") - elsif status == 'error_message' - _("Delivery error") - elsif status == 'requires_admin' - _("Unusual response.") - elsif status == 'attention_requested' - _("Reported for administrator attention.") - elsif status == 'user_withdrawn' - _("Withdrawn by the requester.") - elsif status == 'vexatious' - _("Considered by administrators as vexatious and hidden from site.") - elsif status == 'not_foi' - _("Considered by administrators as not an FOI request and hidden from site.") + descriptions = { + 'waiting_classification' => _("Awaiting classification."), + 'waiting_response' => _("Awaiting response."), + 'waiting_response_overdue' => _("Delayed."), + 'waiting_response_very_overdue' => _("Long overdue."), + 'not_held' => _("Information not held."), + 'rejected' => _("Refused."), + 'partially_successful' => _("Partially successful."), + 'successful' => _("Successful."), + 'waiting_clarification' => _("Waiting clarification."), + 'gone_postal' => _("Handled by post."), + 'internal_review' => _("Awaiting internal review."), + 'error_message' => _("Delivery error"), + 'requires_admin' => _("Unusual response."), + 'attention_requested' => _("Reported for administrator attention."), + 'user_withdrawn' => _("Withdrawn by the requester."), + 'vexatious' => _("Considered by administrators as vexatious and hidden from site."), + 'not_foi' => _("Considered by administrators as not an FOI request and hidden from site."), + } + if descriptions[status] + descriptions[status] + elsif respond_to?(:theme_display_status) + theme_display_status(status) else - begin - return self.theme_display_status(status) - rescue NoMethodError - raise _("unknown status ") + status - end + raise _("unknown status ") + status end end @@ -895,10 +892,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 @@ -909,25 +906,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 @@ -987,13 +966,8 @@ public end def is_old_unclassified? - return false if is_external? - return false if !awaiting_description - return false if url_title == 'holding_pen' - last_response_event = get_last_response_event - return false unless last_response_event - return false if last_response_event.created_at >= Time.now - OLD_AGE_IN_DAYS - return true + !is_external? && awaiting_description && url_title != 'holding_pen' && get_last_response_event && + Time.now > get_last_response_event.created_at + OLD_AGE_IN_DAYS end # List of incoming messages to followup, by unique email @@ -1085,25 +1059,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, @@ -1137,7 +1092,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) @@ -1155,5 +1110,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 09eba31ab..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 @@ -77,17 +77,18 @@ class InfoRequestEvent < ActiveRecord::Base end def user_can_view?(user) - if !self.info_request.user_can_view?(user) + unless info_request.user_can_view?(user) raise "internal error, called user_can_view? on event when there is not permission to view entire request" end - if self.prominence == 'hidden' - return User.view_hidden_requests?(user) - end - if self.prominence == 'requester_only' - return self.info_request.is_owning_user?(user) + case prominence + when 'hidden' + User.view_hidden_requests?(user) + when 'requester_only' + info_request.is_owning_user?(user) + else + true end - return true end @@ -363,16 +364,19 @@ class InfoRequestEvent < ActiveRecord::Base end def is_sent_sort? - if [ 'sent', 'resent'].include?(self.event_type) - return true - end - return false + ['sent', 'resent'].include?(event_type) end + def is_followup_sort? - if [ 'followup_sent', 'followup_resent'].include?(self.event_type) - return true - end - return false + ['followup_sent', 'followup_resent'].include?(event_type) + end + + def outgoing? + ['sent', 'followup_sent'].include?(event_type) + end + + def response? + event_type == 'response' end def same_email_as_previous_send? @@ -401,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 } @@ -416,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 c75894e6a..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' @@ -268,7 +277,7 @@ class OutgoingMessage < ActiveRecord::Base end end if self.body =~ /#{get_signoff}\s*\Z/m - errors.add(:body, _("Please sign at the bottom with your name, or alter the \"%{signoff}\" signature" % { :signoff => get_signoff })) + errors.add(:body, _("Please sign at the bottom with your name, or alter the \"{{signoff}}\" signature", :signoff => get_signoff)) end if !MySociety::Validate.uses_mixed_capitals(self.body) errors.add(:body, _('Please write your message using a mixture of capital and lower case letters. This makes it easier for others to read.')) 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 73d7ca12b..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 @@ -101,7 +85,7 @@ class ProfilePhoto < ActiveRecord::Base end if !self.draft && (self.image.columns != WIDTH || self.image.rows != HEIGHT) - errors.add(:data, N_("Failed to convert image to the correct size: at %{cols}x%{rows}, need %{width}x%{height}" % { :cols => self.image.columns, :rows => self.image.rows, :width => WIDTH, :height => HEIGHT })) + errors.add(:data, N_("Failed to convert image to the correct size: at {{cols}}x{{rows}}, need {{width}}x{{height}}", :cols => self.image.columns, :rows => self.image.rows, :width => WIDTH, :height => HEIGHT)) end if self.draft && self.user_id @@ -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 168b9f4c7..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! @@ -106,28 +106,25 @@ class PublicBody < ActiveRecord::Base # like find_by_url_name but also search historic url_name if none found def self.find_by_url_name_with_historic(name) - locale = self.locale || I18n.locale - PublicBody.with_locale(locale) do - found = PublicBody.find(:all, - :conditions => ["public_body_translations.url_name=?", name], - :joins => :translations, - :readonly => false) - # If many bodies are found (usually because the url_name is the same across - # locales) return any of them - return found.first if found.size >= 1 - - # If none found, then search the history of short names - old = PublicBody::Version.find_all_by_url_name(name) - # Find unique public bodies in it - old = old.map { |x| x.public_body_id } - old = old.uniq - # Maybe return the first one, so we show something relevant, - # rather than throwing an error? - raise "Two bodies with the same historical URL name: #{name}" if old.size > 1 - return unless old.size == 1 - # does acts_as_versioned provide a method that returns the current version? - return PublicBody.find(old.first) - end + found = PublicBody.find(:all, + :conditions => ["public_body_translations.url_name=?", name], + :joins => :translations, + :readonly => false) + # If many bodies are found (usually because the url_name is the same across + # locales) return any of them + return found.first if found.size >= 1 + + # If none found, then search the history of short names + old = PublicBody::Version.find_all_by_url_name(name) + # Find unique public bodies in it + old = old.map { |x| x.public_body_id } + old = old.uniq + # Maybe return the first one, so we show something relevant, + # rather than throwing an error? + raise "Two bodies with the same historical URL name: #{name}" if old.size > 1 + return unless old.size == 1 + # does acts_as_versioned provide a method that returns the current version? + return PublicBody.find(old.first) end # Set the first letter, which is used for faster queries @@ -243,13 +240,13 @@ class PublicBody < ActiveRecord::Base # When name or short name is changed, also change the url name def short_name=(short_name) - globalize.write(self.class.locale || I18n.locale, :short_name, short_name) + globalize.write(I18n.locale, :short_name, short_name) self[:short_name] = short_name self.update_url_name end def name=(name) - globalize.write(self.class.locale || I18n.locale, :name, name) + globalize.write(I18n.locale, :name, name) self[:name] = name self.update_url_name end @@ -329,13 +326,13 @@ class PublicBody < ActiveRecord::Base # The "internal admin" is a special body for internal use. def PublicBody.internal_admin_body - PublicBody.with_locale(I18n.default_locale) do + I18n.with_locale(I18n.default_locale) do pb = PublicBody.find_by_url_name("internal_admin_authority") if pb.nil? pb = PublicBody.new( :name => 'Internal admin authority', :short_name => "", - :request_email => Configuration::contact_email, + :request_email => AlaveteliConfiguration::contact_email, :home_page => "", :notes => "", :publication_scheme => "", @@ -367,7 +364,7 @@ class PublicBody < ActiveRecord::Base # of updating them bodies_by_name = {} set_of_existing = Set.new() - PublicBody.with_locale(I18n.default_locale) do + I18n.with_locale(I18n.default_locale) do bodies = (tag.nil? || tag.empty?) ? PublicBody.find(:all) : PublicBody.find_by_tag(tag) for existing_body in bodies # Hide InternalAdminBody from import notes @@ -410,7 +407,7 @@ class PublicBody < ActiveRecord::Base if public_body = bodies_by_name[name] # Existing public body available_locales.each do |locale| - PublicBody.with_locale(locale) do + I18n.with_locale(locale) do changed = ActiveSupport::OrderedHash.new field_list.each do |field_name| localized_field_name = (locale.to_s == I18n.default_locale.to_s) ? field_name : "#{field_name}.#{locale}" @@ -445,7 +442,7 @@ class PublicBody < ActiveRecord::Base else # New public body public_body = PublicBody.new(:name=>"", :short_name=>"", :request_email=>"") available_locales.each do |locale| - PublicBody.with_locale(locale) do + I18n.with_locale(locale) do changed = ActiveSupport::OrderedHash.new field_list.each do |field_name| localized_field_name = (locale.to_s == I18n.default_locale.to_s) ? field_name : "#{field_name}.#{locale}" @@ -551,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 @@ -635,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 dfe92b7fe..66b8a5c47 100644 --- a/app/models/track_thing.rb +++ b/app/models/track_thing.rb @@ -19,10 +19,12 @@ # 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' +# TODO: TrackThing looks like a good candidate for single table inheritance + class TrackThing < ActiveRecord::Base belongs_to :tracking_user, :class_name => 'User' validates_presence_of :track_query @@ -258,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 e6c666e47..306d6ad4a 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 @@ -98,12 +90,7 @@ class User < ActiveRecord::Base end def get_locale - if !self.locale.nil? - locale = self.locale - else - locale = I18n.locale - end - return locale.to_s + (self.locale || I18n.locale).to_s end def visible_comments @@ -119,7 +106,9 @@ 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 + name = "#{_("{{user_name}} (Account suspended)", :user_name=> name)}" end name end @@ -141,14 +130,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 @@ -201,12 +190,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 ) @@ -279,16 +268,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 @@ -311,7 +300,7 @@ class User < ActiveRecord::Base text = CGI.escapeHTML(text) text = MySociety::Format.make_clickable(text, :contract => 1) text = text.gsub(/\n/, '<br>') - return text + return text.html_safe end # Returns domain part of user's email address @@ -407,6 +396,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/sass/admin.scss b/app/sass/admin.scss new file mode 100644 index 000000000..584b0d00d --- /dev/null +++ b/app/sass/admin.scss @@ -0,0 +1,112 @@ +/* As we're namespacing bootstrap to class admin, which is applied to the body + element in the admin interface (no id or class allowed on the HTML element + in HTML 4.01) and to the navbar also, so it can be styled with bootstrap + when showing for admin users on the front end, re-apply the bootstrap html + and body styles here. +*/ +html { + font-size: 100%; + -webkit-text-size-adjust: 100%; + -ms-text-size-adjust: 100%; +} + +body.admin { + margin: 0; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 14px; + line-height: 20px; + color: #333333; + background-color: white; +} + +/* When the admin stylesheet is loaded (and so the user is seeing the admin navbar), pad the banner of the front end interface so that it isn't hidden, and move any special notice down too. +*/ + +.entirebody, #banner { + padding-top: 50px; +} + +#special-notice { + margin-top: 50px; +} + +.admin { + + @import "compass/css3"; + @import "bootstrap"; + + #main { + padding-top: 50px; + + } + + .form-inline { + display: inline; + } + + table .form { + display: inline-block; + margin: 0; + } + + .accordion-group { + border: none; + } + .accordion-heading { + .btn { + float: left; + margin: 6px 15px; + } + .accordion-toggle { + padding: 2px; + &:hover { + text-decoration: none; + } + } + } + + div.item-detail { + div:nth-child(odd) span { + background-color: #eee; + } + } + + span.label.tag { + margin-right: 2px; + a { + color: white; + } + } + + body.admin blockquote p { + font-size: 13px; + display: inline; + } + + div#user_locale_switcher { + div.btn-group:before, + div.btn-group:after { + display: inline; + } + } + + #request_hidden_user_subject_field { + width: 440px; + } + #request_hidden_user_explanation_field { + width: 100%; + height: 15em; + } + #request_hidden_user_subject, + #request_hide_button, + #request_hidden_user_explanation { + display: none; + } + + #outgoing_message_body, + #comment_body { + width: 750px; + } + +} + diff --git a/app/views/admin_censor_rule/_form.html.erb b/app/views/admin_censor_rule/_form.html.erb new file mode 100644 index 000000000..5035238d6 --- /dev/null +++ b/app/views/admin_censor_rule/_form.html.erb @@ -0,0 +1,75 @@ +<%= error_messages_for 'censor_rule' %> + +<div class="well"> + <%=_("Applies to")%> + <% unless info_request.nil? %> + <%= request_both_links(info_request) %> + <%= hidden_field 'censor_rule', 'info_request_id', { :value => info_request.id } %> + <% end %> + <% unless user.nil? %> + <%= user_both_links(user) %> + <%= hidden_field 'censor_rule', 'user_id', { :value => user.id } %> +<% end %> +</div> + +<div class="control-group"> + <label for="censor_rule_regexp" class="control-label">Is it regexp replacement?</label> + <div class="controls"> + <%= check_box 'censor_rule', 'regexp' %> + <div class="help-block"> + Leave unchecked if you are not sure about this + </div> + </div> +</div> + +<div class="control-group"> + <label for="censor_rule_text" class="control-label">Text</label> + <div class="controls"> + <%= text_field 'censor_rule', 'text', :class => "span3" %> + <div class="help-block"> + that you want to remove, case sensitive + </div> + </div> +</div> + +<div class="control-group"> + <label for="censor_rule_replacement" class="control-label">Replacement</label> + <div class="controls"> + <%= text_field 'censor_rule', 'replacement', :class => "span3" %> + <div class="help-block"> + put it in <strong>[square brackets]</strong>, e.g. [personal information removed]. applies to text in emails and HTML conversions of binaries; binaries themselves must stay the same length and the replacement is just a bunch of 'x's + </div> + </div> +</div> + +<div class="control-group"> + <label for="censor_rule_last_edit_comment" class="control-label">Comment for this edit</label> + <div class="controls"> + <%= text_area 'censor_rule', 'last_edit_comment', :rows => 2, :class => "span6" %> + <div class="help-block"> + put purpose of the rule, and why the change + </div> + </div> +</div> + +<div class="row"> + <div class="span10 offset2"> + <div class="alert alert-info"> + <h3>Warning and notes:</h3> + <p> This does replace text in binary files, but for + most formats only in a naive way. It works well on surprisingly many Word documents. Notably + it doesn't even do UCS-2 (unicode sometimes used in Word). There is also special code + which works on some PDFs. Please <strong>carefully check</strong> all attachments have + changed in the way you expect, and haven't become corrupted. + </p> + <p>You may need to manually rebuild the search index afterwards. You can redact + things by individual request or by user by adding the censor rule from the + appropriate page. If you need to redact across a whole + authority, it will be easy enough to make code changes to add it, so do ask. + </p> + <p> + <strong>Regexp rules that are hard to process will really slow down request display.</strong> Please only use regexps if you really need to. + </p> + </div> + </div> +</div> diff --git a/app/views/admin_censor_rule/_form.rhtml b/app/views/admin_censor_rule/_form.rhtml deleted file mode 100644 index ac43de704..000000000 --- a/app/views/admin_censor_rule/_form.rhtml +++ /dev/null @@ -1,40 +0,0 @@ -<%= error_messages_for 'censor_rule' %> - -<p>Applies to: - <% if !info_request.nil? %> - <%=request_both_links(info_request)%> request - <%= hidden_field 'censor_rule', 'info_request_id', { :value => info_request.id } %> - <% end %> - <% if !user.nil? %> - <%=user_both_links(user)%> user - <%= hidden_field 'censor_rule', 'user_id', { :value => user.id } %> - <% end %> -</p> - -<p><label for="censor_rule_regexp">Is it regexp replacement?</label> (Leave unchecked if you are not sure about this)<br/> -<%= check_box 'censor_rule', 'regexp' %></p> - -<p><label for="censor_rule_text">Text</label> (that you want to remove, case sensitive)<br/> -<%= text_field 'censor_rule', 'text', :size => 60 %></p> - -<p><label for="censor_rule_replacement">Replacement</label> (put it in <strong>[square brackets]</strong>, e.g. [personal information removed]. applies to text in emails and HTML conversions of binaries; binaries themselves must stay the same length and the replacement is just a bunch of 'x's)<br/> -<%= text_field 'censor_rule', 'replacement', :size => 60 %></p> - -<p><label for="censor_rule_last_edit_comment">Comment for this edit</label> (put purpose of the rule, and why the change)<br/> -<%= text_area 'censor_rule', 'last_edit_comment', :rows => 2, :cols => 60 %></p> - -<p><strong>Warning and notes:</strong> This does replace text in binary files, but for -most formats only in a naive way. It works well on surprisingly many Word documents. Notably -it doesn't even do UCS-2 (unicode sometimes used in Word). There is also special code -which works on some PDFs. Please <strong>carefully check</strong> all attachments have -changed in the way you expect, and haven't become corrupted. -</p> - -<p>You may need to manually rebuild the search index afterwards. You can redact -things by individual request or by user by adding the censor rule from the -appropriate page. If you need to redact across a whole -authority, it will be easy enough to make code changes to add it, so do ask. -</p> -<p><strong>Regexp rules that are hard to process will really slow down request display.</strong> Please only use regexps if you really need to. -</p> - diff --git a/app/views/admin_censor_rule/_show.rhtml b/app/views/admin_censor_rule/_show.html.erb index 363c3fb6f..0d4cece93 100644 --- a/app/views/admin_censor_rule/_show.rhtml +++ b/app/views/admin_censor_rule/_show.html.erb @@ -1,6 +1,6 @@ <% if censor_rules.size > 0 %> - <table> + <table class="table table-condensed"> <tr> <th>Id</th> <% for column in CensorRule.content_columns %> @@ -16,7 +16,7 @@ <td><%=h censor_rule.send(column) %></td> <% end %> <td> - <%= link_to "Edit", '../../censor/edit/' + censor_rule.id.to_s %> + <%= link_to "Edit", admin_rule_edit_path(censor_rule) %> </td> </tr> <% end %> @@ -26,14 +26,10 @@ <% end %> <% if defined? info_request %> - <p> - <%= link_to "New censor rule", '../../censor/new?info_request_id=' + info_request.id.to_s %> (for this request only) - </p> + <%= link_to "New censor rule (for this request only)", admin_rule_new_path(:info_request_id => info_request.id), :class => "btn btn-info" %> <% end %> <% if defined? user %> - <p> - <%= link_to "New censor rule", '../../censor/new?user_id=' + user.id.to_s %> (for all requests by this user) - </p> + <%= link_to "New censor rule", admin_rule_new_path(:user_id => user.id), :class => "btn btn-info" %> <span class="label label-info">for all requests by this user</span> <% end %> diff --git a/app/views/admin_censor_rule/edit.html.erb b/app/views/admin_censor_rule/edit.html.erb new file mode 100644 index 000000000..230446ed3 --- /dev/null +++ b/app/views/admin_censor_rule/edit.html.erb @@ -0,0 +1,18 @@ +<% @title = 'Edit censor rule' %> + +<h1><%=@title%></h1> + +<%= 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 %> + <%= hidden_field_tag(:censor_rule_id, @censor_rule.id) %> + <div class="form-actions"> + Permanent! --> <%= submit_tag "Destroy rule", :class => "btn btn-primary" %> + </div> +<% end %> + diff --git a/app/views/admin_censor_rule/edit.rhtml b/app/views/admin_censor_rule/edit.rhtml deleted file mode 100644 index e34e022a0..000000000 --- a/app/views/admin_censor_rule/edit.rhtml +++ /dev/null @@ -1,16 +0,0 @@ -<% @title = 'Edit censor rule' %> - -<h1><%=@title%></h1> - -<% form_tag '../update/' + @censor_rule.id.to_s do %> - <%= render :partial => 'form', :locals => { :info_request => @censor_rule.info_request, :user => @censor_rule.user } %> - <p><%= submit_tag 'Save', :accesskey => 's' %></p> -<% end %> - -<% form_tag('../destroy/' + @censor_rule.id.to_s) do %> - <p> - <%= hidden_field_tag(:censor_rule_id, @censor_rule.id) %> - Permanent! --> <%= submit_tag "Destroy rule" %> - </p> -<% end %> - diff --git a/app/views/admin_censor_rule/new.html.erb b/app/views/admin_censor_rule/new.html.erb new file mode 100644 index 000000000..77d22990c --- /dev/null +++ b/app/views/admin_censor_rule/new.html.erb @@ -0,0 +1,11 @@ +<% @title = _('New censor rule') %> + +<h1><%=@title%></h1> + +<%= 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" %> + </div> +<% end %> + diff --git a/app/views/admin_censor_rule/new.rhtml b/app/views/admin_censor_rule/new.rhtml deleted file mode 100644 index c6b8cea6a..000000000 --- a/app/views/admin_censor_rule/new.rhtml +++ /dev/null @@ -1,9 +0,0 @@ -<% @title = 'New censor rule' %> - -<h1><%=@title%></h1> - -<% form_tag 'create' do %> - <%= render :partial => 'form', :locals => { :info_request => @info_request, :user => @user } %> - <p><%= submit_tag "Create" %></p> -<% end %> - diff --git a/app/views/admin_general/_admin_navbar.html.erb b/app/views/admin_general/_admin_navbar.html.erb new file mode 100644 index 000000000..5cc740f70 --- /dev/null +++ b/app/views/admin_general/_admin_navbar.html.erb @@ -0,0 +1,22 @@ +<div class="admin"> + <div class="navbar navbar-fixed-top navbar-inverse"> + <div class="navbar-inner"> + <div class="container"> + <%= link_to 'Alaveteli', frontpage_path, :class => "brand" %> + <div class="nav-collapse"> + <ul class="nav"> + <li><%= link_to 'Summary', admin_general_index_path %></li> + <li><%= link_to 'Timeline', admin_timeline_path %></li> + <li><%= link_to 'Stats', admin_stats_path %></li> + <li><%= link_to 'Debug', admin_debug_path %></li> + <li><%= link_to 'Authorities', admin_body_list_path %></li> + <li><%= link_to 'Requests', admin_request_list_path %></li> + <li><%= link_to 'Users', admin_user_list_path %></li> + <li><%= link_to 'Tracks', admin_track_list_path %></li> + <li><%= link_to 'Log out', signout_path %></li> + </ul> + </div> + </div> + </div> + </div> +</div> diff --git a/app/views/admin_general/admin.coffee b/app/views/admin_general/admin.coffee new file mode 100644 index 000000000..3d39369a4 --- /dev/null +++ b/app/views/admin_general/admin.coffee @@ -0,0 +1,24 @@ +jQuery -> + $('.locales a:first').tab('show') + $('.accordion-body').on('hidden', -> + $(@).prev().find('i').first().removeClass().addClass('icon-chevron-right') + ) + $('.accordion-body').on('shown', -> + $(@).prev().find('i').first().removeClass().addClass('icon-chevron-down')) + $('.toggle-hidden').live('click', -> + $(@).parents('td').find('div:hidden').show() + false) + $('#request_hidden_user_explanation_reasons input').live('click', -> + $('#request_hidden_user_subject, #request_hidden_user_explanation, #request_hide_button').show() + info_request_id = $('#hide_request_form').attr('data-info-request-id') + reason = $(this).val() + $('#request_hidden_user_explanation_field').attr("value", "[loading default text...]") + $.ajax "/hidden_user_explanation?reason=" + reason + "&info_request_id=" + info_request_id, + type: "GET" + dataType: "text" + error: (data, textStatus, jqXHR) -> + $('#request_hidden_user_explanation_field').attr("value", "Error: #{textStatus}") + success: (data, textStatus, jqXHR) -> + $('#request_hidden_user_explanation_field').attr("value", data) + ) + diff --git a/app/views/admin_general/admin.js b/app/views/admin_general/admin.js new file mode 100644 index 000000000..9daa51459 --- /dev/null +++ b/app/views/admin_general/admin.js @@ -0,0 +1,32 @@ +(function() { + jQuery(function() { + $('.locales a:first').tab('show'); + $('.accordion-body').on('hidden', function() { + return $(this).prev().find('i').first().removeClass().addClass('icon-chevron-right'); + }); + $('.accordion-body').on('shown', function() { + return $(this).prev().find('i').first().removeClass().addClass('icon-chevron-down'); + }); + $('.toggle-hidden').live('click', function() { + $(this).parents('td').find('div:hidden').show(); + return false; + }); + return $('#request_hidden_user_explanation_reasons input').live('click', function() { + var info_request_id, reason; + $('#request_hidden_user_subject, #request_hidden_user_explanation, #request_hide_button').show(); + info_request_id = $('#hide_request_form').attr('data-info-request-id'); + reason = $(this).val(); + $('#request_hidden_user_explanation_field').attr("value", "[loading default text...]"); + return $.ajax("/hidden_user_explanation?reason=" + reason + "&info_request_id=" + info_request_id, { + type: "GET", + dataType: "text", + error: function(data, textStatus, jqXHR) { + return $('#request_hidden_user_explanation_field').attr("value", "Error: " + textStatus); + }, + success: function(data, textStatus, jqXHR) { + return $('#request_hidden_user_explanation_field').attr("value", data); + } + }); + }); + }); +}).call(this); diff --git a/app/views/admin_general/admin_js.erb b/app/views/admin_general/admin_js.erb new file mode 100644 index 000000000..c8788a452 --- /dev/null +++ b/app/views/admin_general/admin_js.erb @@ -0,0 +1,34 @@ +(function() { + + jQuery(function() { + $('.locales a:first').tab('show'); + $('.accordion-body').on('hidden', function() { + return $(this).prev().find('i').first().removeClass().addClass('icon-chevron-right'); + }); + $('.accordion-body').on('shown', function() { + return $(this).prev().find('i').first().removeClass().addClass('icon-chevron-down'); + }); + $('.toggle-hidden').live('click', function() { + $(this).parents('td').find('div:hidden').show(); + return false; + }); + return $('#request_hidden_user_explanation_reasons input').live('click', function() { + var info_request_id, reason; + $('#request_hidden_user_subject, #request_hidden_user_explanation, #request_hide_button').show(); + info_request_id = $('#hide_request_form').attr('data-info-request-id'); + reason = $(this).val(); + $('#request_hidden_user_explanation_field').attr("value", "[loading default text...]"); + return $.ajax("/hidden_user_explanation?reason=" + reason + "&info_request_id=" + info_request_id, { + type: "GET", + dataType: "text", + error: function(data, textStatus, jqXHR) { + return $('#request_hidden_user_explanation_field').attr("value", "Error: " + textStatus); + }, + success: function(data, textStatus, jqXHR) { + return $('#request_hidden_user_explanation_field').attr("value", data); + } + }); + }); + }); + +}).call(this); diff --git a/app/views/admin_general/debug.rhtml b/app/views/admin_general/debug.html.erb index b0749bedb..bf984c2e1 100644 --- a/app/views/admin_general/debug.rhtml +++ b/app/views/admin_general/debug.html.erb @@ -2,14 +2,18 @@ <h1><%=@title%></h1> -<p>You are <%= h @admin_current_user %></p> +<p>You are <%= h @http_auth_user %></p> <h2>Version numbers</h2> <p> Alaveteli version: <%= link_to @current_version, @github_origin + @current_version %> <br> -Alaveteli branch: <%= link_to @current_branch, @github_origin + @current_branch %> +<% if @current_branch == "(no branch)" %> + Alaveteli branch: (no branch) +<% else %> + Alaveteli branch: <%= link_to @current_branch, @github_origin + @current_branch %> +<% end %> <br> Alaveteli commit: <%= link_to @current_commit, @github_origin + @current_commit %> <br> @@ -17,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.html.erb b/app/views/admin_general/index.html.erb new file mode 100644 index 000000000..b239a2b3f --- /dev/null +++ b/app/views/admin_general/index.html.erb @@ -0,0 +1,185 @@ +<% @title = "Summary" %> + +<div class="row"> + <div class="span12"> + <h1><%=@title%></h1> + + <ul> + <li><%=@public_body_count%> public authorities</li> + <li> + <%=@info_request_count%> requests, <%=@outgoing_message_count%> outgoing messages, + <%=@incoming_message_count%> incoming messages + </li> + <li><%=@user_count%> users, <%=@track_thing_count%> tracked things</li> + <li><%=@comment_count%> annotations</li> + </ul> + </div> +</div> + +<hr> + +<div class="row"> + <div class="span12"> + <h1>Things to do</h1> + </div> +</div> + +<div class="accordion" id="things-to-do"> + <% if @holding_pen_messages.size > 0 %> + <div class="accordion-group"> + <div class="accordion-heading"> + <a class="accordion-toggle" href="#holding-pen" data-toggle="collapse" data-parent="things-to-do"><span class="label label-important"><%=@holding_pen_messages.size%></span><%= chevron_right %> Put misdelivered responses with the right request</a> + </div> + <div id="holding-pen" class="accordion-body collapse"> + <table class="table table-striped table-condensed"> + <tbody> + <% for message in @holding_pen_messages %> + <tr> + <td> + <% if message.get_body_for_quoting.strip.size == 0 %> + <%= link_to "(no body)", admin_request_show_raw_email_path(message.raw_email_id) %> + <% else %> + <%= link_to excerpt(message.get_body_for_quoting, "", 60), admin_request_show_raw_email_path(message.raw_email_id) %> + <% end %> + </td> + <td class="span2"> + <%=simple_date(message.sent_at)%> + </td> + </tr> + <% end %> + </tbody> + </table> + </div> + </div> + <% end %> + + <% if @error_message_requests.size > 0 %> + <div class="accordion-group"> + <div class="accordion-heading"> + <a class="accordion-toggle" href="#error-messages" data-toggle="collapse" data-parent="things-to-do"><span class="label label-important"><%=@error_message_requests.size%></span> <%= chevron_right %>Fix these delivery and other errors</a> + </div> + <div id="error-messages" class="accordion-body collapse"> + <table class="table table-striped table-condensed"> + <tbody> + <% for @request in @error_message_requests %> + <tr> + <td class="link"> + <%= request_both_links(@request) %> + </td> + <td class="span2"> + <%=simple_date(@request.info_request_events.last.created_at)%> + </td> + </tr> + <% end %> + </tbody> + </table> + </div> + </div> + <% end %> + + <% if @attention_requests.size > 0 %> + <div class="accordion-group"> + <div class="accordion-heading"> + <a class="accordion-toggle" href="#attention-messages" data-toggle="collapse" data-parent="things-to-do"><span class="label label-important"><%=@attention_requests.size%></span><%= chevron_right %> Review requests marked by users as requiring your attention +</a> + </div> + <div id="attention-messages" class="accordion-body collapse"> + <table class="table table-striped table-condensed"> + <tbody> + <% for @request in @attention_requests %> + <tr> + <td class="link"> + <%= request_both_links(@request) %> + </td> + <td class="span2"> + <%=simple_date(@request.info_request_events.last.created_at)%> + </td> + </tr> + <% end %> + </tbody> + </table> + </div> + </div> + <% end %> + + <% if @requires_admin_requests.size > 0 %> + <div class="accordion-group"> + <div class="accordion-heading"> + <a class="accordion-toggle" href="#requires-admin" data-toggle="collapse" data-parent="things-to-do"><span class="label label-important"><%=@requires_admin_requests.size%></span><%= chevron_right %> These require administrator attention</a> + </div> + <div id="requires-admin" class="accordion-body collapse"> + <table class="table table-striped table-condensed"> + <tbody> + <% for @request in @requires_admin_requests %> + <tr> + <td class="link"> + <%= request_both_links(@request) %> + </td> + <td class="span2"> + <%=simple_date(@request.info_request_events.last.created_at)%> + </td> + </tr> + <% end %> + </tbody> + </table> + </div> + </div> + <% end %> + + <% if @blank_contacts.size > 0 %> + <div class="accordion-group"> + <div class="accordion-heading"> + <a class="accordion-toggle" href="#blank-contacts" data-toggle="collapse" data-parent="things-to-do"><span class="label label-important"><%=@blank_contacts.size%></span><%= chevron_right %> Find missing FOI email for these public authorities (try phoning!)</a> + </div> + <div id="blank-contacts" class="accordion-body collapse"> + <table class="table table-striped table-condensed"> + <tbody> + <% for @blank_contact in @blank_contacts %> + <tr> + <td class="link"> + <%= public_body_both_links(@blank_contact) %> + </td> + <td class="span2"> + <%=simple_date(@blank_contact.updated_at)%> + </td> + </tr> + <% end %> + </tbody> + </table> + </div> + </div> + <% end %> + + <% if @old_unclassified.size > 0 %> + <div class="accordion-group"> + <div class="accordion-heading"> + <a class="accordion-toggle" href="#unclassified" data-toggle="collapse" data-parent="things-to-do"><span class="label label-important"><%=@old_unclassified.size%></span><%= chevron_right %> Classify responses that are still unclassified <%=InfoRequest::OLD_AGE_IN_DAYS.inspect %> after response</a> + </div> + <div id="unclassified" class="accordion-body collapse"> + <table class="table table-striped table-condensed"> + <tbody> + <% for @request in @old_unclassified %> + <tr> + <td class="link"> + <%= request_both_links(@request) %> + </td> + <td class="span2"> + <%=simple_date(@request.get_last_response_event.created_at)%> + </td> + </tr> + <% end %> + </tbody> + + </table> + </div> + </div> + <% end %> +</div> + +<% if @holding_pen_messages.size == 0 && @old_unclassified.size == 0 && @requires_admin_requests.size == 0 && @blank_contacts.size == 0 && @attention_requests.size == 0 %> + <div class="row"> + <div class="span12 alert alert-success"> + No pending administration required. + </div> + </div> +<% end %> diff --git a/app/views/admin_general/index.rhtml b/app/views/admin_general/index.rhtml deleted file mode 100644 index 48bd7f694..000000000 --- a/app/views/admin_general/index.rhtml +++ /dev/null @@ -1,109 +0,0 @@ -<% @title = "Summary" %> - -<h1><%=@title%></h1> - -<ul> -<li><%=@public_body_count%> public authorities</li> -<li><%=@info_request_count%> requests, <%=@outgoing_message_count%> outgoing messages, - <%=@incoming_message_count%> incoming messages -</li> -<li><%=@user_count%> users, <%=@track_thing_count%> tracked things</li> -<li><%=@comment_count%> annotations</li> -</ul> - -<hr> - -<h1>Things to do</h1> - -<% if @holding_pen_messages.size > 0 %> - <h3>Put misdelivered responses with the right request (<%=@holding_pen_messages.size%> total)</h3> - - <ul> - <% for message in @holding_pen_messages %> - <li> - <% if message.get_body_for_quoting.strip.size == 0 %> - <%= link_to "(no body)", "request/show_raw_email/" + message.raw_email_id.to_s %> - <% else %> - <%= link_to excerpt(message.get_body_for_quoting, "", 60), "request/show_raw_email/" + message.raw_email_id.to_s %> - <% end %> - (<%=simple_date(message.sent_at)%>) - </li> - <% end %> - </ul> - -<% end %> - -<% if @error_message_requests.size > 0 %> - <h3>Fix these delivery and other errors (<%=@error_message_requests.size%> total)</h3> - - <ul> - <% for @request in @error_message_requests %> - <li> - <%= request_both_links(@request)%> - – <%=simple_date(@request.get_last_event.created_at)%> - </li> - <% end %> - </ul> -<% end %> - -<% if @attention_requests.size > 0 %> - <h3>Review requests which have been marked as requiring your attention by users (<%=@error_message_requests.size%> total)</h3> - - <ul> - <% for @request in @attention_requests %> - <li> - <%= request_both_links(@request)%> - – <%=simple_date(@request.get_last_event.created_at)%> - </li> - <% end %> - </ul> -<% end %> - - -<% if @requires_admin_requests.size > 0 %> - <h3>These require administrator attention (<%=@requires_admin_requests.size%> total)</h3> - - <ul> - <% for @request in @requires_admin_requests %> - <li> - <%= request_both_links(@request)%> - – <%=simple_date(@request.get_last_event.created_at)%> - </li> - <% end %> - </ul> -<% end %> - -<% if @blank_contacts.size > 0 %> - <h3>Find missing FOI email for these public authorities (try phoning!) (<%=@blank_contacts.size%> total)</h3> - <ul> - <% for @blank_contact in @blank_contacts %> - <li> - <%= public_body_both_links(@blank_contact)%> - – <%=simple_date(@blank_contact.updated_at)%> - </li> - <% end %> - </ul> -<% end %> - -<% if @old_unclassified.size > 0 %> - <h3>Classify responses that are still unclassified <%=InfoRequest::OLD_AGE_IN_DAYS.inspect %> after response</h3> - - <ul> - <% for @request in @old_unclassified %> - <li> - <%= request_both_links(@request) %> - – <%=simple_date(@request.get_last_response_event.created_at)%> - </li> - <% end %> - </ul> - - <p>(<%= link_to "Full list", admin_url("unclassified") %>, or play public - <%= link_to "Categorisation game", main_url(play_url(:only_path => true)) %>) - </p> -<% end %> - -<% if @holding_pen_messages.size == 0 && @old_unclassified.size == 0 && @requires_admin_requests.size == 0 && @blank_contacts.size == 0 %> - <p>No pending administration required.</p> -<% end %> - - diff --git a/app/views/admin_general/stats.html.erb b/app/views/admin_general/stats.html.erb new file mode 100644 index 000000000..27dc25ee0 --- /dev/null +++ b/app/views/admin_general/stats.html.erb @@ -0,0 +1,60 @@ +<% @title = "Statistics" %> +<div class="hero-unit"> + <h2><%=@public_body_count%> public authorities</h2> + <h2><%=@info_request_count%> requests, <%=@outgoing_message_count%> outgoing messages, <%=@incoming_message_count%> incoming messages</h2> + <h2><%=@user_count%> users, <%=@track_thing_count%> tracked things</h2> + <h2><%=@comment_count%> annotations</h2> +</div> + +<div class="row"> + <div class="span12"> + <h1>Statistics</h1> + <h2>Chart of requests (excluding backpaged)</h2> + <img src="/foi-live-creation.png" alt="Chart of requests"> + </div> +</div> +<div class="row"> + <div class="span12"> + <h2>State of requests (includes backpaged)</h2> + <div class="container"> + <% for state, count in @request_by_state %> + <div class="row"> + <div class="span1"> + <span class="label label-info"><%=count%></span> + </div> + <div class="span4"> + <%=state%> + </div> + </div> + <% end %> + </div> + </div> +</div> +<div class="row"> + <div class="span12"> + <h2>Chart of users</h2> + <img src="/foi-user-use.png" alt="Chart of users"> + </div> +</div> +<div class="row"> + <div class="span12"> + <h2>Tracks by type</h2> + <div class="container"> + <% for state, count in @tracks_by_type %> + <div class="row"> + <div class="span1"> + <span class="label label-info"><%=count%></span> + </div> + <div class="span4"> + <%=state%> + </div> + </div> + <% end %> + </div> + </div> +</div> +<div class="row"> + <div class="span12"> + <h2>Web analytics</h2> + </div> +</div> diff --git a/app/views/admin_general/stats.rhtml b/app/views/admin_general/stats.rhtml deleted file mode 100644 index b22adb581..000000000 --- a/app/views/admin_general/stats.rhtml +++ /dev/null @@ -1,38 +0,0 @@ -<% @title = "Statistics" %> - -<h1>Statistics</h1> - -<h2>Chart of requests (excluding backpaged)</h2> - -<p> - <img src="<%= main_url("/foi-live-creation.png")%>"> -</p> - -<h2>State of requests (includes backpaged)</h2> - -<table> -<% for state, count in @request_by_state %> -<tr> <td><%=state %></td><td><%= count %></td> </tr> -<% end %> -</table> - -<h2>Chart of users</h2> - -<p> - <img src="<%= main_url("/foi-user-use.png")%>"> -</p> - -<h2>Tracks by type</h2> - -<table> -<% for state, count in @tracks_by_type %> -<tr> <td><%=state %></td><td><%= count %></td> </tr> -<% end %> -</table> - -<h2>Web analytics</h2> - - -</p> - - diff --git a/app/views/admin_general/timeline.rhtml b/app/views/admin_general/timeline.html.erb index e84539970..8fd8875b6 100644 --- a/app/views/admin_general/timeline.rhtml +++ b/app/views/admin_general/timeline.html.erb @@ -1,14 +1,19 @@ <% @title = "Timeline" %> - -<h1><%=h @events_title%></h1> - -<p> -<a href="?hour=1">Hour</a> -| <a href="?day=1">Day</a> -| <a href="?">2 days</a> -| <a href="?week=1">Week</a> -| <a href="?month=1">Month</a> -| <a href="?all=1">All time</a></p> +<div class="btn-toolbar"> + <div class="btn-group"> + <%= link_to "Hour", admin_timeline_path(:hour => 1), :class => "btn" %> + <%= link_to "Day", admin_timeline_path(:day => 1), :class => "btn" %> + <%= link_to "2 days", admin_timeline_path, :class => "btn" %> + <%= link_to "Week", admin_timeline_path(:week => 1), :class => "btn" %> + <%= link_to "Month", admin_timeline_path(:month => 1), :class => "btn" %> + <%= link_to "All time", admin_timeline_path(:all => 1), :class => "btn" %> + </div> +</div> +<div class="row"> + <div class="span12"> + <h1><%=h @events_title%></h1> + </div> +</div> <% last_date = nil %> <% for event, event_at in @events %> @@ -72,7 +77,7 @@ <% elsif event.event_type == 'response' %> <% incoming_message = event.incoming_message %> received - <%= link_to 'a response', main_url(incoming_message_url(incoming_message)) %> + <%= link_to 'a response', incoming_message_path(incoming_message) %> from <%=h event.info_request.public_body.name %>. <% elsif event.event_type == 'sent' %> was initially sent to <%=h event.params[:email]%> at <%=h event.info_request.public_body.name %>. @@ -92,8 +97,7 @@ was created/updated by administrator <strong><%=h event.last_edit_editor %></strong> <% end %> <% end %> +<%= will_paginate(@events, :class => 'paginator') %> <% if not @events.empty? %> </p> <% end %> -<%= will_paginate(@events) %> - diff --git a/app/views/admin_public_body/_form.html.erb b/app/views/admin_public_body/_form.html.erb new file mode 100644 index 000000000..c577d1e18 --- /dev/null +++ b/app/views/admin_public_body/_form.html.erb @@ -0,0 +1,98 @@ +<%= error_messages_for 'public_body' %> + +<!--[form:public_body]--> + +<div id="div-locales"> + <ul class="locales nav nav-tabs"> + <% I18n.available_locales.each_with_index do |locale, i| %> + <li><a href="#div-locale-<%=locale.to_s%>" data-toggle="tab" ><%=locale_name(locale.to_s) || _("Default locale")%></a></li> + <% end %> + </ul> + <div class="tab-content"> +<% + for locale in I18n.available_locales do + if locale==I18n.default_locale # The default locale is submitted as part of the bigger object... + prefix = 'public_body' + object = @public_body + else # ...but additional locales go "on the side" + prefix = "public_body[translated_versions][]" + object = @public_body.new_record? ? + PublicBody::Translation.new : + @public_body.find_translation_by_locale(locale.to_s) || PublicBody::Translation.new + end +%> + <%= 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 %> + <label for="<%= form_tag_id(t.object_name, :name, locale) %>" class="control-label">Name</label> + <div class="controls"> + <%= t.text_field :name, :id => form_tag_id(t.object_name, :name, locale), :class => "span4" %> + </div> + </div> + <div class="control-group"> + <label for="<%= form_tag_id(t.object_name, :short_name, locale) %>", class="control-label"><%=_("Short name")%></label> + <div class="controls"> + <%= t.text_field :short_name, :id => form_tag_id(t.object_name, :short_name, locale), :class => "span2" %> + <p class="help-block"><%=_("Only put in abbreviations which are really used, otherwise leave blank. Short or long name is used in the URL – don't worry about breaking URLs through renaming, as the history is used to redirect")%></p> + </div> + </div> + <div class="control-group"> + <label for="<%= form_tag_id(t.object_name, :request_email, locale) %>" class="control-label"><%=_("Request email")%></label> + <div class="controls"> + <%= t.text_field :request_email, :id => form_tag_id(t.object_name, :request_email, locale), :class => "span3" %> + <p class="help-block"><%=_("set to <strong>blank</strong> (empty string) if can't find an address; these emails are <strong>public</strong> as anyone can view with a CAPTCHA")%></p> + </div> + </div> + <div class="control-group"> + <label for="<%= form_tag_id(t.object_name, :publication_scheme, locale) %>" class="control-label"><%=_("Publication scheme URL")%></label> + <div class="controls"> + <%= t.text_field :publication_scheme, :size => 60, :id => form_tag_id(t.object_name, :publication_scheme, locale), :class => "span3" %> + </div> + </div> + <div class="control-group"> + <label for="<%= form_tag_id(t.object_name, :disclosure_log, locale) %>" class="control-label"><%=_("Disclosure log URL")%></label> + <div class="controls"> + <%= t.text_field :disclosure_log, :size => 60, :id => form_tag_id(t.object_name, :disclosure_log, locale), :class => "span3" %> + </div> + </div> + <div class="control-group"> + <label for="<%= form_tag_id(t.object_name, :notes, locale) %>" class="control-label"><%=_("Public notes")%></label> + <div class="controls"> + <%= t.text_area :notes, :rows => 3, :id => form_tag_id(t.object_name, :notes, locale), :class => "span6" %> + <p class="help-block"> + HTML, for users to consider when making FOI requests to the authority + </p> + </div> + </div> + </div> +<% + end + end +%> + </div> +</div> + +<h3>Common Fields</h3> +<div class="control-group"> + <label for="public_body_tag_string" class="control-label"><%=_("Tags")%></label> + <div class="controls"> + <%= f.text_field :tag_string, :class => "span4" %> + <p class="help-block">space separated; see list of tags on the right; also <strong>not_apply</strong> if FOI and EIR no longer apply to authority, <strong>eir_only</strong> if EIR but not FOI applies to authority, <strong>defunct</strong> if the authority no longer exists; charity:NUMBER if a registered charity</p> + </div> +</div> +<div class="control-group"> + <label for="public_body_home_page"><%=_("Home page")%></label> + <div class="controls"> + <%= f.text_field :home_page, :class => "span4" %> + <p class="help-block">(of whole authority, not just their FOI page; set to <strong>blank</strong> (empty string) to guess it from the email)</p> + </div> +</div> +<div class="control-group"> + <label for="public_body_last_edit_comment" class="control-label"><strong>Comment</strong> for this edit</label> + <div class="controls"> + <%= f.text_area :last_edit_comment, :rows => 3, :class => "span6" %></p> + <p class="help-block">put URL or other source of new info</p> + </div> +</div> +<!--[eoform:public_body]--> diff --git a/app/views/admin_public_body/_form.rhtml b/app/views/admin_public_body/_form.rhtml deleted file mode 100644 index 0d6ae51e2..000000000 --- a/app/views/admin_public_body/_form.rhtml +++ /dev/null @@ -1,65 +0,0 @@ -<%= error_messages_for 'public_body' %> - -<!--[form:public_body]--> - -<div id="div-locales"> - <ul> - <% for locale in I18n.available_locales do %> - <li><a href="#div-locale-<%=locale.to_s%>"><%=locale_name(locale.to_s)%></a></li> - <% end %> - </ul> - -<% - for locale in I18n.available_locales do - if locale==I18n.default_locale # The default locale is submitted as part of the bigger object... - prefix = 'public_body' - object = @public_body - else # ...but additional locales go "on the side" - prefix = "public_body[translated_versions][]" - object = @public_body.new_record? ? - PublicBody::Translation.new : - @public_body.translation(locale.to_s) || PublicBody::Translation.new - end - - fields_for prefix, object do |t| -%> - <div id="div-locale-<%=locale.to_s%>"> - <%= t.hidden_field :locale, :value => locale.to_s %> - - <p><label for="<%= form_tag_id(t.object_name, :name, locale) %>">Name</label><br/> - <%= t.text_field :name, :size => 60, :id => form_tag_id(t.object_name, :name, locale) %></p> - - <p><label for="<%= form_tag_id(t.object_name, :short_name, locale) %>">Short name <small>(only put in abbreviations which are really used, otherwise leave blank. Short or long name is used in the URL - don't worry about breaking URLs through renaming, as the history is used to redirect)</small></label><br/> - <%= t.text_field :short_name, :size => 60, :id => form_tag_id(t.object_name, :short_name, locale) %></p> - - <p><label for="<%= form_tag_id(t.object_name, :request_email, locale) %>">Request email <small>(set to <strong>blank</strong> (empty string) if can't find an address; these emails are <strong>public</strong> as anyone can view with a CAPTCHA)</small></label><br/> - <%= t.text_field :request_email, :size => 40, :id => form_tag_id(t.object_name, :request_email, locale) %></p> - - <p><label for="<%= form_tag_id(t.object_name, :publication_scheme, locale) %>">Publication scheme URL</label><br/> - <%= t.text_field :publication_scheme, :size => 60, :id => form_tag_id(t.object_name, :publication_scheme, locale) %></p> - - <p><label for="<%= form_tag_id(t.object_name, :disclosure_log, locale) %>">Disclosure log URL</label><br/> - <%= t.text_field :disclosure_log, :size => 60, :id => form_tag_id(t.object_name, :disclosure_log, locale) %></p> - - <p><label for="<%= form_tag_id(t.object_name, :notes, locale) %>">Public notes</label> <small>(HTML, for users to consider when making FOI requests to the authority)</small><br/> - <%= t.text_area :notes, :rows => 3, :cols => 60, :id => form_tag_id(t.object_name, :notes, locale) %></p> - </div> -<% - end - end -%> -</div> - -<h3>Common Fields</h3> - -<p><label for="public_body_tag_string">Tags <small>(space separated; see list of tags on the right; also <strong>not_apply</strong> if FOI and EIR no longer apply to authority, <strong>eir_only</strong> if EIR but not FOI applies to authority, <strong>defunct</strong> if the authority no longer exists; charity:NUMBER if a registered charity)</small></label><br/> - -<%= text_field :public_body, :tag_string, :size => 60, :id => 'public_body_tag_string' %></p> - -<p><label for="public_body_home_page">Home page <small>(of whole authority, not just their FOI page; set to <strong>blank</strong> (empty string) to guess it from the email)</small></label><br/> -<%= text_field :public_body, :home_page, :size => 60, :id => 'public_body_home_page' %></p> - -<p><label for="public_body_last_edit_comment"><strong>Comment</strong> for this edit</label> <small>(put URL or other source of new info)</small><br/> -<%= text_area :public_body, :last_edit_comment, :rows => 3, :cols => 60, :id => 'public_body_last_edit_comment' %></p> - -<!--[eoform:public_body]--> diff --git a/app/views/admin_public_body/_locale_selector.rhtml b/app/views/admin_public_body/_locale_selector.rhtml deleted file mode 100644 index 5ef79f2df..000000000 --- a/app/views/admin_public_body/_locale_selector.rhtml +++ /dev/null @@ -1,10 +0,0 @@ -<div id="locale_switcher"> -<%= _('Edit language version:') %> -<% for possible_locale in @locales %> - <% if possible_locale == @locale %> - <%= possible_locale %> - <% else %> - <a href="?show_locale=<%=possible_locale%>"><%= possible_locale %></a> - <% end %> -<% end %> -</div> diff --git a/app/views/admin_public_body/_one_list.html.erb b/app/views/admin_public_body/_one_list.html.erb new file mode 100644 index 000000000..8f1d719ec --- /dev/null +++ b/app/views/admin_public_body/_one_list.html.erb @@ -0,0 +1,44 @@ +<div class="accordion" id="bodies"> + <% for public_body in bodies %> + <div class="accordion-group"> + <div class="accordion-heading accordion-toggle row"> + <span class="item-title span6"> + <a href="#body_<%=public_body.id%>" data-toggle="collapse" data-parent="requests"><%= chevron_right %></a> + <%= link_to(public_body.name, admin_body_show_path(public_body), :title => "view full details")%> + </span> + <span class="item-metadata span6"> + <%= render :partial => 'tags', :locals => { :body => public_body} %> + </span> + </div> + <div id="body_<%=public_body.id%>" class="item-detail accordion-body collapse row"> + <% public_body.for_admin_column do |name, value, type| %> + <div> + <span class="span6"> + <b><%=name%></b> + </span> + <span class="span6"> + <% if type == 'datetime' %> + <%= I18n.l(value, :format => "%e %B %Y %H:%M:%S") %> + (<%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(value)) %>) + <% else %> + <%= h value %> + <% end %> + </span> + </div> + <% end %> + </div> + </div> + <% end %> +</div> + +<%= 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 } ) %> + <%= hidden_field_tag(:page, params[:page], { :id => "mass_add_page_" + table_name } ) %> + <%= hidden_field_tag(:table_name, table_name, { :id => "mass_add_tag_table_name_" + table_name } ) %> + <%= submit_tag "Add tag to all", :class => "btn btn-primary" %> + (in table just above) + </p> +<% end %> + diff --git a/app/views/admin_public_body/_one_list.rhtml b/app/views/admin_public_body/_one_list.rhtml deleted file mode 100644 index e0d2399d0..000000000 --- a/app/views/admin_public_body/_one_list.rhtml +++ /dev/null @@ -1,29 +0,0 @@ -<table> - <tr> - <th>Name</th> - <th>Tags</th> - <% for column in PublicBody.content_columns.map { |c| c.human_name } - [ "Name", "Last edit comment" ] %> - <th><%= column %></th> - <% end %> - </tr> -<% for public_body in bodies %> - <tr class="<%= cycle('odd', 'even') %>"> - <td><%= public_body_both_links(public_body) %></td> - <td><%= render :partial => 'tags', :locals => { :body => public_body} %></td> - <% for column in PublicBody.content_columns.map { |c| c.name } - [ "name", "last_edit_comment" ] %> - <td><%=h public_body.send(column) %></td> - <% end %> - </tr> -<% end %> -</table> - -<% form_tag(admin_url("body/mass_tag_add"), :method => "post", :class => "forms_on_one_line" ) 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 } ) %> - <%= hidden_field_tag(:page, params[:page], { :id => "mass_add_page_" + table_name } ) %> - <%= hidden_field_tag(:table_name, table_name, { :id => "mass_add_tag_table_name_" + table_name } ) %> - <%= submit_tag "Add tag to all" %> (in table just above) - </p> -<% end %> - diff --git a/app/views/admin_public_body/_tag_help.html.erb b/app/views/admin_public_body/_tag_help.html.erb new file mode 100644 index 000000000..b64e65877 --- /dev/null +++ b/app/views/admin_public_body/_tag_help.html.erb @@ -0,0 +1,16 @@ +<h2>List of tags</h2> +<% first_row = true %> +<% for row in PublicBodyCategories::get().with_headings() %> + <% if row.instance_of?(Array) %> + <% if row[0] != 'other' %> + <strong><%= row[0] %></strong>=<%= row[1] %> + <br/> + <% end %> + <% elsif row != 'Miscellaneous' %> + <% if not first_row %> + <% else %> + <% first_row = false %> + <% end %> + <h3><%=h row%></h3> + <% end %> +<% end %> diff --git a/app/views/admin_public_body/_tag_help.rhtml b/app/views/admin_public_body/_tag_help.rhtml deleted file mode 100644 index 0d0f84dda..000000000 --- a/app/views/admin_public_body/_tag_help.rhtml +++ /dev/null @@ -1,18 +0,0 @@ -<div id="tag_help"> - <h2>List of tags</h2> - <% first_row = true %> - <% for row in PublicBodyCategories::get().with_headings() %> - <% if row.instance_of?(Array) %> - <% if row[0] != 'other' %> - <strong><%= row[0] %></strong>=<%= row[1] %> - <br/> - <% end %> - <% elsif row != 'Miscellaneous' %> - <% if not first_row %> - <% else %> - <% first_row = false %> - <% end %> - <h3><%=h row%></h3> - <% end %> - <% end %> -</div>
\ No newline at end of file diff --git a/app/views/admin_public_body/_tags.html.erb b/app/views/admin_public_body/_tags.html.erb new file mode 100644 index 000000000..26526f304 --- /dev/null +++ b/app/views/admin_public_body/_tags.html.erb @@ -0,0 +1,12 @@ +<% for t in body.tags %> + <span class="label label-info tag"> + <% if t.value %> + <%= link_to(h(t.name), list_public_bodies_path(:tag => t.name)) %>:<%= link_to(h(t.value), list_public_bodies_path(:tag => t.name_and_value)) %> + <% else %> + <%= link_to(h(t.name), list_public_bodies_path(:tag => t.name)) %> + <% end %> + </span> +<% end %> + + + diff --git a/app/views/admin_public_body/_tags.rhtml b/app/views/admin_public_body/_tags.rhtml deleted file mode 100644 index 85dc942fd..000000000 --- a/app/views/admin_public_body/_tags.rhtml +++ /dev/null @@ -1,11 +0,0 @@ -<% for t in body.tags %> - <% if t.value %> - <%= link_to(h(t.name), main_url(list_public_bodies_url(:tag => t.name, :only_path => true))) %>:<%= link_to(h(t.value), main_url(list_public_bodies_url(:tag => t.name_and_value, :only_path => true))) %> - <% else %> - <%= link_to(h(t.name), main_url(list_public_bodies_url(:tag => t.name, :only_path => true))) %> - <% end %> - (<a href="<%= admin_url('body/list') %>?query=<%= h(t.name)%>">admin</a>) -<% end %> - - - diff --git a/app/views/admin_public_body/edit.html.erb b/app/views/admin_public_body/edit.html.erb new file mode 100644 index 000000000..11b7eec22 --- /dev/null +++ b/app/views/admin_public_body/edit.html.erb @@ -0,0 +1,34 @@ +<h1><%=@title%></h1> + +<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| %> + <%= render :partial => 'form', :locals => {:f => f} %> + <div class="form-actions"> + <%= f.submit 'Save', :accesskey => 's', :class => "btn btn-success" %></p> + </div> + <% end %> + + <div class="row"> + <div class="span8"> + <div class="well"> + <%= link_to 'Show', admin_body_show_path(@public_body), :class => "btn" %> + <%= link_to 'List all', admin_body_list_path, :class => "btn" %> + </div> + </div> + </div> + + <% if @public_body.info_requests.empty? %> + <%= 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 %> + <% end %> + </div> + + </div> + <div class="span4"> + <%= render :partial => 'tag_help' %> + </div> +</div> diff --git a/app/views/admin_public_body/edit.rhtml b/app/views/admin_public_body/edit.rhtml deleted file mode 100644 index b19477a6b..000000000 --- a/app/views/admin_public_body/edit.rhtml +++ /dev/null @@ -1,30 +0,0 @@ -<h1><%=@title%></h1> - -<script type="text/javascript"> - $(function() { - $("#div-locales").tabs(); - }); -</script> - -<%= render :partial => 'tag_help' %> - -<div id="public_body_form"> - <% form_tag '../update/' + @public_body.id.to_s do %> - <%= render :partial => 'form' %> - <p><%= submit_tag 'Save', :accesskey => 's' %></p> - <% end %> - - <p> - <%= link_to 'Show', '../show/' + @public_body.id.to_s %> | - <%= link_to 'List all', '../list' %> - </p> - - <% if @public_body.info_requests.size == 0 %> - <% form_tag('../destroy/' + @public_body.id.to_s) do %> - <p> - <%= hidden_field_tag(:public_body_id, { :value => @public_body.id } ) %> - <%= submit_tag "Destroy " + @public_body.name %> (this is permanent!) - </p> - <% end %> - <% end %> -</div> diff --git a/app/views/admin_public_body/import_csv.rhtml b/app/views/admin_public_body/import_csv.html.erb index 1c6100838..afda5a468 100644 --- a/app/views/admin_public_body/import_csv.rhtml +++ b/app/views/admin_public_body/import_csv.html.erb @@ -9,18 +9,18 @@ <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: - <%= @original_csv_file %> - <%= hidden_field_tag :original_csv_file, @original_csv_file %> - <%= hidden_field_tag :temporary_csv_file, @temporary_csv_file %> - <%= link_to 'Clear current file', 'import_csv', :class => "btn btn-warning" %> - <% else %> - <label for="csv_file">CSV file:</label> - <%= file_field_tag :csv_file, :size => 40 %> - <% end %> + <% if @original_csv_file && @temporary_csv_file %> + CSV file: + <%= @original_csv_file %> + <%= hidden_field_tag :original_csv_file, @original_csv_file %> + <%= hidden_field_tag :temporary_csv_file, @temporary_csv_file %> + <%= link_to 'Clear current file', 'import_csv', :class => "btn btn-warning" %> + <% else %> + <label for="csv_file">CSV file:</label> + <%= file_field_tag :csv_file, :size => 40 %> + <% end %> </p> <p> @@ -32,14 +32,15 @@ <label for="tag_behaviour">What to do with existing tags?</label> <%= select_tag 'tag_behaviour', "<option value='add' selected>Add new tags to existing ones</option> - <option value='replace'>Replace existing tags with new ones</option>".html_safe + <option value='replace'>Replace existing tags with new ones</option>" %> </p> - <p><strong>CSV file format:</strong> A first row with the list of fields, - starting with '#', is optional but highly recommended. The fields 'name' - and 'request_email' are required; additionally, translated values are supported by - adding the locale name to the field name, e.g. 'name.es', 'name.de'... Example: + <p><strong>CSV file format:</strong>The first row should be a list + of fields, starting with '#'. The fields 'name' and + 'request_email' are required; additionally, translated values are + supported by adding the locale name to the field name, + e.g. 'name.es', 'name.de'... Example: </p> <blockquote> @@ -57,7 +58,7 @@ actually altering the database. Choose <strong>upload</strong> to actually make the changes. In either case, you will be shown any errors, or details of the changes. When uploading, any changes since last import will be - overwritten - e.g. email addresses changed back. + overwritten – e.g. email addresses changed back. </p> <p><strong>Note:</strong> The import tag will also be added to the imported bodies diff --git a/app/views/admin_public_body/list.html.erb b/app/views/admin_public_body/list.html.erb new file mode 100644 index 000000000..3d7d9c4cd --- /dev/null +++ b/app/views/admin_public_body/list.html.erb @@ -0,0 +1,42 @@ +<% if @query.nil? %> + <% @title = _('Listing public authorities') %> +<% else %> + <% @title = _("Listing public authorities matching '{{query}}'", :query => @query ) %> +<% end %> + +<h1><%=@title%></h1> + +<div class="btn-toolbar"> + <div class="btn-group"> + <%= link_to 'New public authority', admin_body_new_path, :class => "btn btn-primary" %> + </div> + <div class="btn-group"> + <%= link_to 'Import from CSV file', admin_body_import_csv_path, :class => "btn btn-warning" %> + </div> +</div> + +<%= 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? %> + <%= link_to 'Show all', admin_body_list_path, :class => "btn" %> + <% end %><br> + (substring search in names and emails; exact match of tags) +<% end %> + + +<% if @public_bodies_by_tag.size > 0 %> + <h2>Exact tag matches (<%= @public_bodies_by_tag.size %> total)</h2> + <%= render :partial => 'one_list', :locals => { :bodies => @public_bodies_by_tag, :table_name => 'exact' } %> +<% end %> + +<% if @public_bodies.size > 0 %> + <% if @query.nil? %> + <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 %> + +<%= will_paginate(@public_bodies, :class => "paginator") %> diff --git a/app/views/admin_public_body/list.rhtml b/app/views/admin_public_body/list.rhtml deleted file mode 100644 index c28060604..000000000 --- a/app/views/admin_public_body/list.rhtml +++ /dev/null @@ -1,40 +0,0 @@ -<% if @query.nil? %> - <% @title = 'Listing public authorities' %> -<% else %> - <% @title = "Listing public authorities matching '" + @query + "'" %> -<% end %> - -<h1><%=@title%></h1> - -<p> - <% if !@query.nil? %> - <%= link_to 'Show all', 'list' %> | - <% end %> - <%= link_to 'New public authority', 'new' %> - | <%= link_to 'Import from CSV file', 'import_csv' %> -</p> - -<% form_tag("", :method => "get") do %> - <p> - <%= text_field_tag 'query', params[:query], { :size => 30 } %> - <%= submit_tag "Search" %> (substring search in names and emails; exact match of tags) - </p> -<% end %> - - -<% if @public_bodies_by_tag.size > 0 %> - <h2>Exact tag matches (<%= @public_bodies_by_tag.size %> total)</h2> - <%= render :partial => 'one_list', :locals => { :bodies => @public_bodies_by_tag, :table_name => 'exact' } %> -<% end %> - -<% if @public_bodies.size > 0 %> - <% if @query.nil? %> - <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 %> - -<%= will_paginate(@public_bodies) %> - 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.html.erb b/app/views/admin_public_body/new.html.erb new file mode 100644 index 000000000..13e8238d6 --- /dev/null +++ b/app/views/admin_public_body/new.html.erb @@ -0,0 +1,23 @@ +<% @title = 'New public authority' %> + +<h1><%=@title%></h1> +<div class="row"> + <div class="span8"> + <div id="public_body_form"> + <%= 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" %> + </div> + <% end %> + <div class="row"> + <div class="span8 well"> + <%= link_to _('List all'), 'list' %> + </div> + </div> + </div> + </div> + <div class="span4"> + <%= render :partial => 'tag_help' %> + </div> +</div> diff --git a/app/views/admin_public_body/new.rhtml b/app/views/admin_public_body/new.rhtml deleted file mode 100644 index 047d5a5bb..000000000 --- a/app/views/admin_public_body/new.rhtml +++ /dev/null @@ -1,22 +0,0 @@ -<% @title = 'New public authority' %> - -<h1><%=@title%></h1> - -<script type="text/javascript"> - $(function() { - $("#div-locales").tabs(); - }); -</script> - -<%= render :partial => 'tag_help' %> - -<div id="public_body_form"> - <% form_tag './create/' + @public_body.id.to_s do %> - <%= render :partial => 'form' %> - <p><%= submit_tag "Create" %></p> - <% end %> - - <p> - <%= link_to 'List all', 'list' %> - </p> -</div> diff --git a/app/views/admin_public_body/show.html.erb b/app/views/admin_public_body/show.html.erb new file mode 100644 index 000000000..cfb10b24e --- /dev/null +++ b/app/views/admin_public_body/show.html.erb @@ -0,0 +1,89 @@ +<% @title = _("Public authority – {{name}}", :name => h(@public_body.name)) %> + +<h1><%=@title%></h1> + +<table class="table table-striped table-condensed"> + <tbody> + <% @public_body.for_admin_column do |name, value, type, column_name| %> + <tr> + <td> + <b><%=name%></b> + </td> + <td> + <% if ['home_page', 'publication_scheme', 'disclosure_log'].include? column_name %> + <%= link_to(h(value), value) %> + <% elsif column_name == 'request_email' %> + <%= link_to(h(value), "mailto:#{value}") %> + <% unless @public_body.is_requestable? %> + <%=_("not requestable due to: {{reason}}", :reason => h(@public_body.not_requestable_reason))%><% if @public_body.is_followupable? %>; <%=_("but followupable")%><% end %> + <% end %> + <% else %> + <%=h value %> + <% end %> + </td> + </tr> + <% end %> + <tr> + <td> + <b><%=_("Calculated home page")%></b> + </td> + <td> + <% unless @public_body.calculated_home_page.nil? %> + <%= link_to(h(@public_body.calculated_home_page), @public_body.calculated_home_page) %> + <% else %> + <%=_("*unknown*")%> + <% end %> + </td> + </tr> + <tr> + <td> + <b><%=_("Tags")%></b> + </td> + <td> + <%= render :partial => 'tags', :locals => { :body => @public_body} %> + </td> + </tr> + </tbody> +</table> +<%= link_to _("Edit"), admin_body_edit_path(@public_body), :class => "btn btn-primary" %> +<% unless @public_body.url_name.nil? %> + <%=link_to _("Public page"), public_body_path(@public_body), :class => "btn" %> +<% else %> + <%=_("Public page not available")%> +<% end %> +<hr> +<h2>History</h2> +<%# There may be an option to versions() to specify order, but I can't find it. TB 2009-03-09 %> +<% versions = @public_body.reverse_sorted_versions; versions.each_with_index do |historic_public_body, i| %> + <div class="row"> + <div class="span2"> + <b> + <%= _("Version {{version}}", :version => historic_public_body.version)%> + </b> + </div> + <div class="span4"> + <%= I18n.l(historic_public_body.updated_at, :format => "%e %B %Y %H:%M:%S") %> + (<%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(historic_public_body.updated_at)) %>) + </div> + <% if i == versions.length - 1 %> + <div class="span6"> + <%=_("This is the first version.")%> + </div> + <% else %> + <div class="span6"> + <p>“<%= h(historic_public_body.last_edit_comment) %>”</p> + <ul> + <% historic_public_body.compare(versions[i+1]) do |change| %> + <li><%= _("{{thing_changed}} was changed from <code>{{from_value}}</code> to <code>{{to_value}}</code>", :thing_changed => change[:name], :from_value => (change[:from] or "-"), :to_value => (change[:to] or "-")) %></li> + <% end %> + </ul> + </div> + <% end %> + </div> +<% end %> +<hr> +<h2>Requests</h2> +<%= render :partial => 'admin_request/some_requests', :locals => { :info_requests => @public_body.info_requests } %> +<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_public_body/show.rhtml b/app/views/admin_public_body/show.rhtml deleted file mode 100644 index cee306988..000000000 --- a/app/views/admin_public_body/show.rhtml +++ /dev/null @@ -1,83 +0,0 @@ -<% @title = "Public authority - " + h(@public_body.name) %> - -<h1><%=@title%></h1> - -<p> -<% - columns = PublicBody.content_columns + [] # force dup - columns.delete_if {|c| ['last_edit_comment'].include?(c.name)} - - for column in columns %> - <b><%= column.human_name %>:</b> - <% if ['home_page', 'publication_scheme', 'disclosure_log'].include? column.name %> - <%= link_to(h(@public_body.send(column.name)), @public_body.send(column.name)) %> - <% elsif column.name == 'request_email' %> - <%= link_to(h(@public_body.send(column.name)), "mailto:#{@public_body.send(column.name)}") %> - <% if !@public_body.is_requestable? %> - (not requestable due to: <%=h @public_body.not_requestable_reason %><% if @public_body.is_followupable? %>; but followupable<% end %>) - <% end %> - <% else %> - <%=h @public_body.send(column.name) %> - <% end %> - <br/> -<% end %> -<b>Calculated home page:</b> -<% if !@public_body.calculated_home_page.nil? %> - <%= link_to(h(@public_body.calculated_home_page), @public_body.calculated_home_page) %> -<% else %> - *unknown* -<% end %> -<br/><b>Tags:</b> <%= render :partial => 'tags', :locals => { :body => @public_body} %> -<br/> -</p> - -<p> - <%= - # url_name can be missing if the name hasn't been set for this locale - if !@public_body.url_name.nil? - link_to 'Public page', main_url(public_body_url(@public_body)) - else - 'Public page not available' - end - %> - | <%= link_to 'Edit', '../edit/' + @public_body.id.to_s %> -</p> - -<h2>History</h2> -<table border="1"> -<tr> -<th>Updated at</th> -<% - history_columns = PublicBody.content_columns + [] # force dup - history_columns.delete_if {|c| ['created_at', 'updated_at', 'first_letter', 'api_key'].include?(c.name)} - for column in history_columns %> - <th><%= column.human_name %></th> -<% end %> -</tr> -<%# There may be an option to versions() to specify order, but I can't find it. TB 2009-03-09 %> -<% for historic_public_body in @public_body.reverse_sorted_versions %> - <tr class="<%= cycle('odd', 'even') %>"> - <td><%=h historic_public_body.updated_at %></td> - <% for column in history_columns %> - <% - value = h(historic_public_body.send(column.name)) - if column.name == 'last_edit_comment' - value = historic_public_body.last_edit_comment_for_html_display - end - # Highlight entries which have changed since previous version - changed = (!['version', 'last_edit_editor', 'last_edit_comment'].include?(column.name)) && ((historic_public_body.send(column.name) != @public_body.sorted_versions[historic_public_body.version - 2].send(column.name)) || (historic_public_body.version == 1)) %> - <td <%= changed ? ' class="entry_changed" '.html_safe: '' %> > - <%=value%> - </td> - <% end %> - </tr> -<% end %> -</table> - -<h2>Requests</h2> -<%= render :partial => 'admin_request/some_requests', :locals => { :info_requests => @public_body.info_requests } %> - -<h2>Track things</h2> -<%= render :partial => 'admin_track/some_tracks', :locals => { :track_things => @public_body.track_things } %> - - diff --git a/app/views/admin_request/_incoming_message_actions.html.erb b/app/views/admin_request/_incoming_message_actions.html.erb new file mode 100644 index 000000000..653e73337 --- /dev/null +++ b/app/views/admin_request/_incoming_message_actions.html.erb @@ -0,0 +1,45 @@ +<fieldset class="form-horizontal"> + <legend>Actions</legend> + <%= 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"> + <% if @info_requests && @info_requests.size == 1 %> + <%= text_field_tag 'url_title', @info_requests[0].url_title, { :size => 20, :id => "url_title_#{incoming_message.id}" } %> + <% else %> + <%= text_field_tag 'url_title', "", { :size => 20, :id => "url_title_#{incoming_message.id}" } %> + <% end %> + <%= hidden_field_tag 'redeliver_incoming_message_id', incoming_message.id, :id => nil %> + <%= submit_tag "Redeliver to another request", :class => "btn" %> + <p class="help-block"><code>id</code> or <code>url_title</code>; you can supply more than one, separated by commas</p> + </div> + </div> + <% end %> + <div class="control-group"> + <label class="control-label">Generate FOI officer upload URL</label> + <div class="controls"> + <%= link_to 'Generate and take me there', admin_request_generate_upload_url_path(incoming_message.info_request, :incoming_message_id => incoming_message.id), :class => "btn" %> + </div> + </div> + + <%= 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"> + <%= hidden_field_tag 'incoming_message_id', incoming_message.id, :id => nil %> + <%= submit_tag "Destroy message", :class => "btn btn-danger", :confirm => "This is permanent! Are you sure?", :id => "destroy_message_#{incoming_message.id}" %> + </div> + </div> + <% end %> + + <% if @raw_email.nil? %> + <%# we're not on the raw_email page itself %> + <div class="control-group"> + <label class="control-label">Inspect email</label> + <div class="controls"> + <%= link_to "View raw email", admin_request_show_raw_email_path(incoming_message.raw_email_id), :class => "btn" %> + </div> + </div> + <% end %> + +</fieldset> diff --git a/app/views/admin_request/_incoming_message_actions.rhtml b/app/views/admin_request/_incoming_message_actions.rhtml deleted file mode 100644 index 569132861..000000000 --- a/app/views/admin_request/_incoming_message_actions.rhtml +++ /dev/null @@ -1,26 +0,0 @@ -<% form_tag '../redeliver_incoming' do %> - <div> - id or url_title of request (or a list of requests, comma-separated): - <% if @info_requests && @info_requests.size == 1 %> - <%= text_field_tag 'url_title', @info_requests[0].url_title, { :size => 20 } %> - <% else %> - <%= text_field_tag 'url_title', "", { :size => 20 } %> - <% end %> - <%= hidden_field_tag 'redeliver_incoming_message_id', incoming_message.id %> - <%= submit_tag "Redeliver to another request" %> - </div> -<% end %> - -<p> -<%= link_to 'FOI officer upload URL', '../generate_upload_url/' + incoming_message.info_request.id.to_s + "?incoming_message_id=" + incoming_message.id.to_s %> -</p> - -<% form_tag '../destroy_incoming' do %> - <div> - <%= hidden_field_tag 'incoming_message_id', incoming_message.id %> - Warning, this is permanent! ---> - <%= submit_tag "Destroy message" %> - </div> -<% end %> - - diff --git a/app/views/admin_request/_some_requests.html.erb b/app/views/admin_request/_some_requests.html.erb new file mode 100644 index 000000000..cff94956d --- /dev/null +++ b/app/views/admin_request/_some_requests.html.erb @@ -0,0 +1,32 @@ +<div class="accordion" id="requests"> + <% for info_request in info_requests %> + <div class="accordion-group"> + <div class="accordion-heading accordion-toggle row"> + <span class="item-title span6"> + <a href="#request_<%=info_request.id%>" data-toggle="collapse" data-parent="requests"><%= chevron_right %></a> + <%= link_to(info_request.title, admin_request_show_path(info_request), :title => "view full details") %> + </span> + <span class="item-metadata span6"> + <%= user_admin_link_for_request(info_request) %> <%= arrow_right %> <%= link_to("#{info_request.public_body.name}", admin_body_show_path(info_request.public_body)) %>, <%= time_ago_in_words(info_request.updated_at) %> ago + </span> + </div> + <div id="request_<%=info_request.id%>" class="item-detail accordion-body collapse row"> + <% info_request.for_admin_column do | name, value, type | %> + <div> + <span class="span6"> + <%= h name %> + </span> + <span class="span6"> + <% if type == 'datetime' %> + <%= I18n.l(value, :format => "%e %B %Y %H:%M:%S") %> + (<%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(value)) %>) + <% else %> + <%=h value %> + <% end %> + </span> + </div> + <% end %> + </div> + </div> + <% end %> +</div> diff --git a/app/views/admin_request/_some_requests.rhtml b/app/views/admin_request/_some_requests.rhtml deleted file mode 100644 index dc11e0f55..000000000 --- a/app/views/admin_request/_some_requests.rhtml +++ /dev/null @@ -1,31 +0,0 @@ -<table> - <tr> - <th>Title</th> - <th>Authority</th> - <th>User</th> - <% for column in InfoRequest.content_columns.map { |c| c.human_name } - [ "Url title", "Title" ] %> - <th><%= column %></th> - <% end %> - </tr> - -<% for info_request in info_requests %> - <tr class="<%= cycle('odd', 'even') %>"> - <td><%= request_both_links(info_request) %></td> - <td><%= public_body_both_links(info_request.public_body) %></td> - <% if info_request.is_external? %> - <% if info_request.external_user_name.nil? %> - <td><i><%= _("Anonymous user") %></i></td> - <% else %> - <td><%= h(info_request.external_user_name) %></td> - <% end %> - <% else %> - <td><%= user_both_links(info_request.user) %></td> - <% end %> - <% for column in InfoRequest.content_columns.map { |c| c.name } - [ "title", "url_title" ] %> - <td><%=h info_request.send(column) %></td> - <% end %> - </tr> -<% end %> -</table> - - 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 8fa2a1fe2..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 '../update/' + @info_request.id.to_s 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> @@ -22,16 +22,14 @@ </p> <p><label for="info_request_described_state"><strong>Described state</strong></label> - <%= select( 'info_request', "described_state", InfoRequest.enumerate_states ) %>; + <%= select( 'info_request', "described_state", InfoRequest.enumerate_states) %> <label for="info_request_awaiting_description"><strong>Awaiting description</strong></label> - <%= select('info_request', "awaiting_description", [["Yes - needs state updating",true],["No - state is up to date",false]]) %> + <%= select('info_request', "awaiting_description", [["Yes – needs state updating",true],["No – state is up to date",false]]) %> <br/>(don't forget to change 'awaiting description' when you set described state)<br/> </p> - - <p><label for="info_request_comments_allowed"><strong>Are comments allowed?</strong></label> - <%= select('info_request', "comments_allowed", [["Yes – comments allowed", true], ["No – comments disabled", false]]) %> - </p> - + <p><label for="info_request_comments_allowed"><strong>Are comments allowed?</strong></label> + <%= select('info_request', "comments_allowed", [["Yes – comments allowed", true], ["No – comments disabled", false]]) %> + </p> <p><label for="info_request_tag_string"><strong>Tags</strong> <small>(space separated, can use key:value)</small></label><br/> <%= text_field 'info_request', 'tag_string', :size => 60 %></p> @@ -45,13 +43,13 @@ <% end %> <p> -<%= link_to 'Show', '../show/' + @info_request.id.to_s %> | -<%= link_to 'List all', '../list' %> +<%= link_to 'Show', admin_request_show_path(@info_request) %> | +<%= link_to 'List all', admin_request_list_path %> </p> <hr> -<% form_tag '../destroy/' + @info_request.id.to_s 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 ee43e849a..2cf49a4a8 100644 --- a/app/views/admin_request/edit_comment.rhtml +++ b/app/views/admin_request/edit_comment.html.erb @@ -2,13 +2,13 @@ <%= error_messages_for 'comment' %> -<% form_tag '../update_comment/' + @comment.id.to_s 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> <p><label for="comment_visible">Visible</label> - <%= select('comment', "visible", [["Yes - show comment",true],["No - hide comment",false]]) %> + <%= select('comment', "visible", [["Yes – show comment",true],["No – hide comment",false]]) %> </p> @@ -16,7 +16,7 @@ <% end %> <p> -<%= link_to 'Show', '../show/' + @comment.info_request.id.to_s %> | -<%= link_to 'List all', '../list' %> +<%= link_to 'Show', admin_request_show_path(@comment.info_request) %> | +<%= link_to 'List all', admin_request_list_path %> </p> diff --git a/app/views/admin_request/edit_outgoing.rhtml b/app/views/admin_request/edit_outgoing.html.erb index 4932cb52f..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 '../update_outgoing/' + @outgoing_message.id.to_s 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> @@ -18,11 +18,11 @@ <% end %> <p> -<%= link_to 'Show', '../show/' + @outgoing_message.info_request.id.to_s %> | -<%= link_to 'List all', '../list' %> +<%= link_to 'Show', admin_request_show_path(@outgoing_message.info_request) %> | +<%= link_to 'List all', admin_request_list_path %> </p> -<% form_tag '../destroy_outgoing' do %> +<%= form_tag admin_request_destroy_outgoing_path do %> <div> <%= hidden_field_tag 'outgoing_message_id', @outgoing_message.id %> Warning, this is permanent! ---> 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.html.erb b/app/views/admin_request/list.html.erb new file mode 100644 index 000000000..2bd3e3326 --- /dev/null +++ b/app/views/admin_request/list.html.erb @@ -0,0 +1,13 @@ +<% @title = _("Listing FOI requests") %> + +<h1><%=@title%></h1> + +<%= 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 %> + +<%= render :partial => 'some_requests', :locals => { :info_requests => @info_requests } %> + +<%= will_paginate(@info_requests, :class => "paginator") %> + diff --git a/app/views/admin_request/list.rhtml b/app/views/admin_request/list.rhtml deleted file mode 100644 index cb328543e..000000000 --- a/app/views/admin_request/list.rhtml +++ /dev/null @@ -1,15 +0,0 @@ -<% @title = 'Listing FOI/EIR requests' %> - -<h1><%=@title%></h1> - -<% form_tag("", :method => "get") do %> - <p> - <%= text_field_tag 'query', params[:query], { :size => 30 } %> - <%= submit_tag "Search" %> (substring search, titles only) - </p> -<% end %> - -<%= render :partial => 'some_requests', :locals => { :info_requests => @info_requests } %> - -<%= will_paginate(@info_requests) %> - diff --git a/app/views/admin_request/list_old_unclassified.rhtml b/app/views/admin_request/list_old_unclassified.rhtml deleted file mode 100644 index 2e75c2174..000000000 --- a/app/views/admin_request/list_old_unclassified.rhtml +++ /dev/null @@ -1,16 +0,0 @@ -<% @title = "Unclassified responses" %> - -<h1><%=@title%></h1> - -<p>Classify responses that are still unclassified <%=InfoRequest::OLD_AGE_IN_DAYS.inspect %> after response:</p> -<ul> -<% for @request in @info_requests %> - <li> - <%= request_both_links(@request) %> - – <%=simple_date(@request.get_last_response_event.created_at)%> - </li> -<% end %> -</ul> -<%= will_paginate(@info_requests) %> - - diff --git a/app/views/admin_request/show.html.erb b/app/views/admin_request/show.html.erb new file mode 100644 index 000000000..e18e319be --- /dev/null +++ b/app/views/admin_request/show.html.erb @@ -0,0 +1,386 @@ +<% @title = _("FOI request – {{title}}", :title => h(@info_request.title)) %> + +<h1><%=@title%></h1> + +<%= 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"> + <div class="accordion-heading"> + <span class="item-title"> + <a href="#metadata_<%=@info_request.id%>" data-toggle="collapse" data-parent="#info_request"><%= chevron_down %></a>Request metadata + </span> + </div> + <div id="metadata_<%=@info_request.id%>" class="accordion-body collapse in"> + <table class="table table-striped table-condensed"> + <thead> + <tr> + <td colspan="2"> + <%= link_to 'Edit metadata', admin_request_edit_path(@info_request), :class => "btn" %> + </td> + </tr> + </thead> + <tbody> + <tr> + <th>Public page:</th> + <td><%= link_to request_url(@info_request), request_path(@info_request) %></td> + </tr> + <% @info_request.for_admin_column do |name, value, type, column_name|%> + <tr> + <td> + <b><%= name %>:</b> + </td> + <td> + <% if type == 'datetime' %> + <%= I18n.l(value, :format => "%e %B %Y %H:%M:%S") %> + (<%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(value)) %>) + <% else %> + <%= h value %> + <% end %> + <% if column_name == 'described_state' %> + <ul> + <li><strong>Initial request last sent at:</strong> <%= @info_request.calculate_status %></li> + <li><strong>Initial request last sent at:</strong> <%=@info_request.date_initial_request_last_sent_at.to_date %></li> + <li><strong>Date response required by:</strong> <%= @info_request.date_response_required_by %></li> + <li><strong>Very overdue after:</strong> <%= @info_request.date_very_overdue_after %></li> + </ul> + <% end %> + </td> + </tr> + <% end %> + <tr> + <td> + <b>Created by</b> + </td> + <td> + <% if @info_request.is_external? %> + <%= link_to(eye, @info_request.external_url, :title => "view URL of original request on external website") %> + <%= @info_request.public_body.name %> on behalf of <%= (@info_request.user_name || _('an anonymous user'))%> (using API) + <% else %> + <%= user_both_links(@info_request.user) %> + <%= link_to _("move..."), "#", :class => "btn btn-mini btn-warning toggle-hidden" %> + <div style="display:none;"> + <strong>url_name of new user:</strong> + <%= text_field_tag 'user_url_name', "", { :size => 20 } %> + <%= submit_tag "Move request to user", :class => "btn btn-info" %> + </div> + <% end %> + </td> + </tr> + <tr> + <td> + <b>Public authority:</b> + </td> + <td> + <%= public_body_both_links(@info_request.public_body) %> + <%= link_to "move...", "#", :class => "btn btn-mini btn-warning toggle-hidden" %> + <div style="display:none;"> + <strong>url_name of new authority:</strong> + <%= text_field_tag 'public_body_url_name', "", { :size => 20 } %> + <%= submit_tag "Move request to authority", :class => "btn btn-info" %> + </div> + </td> + </tr> + <tr> + <td> + <b><%=_("Incoming email address")%></b> + </td> + <td> + <%= link_to h(@info_request.incoming_email), "mailto:#{@info_request.incoming_email}" %> + </td> + </tr> + <tr> + <td> + <b><%=_("Tags")%></b> + </td> + <td> + <%= render :partial => 'tags', :locals => { :info_request => @info_request} %> + </td> + </tr> + </tbody> + <tfoot> + <tr> + <td colspan="2"> + <%= link_to 'Edit metadata', admin_request_edit_path(@info_request), :class => "btn" %> + </td> + </tr> + </tfoot> + </table> + </div> + </div> + </div> +<% end %> +<fieldset class="form-horizontal"> + <legend>Actions</legend> + <div class="control-group"> + <label class="control-label"> + FOI officer upload URL + </label> + <div class="controls"> + <%= link_to 'Generate URL', admin_request_generate_upload_url_path(@info_request), :class => "btn" %> + <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 %> + <div class="control-group"> + <% if @info_request.is_external? %> + <label class="control-label">Hide the request:</label> + <% else %> + <label class="control-label">Hide the request and notify the user:</label> + <% end %> + + <div class="controls" id="request_hidden_user_explanation_reasons"> + <% if ['hidden', 'requester_only'].include? @info_request.prominence %> + <p class="help-block">This request has already been hidden</p> + <% else %> + <label class="radio inline"> + <%= radio_button_tag "reason", "not_foi" %> <%= _("Not a valid FOI request") %> + </label> + <label class="radio inline"> + <%= radio_button_tag "reason", "vexatious" %> <%= _("A vexatious request") %> + </label> + <% end %> + </div> + </div> + + <% if !['hidden', 'requester_only'].include? @info_request.prominence %> + <% if ! @info_request.is_external? %> + + <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 {{site_name}} hidden", :site_name => site_name), {:id => "request_hidden_user_subject_field", :cols => 100} %> + </div> + </div> + + <div class="control-group" id="request_hidden_user_explanation"> + <label for="request_hidden_user_explanation_field" class="control-label">Reason for hiding the request (will be emailed to user):</label> + <div class="controls"> + <%= text_area_tag "explanation", h(@request_hidden_user_explanation), {:id => "request_hidden_user_explanation_field"} %> + </div> + </div> + + <% end %> + <div class="form-actions" id="request_hide_button"> + <%= submit_tag _("Hide request"), :class => "btn" %> + </div> + <% end %> + <% end %> +</fieldset> + +<hr> +<h2>Events</h2> +<div class="accordion" id="events"> + <% for info_request_event in @info_request.info_request_events.find(:all, :order => "created_at, id") %> + <div class="accordion-group"> + <div class="accordion-heading"> + <span class="item-title"> + <a href="#event_<%=info_request_event.id%>" data-toggle="collapse" data-parent="#events"><%= chevron_right %></a> + <%= _("Event {{id}}", :id => info_request_event.id) %>: + <strong> + <%=h info_request_event.event_type.humanize %><% if !info_request_event.calculated_state.nil? %>; state: <%= info_request_event.calculated_state %><% end %> + </strong> + <em> + <%= info_request_event.created_at%> + </em> + </span> + </div> + <div id="event_<%=info_request_event.id%>" class="accordion-body collapse"> + <table class="table table-striped table-condensed"> + <tbody> + <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 %> + <%= 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 %> + <% end %> + </td> + <td></td> + </tr> + + <% info_request_event.for_admin_column do |name, value, type, column_name| %> + <tr> + <td> + <b><%=h name%></b> + </td> + <td> + <% if column_name == 'params_yaml' %> + <%= info_request_event.params_yaml_as_html.html_safe %> + <% elsif value.nil? %> + nil + <% elsif %w(text string).include?(type) %> + <%=h value.humanize %> + <% elsif type == 'datetime' %> + <%= admin_date value %> + <% else %> + <%=h value %> + <% end %> + </td> + </tr> + <% end %> + </tbody> + </table> + </div> + </div> + <% end %> +</div> +<hr> +<h2>Outgoing messages</h2> +<div class="accordion" id="outgoing_messages"> + <% for outgoing_message in @info_request.outgoing_messages.find(:all, :order => 'created_at') %> + <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 %> + #<%= outgoing_message.id %> -- <%= outgoing_message.status.humanize %> <%= outgoing_message.message_type.humanize %> + <% end %> + <blockquote> + <%= truncate(outgoing_message.body, :length => 400) %> + </blockquote> + </div> + <div id="outgoing_<%=outgoing_message.id%>" class="accordion-body collapse"> + <table class="table table-striped table-condensed"> + <tbody> + <tr> + <td colspan="2"> + <%= 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 %> + </td> + </tr> + <% outgoing_message.for_admin_column do |name, value, type, column_name| %> + <tr> + <td class="span3"> + <b><%=name%></b> + </td> + <td> + <% if column_name == 'body' %> + <%= simple_format(truncate(h(outgoing_message.body), :length => 400, :omission => link_to("...", "#", :class => "toggle-hidden" )).html_safe) %> + <div style="display:none;"><%= simple_format( outgoing_message.body ) %></div> + <% else %> + <%= admin_value(value) %> + <% end %> + </td> + </tr> + <% end %> + </tbody> + </table> + </div> + </div> + <% end %> +</div> +<hr> +<h2>Incoming messages</h2> +<div class="accordion" id="incoming_messages"> + <% for incoming_message in @info_request.incoming_messages.find(:all, :order => 'created_at') %> + <div class="accordion-group"> + <div class="accordion-heading"> + <a href="#incoming_<%=incoming_message.id%>" data-toggle="collapse" data-parent="#incoming_messages"><%= chevron_right %></a> + <%=incoming_message.id%> -- <%= h(incoming_message.mail_from) %> <%=_("at")%> <%=admin_value(incoming_message.sent_at)%> + <blockquote class="incoming-message"> + <% if !incoming_message.cached_main_body_text_folded.nil? %> + <%= truncate(incoming_message.cached_main_body_text_folded.gsub('FOLDED_QUOTED_SECTION', ''), :length => 400) %> + <% end %> + </blockquote> + </div> + <div id="incoming_<%=incoming_message.id%>" class="accordion-body collapse"> + <table class="table table-striped table-condensed"> + <thead> + <tr> + <td colspan="2" class="well"> + <%= render :partial => 'incoming_message_actions', :locals => { :incoming_message => incoming_message } %> + </td> + </tr> + </thead> + <tbody> + <% incoming_message.for_admin_column do |name, value, type, column_name| %> + <tr> + <td> + <b><%=name%></b> + </td> + <td> + <% if column_name =~ /^cached_.*?$/ %> + <%= 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.to_s) %> + <% end %> + </td> + </tr> + <% end %> + </tbody> + </table> + </div> + </div> + <% end %> +</div> +<hr> +<h2>Annotations</h2> + +<% if @info_request.comments.size > 0 %> + <div class="accordion" id="comments"> + <% for comment in @info_request.comments %> + <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 %> + #<%=comment.id%> + -- + <%=h(comment.user.name)%> + <%=admin_value(comment.created_at)%> + <% end %> + <blockquote class="incoming-message"> + <%= truncate(comment.body, :length => 400) %> + </blockquote> + </div> + <div id="comment_<%=comment.id%>" class="accordion-body collapse"> + <table class="table table-striped table-condensed"> + <tbody> + <tr> + <td colspan="2"> + By <%= user_both_links(comment.user) %> + </td> + </tr> + <% comment.for_admin_column do |name, value, type, column_name |%> + <tr> + <td> + <b><%=name%></b> + </td> + <td> + <% if column_name == 'body' && !comment.visible %> + <s><%=h comment.send(column_name) %></s> + <% else %> + <%=h comment.send(column_name) %> + <% end %> + </td> + </tr> + <% end %> + </tbody> + </table> + </div> + </div> + <% end %> + </div> +<% else %> + <p>None yet.</p> +<% end %> +<hr> +<h2>Mail server delivery logs</h2> + +<p><i>(Lines containing the request incoming email address, updated hourly.)</i></p> + +<% for mail_server_log_done_id, mail_server_logs in @info_request.mail_server_logs.group_by(&:mail_server_log_done_id) %> + <!-- <h3><%=h mail_server_logs[0].mail_server_log_done.filename %></h3> --> + <pre><% for mail_server_log in mail_server_logs %><%=h mail_server_log.line%><% end %></pre> +<% end %> +<% if @info_request.mail_server_logs.size == 0 %> + <p>None (perhaps this is an old or a very new request)</p> +<% end %> + +<hr> +<h2>Censor rules</h2> +<%= render :partial => 'admin_censor_rule/show', :locals => { :censor_rules => @info_request.censor_rules, :info_request => @info_request } %> + diff --git a/app/views/admin_request/show.rhtml b/app/views/admin_request/show.rhtml deleted file mode 100644 index 2541fd323..000000000 --- a/app/views/admin_request/show.rhtml +++ /dev/null @@ -1,230 +0,0 @@ -<% @title = "FOI request - " + h(@info_request.title) %> -<%= javascript_include_tag :defaults %> - -<h1><%=@title%></h1> - -<% form_tag '../move_request', { :class => "inline" } do %> -<p> -<%= hidden_field_tag 'info_request_id', @info_request.id %> -<% for column in InfoRequest.content_columns %> - <strong><%= column.human_name %>:</strong> <%=h @info_request.send(column.name) %> - <% if column.name == 'described_state' %> - <strong>Calculated status:</strong> <%= @info_request.calculate_status %> - <br/><strong>Initial request last sent at:</strong> <%=@info_request.date_initial_request_last_sent_at.to_date %> - <strong>Date response required by:</strong> <%= @info_request.date_response_required_by %> - <strong>Very overdue after:</strong> <%= @info_request.date_very_overdue_after %> - <% end %> - <% if ![ 'allow_new_responses_from' ].include?(column.name) %> - <br/> - <% end %> -<% end %> - <strong>Created by:</strong> - <% if @info_request.is_external? %> - <%= @info_request.public_body.name %> on behalf of <%= (@info_request.user_name || _('an anonymous user'))%> (using API) - <% else %> - <%= user_both_links(@info_request.user) %> - <% end %> - - <span> - <span> - (<%= link_to_function("move...", "$(this).up(1).childElements().invoke('toggle')") %>) - </span> - <span style="display:none;"> - <strong>url_name of new user:</strong> - <%= text_field_tag 'user_url_name', "", { :size => 20 } %> - <%= submit_tag "Move request to user" %> - </span> - </span> - <br> -<strong>Public authority:</strong> <%= public_body_both_links(@info_request.public_body) %> - <span> - <span> - (<%= link_to_function("move...", "$(this).up(1).childElements().invoke('toggle')") %>) - </span> - <span style="display:none;"> - <strong>url_name of new authority:</strong> - <%= text_field_tag 'public_body_url_name', "", { :size => 20 } %> - <%= submit_tag "Move request to authority" %> - </span> - </span> - <br> -<strong>Incoming email address:</strong> <%= link_to h(@info_request.incoming_email), "mailto:" + @info_request.incoming_email %> <br> -<b>Tags:</b> <%= render :partial => 'tags', :locals => { :info_request => @info_request} %> <br> -</p> -<% end %> - -<p> - <%= link_to 'Public page', main_url(request_url(@info_request)) %> - | <%= link_to 'Edit', '../edit/' + @info_request.id.to_s %> - | <%= link_to 'FOI officer upload URL', '../generate_upload_url/' + @info_request.id.to_s %> (see also links on incoming messages below) -</p> - -<h2>Events</h2> - -<table> - <tr> - <th>Id</th> - <% for column in InfoRequestEvent.content_columns %> - <th><%= column.human_name %></th> - <% end %> - <th>Actions</th> - </tr> - -<% for info_request_event in @info_request.info_request_events.find(:all, :order => "created_at, id") %> - <tr class="<%= cycle('odd', 'even') %>"> - <td><%=h info_request_event.id %></td> - <% for column in InfoRequestEvent.content_columns %> - <td> - <% if column.name == 'params_yaml' %> - <%= info_request_event.params_yaml_as_html %> - <% elsif column.text? %> - <%=h (info_request_event.send(column.name) || '').gsub(/_/,' ') %> - <% else %> - <%=h info_request_event.send(column.name) %> - <% end %> - </td> - <% end %> - <td> - <% if info_request_event.described_state != 'waiting_clarification' and info_request_event.event_type == 'response' %> - <% form_tag '../mark_event_as_clarification' do %> - <div> - <%= hidden_field_tag 'info_request_event_id', info_request_event.id %> - <%= submit_tag "Was clarification request" %> - </div> - <% end %> - <% end %> - </td> - </tr> -<% end %> -</table> - -<h2>Outgoing messages</h2> - -<table> - <tr> - <th>Id</th> - <% for column in OutgoingMessage.content_columns %> - <th><%= column.human_name %></th> - <% end %> - <th>Actions</th> - </tr> - -<% for outgoing_message in @info_request.outgoing_messages.find(:all, :order => 'created_at') %> - <tr class="<%= cycle('odd', 'even') %>"> - <td><%=h outgoing_message.id %></td> - <% for column in OutgoingMessage.content_columns.map { |c| c.name } %> - - <% if column == 'body' %> - <td> - <div><%= simple_format( truncate(outgoing_message.body, :length => 400, - :omission => link_to_function("...", "$(this).up('td').childElements().invoke('toggle')") - )) %></div> - <div style="display:none;"><%= simple_format( outgoing_message.body ) %></div> - </td> - <% else %> - <td><%= simple_format( outgoing_message.send(column) ) %></td> - <% end %> - - <% end %> - <td> - <% form_tag '../resend' do %> - <div> - <%= hidden_field_tag 'outgoing_message_id', outgoing_message.id %> - <%= submit_tag "Resend" %> - </div> - <% end %> - <%= link_to "Edit", '../edit_outgoing/' + outgoing_message.id.to_s %> - </td> - </tr> -<% end %> -</table> - -<h2>Incoming messages</h2> - -<table> - <tr> - <th>Id</th> - <% for column in IncomingMessage.content_columns %> - <th><%= column.human_name %></th> - <% end %> - <th>Actions</th> - </tr> - -<% for incoming_message in @info_request.incoming_messages.find(:all, :order => 'created_at') %> - <tr class="<%= cycle('odd', 'even') %>" id="incoming-<%=incoming_message.id.to_s%>"> - <td><%=h incoming_message.id %></td> - <% for column in IncomingMessage.content_columns.map { |c| c.name } %> - <% if column =~ /^cached_.*?$/ %> - <td> - <div><%= simple_format( truncate(incoming_message.send(column), :length => 400, - :omission => link_to_function("...", "$(this).up('td').childElements().invoke('toggle')") - )) %></div> - <div style="display:none;"><%= simple_format( incoming_message.send(column) ) %></div> - </td> - <% else %> - <td><%= simple_format( incoming_message.send(column) ) %></td> - <% end %> - <% end %> - <td> - <% if !incoming_message.raw_email_id.nil? %> - <p> - <%= link_to "View raw email", "../show_raw_email/" + incoming_message.raw_email_id.to_s %> - </p> - <% end %> - <%= render :partial => 'incoming_message_actions', :locals => { :incoming_message => incoming_message } %> - </td> - </tr> -<% end %> -</table> - -<h2>Annotations</h2> - -<% if @info_request.comments.size > 0 %> - <table> - <tr> - <th>Id</th> - <th>Posted by</th> - <% for column in Comment.content_columns %> - <th><%= column.human_name %></th> - <% end %> - <th>Actions</th> - </tr> - - <% for comment in @info_request.comments %> - <tr class="<%= cycle('odd', 'even') %>"> - <td><%=h comment.id %></td> - <td><%= user_both_links(comment.user) %></td> - <% for column in Comment.content_columns.map { |c| c.name } %> - <% if column == 'body' && !comment.visible %> - <td><s><%=h comment.send(column) %></s></td> - <% else %> - <td><%=h comment.send(column) %></td> - <% end %> - <% end %> - <td> - <%= link_to "Edit", '../edit_comment/' + comment.id.to_s %> - </td> - </tr> - <% end %> - </table> -<% else %> - <p>None yet.</p> -<% end %> - - - -<h2>Mail server delivery logs</h2> - -<p><i>(Lines containing the request incoming email address, updated hourly.)</i></p> - -<% for mail_server_log_done_id, mail_server_logs in @info_request.mail_server_logs.group_by(&:mail_server_log_done_id) %> - <!-- <h3><%=h mail_server_logs[0].mail_server_log_done.filename %></h3> --> - <pre><% for mail_server_log in mail_server_logs %><%=h mail_server_log.line%><% end %></pre> -<% end %> -<% if @info_request.mail_server_logs.size == 0 %> - <p>None (perhaps this is an old or a very new request)</p> -<% end %> - -<h2>Censor rules</h2> -<%= render :partial => 'admin_censor_rule/show', :locals => { :censor_rules => @info_request.censor_rules, :info_request => @info_request } %> - diff --git a/app/views/admin_request/show_raw_email.html.erb b/app/views/admin_request/show_raw_email.html.erb new file mode 100644 index 000000000..72c782ad6 --- /dev/null +++ b/app/views/admin_request/show_raw_email.html.erb @@ -0,0 +1,67 @@ +<% @title = "Incoming message #{@raw_email.incoming_message.id} of FOI request '#{@raw_email.incoming_message.info_request.title}'" %> + +<h1>Incoming message <%=@raw_email.incoming_message.id %></h1> + +<p> + FOI request: <%= request_both_links(@raw_email.incoming_message.info_request) %> + <% if @holding_pen %> + <br>This is in the holding pen because: <strong><%= @rejected_reason %></strong> + <% if @public_bodies.size > 0 %> + <br>Guessed authority: + <% @public_bodies.each do |public_body| %> + <%=public_body_both_links(public_body)%> + <% end %> + (based on From: email domain) + <% end %> + <% if @info_requests.size > 0 %> + <div class="accordion" id="guessed-requests"> + Guessed request: + <% @info_requests.each do |info_request| %> + <div class="accordion-group"> + <div class="accordion-heading"> + <a href="#info_request_<%= info_request.id %>" data-toggle="collapse"><i class="icon-chevron-right"></i></a> + <%=request_both_links(info_request)%> + </div> + <div class="accordion-body collapse" id="info_request_<%= info_request.id %>"> + <table class="table table-striped table-condensed"> + <tr> + <td><strong>Last outgoing message:</strong></td> + <td><%= info_request.outgoing_messages.last.body %></td> + </tr> + <tr> + <td><strong>Created by:</strong></td> + <td><%= user_admin_link_for_request(info_request) %></td> + </tr> + <tr> + <td><strong>Authority:</strong></td> + <td> + <%= link_to(info_request.public_body.name, admin_body_show_path(info_request.public_body)) %> + </td> + </tr> + <tr> + <td><strong>url_title:</strong></td> + <td><%= info_request.url_title %></td> + </tr> + </table> + <p> + This request was guessed because it has an incoming email address of <strong><%= info_request.incoming_email %></strong> and this incoming message was sent to <strong><%= @raw_email.incoming_message.mail.to %></strong>. + </p> + </div> + </div> + <% end %> + (based on id, not hash, in To/Cc email) + </div> + <% end %> + <% end %> +</p> + +<div> + <%= render :partial => 'incoming_message_actions', :locals => { :incoming_message => @raw_email.incoming_message } %> +</div> + +<h2>Raw email</h2> + +<p><%= link_to "Download", admin_request_download_raw_email_path(@raw_email) %></p> + +<pre><%=h(@raw_email.data).gsub(/\n/, '<br>').html_safe %></pre> + diff --git a/app/views/admin_request/show_raw_email.rhtml b/app/views/admin_request/show_raw_email.rhtml deleted file mode 100644 index ea0d6017e..000000000 --- a/app/views/admin_request/show_raw_email.rhtml +++ /dev/null @@ -1,37 +0,0 @@ -<% @title = 'Incoming message ' + @raw_email.incoming_message.id.to_s + ' of FOI request \'' + h(@raw_email.incoming_message.info_request.title) + "'" %> - -<h1>Incoming message <%=@raw_email.incoming_message.id.to_s %></h1> - -<p> - FOI request: <%= request_both_links(@raw_email.incoming_message.info_request) %> - <% if @holding_pen %> - <br>This is in the holding pen because: <strong><%= @rejected_reason %></strong> - <% if @public_bodies.size > 0 %> - <br>Guessed authority: - <% for public_body in @public_bodies %> - <%=public_body_both_links(public_body)%> - <% end %> - (based on From: email domain) - <% end %> - <% if @info_requests.size > 0 %> - <br>Guessed request: - <% for info_request in @info_requests %> - <%=request_both_links(info_request)%> - <% end %> - (based on id, not hash, in To/Cc email) - <% end %> - <% end %> -</p> - -<h2>Actions</h2> - -<div> - <%= render :partial => 'incoming_message_actions', :locals => { :incoming_message => @raw_email.incoming_message } %> -</div> - -<h2>Raw email</h2> - -<p><%= link_to "Download", "../download_raw_email/" + @raw_email.id.to_s %></p> - -<pre><%= h(@raw_email.data).gsub(/\n/, '<br>').html_safe %></pre> - diff --git a/app/views/admin_track/_some_tracks.html.erb b/app/views/admin_track/_some_tracks.html.erb new file mode 100644 index 000000000..e9facfb5d --- /dev/null +++ b/app/views/admin_track/_some_tracks.html.erb @@ -0,0 +1,74 @@ +<% include_destroy = include_destroy || false %> +<% if track_things.empty? %> + <div class="row"> + <div class="span12"> + <%=_("No tracked things found.")%> + </div> + </div> +<% else %> + <div class="accordion" id="tracks"> + <% for track_thing in track_things %> + <div class="accordion-group"> + <div class="accordion-heading"> + <a href="#track_<%=track_thing.id%>" data-toggle="collapse" data-parent="requests"><%= chevron_right %></a> + <%=track_thing.id%>: + <% if track_thing.public_body_id %> + <%= link_to "<code>#{h track_thing.track_query}</code>".html_safe, public_body_path(track_thing.public_body) %> + <% elsif track_thing.info_request_id %> + <%= link_to "<code>#{h track_thing.track_query}</code>".html_safe, request_path(track_thing.info_request) %> + <% elsif track_thing.tracked_user_id %> + <%= link_to "<code>#{h track_thing.track_query}</code>".html_safe, user_path(track_thing.tracked_user) %> + <% else %> + <code><%=h track_thing.track_query%></code> + <% end %> + <% if @admin_user.nil? %> + <%# Do not show this on the list of tracks on the user page, because it’s rather repetitive there %> + tracked by <%= user_both_links track_thing.tracking_user %> + <% end %> + </div> + <div id="track_<%=track_thing.id%>" class="accordion-body collapse"> + <table class="table table-striped table-condensed"> + <tbody> + <% if include_destroy %> + <tr> + <td colspan="2"> + <%= 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" %> + </div> + <% end %> + </td> + </tr> + + <% end %> + <% TrackThing.content_columns.each do |column| %> + <tr> + <td> + <b><%=column.human_name%></b> + </td> + <td> + <% if column.type.to_s == 'datetime' %> + <%= I18n.l(track_thing.send(column.name), :format => "%e %B %Y %H:%M:%S") %> + (<%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(track_thing.send(column.name))) %>) + <% elsif column.name == 'track_medium' and track_thing.track_medium == 'feed' %> + <%= link_to track_thing.track_medium, atom_feed_path(:track_id => track_thing.id) %> + <% else %> + <%= h track_thing.send(column.name)%> + <% end %> + </td> + </tr> + <% end %> + <tr> + <td><b><%=_("Items sent in last month")%></b></td> + <td><%= track_thing.track_things_sent_emails.size %></td> + </tr> + </tbody> + </table> + </div> + </div> + <% end %> + </div> +<% end %> +</table> + diff --git a/app/views/admin_track/_some_tracks.rhtml b/app/views/admin_track/_some_tracks.rhtml deleted file mode 100644 index 72ee5fd95..000000000 --- a/app/views/admin_track/_some_tracks.rhtml +++ /dev/null @@ -1,31 +0,0 @@ -<table> - <tr> - <th>Id</th> - <th>User</th> - <% for column in TrackThing.content_columns %> - <th><%= column.human_name %></th> - <% end %> - <th>Items sent by email (in last month)</th> - <th>Actions</th> - </tr> - -<% for track_thing in track_things %> - <tr class="<%= cycle('odd', 'even') %>"> - <td><%=h track_thing.id %></td> - <td><%=user_both_links(track_thing.tracking_user) %></td> - <% for column in TrackThing.content_columns.map { |c| c.name } %> - <td><%=h track_thing.send(column) %></td> - <% end %> - <td><%= track_thing.track_things_sent_emails.size %></td> - <td> - <% form_tag '../../user/destroy_track' do %> - <div> - <%= hidden_field_tag 'track_id', track_thing.id %> - <%= submit_tag "Destroy track" %> - </div> - <% end %> - </td> - </tr> -<% end %> -</table> - diff --git a/app/views/admin_track/list.html.erb b/app/views/admin_track/list.html.erb new file mode 100644 index 000000000..5e967a926 --- /dev/null +++ b/app/views/admin_track/list.html.erb @@ -0,0 +1,20 @@ +<% @title = _('Listing tracks') %> + +<h1><%=@title%></h1> + +<%= 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 %> + +<%= render :partial => 'some_tracks', :locals => { :track_things => @admin_tracks } %> + +<%= will_paginate(@admin_tracks, :class => "paginator" ) %> + +<h2>Current top tracks:</h2> +<ol> +<% for row in @popular %> + <li><%= link_to row['title'], admin_request_show_path(row['info_request_id']) %> (<%= row['count'] %> people following)</li> +<% end %> +</ol> + diff --git a/app/views/admin_track/list.rhtml b/app/views/admin_track/list.rhtml deleted file mode 100644 index 58c87ddba..000000000 --- a/app/views/admin_track/list.rhtml +++ /dev/null @@ -1,39 +0,0 @@ -<% @title = 'Listing tracks' %> - -<h1><%=@title%></h1> - -<% form_tag("", :method => "get") do %> - <p> - <%= text_field_tag 'query', params[:query], { :size => 30 } %> - <%= submit_tag "Search" %> (substring search the query - so use url_names_for_a_particular_request_or_authority_or_person) - </p> -<% end %> - -<table> - <tr> - <th>Id</th> - <th>Tracked by</th> - <% for column in TrackThing.content_columns %> - <th><%= column.human_name %></th> - <% end %> - <th>Items sent by email (in last month)</th> - </tr> - -<% for track_thing in @admin_tracks %> - <tr class="<%= cycle('odd', 'even') %>"> - <td><%=h track_thing.id %></td> - <td><%= user_both_links(track_thing.tracking_user) %></td> - <% for column in TrackThing.content_columns.map { |c| c.name } %> - <% if column == 'track_medium' and track_thing.track_medium == 'feed'%> - <td><%= link_to track_thing.track_medium, atom_feed_url(:track_id => track_thing.id) %></td> - <% else %> - <td><%=h track_thing.send(column) %></td> - <% end %> - <% end %> - <td><%= track_thing.track_things_sent_emails.size %></td> - </tr> -<% end %> -</table> - -<%= will_paginate(@admin_tracks) %> - diff --git a/app/views/admin_user/_form.html.erb b/app/views/admin_user/_form.html.erb new file mode 100644 index 000000000..e7175d09c --- /dev/null +++ b/app/views/admin_user/_form.html.erb @@ -0,0 +1,66 @@ +<%= error_messages_for 'admin_user' %> + +<!--[form:admin_user]--> + +<div class="control-group"> + <label for="admin_user_name" class="control-label">Name</label> + <div class="controls"> + <%= text_field 'admin_user', 'name', :class => "span3" %> + <div class="help-block"> + will change URL name and break URLs; unlike authorities, there is no history; you will need to rebuild the search index afterwards + </div> + </div> +</div> + +<div class="control-group"> + <label for="admin_user_email" class="control-label">Email</label> + <div class="controls"> + <%= text_field 'admin_user', 'email', :class => "span3" %> + <div class="help-block"> + <strong>you must</strong> first validate this + </div> + </div> +</div> + +<div class="control-group"> + <label for="admin_level" class="control-label">Admin level</label> + <div class="controls"> + <%= text_field 'admin_user', 'admin_level', :class => "span3" %> + <div class="help-block"> + <strong>none</strong> or <strong>super</strong>; this is for admin features and links which are in the site proper + </div> + </div> +</div> + +<div class="control-group"> + <label for="ban_text" class="control-label">Ban text</label> + <div class="controls"> + <%= text_area 'admin_user', 'ban_text', :class => "span6", :rows => 3 %> + <div class="help-block"> + if not blank will stop the + user from filing new requests, making annotations or messaging other users; + the text is shown in public on the user's page and when they try to do a + forbidden action; write in the second person (you); see + <%= link_to 'banned users', admin_user_list_banned_path %> for examples</small> + </div> + </div> +</div> + +<div class="control-group"> + <label for="about_me" class="control-label">About me</label> + <div class="controls"> + <%= text_area 'admin_user', 'about_me', :class => "span6", :rows => 3 %> + <div class="help-block"> + user's own text on their profile, format like comments + </div> + </div> +</div> +<div class="control-group"> + <label for="admin_user_no_limit" class="control-label">No rate limit</label> + <div class="controls"> + <%= check_box 'admin_user', 'no_limit' %> + <div class="help-block"> + disable the limit on daily requests + </div> + </div> +</div> diff --git a/app/views/admin_user/_form.rhtml b/app/views/admin_user/_form.rhtml deleted file mode 100644 index be69d9a80..000000000 --- a/app/views/admin_user/_form.rhtml +++ /dev/null @@ -1,27 +0,0 @@ -<%= error_messages_for 'admin_user' %> - -<!--[form:admin_user]--> - -<p><label for="admin_user_name">Name</label> (will change URL name and break URLs; unlike authorities, there is no history; you will need to rebuild the search index afterwards)<br/> -<%= text_field 'admin_user', 'name', :size => 60 %></p> - -<p><label for="admin_user_email">Email</label> (<strong>you must</strong> first validate this)<br/> -<%= text_field 'admin_user', 'email', :size => 60 %></p> - -<p><label for="admin_user_admin_level">Admin level</label> (<strong>none</strong> or <strong>super</strong>; this is for admin features and links which are in the site proper)<br/> -<%= text_field 'admin_user', 'admin_level', :size => 60 %></p> - -<p><label for="admin_user_ban_text">Ban text</label> <small>(if not blank will stop the - user from filing new requests, making annotations or messaging other users; - the text is shown in public on the user's page and when they try to do a - forbidden action; write in the second person (you); see - <%= link_to 'banned users', '../banned' %> for examples</small>)<br/> - -<%= text_area 'admin_user', 'ban_text', :cols => 60, :rows => 3 %></p> - -<p><label for="admin_user_about_me">About me</label> (user's own text on their profile, format like comments):<br/> -<%= text_area 'admin_user', 'about_me', :cols => 60, :rows => 3 %></p> - -<p><%= check_box 'admin_user', 'no_limit' %> -<label for="admin_user_no_limit">No rate limit</label> (disable the limit on daily requests)</p> - diff --git a/app/views/admin_user/_user_table.html.erb b/app/views/admin_user/_user_table.html.erb new file mode 100644 index 000000000..57066bf3f --- /dev/null +++ b/app/views/admin_user/_user_table.html.erb @@ -0,0 +1,47 @@ +<div class="accordion" id="users"> + <% for user in users %> + <div class="accordion-group"> + <div class="accordion-heading accordion-toggle"> + <span class="item-title"> + <a href="#user_<%=user.id%>" data-toggle="collapse" data-parent="requests"><%= chevron_right %></a> + <% if user.admin_level == "super" %> + <span class="label">superuser</span> + <% end %> + <%= link_to("#{h(user.name)}", admin_user_show_path(user))%> + <%= link_to("(#{h(user.email)})", "mailto:#{h(user.email)}")%> + </span> + <span class="item-metadata"> + updated <%=I18n.l(user.updated_at, :format => "%e %B %Y %H:%M:%S")%> + </span> + </div> + <div id="user_<%=user.id%>" class="accordion-body collapse"> + <table class="table table-striped table-condensed"> + <tbody> + <% if banned_column %> + <tr> + <td><b>Ban text</b></td> + <td><%= h user.ban_text %></td> + </tr> + <% end %> + <% user.for_admin_column do |name, value, type|%> + <tr> + <td><b><%=h name%></b></td> + <td> + <% if type == 'datetime' %> + <%= I18n.l(value, :format => "%e %B %Y %H:%M:%S") %> + (<%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(value)) %>) + <% else %> + <%= h value %> + <% end %> + </td> + </tr> + <% end %> + </tbody> + </table> + </div> + </div> + <% end %> +</div> + +<%= will_paginate(users, :class => "paginator") %> + diff --git a/app/views/admin_user/_user_table.rhtml b/app/views/admin_user/_user_table.rhtml deleted file mode 100644 index d35c78594..000000000 --- a/app/views/admin_user/_user_table.rhtml +++ /dev/null @@ -1,22 +0,0 @@ -<table> - <tr> - <th>Id</th> - <% for column in ['Name', 'Email', 'Created at', 'Updated at', 'Email confirmed', 'Admin'] + (banned_column ? ['Ban text'] : []) %> - <th><%= column %></th> - <% end %> - </tr> - -<% for user in users %> - <tr class="<%= cycle('odd', 'even') %>"> - <td><%= user.id.to_s %></td> - <td><%= user_both_links(user) %></td> - <td><a href="mailto:<%=h user.email %>"><%=h user.email%></a></td> - <% for column in ['created_at', 'updated_at', 'email_confirmed', 'admin_level'] + (banned_column ? ['ban_text'] : []) %> - <td><%=h user.send(column) %></td> - <% end %> - </tr> -<% end %> -</table> - -<%= will_paginate(users) %> - diff --git a/app/views/admin_user/edit.html.erb b/app/views/admin_user/edit.html.erb new file mode 100644 index 000000000..e641a13d6 --- /dev/null +++ b/app/views/admin_user/edit.html.erb @@ -0,0 +1,11 @@ +<h1><%=@title%></h1> + +<%= 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" %> + </div> +<% end %> + +<%= link_to 'Show', admin_user_show_path(@admin_user), :class => "btn" %> +<%= link_to 'List all', admin_user_list_path, :class => "btn" %> diff --git a/app/views/admin_user/edit.rhtml b/app/views/admin_user/edit.rhtml deleted file mode 100644 index 06ddc57d3..000000000 --- a/app/views/admin_user/edit.rhtml +++ /dev/null @@ -1,23 +0,0 @@ - - -<h1><%=@title%></h1> - -<% form_tag '../update/' + @admin_user.id.to_s do %> - <%= render :partial => 'form' %> - <p><%= submit_tag 'Save', :accesskey => 's' %></p> -<% end %> - -<p> -<%= link_to 'Show', '../show/' + @admin_user.id.to_s %> | -<%= link_to 'List all', '../list' %> -</p> - -<% if false #@admin_user.info_requests.size == 0 %> - <% form_tag('../destroy/' + @admin_user.id.to_s) do %> - <p> - <%= hidden_field_tag(:admin_user_id, { :value => @admin_user.id } ) %> - <%= submit_tag "Destroy " + @admin_user.name %> (this is permanent!) - </p> - <% end %> -<% end %> - diff --git a/app/views/admin_user/list.html.erb b/app/views/admin_user/list.html.erb new file mode 100644 index 000000000..b1238f87a --- /dev/null +++ b/app/views/admin_user/list.html.erb @@ -0,0 +1,13 @@ +<% @title = _('Listing users') %> + +<h1><%=@title%></h1> + +<%= 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" %> +<% end %> + +<%= render :partial => 'user_table', :locals => { :users => @admin_users, :banned_column => false } %> + + diff --git a/app/views/admin_user/list.rhtml b/app/views/admin_user/list.rhtml deleted file mode 100644 index 9de381ecc..000000000 --- a/app/views/admin_user/list.rhtml +++ /dev/null @@ -1,15 +0,0 @@ -<% @title = 'Listing users' %> - -<h1><%=@title%></h1> - -<% form_tag("", :method => "get") do %> - <p> - <%= text_field_tag 'query', params[:query], { :size => 30 } %> - <%= submit_tag "Search" %> (substring search, names and emails) - <%= link_to 'Banned users', 'banned' %> - </p> -<% end %> - -<%= render :partial => 'user_table', :locals => { :users => @admin_users, :banned_column => false } %> - - diff --git a/app/views/admin_user/list_banned.rhtml b/app/views/admin_user/list_banned.html.erb index be2d45399..e535415e6 100644 --- a/app/views/admin_user/list_banned.rhtml +++ b/app/views/admin_user/list_banned.html.erb @@ -2,7 +2,7 @@ <h1><%=@title%></h1> -<p><%= link_to 'List all', 'list' %></p> +<p><%= link_to 'List all', admin_user_list_path %></p> <%= render :partial => 'user_table', :locals => { :users => @banned_users, :banned_column => true } %> diff --git a/app/views/admin_user/show.html.erb b/app/views/admin_user/show.html.erb new file mode 100644 index 000000000..c93c08e50 --- /dev/null +++ b/app/views/admin_user/show.html.erb @@ -0,0 +1,96 @@ +<% @title = _("User – {{name}}", :name => h(@admin_user.name)) %> + +<h1><%=@title%></h1> + +<% 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 %> + <img src="<%= get_profile_photo_url(:url_name => @admin_user.url_name) %>"> + <br> + <%= submit_tag "Clear photo", :class => "btn btn-info" %> + <% end %> + </div> +<% end %> + +<table class="table table-striped table-condensed"> + <tbody> + <tr> + <td> + <b><%=_("Id")%></b> + </td> + <td> + <%=@admin_user.id%> + </td> + </tr> + <% @admin_user.for_admin_column(:complete => true) do |name, value, type, column_name| %> + <tr> + <td> + <b><%=_(name)%></b> + </td> + <td> + <% if column_name == 'email' %> + <%=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_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 %> + <input type="submit" name="action" value="Clear bounce" class="btn btn-info"> + <% end %> + <% end %> + </td> + </tr> + <% end %> + </tbody> +</table> + + +<%= link_to 'Edit', admin_user_edit_path(@admin_user), :class => "btn btn-primary" %> +<%= link_to 'Public page', user_path(@admin_user), :class => "btn" %> +<%= link_to "Log in as #{@admin_user.name} (also confirms their email)", admin_user_login_as_path(@admin_user), :class => "btn btn-info" %> + +<hr> + +<h2>Track things</h2> +<%= render :partial => 'admin_track/some_tracks', :locals => { :track_things => @admin_user.track_things, :include_destroy => true } %> + +<hr> + +<h2>Post redirects</h2> + +<table class="table table-condensed table-striped"> + <tr> + <th>Id</th> + <% for column in PostRedirect.content_columns %> + <th><%= column.human_name %></th> + <% end %> + </tr> + +<% for post_redirect in @admin_user.post_redirects.find(:all, :order => 'created_at desc') %> + <tr class="<%= cycle('odd', 'even') %>"> + <td><%=h post_redirect.id %></td> + <% for column in PostRedirect.content_columns.map { |c| c.name } %> + <% if column == 'email_token' %> + <td><%=link_to post_redirect.send(column), confirm_path(:email_token => post_redirect.send(column)) %></td> + <% else %> + <td><%=h post_redirect.send(column) %></td> + <% end %> + <% end %> + </tr> +<% end %> +</table> + +<hr> + +<h2>Requests</h2> +<%= render :partial => 'admin_request/some_requests', :locals => { :info_requests => @admin_user.info_requests } %> + +<hr> + +<h2>Censor rules</h2> +<%= render :partial => 'admin_censor_rule/show', :locals => { :censor_rules => @admin_user.censor_rules, :user => @admin_user } %> + diff --git a/app/views/admin_user/show.rhtml b/app/views/admin_user/show.rhtml deleted file mode 100644 index 4af79e45a..000000000 --- a/app/views/admin_user/show.rhtml +++ /dev/null @@ -1,74 +0,0 @@ -<% @title = "User - " + h(@admin_user.name) %> - -<h1><%=@title%></h1> - -<% if @admin_user.profile_photo %> - <div class="user_photo_on_admin"> - <% form_tag '../clear_profile_photo/' + @admin_user.id.to_s, :multipart => true do %> - <img src="<%= main_url(get_profile_photo_url(:url_name => @admin_user.url_name, :only_path => true)) %>"> - <br> - <%= submit_tag "Clear photo" %> - <% end %> - </div> -<% end %> - - -<div> -<strong>Id:</strong> <%= @admin_user.id%> <br> -<% for column in User.content_columns %> - <strong><%= column.human_name %>:</strong> - <% if column.name == 'email' %> - <a href="mailto:<%=h @admin_user.email %>"><%=h @admin_user.email%></a> - <% elsif column.name == 'email_bounce_message' %> - <% if !@admin_user.email_bounce_message.empty? %> - <a href="../show_bounce_message/<%= @admin_user.id.to_s %>">See bounce message</a> - <% end %> - <% else %> - <%=h @admin_user.send(column.name) %> - <% end %> - <% if column.name == 'email_bounced_at' && !@admin_user.email_bounced_at.nil? %> - <form action="../clear_bounce/<%= @admin_user.id.to_s %>" style="display: inline;"><input type="submit" name="action" value="Clear bounce"></form> - <% end %> - <br> -<% end %> -</div> - -<p> - <%= link_to 'Public page', main_url(user_url(@admin_user)) %> - | <%= link_to 'Edit', '../edit/' + @admin_user.id.to_s %> - | <%= link_to 'Log in as this user', '../login_as/' + @admin_user.id.to_s %> (also confirms their email) -</p> - -<h2>Track things</h2> -<%= render :partial => 'admin_track/some_tracks', :locals => { :track_things => @admin_user.track_things } %> - -<h2>Post redirects</h2> - -<table> - <tr> - <th>Id</th> - <% for column in PostRedirect.content_columns %> - <th><%= column.human_name %></th> - <% end %> - </tr> - -<% for post_redirect in @admin_user.post_redirects.find(:all, :order => 'created_at desc') %> - <tr class="<%= cycle('odd', 'even') %>"> - <td><%=h post_redirect.id %></td> - <% for column in PostRedirect.content_columns.map { |c| c.name } %> - <% if column == 'email_token' %> - <td><%=link_to post_redirect.send(column), main_url(confirm_url(:email_token => post_redirect.send(column), :only_path => true)) %></td> - <% else %> - <td><%=h post_redirect.send(column) %></td> - <% end %> - <% end %> - </tr> -<% end %> -</table> - -<h2>Requests</h2> -<%= render :partial => 'admin_request/some_requests', :locals => { :info_requests => @admin_user.info_requests } %> - -<h2>Censor rules</h2> -<%= render :partial => 'admin_censor_rule/show', :locals => { :censor_rules => @admin_user.censor_rules, :user => @admin_user } %> - 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/api/request_events.atom.builder b/app/views/api/request_events.atom.builder index 44759ae7e..648a81e5c 100644 --- a/app/views/api/request_events.atom.builder +++ b/app/views/api/request_events.atom.builder @@ -8,7 +8,7 @@ atom_feed("xmlns:alaveteli" => "http://www.alaveteli.org/API/v2/RequestEvents/At entry.updated(event.created_at.utc.iso8601) entry.tag!("alaveteli:event_type", event.event_type) - entry.tag!("alaveteli:request_url", main_url(request_url(request))) + entry.tag!("alaveteli:request_url", request_url(request)) entry.title(request.title) entry.content(event.outgoing_message.body, :type => 'text') @@ -16,7 +16,7 @@ atom_feed("xmlns:alaveteli" => "http://www.alaveteli.org/API/v2/RequestEvents/At entry.author do |author| author.name(request.user_name) if !request.user.nil? - author.uri(main_url(user_url(request.user))) + author.uri(user_url(request.user)) end author.email(request.incoming_email) end diff --git a/app/views/comment/_comment_form.rhtml b/app/views/comment/_comment_form.html.erb index 120929643..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> @@ -13,7 +13,7 @@ <%= hidden_field_tag 'submitted_comment', 1 %> <%= hidden_field_tag 'preview', 1 %> <%= submit_tag _('Preview your annotation') %> - <%= raw(_(' (<strong>no ranty</strong> politics, read our <a href="%s">moderation policy</a>)') % [help_requesting_path+'#moderation']) %> + <%= _(' (<strong>no ranty</strong> politics, read our <a href="{{url}}">moderation policy</a>)', :url => (help_requesting_path+'#moderation').html_safe) %> </p> <% end %> diff --git a/app/views/comment/_single_comment.rhtml b/app/views/comment/_single_comment.html.erb index b645721cf..421a9d4ba 100644 --- a/app/views/comment/_single_comment.rhtml +++ b/app/views/comment/_single_comment.html.erb @@ -17,11 +17,11 @@ </div> <p class="event_actions"> <% if !comment.id.nil? %> - <%= link_to "Link to this", comment_url(comment), :class => "link_to_this" %> + <%= link_to "Link to this", comment_path(comment), :class => "link_to_this" %> <% if !@user.nil? && @user.admin_page_links? %> - | <%= link_to "Admin", admin_url("request/edit_comment/" + comment.id.to_s) %> + | <%= link_to "Admin", admin_request_edit_comment_path(comment) %> <% end %> - <!-- | <%= link_to _('Report abuse'), comment_url(comment) %> --> + <!-- | <%= link_to _('Report abuse'), comment_path(comment) %> --> <% end %> </p> </div> diff --git a/app/views/comment/new.rhtml b/app/views/comment/new.html.erb index aa5b6051c..578732cdb 100644 --- a/app/views/comment/new.rhtml +++ b/app/views/comment/new.html.erb @@ -67,10 +67,10 @@ </ul> <p> - <big><%= _('Annotations will be posted publicly here, and are - <strong>not</strong> sent to {{public_body_name}}.',:public_body_name=>h(@info_request.public_body.name)) %></big> + <span class="big"><%= _('Annotations will be posted publicly here, and are + <strong>not</strong> sent to {{public_body_name}}.',:public_body_name=>h(@info_request.public_body.name)) %></span> <% if @info_request.is_external? %> - <big><%= _('Note that the requester will not be notified about your annotation, because the request was published by {{public_body_name}} on their behalf.', :public_body_name => @info_request.public_body.name) %></big> + <span class="big"><%= _('Note that the requester will not be notified about your annotation, because the request was published by {{public_body_name}} on their behalf.', :public_body_name => @info_request.public_body.name) %></span> <% end %> </p> 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.rhtml deleted file mode 100644 index 43938e0dd..000000000 --- a/app/views/contact_mailer/from_admin_message.rhtml +++ /dev/null @@ -1,2 +0,0 @@ -<%= @message %> - diff --git a/app/views/contact_mailer/from_admin_message.text.erb b/app/views/contact_mailer/from_admin_message.text.erb new file mode 100644 index 000000000..4169d8d3a --- /dev/null +++ b/app/views/contact_mailer/from_admin_message.text.erb @@ -0,0 +1,2 @@ +<%= raw @message %> + diff --git a/app/views/contact_mailer/to_admin_message.rhtml b/app/views/contact_mailer/to_admin_message.rhtml deleted file mode 100644 index 9c0a74c02..000000000 --- a/app/views/contact_mailer/to_admin_message.rhtml +++ /dev/null @@ -1,11 +0,0 @@ -<%= @message.strip %> - ---------------------------------------------------------------------- -<%= _('Message sent using {{site_name}} contact form, ', :site_name=>site_name)%> -<%=(@logged_in_user ? ("logged in as user " + main_url(user_url(@logged_in_user))) : "not logged in")%><% if !@last_request.nil? %> - -<%= _('Last request viewed: ')%><%= main_url(request_url(@last_request)) %> -<% end %> <% if !@last_body.nil? %> - -<%= _('Last authority viewed: ')%><%= main_url(public_body_url(@last_body)) %> -<% end %>--------------------------------------------------------------------- diff --git a/app/views/contact_mailer/to_admin_message.text.erb b/app/views/contact_mailer/to_admin_message.text.erb new file mode 100644 index 000000000..dc9b1090b --- /dev/null +++ b/app/views/contact_mailer/to_admin_message.text.erb @@ -0,0 +1,11 @@ +<%= raw @message.strip %> + +--------------------------------------------------------------------- +<%= _('Message sent using {{site_name}} contact form, ', :site_name=>site_name)%> +<%=(@logged_in_user ? ("logged in as user " + user_url(@logged_in_user)) : "not logged in")%><% if !@last_request.nil? %> + +<%= _('Last request viewed: ')%><%= request_url(@last_request) %> +<% end %> <% if !@last_body.nil? %> + +<%= _('Last authority viewed: ')%><%= public_body_url(@last_body) %> +<% end %>--------------------------------------------------------------------- diff --git a/app/views/contact_mailer/user_message.rhtml b/app/views/contact_mailer/user_message.text.erb index b1d6e81ae..afa1494db 100644 --- a/app/views/contact_mailer/user_message.rhtml +++ b/app/views/contact_mailer/user_message.text.erb @@ -5,7 +5,7 @@ learn your email address. Only reply if that is okay.', :user_name => @from_user.name) %> --------------------------------------------------------------------- -<%= @message.strip %> +<%= raw @message.strip %> --------------------------------------------------------------------- <%= _('View Freedom of Information requests made by {{user_name}}:', :user_name=>@from_user.name)%> diff --git a/app/views/general/_advanced_search_tips.rhtml b/app/views/general/_advanced_search_tips.html.erb index 914abc1af..08ce04439 100644 --- a/app/views/general/_advanced_search_tips.rhtml +++ b/app/views/general/_advanced_search_tips.html.erb @@ -23,27 +23,27 @@ <p><%= _("All the options below can use <strong>status</strong> or <strong>latest_status</strong> before the colon. For example, <strong>status:not_held</strong> will match requests which have <em>ever</em> been marked as not held; <strong>latest_status:not_held</strong> will match only requests that are <em>currently</em> marked as not held.") %></p> <table class="status_table"> - <tr><td><strong><%=search_link('status:waiting_response', nil, nil, true)%></strong></td><td><%= _('Waiting for the public authority to reply') %></td></tr> - <tr><td><strong><%=search_link('status:not_held', nil, nil, true)%></strong></td><td><%= _('The public authority does not have the information requested') %></td></tr> - <tr><td><strong><%=search_link('status:rejected', nil, nil, true)%></strong></td><td><%= _('The request was refused by the public authority') %></td></tr> - <tr><td><strong><%=search_link('status:partially_successful', nil, nil, true)%></strong></td><td><%= _('Some of the information requested has been received') %></td></tr> - <tr><td><strong><%=search_link('status:successful', nil, nil, true)%></strong></td><td><%= _('All of the information requested has been received') %></td></tr> - <tr><td><strong><%=search_link('status:waiting_clarification', nil, nil, true)%></strong></td><td><%= _('The public authority would like part of the request explained') %></td></tr> - <tr><td><strong><%=search_link('status:gone_postal', nil, nil, true)%></strong></td><td><%= _('The public authority would like to / has responded by post') %></td></tr> - <tr><td><strong><%=search_link('status:internal_review', nil, nil, true)%></strong></td><td><%= _('Waiting for the public authority to complete an internal review of their handling of the request') %></td></tr> - <tr><td><strong><%=search_link('status:error_message', nil, nil, true)%></strong></td><td><%= _('Received an error message, such as delivery failure.') %></td></tr> - <tr><td><strong><%=search_link('status:requires_admin', nil, nil, true)%></strong></td><td><%= _('A strange reponse, required attention by the {{site_name}} team', :site_name=>site_name) %></td></tr> - <tr><td><strong><%=search_link('status:user_withdrawn', nil, nil, true)%></strong></td><td><%= _('The requester has abandoned this request for some reason') %></td></tr> + <tr><td><strong><%=search_link('status:waiting_response')%></strong></td><td><%= _('Waiting for the public authority to reply') %></td></tr> + <tr><td><strong><%=search_link('status:not_held')%></strong></td><td><%= _('The public authority does not have the information requested') %></td></tr> + <tr><td><strong><%=search_link('status:rejected')%></strong></td><td><%= _('The request was refused by the public authority') %></td></tr> + <tr><td><strong><%=search_link('status:partially_successful')%></strong></td><td><%= _('Some of the information requested has been received') %></td></tr> + <tr><td><strong><%=search_link('status:successful')%></strong></td><td><%= _('All of the information requested has been received') %></td></tr> + <tr><td><strong><%=search_link('status:waiting_clarification')%></strong></td><td><%= _('The public authority would like part of the request explained') %></td></tr> + <tr><td><strong><%=search_link('status:gone_postal')%></strong></td><td><%= _('The public authority would like to / has responded by post') %></td></tr> + <tr><td><strong><%=search_link('status:internal_review')%></strong></td><td><%= _('Waiting for the public authority to complete an internal review of their handling of the request') %></td></tr> + <tr><td><strong><%=search_link('status:error_message')%></strong></td><td><%= _('Received an error message, such as delivery failure.') %></td></tr> + <tr><td><strong><%=search_link('status:requires_admin')%></strong></td><td><%= _('A strange reponse, required attention by the {{site_name}} team', :site_name=>site_name) %></td></tr> + <tr><td><strong><%=search_link('status:user_withdrawn')%></strong></td><td><%= _('The requester has abandoned this request for some reason') %></td></tr> </table> <h2 id="varieties"><%= _('Table of varieties') %></h2> <p><%= _("All the options below can use <strong>variety</strong> or <strong>latest_variety</strong> before the colon. For example, <strong>variety:sent</strong> will match requests which have <em>ever</em> been sent; <strong>latest_variety:sent</strong> will match only requests that are <em>currently</em> marked as sent.") %></p> <table class="status_table"> - <tr><td><strong><%=search_link('variety:sent', nil, nil, true)%></strong></td><td><%= _('Original request sent') %></td></tr> - <tr><td><strong><%=search_link('variety:followup_sent', nil, nil, true)%></strong></td><td><%= _('Follow up message sent by requester') %></td></tr> - <tr><td><strong><%=search_link('variety:response', nil, nil, true)%></strong></td><td><%= _('Response from a public authority') %></td></tr> - <tr><td><strong><%=search_link('variety:comment', nil, nil, true)%></strong></td><td><%= _('Annotation added to request') %></td></tr> - <tr><td><strong><%=search_link('variety:authority', nil, nil, true)%></strong></td><td><%= _('A public authority') %></td></tr> - <tr><td><strong><%=search_link('variety:user', nil, nil, true)%></strong></td><td><%= _('A {{site_name}} user', :site_name=>site_name) %></td></tr> + <tr><td><strong><%=search_link('variety:sent')%></strong></td><td><%= _('Original request sent') %></td></tr> + <tr><td><strong><%=search_link('variety:followup_sent')%></strong></td><td><%= _('Follow up message sent by requester') %></td></tr> + <tr><td><strong><%=search_link('variety:response')%></strong></td><td><%= _('Response from a public authority') %></td></tr> + <tr><td><strong><%=search_link('variety:comment')%></strong></td><td><%= _('Annotation added to request') %></td></tr> + <tr><td><strong><%=search_link('variety:authority')%></strong></td><td><%= _('A public authority') %></td></tr> + <tr><td><strong><%=search_link('variety:user')%></strong></td><td><%= _('A {{site_name}} user', :site_name=>site_name) %></td></tr> </table> </div> 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 ab5ab2c47..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_url %> -| <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> + <%= 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/<%= AlaveteliConfiguration::twitter_username %>"><%= _("Follow us on twitter") %></a> <%= render :partial => 'general/credits' %> </div> <div class="after-footer"> </div> diff --git a/app/views/general/_frontpage_bodies_list.rhtml b/app/views/general/_frontpage_bodies_list.html.erb index 503b38953..75daea41d 100644 --- a/app/views/general/_frontpage_bodies_list.rhtml +++ b/app/views/general/_frontpage_bodies_list.html.erb @@ -6,12 +6,12 @@ <ul> <% for popular_body in @popular_bodies %> <li><%=public_body_link(popular_body)%> - <%= n_('%d request', '%d requests', popular_body.info_requests_count) % popular_body.info_requests_count %> + <%= n_('{{count}} request', '{{count}} requests', popular_body.info_requests_count, :count => popular_body.info_requests_count) %> </li> <% end%> </ul> <p><strong> - <%= link_to _('Browse all authorities...'), list_public_bodies_default %> + <%= link_to _('Browse all authorities...'), list_public_bodies_default_path %> </strong></p> </div> <% end %> diff --git a/app/views/general/_frontpage_intro_sentence.rhtml b/app/views/general/_frontpage_intro_sentence.html.erb index 70b47ad06..74b849fc9 100644 --- a/app/views/general/_frontpage_intro_sentence.rhtml +++ b/app/views/general/_frontpage_intro_sentence.html.erb @@ -1,4 +1,4 @@ <h2> Your <strong>Right to Know</strong> </h2> -<p>Every citizen has the right to access information held by public authorities. <strong>By law, they have to respond</strong>. <a href="<%= help_about_url %>">Find out more about freedom of information.</a></p> +<p>Every citizen has the right to access information held by public authorities. <strong>By law, they have to respond</strong>. <a href="<%= help_about_path %>">Find out more about freedom of information.</a></p> 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 3b0efb65e..fa498dfa7 100644 --- a/app/views/general/_frontpage_requests_list.rhtml +++ b/app/views/general/_frontpage_requests_list.html.erb @@ -19,17 +19,17 @@ :public_body_link => public_body_link(event.info_request.public_body)) %> <% end %> - <%=link_to h(event.info_request.title), request_url(event.info_request)%> + <%=link_to h(event.info_request.title), request_path(event.info_request)%> <%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(event.described_at)) %> - <p class="excerpt" onclick="document.location.href='<%=request_url(event.info_request)%>'"><%= excerpt(event.search_text_main(true), "", 200) %></p> + <p class="excerpt" onclick="document.location.href='<%=request_path(event.info_request)%>'"><%= excerpt(event.search_text_main(true), "", 200) %></p> </li> <% end %> </ul> <p><strong> <% if @request_events_all_successful %> - <%=link_to _('More successful requests...'), request_list_successful_url %> + <%=link_to _('More successful requests...'), request_list_successful_path %> <% else %> - <%=link_to _('More requests...'), request_list_all_url %> + <%=link_to _('More requests...'), request_list_all_path %> <% end %> </strong></p> </div> 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..d0040bb0d 100644 --- a/app/views/general/_locale_switcher.rhtml +++ b/app/views/general/_locale_switcher.html.erb 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.html.erb b/app/views/general/_orglink.html.erb new file mode 100644 index 000000000..66002c021 --- /dev/null +++ b/app/views/general/_orglink.html.erb @@ -0,0 +1,2 @@ +<%# Put the link to your organisation here, or leave blank %> +<%= link_to image_tag('logo.png'), frontpage_path, :id=>'logo' %> diff --git a/app/views/general/_orglink.rhtml b/app/views/general/_orglink.rhtml deleted file mode 100644 index fbe688d85..000000000 --- a/app/views/general/_orglink.rhtml +++ /dev/null @@ -1,2 +0,0 @@ -<%# Put the link to your organisation here, or leave blank %> -<%= link_to image_tag('logo.png'), frontpage_url, :id=>'logo' %> diff --git a/app/views/admin_general/_admin_navbar.rhtml b/app/views/general/_popup_banner.html.erb index 8b1378917..8b1378917 100644 --- a/app/views/admin_general/_admin_navbar.rhtml +++ b/app/views/general/_popup_banner.html.erb diff --git a/app/views/general/_popup_banner.rhtml b/app/views/general/_popup_banner.rhtml deleted file mode 100644 index 8b1378917..000000000 --- a/app/views/general/_popup_banner.rhtml +++ /dev/null @@ -1 +0,0 @@ - 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 8ef928bba..c7f2cedea 100644 --- a/app/views/general/_topnav.rhtml +++ b/app/views/general/_topnav.html.erb @@ -1,10 +1,10 @@ <div id="topnav"> <ul id="navigation"> - <li class="<%= 'selected' if params[:controller] == 'general' and params[:action] != 'blog' and params[:action] != 'search' %>"><%= link_to _("Home"), frontpage_url %></li> - <li class="<%= 'selected' if params[:controller] == 'request' and ['new', 'select_authority'].include?(params[:action]) %>"><%= link_to _("Make a request"), select_authority_url, :id => 'make-request-link' %></li> - <li class="<%= 'selected' if params[:controller] == 'request' and !['new', 'select_authority'].include?(params[:action]) %>"><%= link_to _("View requests"), request_list_successful_url %></li> - <li class="<%= 'selected' if params[:controller] == 'public_body' %>"><%= link_to _("View authorities"), list_public_bodies_default %></li> - <li class="<%= 'selected' if params[:controller] == 'general' and params[:action] == 'blog' %>"><%= link_to _("Read blog"), blog_url %></li> - <li class="<%= 'selected' if params[:controller] == 'help' %>"><%= link_to _("Help"), help_about_url %></li> + <li class="<%= 'selected' if params[:controller] == 'general' and params[:action] != 'blog' and params[:action] != 'search' %>"><%= link_to _("Home"), frontpage_path %></li> + <li class="<%= 'selected' if params[:controller] == 'request' and ['new', 'select_authority'].include?(params[:action]) %>"><%= link_to _("Make a request"), select_authority_path, :id => 'make-request-link' %></li> + <li class="<%= 'selected' if params[:controller] == 'request' and !['new', 'select_authority'].include?(params[:action]) %>"><%= link_to _("View requests"), request_list_successful_path %></li> + <li class="<%= 'selected' if params[:controller] == 'public_body' %>"><%= link_to _("View authorities"), list_public_bodies_default_path %></li> + <li class="<%= 'selected' if params[:controller] == 'general' and params[:action] == 'blog' %>"><%= link_to _("Read blog"), blog_path %></li> + <li class="<%= 'selected' if params[:controller] == 'help' %>"><%= link_to _("Help"), help_about_path %></li> </ul> </div> diff --git a/app/views/general/blog.rhtml b/app/views/general/blog.html.erb index 07d6d2f14..ef587421e 100644 --- a/app/views/general/blog.rhtml +++ b/app/views/general/blog.html.erb @@ -5,11 +5,11 @@ <div class="act_link"> <h2><%= _("Stay up to date") %></h2> <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" valign="middle"> <a href="<%= @feed_url %>"><%= _("Subscribe to blog") %></a> + <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 7d402b9b9..6234687f2 100644 --- a/app/views/general/search.rhtml +++ b/app/views/general/search.html.erb @@ -16,13 +16,13 @@ <% if @query.nil? %> <h1><%= _("Search") %></h1> <% else %> - <h1><%= _("Search results") %></h1> + <h1><%= _("Search results") %></h1> <% end%> <% 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,7 +35,7 @@ <% end %> </div> <% else %> - <% form_tag(request.url, {:method => "get", :id => "search_form"}) do %> + <%= form_tag(request.url, {:method => "get", :id => "search_form"}) do %> <p> <%= text_field_tag 'query', params[:query], { :size => 40, :title => "type your search term here" } %> <%= hidden_field_tag 'sortby', @inputted_sortby %> @@ -43,7 +43,7 @@ <%= hidden_field_tag 'bodies', 1 %> <% end %> <%= submit_tag _("Search") %> - <%= link_to(_("Advanced search"), advanced_search_url) %> + <%= link_to(_("Advanced search"), advanced_search_path) %> </p> <div id="common-subfilters"> @@ -56,7 +56,7 @@ ["all", _("everything")]]%> <% for variety, label in labels %> <% if @variety_postfix != variety %> - <%= link_to label, search_url([params[:query], variety, @sort_postfix]) %> + <%= link_to label, search_path([params[:query], variety, @sort_postfix]) %> <% else %> <%= label %> <% end %> @@ -94,7 +94,7 @@ <div> <h3 class="title"><%= _("Search in") %></h3> - <% [["sent", _("messages from users")], + <% [["sent", _("messages from users")], ["response", _("messages from authorities")], ["comment", _("comments")]].each_with_index do |item, index| variety, title = item %> @@ -110,21 +110,21 @@ <label class="form_label" for="query"> <%= _("and") %></label> <%= text_field_tag(:request_date_before, params[:request_date_before], {:class => "use-datepicker", :size => 10}) %> </div> - </div> + </div> <% end %> - + <div> <%= submit_tag _("Filter") if @variety_postfix == "requests"%> </div> <% end # Search form%> - + <% end # if @advanced %> <% if !@query.nil? %> <p id="search_controls"> - <%=link_to_unless @sortby == 'relevant', _("Show most relevant results first"), search_url([params[:query], @variety_postfix, 'relevant'], params) %> + <%=link_to_unless @sortby == 'relevant', _("Show most relevant results first"), search_path([params[:query], @variety_postfix, 'relevant'], params) %> | - <%=link_to_unless @sortby == 'newest', _("Newest results first"), search_url([params[:query], @variety_postfix, 'newest'], params) %> + <%=link_to_unless @sortby == 'newest', _("Newest results first"), search_path([params[:query], @variety_postfix, 'newest'], params) %> <% if @sortby == 'described' %> | <%= _('Recently described results first') %> <% end %> @@ -162,9 +162,9 @@ <%= will_paginate WillPaginate::Collection.new(@page, @bodies_per_page, @xapian_bodies.matches_estimated) %> <% elsif @bodies && !@query.nil? && @xapian_bodies.results.size == 0 && @page == 1 %> <% if @spelling_correction %> - <p id="did_you_mean"><%= _('Did you mean: {{correction}}', :correction => search_link(@spelling_correction, @postfix)) %></p> + <p id="did_you_mean"><%= _('Did you mean: {{correction}}', :correction => search_link(@spelling_correction)) %></p> <% end %> - <p><%= raw(_('<a href="%s">Browse all</a> or <a href="%s">ask us to add one</a>.') % [list_public_bodies_default, help_requesting_path + '#missing_body']) %></p> + <p><%= raw(_('<a href="{{browse_url}}">Browse all</a> or <a href="{{add_url}}">ask us to add one</a>.', :browse_url => list_public_bodies_default_path.html_safe, :add_url => (help_requesting_path + '#missing_body').html_safe)) %></p> <% end %> </div> 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 da6253f87..57390d65a 100644 --- a/app/views/help/api.rhtml +++ b/app/views/help/api.html.erb @@ -19,7 +19,7 @@ <dt>Linking to new requests</dt> <dd> <p>To encourage your users to make links to a particular public authority, use URLs of the form - <%= link_to new_request_to_body_url(:url_name => "liverpool_city_council") , new_request_to_body_url(:url_name => "liverpool_city_council") %>. + <%= link_to new_request_to_body_path(:url_name => "liverpool_city_council") , new_request_to_body_path(:url_name => "liverpool_city_council") %>. These are the parameters you can add to those URLs, either in the URL or from a form. <ul> @@ -30,15 +30,15 @@ </ul> </dd> - <dt>RSS (actually, Atom) feeds</h2> + <dt>RSS (actually, Atom) feeds</dt> <dd> <p>There are Atom feeds on most pages which list FOI requests, which you can use to get updates and links in XML format. Find the URL of the Atom feed in one of these ways: <ul> <li>Look for the <img src="/images/feed-16.png" alt=""> RSS feed links.</li> - <li>Examine the <tt><link rel="alternate" type="application/atom+xml"></tt> tag in the head of the HTML. </li> - <li>Add <tt>/feed</tt> to the start of another URL. + <li>Examine the <code><link rel="alternate" type="application/atom+xml"></code> tag in the head of the HTML. </li> + <li>Add <code>/feed</code> to the start of another URL. </ul> <p>In particular, even complicated search queries have Atom feeds. @@ -53,8 +53,8 @@ objects in a structured form. Find them by: </p> <ul> - <li>Adding <tt>.json</tt> to the end of the URL. </li> - <li>Look for the <tt><link rel="alternate" type="application/json"></tt> tag in the head of the HTML. </li> + <li>Adding <code>.json</code> to the end of the URL. </li> + <li>Look for the <code><link rel="alternate" type="application/json"></code> tag in the head of the HTML. </li> </ul> <p>Requests, users and authorities all have JSON versions containing basic @@ -67,7 +67,7 @@ <dd> <p> A spreadsheet file listing every body in WhatDoTheyKnow is available: - <%= link_to "all-authorities.csv", all_public_bodies_csv_url() %> + <%= link_to "all-authorities.csv", all_public_bodies_csv_path %> </p> </dd> diff --git a/app/views/help/contact.rhtml b/app/views/help/contact.html.erb index fab5017b8..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_url(: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 b13e225fe..6db706f78 100644 --- a/app/views/help/officers.rhtml +++ b/app/views/help/officers.html.erb @@ -222,7 +222,7 @@ form in an annotation. </dd> - <dt id="copyright"><a name="commercial"></a>What is your policy on copyright of documents?<a href="#copyright">#</a> </dt> + <dt id="copyright"><a id="commercial"></a>What is your policy on copyright of documents?<a href="#copyright">#</a> </dt> <dd>Our Freedom of Information law is "applicant blind", so anyone in the world can request the same document and get a copy of it. @@ -235,9 +235,6 @@ </dl> - - </dl> - <p><strong>If you haven't already</strong>, read <a href="<%= help_about_path %>">the introduction</a> --> <br><strong>Otherwise</strong>, the <a href="<%= help_credits_path %>">credits</a> or the <a href="<%= help_api_path %>">programmers API</a> --> 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 2b00341c2..79e3f8273 100644 --- a/app/views/help/unhappy.rhtml +++ b/app/views/help/unhappy.html.erb @@ -29,7 +29,7 @@ to your request '<%=request_link(@info_request) %>'? <p> <% if !@info_request.nil? %> - <%= link_to "Request an internal review", show_response_no_followup_url(:id => @info_request.id, :incoming_message_id => nil) + "?internal_review=1#followup", :class => 'link_button_green' %> and then write a message asking the authority to review your request. + <%= link_to "Request an internal review", show_response_no_followup_path(:id => @info_request.id, :incoming_message_id => nil) + "?internal_review=1#followup", :class => 'link_button_green' %> and then write a message asking the authority to review your request. <% else %> At the bottom of the relevant request page on <%= site_name %> choose "request an internal review". Then write a message asking for an internal @@ -62,7 +62,7 @@ to the Scottish Information Commissioner</a>. Information Commissioner, either <% if !@info_request.nil? %> include a link to your request - <strong><%=h main_url(request_url(@info_request)) %></strong> + <strong><%=h request_url(@info_request) %></strong> <% else %> include a link to your request on <%= site_name %> <% end %> 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.html.erb b/app/views/layouts/admin.html.erb new file mode 100644 index 000000000..a58913892 --- /dev/null +++ b/app/views/layouts/admin.html.erb @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<html lang="en-gb"> + <head> + <meta http-equiv="content-type" content="text/html;charset=UTF-8" > + <title><%= site_name %> admin<%= @title ? ":" : "" %> <%=@title%></title> + + <%= javascript_include_tag '/javascripts/jquery.js', '/admin/javascripts/jquery-ui.min.js', '/admin/javascripts/bootstrap-collapse', '/admin/javascripts/bootstrap-tab', '/admin/javascripts/admin' %> + <%= stylesheet_link_tag 'admin-theme/jquery-ui-1.8.15.custom.css', :rel => 'stylesheet'%> + <%= stylesheet_link_tag "/admin/stylesheets/admin", :title => "Main", :rel => "stylesheet" %> + + </head> + <body class="admin"> + <div id="main" class="container"> + <%= render :partial => 'admin_general/admin_navbar' %> + <% if flash[:error] %> + <div class="row"> + <div class="span12"> + <div class="alert alert-error"> + <%= flash[:error] %> + </div> + </div> + </div> + <% end %> + + <% if flash[:notice] %> + <div class="row"> + <div class="span12"> + <div class="alert alert-info"> + <%= flash[:notice] %> + </div> + </div> + </div> + <% end %> + + <%= yield %> + </div> + </body> +</html> diff --git a/app/views/layouts/admin.rhtml b/app/views/layouts/admin.rhtml deleted file mode 100644 index d85eecbf2..000000000 --- a/app/views/layouts/admin.rhtml +++ /dev/null @@ -1,39 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> -<html lang="en-gb"> - <head> - <meta http-equiv="content-type" content="text/html;charset=UTF-8" > - <title><%= site_name %> admin<%= @title ? ":" : "" %> <%=@title%></title> - - <%= javascript_include_tag 'jquery.js', 'jquery-ui.min' %> - - <%= stylesheet_link_tag 'admin-theme/jquery-ui-1.8.15.custom.css', :rel => 'stylesheet'%> - <%= stylesheet_link_tag 'admin', :title => "Main", :rel => "stylesheet" %> - </head> - <body class="admin"> - - <p> - <strong><%= link_to 'Alaveteli', main_url('/') %> admin:</strong> - <%= link_to 'Summary', admin_url("") %> - | <%= link_to 'Timeline', admin_url("timeline") %> - | <%= link_to 'Stats', admin_url("stats") %> - | <%= link_to 'Debug', admin_url("debug") %> - <strong>View:</strong> - <%= link_to 'Authorities', admin_url("body/list") %> - | <%= link_to 'Requests', admin_url("request/list") %> - | <%= link_to 'Users', admin_url("user/list") %> - | <%= link_to 'Tracks', admin_url("track/list") %> - </p> - <%= render :partial => 'general/locale_switcher' %> - - <% if flash[:error] %> - <p id="error"><%= flash[:error] %></p> - <% end %> - - <% if flash[:notice] %> - <p id="notice"><%= flash[:notice] %></p> - <% end %> - - <%= yield %> - - </body> -</html> 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 9eb967578..32ea5e4ff 100644 --- a/app/views/layouts/default.rhtml +++ b/app/views/layouts/default.html.erb @@ -1,6 +1,7 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<!DOCTYPE html> <html lang="<%= I18n.locale %>"> <head> + <meta charset="utf-8"> <title> <% if @title %> <%=@title%> - <%= site_name %> @@ -13,7 +14,7 @@ <%= render :partial => 'general/stylesheet_includes' %> <% if is_admin? %> - <%= stylesheet_link_tag "/adminbootstraptheme/stylesheets/admin", :title => "Main", :rel => "stylesheet" %> + <%= stylesheet_link_tag "/admin/stylesheets/admin", :title => "Main", :rel => "stylesheet" %> <% end %> <%= javascript_include_tag 'jquery.js', 'jquery-ui.min','jquery.cookie.js', 'general.js' %> @@ -32,7 +33,7 @@ <% end %> <% end %> <% if @has_json %> - <link rel="alternate" type="application/json" title="JSON version of this page" href="<%=h main_url(request.request_uri, '.json') %>"> + <link rel="alternate" type="application/json" title="JSON version of this page" href="<%=h url_for(request.query_parameters.merge(:format => 'json')) %>"> <% end %> <% if @no_crawl %> @@ -42,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() { @@ -66,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 %> @@ -92,9 +93,9 @@ <% end %> - <%= link_to _("Sign out"), signout_url(:r => request.request_uri) %> + <%= link_to _("Sign out"), signout_path(:r => request.fullpath) %> <% else %> - <%= link_to _("Sign in or sign up"), signin_url(:r => request.request_uri) %> + <%= link_to _("Sign in or sign up"), signin_path(:r => request.fullpath) %> <% end %> </div> <% end %> @@ -139,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 74c79b701..d7918cffc 100644 --- a/app/views/layouts/no_chrome.rhtml +++ b/app/views/layouts/no_chrome.html.erb @@ -1,6 +1,7 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<!DOCTYPE html> <html lang="<%= I18n.locale %>"> <head> + <meta charset="utf-8"> <title> <% if @title %> <%=@title%> - <%= site_name %> @@ -11,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> @@ -38,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 7050a295b..049ebc881 100644 --- a/app/views/outgoing_mailer/followup.rhtml +++ b/app/views/outgoing_mailer/followup.text.erb @@ -1,6 +1,6 @@ -<%= @outgoing_message.body.strip %> +<%= raw @outgoing_message.body.strip %> -<%= @outgoing_message.quoted_part_to_append_to_email.strip %> +<%= raw @outgoing_message.quoted_part_to_append_to_email.strip %> ------------------------------------------------------------------- <%= _('Please use this email address for all replies to this request:')%> diff --git a/app/views/outgoing_mailer/initial_request.rhtml b/app/views/outgoing_mailer/initial_request.text.erb index d537a20bc..5c418ecc7 100644 --- a/app/views/outgoing_mailer/initial_request.rhtml +++ b/app/views/outgoing_mailer/initial_request.text.erb @@ -1,4 +1,4 @@ -<%= @outgoing_message.body.strip %> +<%= raw @outgoing_message.body.strip %> ------------------------------------------------------------------- diff --git a/app/views/public_body/_alphabet.html.erb b/app/views/public_body/_alphabet.html.erb new file mode 100644 index 000000000..111da5b3b --- /dev/null +++ b/app/views/public_body/_alphabet.html.erb @@ -0,0 +1,3 @@ +<%= "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/_alphabet.rhtml b/app/views/public_body/_alphabet.rhtml deleted file mode 100644 index 92674b8aa..000000000 --- a/app/views/public_body/_alphabet.rhtml +++ /dev/null @@ -1,3 +0,0 @@ -<% "A".upto("Z") do |l| -%> - <%= link_to_unless (@tag == l), l, list_public_bodies_url(: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 b01d2ebb2..8e0a64df7 100644 --- a/app/views/public_body/_body_listing_single.rhtml +++ b/app/views/public_body/_body_listing_single.html.erb @@ -4,7 +4,7 @@ <div class="body_listing"> <span class="head"> - <%= link_to highlight_words(public_body.name, @highlight_words), public_body_url(public_body) %> + <%= link_to highlight_words(public_body.name, @highlight_words), public_body_path(public_body) %> </span> <span class="desc"> <% if !public_body.short_name.empty? || !public_body.notes_without_html.empty? %> @@ -18,9 +18,10 @@ <% end %> </span> <span class="bottomline"> - <%= n_('%d request made.', '%d requests made.', public_body.info_requests.size) % public_body.info_requests.size %> + <%= 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_url(public_body) %>. + <%= link_to _("Make your own request"), public_body_path(public_body) %>. <% end %> <br> <span class="date_added"> diff --git a/app/views/public_body/_list_sidebar_extra.html.erb b/app/views/public_body/_list_sidebar_extra.html.erb new file mode 100644 index 000000000..290593d6a --- /dev/null +++ b/app/views/public_body/_list_sidebar_extra.html.erb @@ -0,0 +1,6 @@ +<p> + <%= link_to _('Are we missing a public authority?'), help_requesting_path + '#missing_body' %> +</p> +<p> + <%= link_to _('List of all authorities (CSV)'), all_public_bodies_csv_path %> +</p> diff --git a/app/views/public_body/_list_sidebar_extra.rhtml b/app/views/public_body/_list_sidebar_extra.rhtml deleted file mode 100644 index 54f20a736..000000000 --- a/app/views/public_body/_list_sidebar_extra.rhtml +++ /dev/null @@ -1,6 +0,0 @@ -<p> - <%= raw(_('<a href="%s">Are we missing a public authority?</a>') % [help_requesting_path + '#missing_body']) %> -</p> -<p> - <%= link_to _('List of all authorities (CSV)'), all_public_bodies_csv_url() %> -</p> 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 dd97b99fd..ce24daaf9 100644 --- a/app/views/public_body/list.rhtml +++ b/app/views/public_body/list.html.erb @@ -10,7 +10,7 @@ <% for row in PublicBodyCategories::get().with_headings() %> <% if row.instance_of?(Array) %> <li> - <%= link_to_unless (@tag == row[0]), row[1], list_public_bodies_url(:tag => row[0]) %> + <%= link_to_unless (@tag == row[0]), row[1], list_public_bodies_path(:tag => row[0]) %> </li> <% else %> <% if not first_row %> @@ -23,7 +23,7 @@ <% end %> <% end %> <% if not first_row %> - </ul> + </ul> <% end %> <%= render :partial => "list_sidebar_extra" %> </div> @@ -32,16 +32,22 @@ <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" } ) %> + <%= text_field_tag(:public_body_query, params[:public_body_query], { :title => "type your search term here" } ) %> <%= submit_tag(_("Search")) %> </div> <% end %> -<h2 class="publicbody_results"><%= n_('Found %d public authority %s', 'Found %d public authorities %s', @public_bodies.total_entries) % [@public_bodies.total_entries, @description] %></h2> +<h2 class="publicbody_results"> + <%= n_('Found {{count}} public authority {{description}}', + 'Found {{count}} public authorities {{description}}', + @public_bodies.total_entries, + :count => @public_bodies.total_entries, + :description => @description) %> +</h2> <%= render :partial => 'body_listing', :locals => { :public_bodies => @public_bodies } %> <%= will_paginate(@public_bodies) %><br/> - <%= raw _('<a href="%s">Can\'t find the one you want?</a>') % [help_requesting_path + '#missing_body'] %> + <%= link_to _("Can't find the one you want?"), help_requesting_path + '#missing_body' %> </div> diff --git a/app/views/public_body/show.rhtml b/app/views/public_body/show.html.erb index 8fc1eadda..47075a1f5 100644 --- a/app/views/public_body/show.rhtml +++ b/app/views/public_body/show.html.erb @@ -4,7 +4,12 @@ <h2><%= _('Follow this authority')%></h2> <% follower_count = TrackThing.count(:all, :conditions => ["public_body_id = ?", @public_body.id]) %> - <p><%= raw(n_("<span id='follow_count'>%d</span> person is following this authority", "<span id='follow_count'>%d</span> people are following this authority", follower_count) % follower_count) %></p> + <p> + <%= n_("{{count}} person is following this authority", + "{{count}} people are following this authority", + follower_count, + :count => content_tag(:span, follower_count, :id => "follow_count")) %> + </p> <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => false, :location => 'sidebar' } %> <h2><%= _('More about this authority')%></h2> @@ -26,7 +31,7 @@ <% end %> <% end %> <% end %> - <%= link_to _('View FOI email address'), view_public_body_email_url(@public_body.url_name) %><br> + <%= link_to _('View FOI email address'), view_public_body_email_path(@public_body.url_name) %><br> </div> <div id="header_left"> @@ -37,7 +42,7 @@ <%=@public_body.type_of_authority(true)%><% if not @public_body.short_name.empty? %>, <%= _('also called {{public_body_short_name}}', :public_body_short_name => h(@public_body.short_name))%><% end %> <% if !@user.nil? && @user.admin_page_links? %> - (<%= link_to _("admin"), public_body_admin_url(@public_body) %>) + (<%= link_to _("admin"), admin_body_show_path(@public_body) %>) <% end %> </p> @@ -51,12 +56,7 @@ <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 %> - <%= _('<a class="link_button_green" href="{{url}}">{{text}}</a>', :url=>new_request_to_body_url(:url_name => @public_body.url_name), :text=>_("Start"))%> + <%= 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' %> @@ -91,9 +91,13 @@ <%= pluralize(@public_body.info_requests.size, "Environmental Information Regulations request made using this site") %> <% else %> <% if @public_body.info_requests.size > 4 %> - <%= n_('Search within the %d Freedom of Information requests to %s', 'Search within the %d Freedom of Information requests made to %s', @public_body.info_requests.size) % [@public_body.info_requests.size, @public_body.name] %> + <%= n_('Search within the {{count}} Freedom of Information requests to {{public_body_name}}', 'Search within the {{count}} Freedom of Information requests made to {{public_body_name}}', @public_body.info_requests.size, :count => @public_body.info_requests.size, :public_body_name => @public_body.name) %> <% else %> - <%= n_('%d Freedom of Information request to %s', '%d Freedom of Information requests to %s', @public_body.info_requests.size) % [@public_body.info_requests.size, @public_body.name] %> + <%= n_('{{count}} Freedom of Information request to {{public_body_name}}', + '{{count}} Freedom of Information requests to {{public_body_name}}', + @public_body.info_requests.size, + :count => @public_body.info_requests.size, + :public_body_name => @public_body.name) %> <% end %> <% end %> <%= @page_desc %> diff --git a/app/views/public_body/view_email.rhtml b/app/views/public_body/view_email.html.erb index 79d7f7f4c..3f0a558c7 100644 --- a/app/views/public_body/view_email.rhtml +++ b/app/views/public_body/view_email.html.erb @@ -25,19 +25,19 @@ <p> <% if @public_body.is_requestable? || @public_body.not_requestable_reason != 'bad_contact' %> - <%= raw _('If the address is wrong, or you know a better address, please <a href="%s">contact us</a>.')% [help_contact_path]%> + <%= raw(_('If the address is wrong, or you know a better address, please <a href="{{url}}">contact us</a>.', :url => help_contact_path.html_safe)) %> <% else %> - <%= raw _(' If you know the address to use, then please <a href="%s">send it to us</a>. - You may be able to find the address on their website, or by phoning them up and asking.')% [help_contact_path] %> + <%= raw(_(' If you know the address to use, then please <a href="{{url}}">send it to us</a>. + You may be able to find the address on their website, or by phoning them up and asking.', :url =>help_contact_path.html_safe)) %> <% end %> </p> <div id="stepwise_make_request_view_email"> <strong> <% if @public_body.eir_only? %> - <%= link_to "Make a new EIR request", new_request_to_body_url(:url_name => @public_body.url_name)%> + <%= link_to "Make a new EIR request", new_request_to_body_path(:url_name => @public_body.url_name)%> <% else %> - <%= link_to "Make a new FOI request", new_request_to_body_url(:url_name => @public_body.url_name)%> + <%= link_to "Make a new FOI request", new_request_to_body_path(:url_name => @public_body.url_name)%> <% end %> to <%= h(@public_body.name) %> </strong> 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 3d74cf42d..b54a8f5fb 100644 --- a/app/views/request/_after_actions.rhtml +++ b/app/views/request/_after_actions.html.erb @@ -7,7 +7,7 @@ <ul> <% if @info_request.comments_allowed? %> <li> - <%= raw(_('<a href="%s">Add an annotation</a> (to help the requester or others)') % [new_comment_url(:url_title => @info_request.url_title)]) %> + <%= raw(_('<a href="{{url}}">Add an annotation</a> (to help the requester or others)', :url => new_comment_url(:url_title => @info_request.url_title).html_safe)) %> </li> <% end %> <% if @old_unclassified %> @@ -17,7 +17,7 @@ <% end %> <% if @info_request.all_can_view? %> <li> - <%= link_to _("Download a zip file of all correspondence"), download_entire_request_url(:url_title => @info_request.url_title) %> + <%= link_to _("Download a zip file of all correspondence"), download_entire_request_path(:url_title => @info_request.url_title) %> </li> <% end %> </ul> @@ -29,18 +29,18 @@ <li> <% if @last_response.nil? %> - <%= link_to _("Send a followup"), show_response_no_followup_url(:id => @info_request.id, :incoming_message_id => nil) + "#followup" %> + <%= link_to _("Send a followup"), show_response_no_followup_path(:id => @info_request.id, :incoming_message_id => nil) + "#followup" %> <% else %> - <%= link_to _("Write a reply"), show_response_url(:id => @info_request.id, :incoming_message_id => @last_response.id) + "#followup" %> + <%= link_to _("Write a reply"), show_response_path(:id => @info_request.id, :incoming_message_id => @last_response.id) + "#followup" %> <% end %> </li> <% if !@old_unclassified %> <li> - <%= link_to _("Update the status of this request"), request_url(@info_request, :update_status => 1) %> + <%= link_to _("Update the status of this request"), request_path(@info_request, :update_status => 1) %> </li> <% end %> <li> - <%= link_to _("Request an internal review"), show_response_no_followup_url(:id => @info_request.id, :incoming_message_id => nil) + "?internal_review=1#followup" %> + <%= link_to _("Request an internal review"), show_response_no_followup_path(:id => @info_request.id, :incoming_message_id => nil) + "?internal_review=1#followup" %> </li> </ul> </div> @@ -50,7 +50,7 @@ <strong><%= _('{{public_body_name}} only:',:public_body_name=>h(@info_request.public_body.name) ) %> </strong> <ul> <li> - <%= link_to _("Respond to request"), upload_response_url(:url_title => @info_request.url_title) %> + <%= link_to _("Respond to request"), upload_response_path(:url_title => @info_request.url_title) %> </li> </ul> </div> diff --git a/app/views/request/_bubble.rhtml b/app/views/request/_bubble.html.erb index 747e2aa1f..94498612a 100644 --- a/app/views/request/_bubble.rhtml +++ b/app/views/request/_bubble.html.erb @@ -5,26 +5,26 @@ <% attachments.each do |a| %> <p class="attachment"> <% - attachment_url = get_attachment_url(:id => incoming_message.info_request_id, + attachment_path = get_attachment_path(:id => incoming_message.info_request_id, :incoming_message_id => incoming_message.id, :part => a.url_part_number, :file_name => a.display_filename) - attachment_as_html_url = get_attachment_as_html_url(:id => incoming_message.info_request_id, + attachment_as_html_path = get_attachment_as_html_path(:id => incoming_message.info_request_id, :incoming_message_id => incoming_message.id, :part => a.url_part_number, :file_name => a.display_filename + '.html') %> <% img_filename = "icon_" + a.content_type.sub('/', '_') + "_large.png" full_filename = File.expand_path(File.join(File.dirname(__FILE__), "../../../public/images", img_filename)) if File.exist?(full_filename) %> - <a href="<%=attachment_url%>"><img class="attachment_image" alt="Attachment" src="/images/<%=img_filename%>"></a> + <a href="<%=attachment_path%>"><img class="attachment_image" alt="Attachment" src="/images/<%=img_filename%>"></a> <% else %> - <a href="<%=attachment_url%>"><img class="attachment_image" alt="Attachment" src="/images/icon_unknown.png"></a> + <a href="<%=attachment_path%>"><img class="attachment_image" alt="Attachment" src="/images/icon_unknown.png"></a> <% end %> <strong><%= h a.display_filename %></strong> <br> <%= a.display_size %> - <%= link_to "Download", attachment_url %> + <%= link_to "Download", attachment_path %> <% if a.has_body_as_html? && incoming_message.info_request.all_can_view? %> - <%= link_to "View as HTML", attachment_as_html_url %> + <%= link_to "View as HTML", attachment_as_html_path %> <% end %> <!-- (<%= a.content_type %>) --> <%= a.extra_note %> diff --git a/app/views/request/_correspondence.rhtml b/app/views/request/_correspondence.html.erb index 99c6c7d26..68711b259 100644 --- a/app/views/request/_correspondence.rhtml +++ b/app/views/request/_correspondence.html.erb @@ -21,9 +21,9 @@ if not incoming_message.nil? <p class="event_actions"> <% if !@user.nil? && @user.admin_page_links? %> - <%= link_to "Admin", admin_url("request/show_raw_email/" + incoming_message.raw_email_id.to_s) %> | + <%= link_to "Admin", admin_request_show_raw_email_path(incoming_message.raw_email_id) %> | <% end %> - <%= link_to _("Link to this"), incoming_message_url(incoming_message), :class => "link_to_this" %> + <%= link_to _("Link to this"), incoming_message_path(incoming_message), :class => "link_to_this" %> </p> </div> <% @@ -51,7 +51,7 @@ elsif [ 'sent', 'followup_sent' ].include?(info_request_event.event_type) <% end %> --> - <%= link_to _("Link to this"), outgoing_message_url(outgoing_message), :class => "link_to_this" %> + <%= link_to _("Link to this"), outgoing_message_path(outgoing_message), :class => "link_to_this" %> </p> </div> <% elsif [ 'resent', 'followup_resent' ].include?(info_request_event.event_type) %> diff --git a/app/views/request/_describe_state.rhtml b/app/views/request/_describe_state.html.erb index 5b6004e81..05cce013e 100644 --- a/app/views/request/_describe_state.rhtml +++ b/app/views/request/_describe_state.html.erb @@ -1,9 +1,9 @@ <% 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> <!------------------------------------------------> + <hr> <h3><%= _('This request is still in progress:') %></h3> <% if @info_request.described_state != 'internal_review' %> <div> @@ -40,7 +40,7 @@ <%= render :partial => 'general/custom_state_transitions_pending', :locals => {:id_suffix => id_suffix } %> - <hr> <!------------------------------------------------> + <hr> <h3><%= _('This particular request is finished:') %></h3> <% if @info_request.described_state == 'internal_review' %> @@ -67,7 +67,7 @@ <%= render :partial => 'general/custom_state_transitions_complete', :locals => {:id_suffix => id_suffix } %> - <hr> <!------------------------------------------------> + <hr> <h3><%= _('Other:') %></h3> <div> @@ -97,18 +97,17 @@ <p> <%= hidden_field_tag 'last_info_request_event_id', @last_info_request_event_id, :id => 'last_info_request_event_id' + id_suffix %> - <%= hidden_field_tag 'submitted_describe_state', 1, :id => 'submitted_describe_state' + id_suffix %> <%= submit_tag _("Submit status") %> (<%= _('and we\'ll suggest <strong>what to do next</strong>') %>) </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 – - 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 045bcd9ba..bb099ff15 100644 --- a/app/views/request/_followup.rhtml +++ b/app/views/request/_followup.html.erb @@ -25,18 +25,18 @@ <ul> <% @info_request.who_can_followup_to(incoming_message).each do |name, email, id| %> <% if id.nil? && !incoming_message.nil? && incoming_message.valid_to_reply_to? %> - <li><%= link_to(_("the main FOI contact address for {{public_body}}", :public_body => name), show_response_no_followup_url(:id => @info_request.id, :incoming_message_id => nil)) %></li> + <li><%= link_to(_("the main FOI contact address for {{public_body}}", :public_body => name), show_response_no_followup_path(:id => @info_request.id, :incoming_message_id => nil)) %></li> <% else %> <% if !id.nil? %> <% if @info_request.public_body.request_email == email %> <% if !incoming_message.nil? %> - <li><%= link_to(_("the main FOI contact address for {{public_body}}", :public_body => name), show_response_no_followup_url(:id => @info_request.id, :incoming_message_id => nil)) %></li> + <li><%= link_to(_("the main FOI contact address for {{public_body}}", :public_body => name), show_response_no_followup_path(:id => @info_request.id, :incoming_message_id => nil)) %></li> <% end %> <% else %> - <li><%= link_to name, show_response_url(:id => @info_request.id, :incoming_message_id => id)%></li> + <li><%= link_to name, show_response_path(:id => @info_request.id, :incoming_message_id => id)%></li> <% end %> <% else %> - <li><%= link_to(_("the main FOI contact address for {{public_body}}", :public_body => name), show_response_no_followup_url(:id => @info_request.id, :incoming_message_id => nil)) %></li> + <li><%= link_to(_("the main FOI contact address for {{public_body}}", :public_body => name), show_response_no_followup_path(:id => @info_request.id, :incoming_message_id => nil)) %></li> <% end %> <% end %> @@ -49,9 +49,9 @@ <% else %> <% if @internal_review %> <p> - <%= raw(_('If you are dissatisfied by the response you got from + <%= _('If you are dissatisfied by the response you got from the public authority, you have the right to - complain (<a href="%s">details</a>).') % "http://foiwiki.com/foiwiki/index.php/Internal_reviews") %> + complain (<a href="{{url}}">details</a>).', :url => "http://foiwiki.com/foiwiki/index.php/Internal_reviews".html_safe) %> </p> <% end %> @@ -61,25 +61,24 @@ <% status = @info_request.calculate_status %> <% if status == 'waiting_response_overdue' %> - <p><%= _('The response to your request has been <strong>delayed</strong>. You can say that, + <p><%= _('The response to your request has been <strong>delayed</strong>. You can say that, by law, the authority should normally have responded <strong>promptly</strong> and') %> <% if @info_request.public_body.is_school? %> <%= _('in term time') %> <% end %> <%= _('by <strong>{{date}}</strong>',:date=>simple_date(@info_request.date_response_required_by)) %> - (<%= raw(_('<a href="%s">details</a>') % ["#{help_requesting_path}#quickly_response"]) %>). - + (<%= link_to _('details'), "#{help_requesting_path}#quickly_response" %>). </p> <% elsif status == 'waiting_response_very_overdue' %> <p> - <%= _('The response to your request is <strong>long overdue</strong>. You can say that, by + <%= _('The response to your request is <strong>long overdue</strong>. You can say that, by law, under all circumstances, the authority should have responded - by now') %> (<%= raw(_('<a href="%s">details</a>') % ["#{help_requesting_path}#quickly_response"]) %>). + by now') %> (<%= link_to _('details'), "#{help_requesting_path}#quickly_response" %>). </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> @@ -103,7 +102,7 @@ <div> <%= radio_button "outgoing_message", "what_doing", "internal_review", :id => "internal_review" %> <label for="internal_review"><%= _('I am requesting an <strong>internal review</strong>') %> - <%= raw(_('<a href="%s">what\'s that?</a>') % ["/help/unhappy"]) %> + <%= link_to _("what's that?"), "/help/unhappy" %> </label> </div> <div> diff --git a/app/views/request/_hidden_correspondence.rhtml b/app/views/request/_hidden_correspondence.html.erb index 0873b312f..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> - <%= raw(_('This response has been hidden. See annotations to find out why. - If you are the requester, then you may <a href="%s">sign in</a> to view the response.') % [signin_url(:r => request.request_uri)]) %> + <%= _('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> - <%= raw(_('This outgoing message has been hidden. See annotations to - find out why. If you are the requester, then you may <a href="%s">sign in</a> to view the response.') % [signin_url(:r => request.request_uri)]) %> + <%= _('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><%= raw(_('This comment has been hidden. See annotations to - find out why. If you are the requester, then you may <a href="%s">sign in</a> to view the response.') % [signin_url(:r => request.request_uri)]) %> + <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.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 e274fe8c9..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? @@ -75,7 +75,6 @@ <p> <%= hidden_field_tag 'last_info_request_event_id', @last_info_request_event_id, :id => 'last_info_request_event_id' + id_suffix %> - <%= hidden_field_tag 'submitted_describe_state', 1, :id => 'submitted_describe_state' + id_suffix %> <%= submit_tag "Submit status" %> </p> <% end %> 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 d93a91070..c2f6474a1 100644 --- a/app/views/request/_request_listing_short_via_event.rhtml +++ b/app/views/request/_request_listing_short_via_event.html.erb @@ -3,11 +3,11 @@ end %> <div class="request_short_listing"> - <h3><%= link_to highlight_words(info_request.title, @highlight_words), request_url(info_request) %></h3> + <h3><%= link_to highlight_words(info_request.title, @highlight_words), request_path(info_request) %></h3> <p> -<%= _('To {{public_body_link_absolute}}',:public_body_link_absolute => public_body_link_absolute(info_request.public_body))%> -<%= _('by {{user_link_absolute}}',:user_link_absolute => request_user_link_absolute(info_request))%> +<%= _('To {{public_body_link_absolute}}',:public_body_link_absolute => public_body_link(info_request.public_body))%> +<%= _('by {{user_link_absolute}}',:user_link_absolute => request_user_link(info_request))%> <%= simple_date(info_request.created_at) %> </p> </div> diff --git a/app/views/request/_request_listing_single.rhtml b/app/views/request/_request_listing_single.html.erb index e8c1a393f..56737fd3e 100644 --- a/app/views/request/_request_listing_single.rhtml +++ b/app/views/request/_request_listing_single.html.erb @@ -1,6 +1,6 @@ <div class="request_listing"> <span class="head"> - <%= link_to h(info_request.title), (@play_urls ? request_path(:url_title => info_request.url_title) : request_url(info_request)) %> + <%= link_to h(info_request.title), (@play_urls ? categorise_request_path(:url_title => info_request.url_title) : request_path(info_request)) %> </span> <span class="desc"> <%= excerpt(info_request.initial_request_text, "", 150) %> diff --git a/app/views/request/_request_listing_via_event.rhtml b/app/views/request/_request_listing_via_event.html.erb index 2ba9613e5..cc8bae8a9 100644 --- a/app/views/request/_request_listing_via_event.rhtml +++ b/app/views/request/_request_listing_via_event.html.erb @@ -6,13 +6,13 @@ end %> <div class="request_left"> <span class="head"> <% if event.is_incoming_message? %> - <%= link_to highlight_words(info_request.title, @highlight_words), incoming_message_url(event.incoming_message_selective_columns("incoming_messages.id")) %> + <%= link_to highlight_words(info_request.title, @highlight_words), incoming_message_path(event.incoming_message_selective_columns("incoming_messages.id")) %> <% elsif event.is_outgoing_message? and event.event_type == 'followup_sent' %> - <%= link_to highlight_words(info_request.title, @highlight_words), outgoing_message_url(event.outgoing_message) %> + <%= link_to highlight_words(info_request.title, @highlight_words), outgoing_message_path(event.outgoing_message) %> <% elsif event.is_comment? %> - <%= link_to highlight_words(info_request.title, @highlight_words), comment_url(event.comment) %> + <%= link_to highlight_words(info_request.title, @highlight_words), comment_path(event.comment) %> <% else %> - <%= link_to highlight_words(info_request.title, @highlight_words), request_url(info_request) %> + <%= link_to highlight_words(info_request.title, @highlight_words), request_path(info_request) %> <% end %> </span> <div class="requester"> 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 884d4b2b1..aba5c2fb3 100644 --- a/app/views/request/_sidebar.rhtml +++ b/app/views/request/_sidebar.html.erb @@ -3,7 +3,12 @@ <h2><%= _('Follow this request') %></h2> <% follower_count = TrackThing.count(:all, :conditions => ["info_request_id = ?", @info_request.id]) + 1 %> - <p><%= n_("There is %d person following this request", "There are %d people following this request", follower_count) % follower_count %></p> + <p> + <%= n_("There is {{count}} person following this request", + "There are {{count}} people following this request", + follower_count, + :count => follower_count) %> + </p> <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => @info_request.user && @info_request.user == @user, :location => 'sidebar' } %> </div> <% if @info_request.described_state != "attention_requested" %> @@ -11,34 +16,34 @@ <% 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 %> - <p><%= raw(_('This request is hidden, so that only you the requester can see it. Please - <a href="%s">contact us</a> if you are not sure why.') % [help_requesting_path]) %></p> + 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 %> - <p><%= raw(_('This request has been marked for review by the site administrators, who have not hidden it at this time. If you believe it should be hidden, please <a href="%s">contact us</a>.') % [help_requesting_path]) %></p> + <p><%= _('This request has been marked for review by the site administrators, who have not hidden it at this time. If you believe it should be hidden, please <a href="{{url}}">contact us</a>.', :url => help_requesting_path.html_safe) %></p> <% end %> <% 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"> - <% tweet_link = "https://twitter.com/share?url=#{h(request.url)}&via=#{h(Configuration::twitter_username)}&text='#{h(@info_request.title)}'&related=#{_('alaveteli_foi:The software that runs {{site_name}}', :site_name => h(site_name))}" %> + <% 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" %> <% 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" %> <% end %> <%= link_to _("Start your own blog"), "http://wordpress.com/"%> @@ -53,16 +58,15 @@ <%= 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"), request_similar_url(@info_request) %></p> + <p><%= link_to _("More similar requests"), similar_request_path(@info_request) %></p> <% end %> <!-- Important terms: <%= @xapian_similar.important_terms.join(" ") %> --> <% end %> - <p><%= link_to _('Event history details'), request_details_url(@info_request) %></p> + <p><%= link_to _('Event history details'), request_details_path(@info_request) %></p> <!-- this link with this wording is here for legal reasons, discuss with board and our lawyer before changing or removing it --> - <p><small><%= raw(_('<a href="%s">Are you the owner of - any commercial copyright on this page?</a>') % [help_officers_path+"#copyright"]) %></small></p> + <p><small><%= link_to _('Are you the owner of any commercial copyright on this page?'), help_officers_path+"#copyright" %></small></p> </div> 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 b29830ac7..3a9946745 100644 --- a/app/views/request/_view_html_prefix.rhtml +++ b/app/views/request/_view_html_prefix.html.erb @@ -7,6 +7,6 @@ <br>(<%=h @attachment.name_of_content_type %>) </div> <%= _('This is an HTML version of an attachment to the Freedom of Information request')%> - '<%=link_to h(@info_request.title), incoming_message_url(@incoming_message)%>'. + '<%=link_to h(@info_request.title), incoming_message_path(@incoming_message)%>'. </div> 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 26d34e1a1..b6b4b38b1 100644 --- a/app/views/request/_wall_listing.rhtml +++ b/app/views/request/_wall_listing.html.erb @@ -6,11 +6,11 @@ end %> <div class="request_left"> <div class="requester"> <% if event.event_type == 'sent' %> - <%= _('A new request, <em><a href="{{request_url}}">{{request_title}}</a></em>, was sent to {{public_body_name}} by {{info_request_user}} on {{date}}.',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>request_user_link_absolute(info_request),:date=>simple_date(event.created_at),:request_url=>request_url(info_request),:request_title=>info_request.title) %> + <%= _('A new request, <em><a href="{{request_url}}">{{request_title}}</a></em>, was sent to {{public_body_name}} by {{info_request_user}} on {{date}}.',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>request_user_link_absolute(info_request),:date=>simple_date(event.created_at),:request_url=>request_path(info_request),:request_title=>info_request.title) %> <% elsif event.event_type == 'followup_sent' %> - <%= _('A <a href="{{request_url}}">follow up</a> to <em>{{request_title}}</em> was sent to {{public_body_name}} by {{info_request_user}} on {{date}}.',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>request_user_link_absolute(info_request),:date=>simple_date(event.created_at),:request_url=>outgoing_message_url(event.outgoing_message),:request_title=>info_request.title) %> + <%= _('A <a href="{{request_url}}">follow up</a> to <em>{{request_title}}</em> was sent to {{public_body_name}} by {{info_request_user}} on {{date}}.',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>request_user_link_absolute(info_request),:date=>simple_date(event.created_at),:request_url=>outgoing_message_path(event.outgoing_message),:request_title=>info_request.title) %> <% elsif event.event_type == 'response' %> - <%= _('A <a href="{{request_url}}">response</a> to <em>{{request_title}}</em> was sent by {{public_body_name}} to {{info_request_user}} on {{date}}. The request status is: {{request_status}}',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>request_user_link_absolute(info_request),:date=>simple_date(event.created_at),:request_url=>incoming_message_url(event.incoming_message_selective_columns("incoming_messages.id")),:request_title=>info_request.title,:request_status=>info_request.display_status) %> + <%= _('A <a href="{{request_url}}">response</a> to <em>{{request_title}}</em> was sent by {{public_body_name}} to {{info_request_user}} on {{date}}. The request status is: {{request_status}}',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>request_user_link_absolute(info_request),:date=>simple_date(event.created_at),:request_url=>incoming_message_path(event.incoming_message_selective_columns("incoming_messages.id")),:request_title=>info_request.title,:request_status=>info_request.display_status) %> <% elsif event.event_type == 'comment' %> <%= _('An <a href="{{request_url}}">annotation</a> to <em>{{request_title}}</em> was made by {{event_comment_user}} on {{date}}',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>request_user_link_absolute(info_request),:event_comment_user=>user_link_absolute(event.comment.user),:date=>simple_date(event.created_at),:request_url=>comment_url(event.comment),:request_title=>info_request.title) %> <% else %> diff --git a/app/views/request/describe_state_message.html.erb b/app/views/request/describe_state_message.html.erb new file mode 100644 index 000000000..73237759f --- /dev/null +++ b/app/views/request/describe_state_message.html.erb @@ -0,0 +1,30 @@ +<h1><%= @title %></h1> + + +<p> + <% if @described_state == "error_message" %> + <%= _("If the error was a delivery failure, and you can find an up to date FOI email address for the authority, please tell us using the form below.") %> + <% else %> + <%= _("Just one more thing") %> + <% end %> +</p> + +<%= 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> + <%= f.text_area :message, :rows => 10, :cols => 60 %> + </p> + + <div> + <%= hidden_field_tag "incoming_message[described_state]", @described_state %> + <%= hidden_field_tag :last_info_request_event_id, @last_info_request_event_id %> + </div> + + <div class="form_button"> + <%= submit_tag _("Submit status and send message") %> + </div> + +<% end %> + + diff --git a/app/views/request/details.rhtml b/app/views/request/details.html.erb index d4c63902f..3cb2f5afe 100644 --- a/app/views/request/details.rhtml +++ b/app/views/request/details.html.erb @@ -36,10 +36,10 @@ way authorities use it. Plus you\'ll need to be an elite statistician. Please <% end %> <td> <% if info_request_event.outgoing_message %> - <%= link_to "outgoing", outgoing_message_url(info_request_event.outgoing_message) %> + <%= link_to "outgoing", outgoing_message_path(info_request_event.outgoing_message) %> <% end %> <% if info_request_event.incoming_message %> - <%= link_to "incoming", incoming_message_url(info_request_event.incoming_message) %> + <%= link_to "incoming", incoming_message_path(info_request_event.incoming_message) %> <% end %> </td> </tr> diff --git a/app/views/request/followup_bad.rhtml b/app/views/request/followup_bad.html.erb index c892263e6..ea2400c5d 100644 --- a/app/views/request/followup_bad.rhtml +++ b/app/views/request/followup_bad.html.erb @@ -9,21 +9,21 @@ <% if @reason == 'not_apply' %> <!-- we should never get here, but just in case give a sensible message --> <p><%= _('Freedom of Information law no longer applies to') %> <%=h @info_request.public_body.name %>. - <%= raw(_('From the request page, try replying to a particular message, rather than sending + <%= _('From the request page, try replying to a particular message, rather than sending a general followup. If you need to make a general followup, and know - an email which will go to the right place, please <a href="%s">send it to us</a>.') % [help_contact_path]) %> + an email which will go to the right place, please <a href="{{url}}">send it to us</a>.', :url => help_contact_path.html_safe) %> </p> <% elsif @reason == 'defunct' %> <!-- we should never get here, but just in case give a sensible message --> - <p><%=h @info_request.public_body.name %> <%= raw(_('no longer exists. If you are trying to make + <p><%=h @info_request.public_body.name %> <%= _('no longer exists. If you are trying to make From the request page, try replying to a particular message, rather than sending a general followup. If you need to make a general followup, and know - an email which will go to the right place, please <a href="%s">send it to us</a>.') % [help_contact_path]) %> + an email which will go to the right place, please <a href="{{url}}">send it to us</a>.', :url => help_contact_path.html_safe) %> </p> <% elsif @reason == 'bad_contact' %> - <p><%= _('We do not have a working {{law_used_full}} address for {{public_body_name}}.',:law_used_full=>h(@info_request.law_used_full),:public_body_name=>h(@info_request.public_body.name)) %> <%= raw(_('You may be able to find + <p><%= _('We do not have a working {{law_used_full}} address for {{public_body_name}}.',:law_used_full=>h(@info_request.law_used_full),:public_body_name=>h(@info_request.public_body.name)) %> <%= _('You may be able to find one on their website, or by phoning them up and asking. If you manage - to find one, then please <a href="%s">send it to us</a>.') % [help_contact_path]) %> + to find one, then please <a href="{{url}}">send it to us</a>.', :url => help_contact_path.html_safe) %> </p> <% elsif @reason == 'external' %> <p><%= _("Followups cannot be sent for this request, as it was made externally, and published here by {{public_body_name}} on the requester's behalf.", :public_body_name => h(@info_request.public_body.name)) %> 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.html.erb b/app/views/request/hidden.html.erb new file mode 100644 index 000000000..f2f76a817 --- /dev/null +++ b/app/views/request/hidden.html.erb @@ -0,0 +1,19 @@ +<% @title = _("Request has been removed") %> + +<h1><%=@title%></h1> + +<p> +<%=@details%> +</p> + +<p><%= _('The request you have tried to view has been removed. There are +various reasons why we might have done this, sorry we can\'t be more specific here. Please <a + href="{{url}}">contact us</a> if you have any questions.', :url => help_contact_path.html_safe) %> +</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.fullpath).html_safe) %> + </p> +<% end %> + + diff --git a/app/views/request/hidden.rhtml b/app/views/request/hidden.rhtml deleted file mode 100644 index 2d038a663..000000000 --- a/app/views/request/hidden.rhtml +++ /dev/null @@ -1,19 +0,0 @@ -<% @title = _("Request has been removed") %> - -<h1><%=@title%></h1> - -<p> -<%=@details%> -</p> - -<p><%= raw(_('The request you have tried to view has been removed. There are -various reasons why we might have done this, sorry we can\'t be more specific here. Please <a - href="%s">contact us</a> if you have any questions.') % [help_contact_path]) %> -</p> -<% if @info_request.prominence == 'requester_only' %> - <p> - <%= raw(_('If you are the requester, then you may <a href="%s">sign in</a> to view the request.') % [signin_url(:r => request.request_uri)]) %> - </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 c16105560..8b7d38ac0 100644 --- a/app/views/request/new.rhtml +++ b/app/views/request/new.html.erb @@ -26,22 +26,22 @@ <li> <%= _('{{existing_request_user}} already created the same request on {{date}}. You can either view the <a href="{{existing_request}}">existing request</a>, - or edit the details below to make a new but similar request.',:existing_request_user=>user_or_you_capital_link(@existing_request.user), :date=>simple_date(@existing_request.created_at), :existing_request=>request_url(@existing_request)) %> + or edit the details below to make a new but similar request.',:existing_request_user=>user_or_you_capital_link(@existing_request.user), :date=>simple_date(@existing_request.created_at), :existing_request=>request_path(@existing_request)) %> </li> </ul></div> <% end %> <%= 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"> - <label class="form_label" for="info_request_public_body_id"><%= _('To:') %></label> + <label class="form_label"><%= _('To:') %></label> <span id="to_public_body"><%=h(@info_request.public_body.name)%></span> <div class="form_item_note"> <% if @info_request.public_body.info_requests.size > 0 %> - <%= _("Browse <a href='{{url}}'>other requests</a> to '{{public_body_name}}' for examples of how to word your request.", :public_body_name=>h(@info_request.public_body.name), :url=>public_body_url(@info_request.public_body)) %> + <%= _("Browse <a href='{{url}}'>other requests</a> to '{{public_body_name}}' for examples of how to word your request.", :public_body_name=>h(@info_request.public_body.name), :url=>public_body_path(@info_request.public_body)) %> <% else %> <%= _("Browse <a href='{{url}}'>other requests</a> for examples of how to word your request.", :url=>request_list_url) %> <% end %> @@ -98,12 +98,12 @@ <ul> <li><%= _('Write your request in <strong>simple, precise language</strong>.') %></li> <li><%= _('Ask for <strong>specific</strong> documents or information, this site is not suitable for general enquiries.') %></li> - <li><%= raw(_('Keep it <strong>focused</strong>, you\'ll be more likely to get what you want (<a href="%s">why?</a>).') % [help_requesting_path + '#focused']) %></li> + <li><%= _('Keep it <strong>focused</strong>, you\'ll be more likely to get what you want (<a href="{{url}}">why?</a>).', :url => (help_requesting_path + '#focused').html_safe) %></li> </ul> </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 %> @@ -112,23 +112,24 @@ <% if !@user %> <p class="form_note"> + <%= raw(_('Everything that you enter on this page, including <strong>your name</strong>, will be <strong>displayed publicly</strong> on - this website forever (<a href="%s">why?</a>).') % [help_privacy_path+"#public_request"]) %> + this website forever (<a href="{{url}}">why?</a>).', :url => (help_privacy_path+"#public_request").html_safe)) %> <%= raw(_('If you are thinking of using a pseudonym, - please <a href="%s">read this first</a>.') % [help_privacy_path+"#real_name"]) %> + please <a href="{{url}}">read this first</a>.', :url => (help_privacy_path+"#real_name").html_safe)) %> </p> <% else %> <p class="form_note"> <%= raw(_('Everything that you enter on this page will be <strong>displayed publicly</strong> on - this website forever (<a href="%s">why?</a>).') % [help_privacy_path+"#public_request"]) %> + this website forever (<a href="{{url}}">why?</a>).', :url => (help_privacy_path+"#public_request").html_safe)) %> </p> <% end %> <p class="form_note"> <%= raw(_("<strong> Can I request information about myself?</strong>\n" + - "\t\t\t<a href=\"%s\">No! (Click here for details)</a>") % [help_requesting_path+"#data_protection"]) %> + "\t\t\t<a href=\"{{url}}\">No! (Click here for details)</a>", :url => (help_requesting_path+"#data_protection").html_safe)) %> </p> <div class="form_button"> 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 ff27405b8..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> - <%= raw(_('When you\'re done, <strong>come back here</strong>, <a href="%s">reload this page</a> and file your new request.') % [request.request_uri]) %> + <%= _('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 8d1fd753e..243dc90a9 100644 --- a/app/views/request/preview.rhtml +++ b/app/views/request/preview.html.erb @@ -1,16 +1,16 @@ <% @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> <li><%= _('Check you haven\'t included any <strong>personal information</strong>.') %></li> <li><%= raw(_('Your name, request and any responses will appear in <strong>search engines</strong> - (<a href="%s">details</a>).') % [help_privacy_path+"#public_request"]) %> + (<a href="{{url}}">details</a>).', :url => (help_privacy_path+"#public_request").html_safe)) %> </li> </ul> - <% fields_for :outgoing_message do |o| %> + <%= fields_for :outgoing_message do |o| %> <div class="correspondence" id="outgoing-0"> <p class="preview_subject"> @@ -23,13 +23,13 @@ <%= o.hidden_field(:body) %> </div> - <p class="event_actions"> + <p class="event_actions"> </p> </div> <% end %> - <p><%= raw(_('<strong>Privacy note:</strong> If you want to request private information about - yourself then <a href="%s">click here</a>.') % [help_requesting_path+"#data_protection"]) %> + <p><%= _('<strong>Privacy note:</strong> If you want to request private information about + yourself then <a href="{{url}}">click here</a>.', :url => (help_requesting_path+"#data_protection").html_safe) %> <p> <%= f.hidden_field(:title) %> @@ -38,11 +38,11 @@ <%= hidden_field_tag(:submitted_new_request, 1) %> <%= hidden_field_tag(:preview, 0 ) %> <%= submit_tag _("Edit this request"), :name => 'reedit', :id => 'reedit_button' %> - <%= submit_tag _("Send request"), :name => 'submit', :id => 'submit_button' %> + <%= submit_tag _("Send request"), :name => 'submit', :id => 'submit_button' %> </p> <% if !@info_request.tag_string.empty? %> <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 df0498d6a..75c51fc57 100644 --- a/app/views/request/select_authority.rhtml +++ b/app/views/request/select_authority.html.erb @@ -2,22 +2,22 @@ <script type="text/javascript"> $(document).ready(function(){ $("#authority_preview").hide(); - + // Avoid triggering too often (on each keystroke) by using the debounce jQuery plugin: // http://benalman.com/projects/jquery-throttle-debounce-plugin/ - $("#query").keypress($.debounce( 300, function() { + $("#query").keypress($.debounce( 300, function() { // Do a type ahead search and display results $("#typeahead_response").load("<%=search_ahead_bodies_url%>?query="+encodeURI(this.value), function() { $("#authority_preview").hide(); // Hide the preview, since results have changed }); })); - // We're using the existing body list: we intercept the clicks on the titles to + // We're using the existing body list: we intercept the clicks on the titles to // display a preview on the right hand side of the screen $("#typeahead_response .head a").live('click', function() { $("#authority_preview").load(this.href+" #public_body_show", function() { $("#authority_preview").show(); - $(window).scrollTop($("#banner").height()); + $(window).scrollTop($("#banner").height()); $("#authority_preview #header_right").hide(); }); return false; @@ -30,41 +30,24 @@ <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> - <%= raw(_('First, type in the <strong>name of the UK public authority</strong> you\'d + <%= _('First, type in the <strong>name of the UK public authority</strong> you\'d like information from. <strong>By law, they have to respond</strong> - (<a href="%s#%s">why?</a>).') % [help_about_url, "whybother_them"]) %> + (<a href="{{url}}">why?</a>).', :url => (help_about_path + "#whybother_them").html_safe) %> </p> <%= text_field_tag 'query', params[:query], { :size => 30, :title => "type your search term here" } %> <%= hidden_field_tag 'bodies', 1 %> <%= 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> - + <div id="authority_preview"> </div> - + diff --git a/app/views/request/show.rhtml b/app/views/request/show.html.erb index 0cae3a9aa..4b0663f76 100644 --- a/app/views/request/show.rhtml +++ b/app/views/request/show.html.erb @@ -10,8 +10,8 @@ <% end %> <% if @info_request.prominence == 'requester_only' %> <p id="hidden_request"> - <%= raw(_('This request is hidden, so that only you the requester can see it. Please - <a href="%s">contact us</a> if you are not sure why.') % [help_requesting_path]) %> + <%= _('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> <% end %> @@ -37,9 +37,9 @@ :user => @info_request.is_external? ? (@info_request.user_name || _('An anonymous user')) : user_link(@info_request.user), :law_used_full => h(@info_request.law_used_full), :user_admin_link => user_admin_link_for_request(@info_request, _('external'), _('admin')), - :request_admin_url => request_admin_url(@info_request), + :request_admin_url => admin_request_show_url(@info_request), :public_body_link => public_body_link(@info_request.public_body), - :public_body_admin_url => public_body_admin_url(@info_request.public_body)) %> + :public_body_admin_url => admin_body_show_url(@info_request.public_body)) %> <% else %> <%= _('{{user}} made this {{law_used_full}} request',:user=>@info_request.is_external? ? (@info_request.user_name || _('An anonymous user')) : user_link(@info_request.user), :law_used_full=>h(@info_request.law_used_full)) %> <%= _('to {{public_body}}',:public_body=>public_body_link(@info_request.public_body)) %> @@ -80,14 +80,14 @@ <%= _('in term time') %> <% end %> <%= _('by') %> <strong><%= simple_date(@info_request.date_response_required_by) %></strong> - (<%= raw(_('<a href="%s">details</a>') % [help_requesting_path + '#quickly_response']) %>) + (<%= link_to _('details'), help_requesting_path + '#quickly_response' %>) <% elsif @status == 'waiting_response_very_overdue' %> <%= _('Response to this request is <strong>long overdue</strong>.') %> <%= _('By law, under all circumstances, {{public_body_link}} should have responded by now',:public_body_link => public_body_link(@info_request.public_body)) %> - (<%= raw(_('<a href="%s">details</a>') % [help_requesting_path + '#quickly_response']) %>). + (<%= link_to _('details'), help_requesting_path + '#quickly_response' %>). <% if !@info_request.is_external? %> <%= _('You can <strong>complain</strong> by') %> - <%= link_to _("requesting an internal review"), show_response_no_followup_url(:id => @info_request.id, :incoming_message_id => nil) + "?internal_review=1#followup" %>. + <%= link_to _("requesting an internal review"), show_response_no_followup_path(:id => @info_request.id, :incoming_message_id => nil) + "?internal_review=1#followup" %>. <% end %> <% elsif @status == 'not_held' %> <%= public_body_link(@info_request.public_body) %> <%= _('<strong>did not have</strong> the information requested.') %> @@ -101,12 +101,12 @@ <% if @is_owning_user && !@info_request.is_external? %> <%=h @info_request.public_body.name %> <%= _('is <strong>waiting for your clarification</strong>.') %> <%= _('Please') %> - <%= link_to _("send a follow up message"), respond_to_last_url(@info_request) + '#followup' %>. + <%= link_to _("send a follow up message"), respond_to_last_path(@info_request) + '#followup' %>. <% else %> <%= _('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_url(: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 ac1f04227..a61359679 100644 --- a/app/views/request/show_response.rhtml +++ b/app/views/request/show_response.html.erb @@ -26,8 +26,8 @@ <%= _('The authority only has a <strong>paper copy</strong> of the information.') %> </dt> <dd> - <%= raw(_('At the bottom of this page, write a reply to them trying to persuade them to scan it in - (<a href="%s">more details</a>).') % [help_privacy_path + '#postal_answer']) %> + <%= _('At the bottom of this page, write a reply to them trying to persuade them to scan it in + (<a href="{{url}}">more details</a>).', :url => (help_privacy_path + '#postal_answer').html_safe) %> </dd> <dt> diff --git a/app/views/request/similar.rhtml b/app/views/request/similar.html.erb index 0d53f6919..0d53f6919 100644 --- a/app/views/request/similar.rhtml +++ b/app/views/request/similar.html.erb 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 675951595..f5fd6f000 100644 --- a/app/views/request/upload_response.rhtml +++ b/app/views/request/upload_response.html.erb @@ -12,7 +12,7 @@ <h1><%= _('Respond to the FOI request')%> '<%=request_link(@info_request)%>'<% _(' made by ')%><%=user_link(@info_request.user) %></h1> <p> - <%= raw(_('Your response will <strong>appear on the Internet</strong>, <a href="%s">read why</a> and answers to other questions.') % [help_officers_path]) %> + <%= raw(_('Your response will <strong>appear on the Internet</strong>, <a href="{{url}}">read why</a> and answers to other questions.', :url => help_officers_path.html_safe)) %> </p> <h2><%= _('Respond by email')%></h2> @@ -28,9 +28,9 @@ <h2><%= _('Respond using the web')%></h2> <p><%= raw(_('Enter your response below. You may attach one file (use email, or - <a href="%s">contact us</a> if you need more).')% [help_contact_path]) %></p> + <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 3bd23e306..d5aa0d00e 100644 --- a/app/views/request_game/play.rhtml +++ b/app/views/request_game/play.html.erb @@ -36,8 +36,8 @@ information has been provided. Everyone'll be exceedingly grateful.")%></p> <%= render :partial => 'request/request_listing_single', :locals => { :info_request => info_request } %> <% end %> <p id="game_buttons"> -<%= button_to _('I don\'t like these ones — give me some more!'), play_url %> -<%= button_to _('I don\'t want to do any more tidying now!'), stop_url %> +<%= button_to _('I don\'t like these ones — give me some more!'), categorise_play_url %> +<%= button_to _('I don\'t want to do any more tidying now!'), categorise_stop_url %> </p> <p><%= _('Thanks for helping - your work will make it easier for everyone to find successful responses, and maybe even let us make league tables...')%></p> 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 e9858f03f..000000000 --- a/app/views/request_mailer/external_response.rhtml +++ /dev/null @@ -1 +0,0 @@ -<%=@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 e9858f03f..000000000 --- a/app/views/request_mailer/fake_response.rhtml +++ /dev/null @@ -1 +0,0 @@ -<%=@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 083f873b4..672212f20 100644 --- a/app/views/request_mailer/new_response.rhtml +++ b/app/views/request_mailer/new_response.text.erb @@ -1,6 +1,6 @@ <%= _('You have a new response to the {{law_used_full}} request ',:law_used_full=>@info_request.law_used_full)%> -'<%= @info_request.title %>' <%=_('that you made to')%> -<%= @info_request.public_body.name %>. +'<%= raw @info_request.title %>' <%=_('that you made to')%> +<%= raw @info_request.public_body.name %>. <%= _('To view the response, click on the link below.')%> diff --git a/app/views/request_mailer/new_response_reminder_alert.rhtml b/app/views/request_mailer/new_response_reminder_alert.text.erb index 86fc71de7..c196dafe6 100644 --- a/app/views/request_mailer/new_response_reminder_alert.rhtml +++ b/app/views/request_mailer/new_response_reminder_alert.text.erb @@ -3,7 +3,7 @@ <%=@url%> <%= _('Your request was called {{info_request}}. Letting everyone know whether you got the information will help us keep tabs on',:info_request=>@info_request.title)%> -<%= @info_request.public_body.name %>. +<%= raw @info_request.public_body.name %>. -- <%= _('the {{site_name}} team', :site_name=>site_name) %> 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 b8a9ba525..249bf6bb8 100644 --- a/app/views/request_mailer/overdue_alert.rhtml +++ b/app/views/request_mailer/overdue_alert.text.erb @@ -1,4 +1,4 @@ -<%= @info_request.public_body.name %> <%= _('have delayed.')%> +<%= raw @info_request.public_body.name %> <%= _('have delayed.')%> <%= _('They have not replied to your {{law_used_short}} request {{title}} promptly, as normally required by law',:law_used_short=>@info_request.law_used_short,:title=>@info_request.title)%><% if @info_request.public_body.is_school? %> <%=_('during term time')%> <% end %>. diff --git a/app/views/request_mailer/requires_admin.rhtml b/app/views/request_mailer/requires_admin.text.erb index 06a798792..b2e58295e 100644 --- a/app/views/request_mailer/requires_admin.rhtml +++ b/app/views/request_mailer/requires_admin.text.erb @@ -1,9 +1,11 @@ +<%= raw @message %> + --------------------------------------------------------------------- -<%=@reported_by.name%> <%= _('has reported an')%> <%=@info_request.law_used_short%> +<%= raw @reported_by.name %> <%= _('has reported an')%> <%= raw @info_request.law_used_short %> <%= _('response as needing administrator attention. Take a look, and reply to this email to let them know what you are going to do about it.')%> -Request '<%=@info_request.title%>': +Request '<%= raw @info_request.title %>': <%= @url %> <%= _('Administration URL:') %> 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 6abd198a0..80597473c 100644 --- a/app/views/request_mailer/very_overdue_alert.rhtml +++ b/app/views/request_mailer/very_overdue_alert.text.erb @@ -1,4 +1,4 @@ -<%= @info_request.public_body.name %> <%= _('are long overdue.')%> +<%= raw @info_request.public_body.name %> <%= _('are long overdue.')%> <%= _('They have not replied to your {{law_used_short}} request {{title}}, as required by law',:law_used_short=>@info_request.law_used_short,:title=>@info_request.title)%><% if @info_request.public_body.is_school? %> <%= _('even during holidays')%><% end %>. diff --git a/app/views/track/_tracking_links.rhtml b/app/views/track/_tracking_links.html.erb index 06e87ac74..a16dbc78f 100644 --- a/app/views/track/_tracking_links.rhtml +++ b/app/views/track/_tracking_links.html.erb @@ -9,20 +9,20 @@ <% 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%>"> <% if defined? follower_count && follower_count > 0 %> - <%= link_to _("I like this request"), do_track_url(track_thing), :class => "link_button_green" %> + <%= link_to _("I like this request"), do_track_path(track_thing), :class => "link_button_green" %> <% else %> - <%= link_to _("Follow"), do_track_url(track_thing), :class => "link_button_green" %> + <%= link_to _("Follow"), do_track_path(track_thing), :class => "link_button_green" %> <% end %> </div> <div class="feed_link feed_link_<%=location%>"> - <%= link_to '<img src="/images/feed-16.png" alt="">'.html_safe, do_track_url(track_thing, 'feed') %> - <%= link_to (location == 'sidebar' ? _('RSS feed of updates') : _('RSS feed')), do_track_url(track_thing, 'feed') %> + <%= link_to '<img src="/images/feed-16.png" alt="">'.html_safe, do_track_path(track_thing, 'feed') %> + <%= link_to (location == 'sidebar' ? _('RSS feed of updates') : _('RSS feed')), do_track_path(track_thing, 'feed') %> </div> <% end %> 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 dc8132b99..8dbc7fe06 100644 --- a/app/views/track_mailer/event_digest.rhtml +++ b/app/views/track_mailer/event_digest.text.erb @@ -17,17 +17,17 @@ # e.g. Julian Burgess sent a request to Royal Mail Group (15 May 2008) if event.event_type == 'response' - url = main_url(incoming_message_url(event.incoming_message)) + url = incoming_message_url(event.incoming_message) main_text += _("{{public_body}} sent a response to {{user_name}}", :public_body => event.info_request.public_body.name, :user_name => event.info_request.user_name) elsif event.event_type == 'followup_sent' - url = main_url(outgoing_message_url(event.outgoing_message)) + url = outgoing_message_url(event.outgoing_message) main_text += _("{{user_name}} sent a follow up message to {{public_body}}", :user_name => event.info_request.user_name, :public_body => event.info_request.public_body.name) elsif event.event_type == 'sent' # this is unlikely to happen in real life, but happens in the test code - url = main_url(outgoing_message_url(event.outgoing_message)) + url = outgoing_message_url(event.outgoing_message) main_text += _("{{user_name}} sent a request to {{public_body}}", :user_name => event.info_request.user_name, :public_body => event.info_request.public_body.name) elsif event.event_type == 'comment' - url = main_url(comment_url(event.comment)) + url = comment_url(event.comment) main_text += _("{{user_name}} added an annotation", :user_name => event.comment.user.name) else raise "unknown type in event_digest " + event.event_type 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 3c229e9ce..305300236 100644 --- a/app/views/user/_show_user_info.rhtml +++ b/app/views/user/_show_user_info.html.erb @@ -4,7 +4,7 @@ <img class="comment_quote" src="/images/quote-marks.png" alt=""> <%= @display_user.get_about_me_for_html_display %> <% if @is_you %> - (<%= link_to _("edit text about you"), set_profile_about_me_url() %>) + (<%= link_to _("edit text about you"), set_profile_about_me_path %>) <% end %> </div> <% end %> @@ -12,9 +12,9 @@ <% if @is_you %> <p id="user_change_password_email"> <% if @display_user.profile_photo %> - <%= link_to _('Change profile photo'), set_profile_photo_url() %> | + <%= link_to _('Change profile photo'), set_profile_photo_path %> | <% end %> - <%= link_to _('Change your password'), signchangepassword_url() %> | - <%= link_to _('Change your email'), signchangeemail_url() %> + <%= link_to _('Change your password'), signchangepassword_path %> | + <%= link_to _('Change your email'), signchangeemail_path %> </p> <% end %> diff --git a/app/views/user/_signin.rhtml b/app/views/user/_signin.html.erb index c4d917991..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 %> @@ -18,7 +18,7 @@ </p> <p class="form_note"> - <%= link_to _('Forgotten your password?'), signchangepassword_url + "?pretoken=" + h(params[:token]), :tabindex => 30 %> + <%= link_to _('Forgotten your password?'), signchangepassword_path + "?pretoken=" + h(params[:token]), :tabindex => 30 %> </p> <p class="form_checkbox"> diff --git a/app/views/user/_signup.rhtml b/app/views/user/_signup.html.erb index 913423ffa..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>--> @@ -10,30 +10,30 @@ <%= text_field 'user_signup', 'email', { :size => 20, :tabindex => 60 } %> </p> <div class="form_item_note"> - <%= raw(_('We will not reveal your email address to anybody unless you or - the law tell us to (<a href="%s">details</a>). ') %[help_privacy_path]) %> + <%= _('We will not reveal your email address to anybody unless you or + the law tell us to (<a href="{{url}}">details</a>). ', :url => help_privacy_path) %> </div> <p> <label class="form_label" for="user_signup_name"> <%= _('Your name:')%></label> - <%= text_field 'user_signup', 'name', { :size => 20, :tabindex => 70 } %> + <%= text_field 'user_signup', 'name', { :size => 20, :tabindex => 70, :autocomplete => "off" } %> </p> <div class="form_item_note"> - <%= raw(_('Your <strong>name will appear publicly</strong> - (<a href="%s">why?</a>) + <%= _('Your <strong>name will appear publicly</strong> + (<a href="{{why_url}}">why?</a>) on this website and in search engines. If you - are thinking of using a pseudonym, please - <a href="%s">read this first</a>.') % [help_privacy_path+"#public_request", help_privacy_path+"#real_name"]) %> + are thinking of using a pseudonym, please + <a href="{{help_url}}">read this first</a>.', :why_url => (help_privacy_path+"#public_request").html_safe, :help_url => (help_privacy_path+"#real_name").html_safe) %> </div> <p> <label class="form_label" for="user_signup_password"> <%= _('Password:')%></label> - <%= password_field 'user_signup', 'password', { :size => 15, :tabindex => 80 } %> + <%= password_field 'user_signup', 'password', { :size => 15, :tabindex => 80, :autocomplete => "off" } %> </p> <p> <label class="form_label" for="user_signup_password_confirmation"> <%= _('Password: (again)')%></label> - <%= password_field 'user_signup', 'password_confirmation', { :size => 15, :tabindex => 90 } %> + <%= password_field 'user_signup', 'password_confirmation', { :size => 15, :tabindex => 90, :autocomplete => "off" } %> </p> <% if @request_from_foreign_country %> diff --git a/app/views/user/_user_listing_single.rhtml b/app/views/user/_user_listing_single.html.erb index 53df3a7e8..ed1b95718 100644 --- a/app/views/user/_user_listing_single.rhtml +++ b/app/views/user/_user_listing_single.html.erb @@ -5,14 +5,14 @@ end %> <div class="user_listing"> <% if display_user.profile_photo %> <div class="user_photo_on_search"> - <a href="<%=user_url(display_user)%>"> + <a href="<%=user_path(display_user)%>"> <img src="<%= get_profile_photo_url(:url_name => display_user.url_name) %>" alt=""> </a> </div> <% end %> <span class="head <% if display_user.profile_photo %>no_icon<% end %>"> - <%= link_to highlight_words(display_user.name, @highlight_words), user_url(display_user) %> + <%= link_to highlight_words(display_user.name, @highlight_words), user_path(display_user) %> </span> <span class="bottomline"> 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 c291367f2..0a4a39b1b 100644 --- a/app/views/user/no_cookies.rhtml +++ b/app/views/user/no_cookies.html.erb @@ -12,11 +12,11 @@ browser. Then press refresh to have another go.')%></p> <p><%= _('If your browser is set to accept cookies and you are seeing this message, then there is probably a fault with our server.')%> -<%= raw(_('Please <a href="%s">get in touch</a> with us so we can fix it.') % [help_contact_path]) %> +<%= _('Please <a href="{{url}}">get in touch</a> with us so we can fix it.', :url => help_contact_path.html_safe) %> <%= _('Let us know what you were doing when this message appeared and your browser and operating system type and version.')%></p> -<p><%= raw(_('If you are still having trouble, please <a href="%s">contact us</a>.') % [help_contact_path]) %> +<p><%= _('If you are still having trouble, please <a href="{{url}}">contact us</a>.', :url => help_contact_path.html_safe) %> </p> 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") + " >>" %> + <%= submit_tag _("Done >>") %> </p> <% end %> diff --git a/app/views/user/set_draft_profile_photo.rhtml b/app/views/user/set_draft_profile_photo.html.erb index b3faba7fc..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,14 +45,14 @@ <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 %> <% end %> <p> - <%= link_to _("Cancel, return to your profile page"), user_url(@user) %> + <%= link_to _("Cancel, return to your profile page"), user_path(@user) %> </p> </div> 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 9d8bf6f2f..c9862effe 100644 --- a/app/views/user/show.rhtml +++ b/app/views/user/show.html.erb @@ -55,7 +55,7 @@ <% else %> <% if @is_you %> <span id="set_photo"> - <%= link_to _('Set your profile photo'), set_profile_photo_url() %> + <%= link_to _('Set your profile photo'), set_profile_photo_path %> </span> <% end %> <% end %> @@ -66,12 +66,12 @@ <p class="subtitle"> <%= _('Joined {{site_name}} in', :site_name=>site_name) %> <%= year_from_date(@display_user.created_at) %> <% if !@user.nil? && @user.admin_page_links? %> - (<%= link_to "admin", user_admin_url(@display_user) %>) + (<%= link_to "admin", admin_user_show_path(@display_user) %>) <% end %> </p> <p> - <%= link_to _('Send message to ') + h(@display_user.name), contact_user_url(:id => @display_user.id) %> + <%= link_to _('Send message to ') + h(@display_user.name), contact_user_path(:id => @display_user.id) %> <% if @is_you %> (<%= _('just to see how it works')%>) <% end %> @@ -97,7 +97,7 @@ <% if not @is_you %> <p id="user_not_logged_in"> - <%= raw(_('<a href="%s">Sign in</a> to change password, subscriptions and more ({{user_name}} only)',:user_name=>h(@display_user.name)) % [signin_url(:r => request.request_uri)]) %> + <%= _('<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 %> @@ -128,7 +128,7 @@ <% end %> <% else %> <h2 class="foi_results" id="foi_requests"> - <%= @is_you ? n_('Your %d Freedom of Information request', 'Your %d Freedom of Information requests', @xapian_requests.matches_estimated) % @xapian_requests.matches_estimated.to_s : n_('This person\'s %d Freedom of Information request', 'This person\'s %d Freedom of Information requests', @xapian_requests.matches_estimated) % @xapian_requests.matches_estimated %> + <%= @is_you ? n_('Your {{count}} Freedom of Information request', 'Your {{count}} Freedom of Information requests', @xapian_requests.matches_estimated, :count => @xapian_requests.matches_estimated) : n_("This person's {{count}} Freedom of Information request", "This person's {{count}} Freedom of Information requests", @xapian_requests.matches_estimated, :count => @xapian_requests.matches_estimated) %> <!-- matches_estimated <%=@xapian_requests.matches_estimated%> --> <%= @match_phrase %> <%= @page_desc %> @@ -158,7 +158,7 @@ <% end %> <% else %> <h2 id="annotations"> - <%= @is_you ? n_('Your %d annotation', 'Your %d annotations', @display_user.visible_comments.size) % @display_user.visible_comments.size : n_('This person\'s %d annotation', 'This person\'s %d annotations', @display_user.visible_comments.size) % @display_user.visible_comments.size %> + <%= @is_you ? n_('Your {{count}} annotation', 'Your {{count}} annotations', @display_user.visible_comments.size, :count => @display_user.visible_comments.size) : n_("This person's {{count}} annotation", "This person's {{count}} annotations", @display_user.visible_comments.size, :count => @display_user.visible_comments.size) %> <!-- matches_estimated <%=@xapian_comments.matches_estimated%> --> <%= @page_desc %> </h2> @@ -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 6a1979155..8291cdace 100644 --- a/app/views/user/sign.rhtml +++ b/app/views/user/sign.html.erb @@ -12,7 +12,9 @@ <% end %> </p> <% if @post_redirect.post_params["controller"] == "admin_general" %> - <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> + <% 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 %> <%= render :partial => 'signin', :locals => { :sign_in_as_existing_user => true } %> 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.html.erb b/app/views/user/wrong_user_unknown_email.html.erb new file mode 100644 index 000000000..c1967fc1f --- /dev/null +++ b/app/views/user/wrong_user_unknown_email.html.erb @@ -0,0 +1,8 @@ + +<p id="sign_in_reason"> +<%= @reason_params[:web] %>. <%= _('Unfortunately we don\'t know the FOI +email address for that authority, so we can\'t validate this. +Please <a href="{{url}}">contact us</a> to sort it out.', :url => help_contact_path.html_safe) %> +</p> + + diff --git a/app/views/user/wrong_user_unknown_email.rhtml b/app/views/user/wrong_user_unknown_email.rhtml deleted file mode 100644 index c59c56941..000000000 --- a/app/views/user/wrong_user_unknown_email.rhtml +++ /dev/null @@ -1,8 +0,0 @@ - -<p id="sign_in_reason"> -<%= @reason_params[:web] %>. <%= raw(_('Unfortunately we don\'t know the FOI -email address for that authority, so we can\'t validate this. -Please <a href="%s">contact us</a> to sort it out.') % [help_contact_path]) %> -</p> - - diff --git a/app/views/user_mailer/already_registered.rhtml b/app/views/user_mailer/already_registered.text.erb index 59ffcbf94..32c2c7e63 100644 --- a/app/views/user_mailer/already_registered.rhtml +++ b/app/views/user_mailer/already_registered.text.erb @@ -1,10 +1,10 @@ -<%= @name %>, +<%= raw @name %>, <%= _('You just tried to sign up to {{site_name}}, when you already have an account. Your name and password have been left as they previously were. -Please click on the link below.', :site_name=>site_name)%> <%=@reasons[:email]%> +Please click on the link below.', :site_name=>site_name)%> <%=raw @reasons[:email] %> <%=@url%> 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 ffb9737f7..c73e9486b 100644 --- a/app/views/user_mailer/changeemail_confirm.rhtml +++ b/app/views/user_mailer/changeemail_confirm.text.erb @@ -1,4 +1,4 @@ -<%= @name %>, +<%= raw @name %>, <%= _('Please click on the link below to confirm that you want to change the email address that you use for {{site_name}} diff --git a/app/views/user_mailer/confirm_login.rhtml b/app/views/user_mailer/confirm_login.text.erb index 6f4feff00..fa86dc2b1 100644 --- a/app/views/user_mailer/confirm_login.rhtml +++ b/app/views/user_mailer/confirm_login.text.erb @@ -1,7 +1,7 @@ -<%= @name %>, +<%= raw @name %>, <%= _('Please click on the link below to confirm your email address.')%> -<%=@reasons[:email]%> +<%= raw @reasons[:email] %> <%=@url%> |