aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/images/icon_application_octet-stream_large.pngbin3184 -> 1315 bytes
-rw-r--r--app/assets/images/icon_application_pdf_large.pngbin2522 -> 849 bytes
-rw-r--r--app/assets/images/icon_application_rtf_large.pngbin2564 -> 818 bytes
-rw-r--r--app/assets/images/icon_application_vnd.ms-excel_large.pngbin2891 -> 848 bytes
-rw-r--r--app/assets/images/icon_application_vnd.ms-powerpoint_large.pngbin2495 -> 894 bytes
-rw-r--r--app/assets/images/icon_application_vnd.ms-word_large.pngbin2775 -> 935 bytes
-rw-r--r--app/assets/images/icon_application_zip_large.pngbin2863 -> 443 bytes
l---------[-rw-r--r--]app/assets/images/icon_image_bmp_large.pngbin2774 -> 24 bytes
l---------[-rw-r--r--]app/assets/images/icon_image_gif_large.pngbin2575 -> 24 bytes
-rw-r--r--app/assets/images/icon_image_img_large.pngbin0 -> 890 bytes
l---------[-rw-r--r--]app/assets/images/icon_image_jpeg_large.pngbin2633 -> 24 bytes
l---------[-rw-r--r--]app/assets/images/icon_image_png_large.pngbin2736 -> 24 bytes
-rw-r--r--app/assets/images/icon_image_tiff_large.pngbin2552 -> 1160 bytes
-rw-r--r--app/assets/images/icon_message_delivery-status_large.pngbin3184 -> 1010 bytes
-rw-r--r--app/assets/images/icon_text_html_large.pngbin3259 -> 1186 bytes
-rw-r--r--app/assets/images/icon_text_plain_large.pngbin2138 -> 400 bytes
-rw-r--r--app/assets/images/icon_text_x-vcard_large.pngbin2779 -> 1059 bytes
-rw-r--r--app/assets/images/icon_unknown.pngbin3604 -> 949 bytes
-rw-r--r--app/assets/images/widget-base.pngbin0 -> 569 bytes
-rw-r--r--app/assets/javascripts/general.js10
-rw-r--r--app/assets/stylesheets/responsive/_global_layout.scss7
-rw-r--r--app/assets/stylesheets/responsive/_global_style.scss3
-rw-r--r--app/assets/stylesheets/responsive/_header_layout.scss16
-rw-r--r--app/assets/stylesheets/responsive/_header_style.scss6
-rw-r--r--app/assets/stylesheets/responsive/_request_style.scss15
-rw-r--r--app/assets/stylesheets/responsive/_utils.scss15
-rw-r--r--app/assets/stylesheets/widget.scss109
-rw-r--r--app/controllers/admin_censor_rule_controller.rb1
-rw-r--r--app/controllers/admin_comment_controller.rb5
-rw-r--r--app/controllers/admin_controller.rb1
-rw-r--r--app/controllers/admin_general_controller.rb35
-rw-r--r--app/controllers/admin_holiday_imports_controller.rb1
-rw-r--r--app/controllers/admin_holidays_controller.rb1
-rw-r--r--app/controllers/admin_incoming_message_controller.rb7
-rw-r--r--app/controllers/admin_info_request_event_controller.rb1
-rw-r--r--app/controllers/admin_outgoing_message_controller.rb5
-rw-r--r--app/controllers/admin_public_body_categories_controller.rb1
-rw-r--r--app/controllers/admin_public_body_change_requests_controller.rb1
-rw-r--r--app/controllers/admin_public_body_controller.rb17
-rw-r--r--app/controllers/admin_public_body_headings_controller.rb5
-rw-r--r--app/controllers/admin_raw_email_controller.rb1
-rw-r--r--app/controllers/admin_request_controller.rb30
-rw-r--r--app/controllers/admin_spam_addresses_controller.rb1
-rw-r--r--app/controllers/admin_track_controller.rb1
-rw-r--r--app/controllers/admin_user_controller.rb4
-rw-r--r--app/controllers/api_controller.rb3
-rw-r--r--app/controllers/application_controller.rb4
-rw-r--r--app/controllers/comment_controller.rb1
-rw-r--r--app/controllers/general_controller.rb5
-rw-r--r--app/controllers/health_checks_controller.rb1
-rw-r--r--app/controllers/help_controller.rb1
-rw-r--r--app/controllers/holiday_controller.rb1
-rw-r--r--app/controllers/info_request_batch_controller.rb1
-rw-r--r--app/controllers/public_body_change_requests_controller.rb1
-rw-r--r--app/controllers/public_body_controller.rb10
-rw-r--r--app/controllers/reports_controller.rb1
-rw-r--r--app/controllers/request_controller.rb18
-rw-r--r--app/controllers/request_game_controller.rb3
-rw-r--r--app/controllers/services_controller.rb1
-rw-r--r--app/controllers/track_controller.rb3
-rw-r--r--app/controllers/user_controller.rb9
-rw-r--r--app/controllers/widgets_controller.rb64
-rw-r--r--app/helpers/admin_helper.rb1
-rw-r--r--app/helpers/admin_public_body_category_helper.rb1
-rw-r--r--app/helpers/application_helper.rb1
-rw-r--r--app/helpers/config_helper.rb1
-rw-r--r--app/helpers/date_time_helper.rb1
-rw-r--r--app/helpers/health_checks_helper.rb3
-rwxr-xr-xapp/helpers/link_to_helper.rb1
-rw-r--r--app/helpers/mailer_helper.rb1
-rw-r--r--app/helpers/public_body_helper.rb5
-rw-r--r--app/helpers/track_helper.rb1
-rw-r--r--app/helpers/widget_helper.rb47
-rw-r--r--app/mailers/application_mailer.rb1
-rw-r--r--app/mailers/contact_mailer.rb1
-rw-r--r--app/mailers/info_request_batch_mailer.rb1
-rw-r--r--app/mailers/outgoing_mailer.rb13
-rw-r--r--app/mailers/request_mailer.rb98
-rw-r--r--app/mailers/track_mailer.rb3
-rw-r--r--app/mailers/user_mailer.rb1
-rw-r--r--app/models/about_me_validator.rb12
-rw-r--r--app/models/censor_rule.rb13
-rw-r--r--app/models/change_email_validator.rb1
-rw-r--r--app/models/comment.rb14
-rw-r--r--app/models/concerns/admin_column.rb17
-rw-r--r--app/models/concerns/translatable.rb43
-rw-r--r--app/models/contact_validator.rb1
-rw-r--r--app/models/foi_attachment.rb36
-rw-r--r--app/models/holiday.rb1
-rw-r--r--app/models/holiday_import.rb1
-rw-r--r--app/models/incoming_message.rb14
-rw-r--r--app/models/info_request.rb187
-rw-r--r--app/models/info_request_batch.rb5
-rw-r--r--app/models/info_request_event.rb32
-rw-r--r--app/models/mail_server_log.rb55
-rw-r--r--app/models/mail_server_log_done.rb1
-rw-r--r--app/models/outgoing_message.rb55
-rw-r--r--app/models/post_redirect.rb7
-rw-r--r--app/models/profile_photo.rb1
-rw-r--r--app/models/public_body.rb90
-rw-r--r--app/models/public_body_category.rb41
-rw-r--r--app/models/public_body_category/category_collection.rb9
-rw-r--r--app/models/public_body_category_link.rb1
-rw-r--r--app/models/public_body_change_request.rb1
-rw-r--r--app/models/public_body_heading.rb39
-rw-r--r--app/models/purge_request.rb1
-rw-r--r--app/models/raw_email.rb1
-rw-r--r--app/models/request_classification.rb3
-rw-r--r--app/models/spam_address.rb1
-rw-r--r--app/models/track_thing.rb1
-rw-r--r--app/models/track_things_sent_email.rb1
-rw-r--r--app/models/user.rb5
-rw-r--r--app/models/user_info_request_sent_alert.rb1
-rw-r--r--app/models/widget_vote.rb20
-rw-r--r--app/views/admin_general/index.html.erb99
-rw-r--r--app/views/admin_public_body/edit.html.erb2
-rw-r--r--app/views/comment/_comment_form.html.erb2
-rw-r--r--app/views/comment/_single_comment.html.erb2
-rw-r--r--app/views/general/_responsive_topnav.html.erb13
-rw-r--r--app/views/help/unhappy.html.erb5
-rw-r--r--app/views/public_body/show.html.erb12
-rw-r--r--app/views/public_body_change_requests/new.html.erb2
-rw-r--r--app/views/request/_act.html.erb5
-rw-r--r--app/views/request/_followup.html.erb2
-rw-r--r--app/views/request/_incoming_correspondence.html.erb2
-rw-r--r--app/views/request/_outgoing_correspondence.html.erb2
-rw-r--r--app/views/request/_resent_outgoing_correspondence.html.erb2
-rw-r--r--app/views/request/new.html.erb4
-rw-r--r--app/views/request/new_bad_contact.html.erb2
-rw-r--r--app/views/request/show.html.erb4
-rw-r--r--app/views/request_game/play.html.erb7
-rw-r--r--app/views/user/_user_listing_single.html.erb2
-rw-r--r--app/views/user/show.html.erb4
-rw-r--r--app/views/widgets/new.html.erb15
-rw-r--r--app/views/widgets/show.html.erb48
135 files changed, 971 insertions, 583 deletions
diff --git a/app/assets/images/icon_application_octet-stream_large.png b/app/assets/images/icon_application_octet-stream_large.png
index a239862e1..a23916e9c 100644
--- a/app/assets/images/icon_application_octet-stream_large.png
+++ b/app/assets/images/icon_application_octet-stream_large.png
Binary files differ
diff --git a/app/assets/images/icon_application_pdf_large.png b/app/assets/images/icon_application_pdf_large.png
index 9a38ca33c..990b96c0a 100644
--- a/app/assets/images/icon_application_pdf_large.png
+++ b/app/assets/images/icon_application_pdf_large.png
Binary files differ
diff --git a/app/assets/images/icon_application_rtf_large.png b/app/assets/images/icon_application_rtf_large.png
index 2ad990608..977972124 100644
--- a/app/assets/images/icon_application_rtf_large.png
+++ b/app/assets/images/icon_application_rtf_large.png
Binary files differ
diff --git a/app/assets/images/icon_application_vnd.ms-excel_large.png b/app/assets/images/icon_application_vnd.ms-excel_large.png
index 3f346f5ef..acca5d92c 100644
--- a/app/assets/images/icon_application_vnd.ms-excel_large.png
+++ b/app/assets/images/icon_application_vnd.ms-excel_large.png
Binary files differ
diff --git a/app/assets/images/icon_application_vnd.ms-powerpoint_large.png b/app/assets/images/icon_application_vnd.ms-powerpoint_large.png
index 82c225059..9a1582930 100644
--- a/app/assets/images/icon_application_vnd.ms-powerpoint_large.png
+++ b/app/assets/images/icon_application_vnd.ms-powerpoint_large.png
Binary files differ
diff --git a/app/assets/images/icon_application_vnd.ms-word_large.png b/app/assets/images/icon_application_vnd.ms-word_large.png
index 91a696ab5..2f3cb8efa 100644
--- a/app/assets/images/icon_application_vnd.ms-word_large.png
+++ b/app/assets/images/icon_application_vnd.ms-word_large.png
Binary files differ
diff --git a/app/assets/images/icon_application_zip_large.png b/app/assets/images/icon_application_zip_large.png
index 0a14e978e..c52d6d5aa 100644
--- a/app/assets/images/icon_application_zip_large.png
+++ b/app/assets/images/icon_application_zip_large.png
Binary files differ
diff --git a/app/assets/images/icon_image_bmp_large.png b/app/assets/images/icon_image_bmp_large.png
index f6e8dbaed..347bdaaf1 100644..120000
--- a/app/assets/images/icon_image_bmp_large.png
+++ b/app/assets/images/icon_image_bmp_large.png
Binary files differ
diff --git a/app/assets/images/icon_image_gif_large.png b/app/assets/images/icon_image_gif_large.png
index 424d1e0fd..347bdaaf1 100644..120000
--- a/app/assets/images/icon_image_gif_large.png
+++ b/app/assets/images/icon_image_gif_large.png
Binary files differ
diff --git a/app/assets/images/icon_image_img_large.png b/app/assets/images/icon_image_img_large.png
new file mode 100644
index 000000000..e19e7553c
--- /dev/null
+++ b/app/assets/images/icon_image_img_large.png
Binary files differ
diff --git a/app/assets/images/icon_image_jpeg_large.png b/app/assets/images/icon_image_jpeg_large.png
index fd50a889d..347bdaaf1 100644..120000
--- a/app/assets/images/icon_image_jpeg_large.png
+++ b/app/assets/images/icon_image_jpeg_large.png
Binary files differ
diff --git a/app/assets/images/icon_image_png_large.png b/app/assets/images/icon_image_png_large.png
index f16edb08e..347bdaaf1 100644..120000
--- a/app/assets/images/icon_image_png_large.png
+++ b/app/assets/images/icon_image_png_large.png
Binary files differ
diff --git a/app/assets/images/icon_image_tiff_large.png b/app/assets/images/icon_image_tiff_large.png
index 356f63478..000bd0318 100644
--- a/app/assets/images/icon_image_tiff_large.png
+++ b/app/assets/images/icon_image_tiff_large.png
Binary files differ
diff --git a/app/assets/images/icon_message_delivery-status_large.png b/app/assets/images/icon_message_delivery-status_large.png
index a239862e1..dccdbbccd 100644
--- a/app/assets/images/icon_message_delivery-status_large.png
+++ b/app/assets/images/icon_message_delivery-status_large.png
Binary files differ
diff --git a/app/assets/images/icon_text_html_large.png b/app/assets/images/icon_text_html_large.png
index 914502cf4..3813d2582 100644
--- a/app/assets/images/icon_text_html_large.png
+++ b/app/assets/images/icon_text_html_large.png
Binary files differ
diff --git a/app/assets/images/icon_text_plain_large.png b/app/assets/images/icon_text_plain_large.png
index f74a997ba..f15b0dbdc 100644
--- a/app/assets/images/icon_text_plain_large.png
+++ b/app/assets/images/icon_text_plain_large.png
Binary files differ
diff --git a/app/assets/images/icon_text_x-vcard_large.png b/app/assets/images/icon_text_x-vcard_large.png
index cc44d3edc..804066af8 100644
--- a/app/assets/images/icon_text_x-vcard_large.png
+++ b/app/assets/images/icon_text_x-vcard_large.png
Binary files differ
diff --git a/app/assets/images/icon_unknown.png b/app/assets/images/icon_unknown.png
index 992c646c0..9a06d9baa 100644
--- a/app/assets/images/icon_unknown.png
+++ b/app/assets/images/icon_unknown.png
Binary files differ
diff --git a/app/assets/images/widget-base.png b/app/assets/images/widget-base.png
new file mode 100644
index 000000000..872244543
--- /dev/null
+++ b/app/assets/images/widget-base.png
Binary files differ
diff --git a/app/assets/javascripts/general.js b/app/assets/javascripts/general.js
index 002eef760..639a6917b 100644
--- a/app/assets/javascripts/general.js
+++ b/app/assets/javascripts/general.js
@@ -34,12 +34,12 @@ $(document).ready(function() {
box.width(location.length + " em");
box.find('input').val(location).attr('size', location.length + " em");
box.show();
- box.find('input').select();
box.position({
my: "right center",
at: "left bottom",
of: this,
collision: "fit" });
+ box.find('input').select();
return false;
});
@@ -57,4 +57,12 @@ $(document).ready(function() {
$('#everypage').hide();
}
+ // "Create widget" page
+ $("#widgetbox").select()
+ // Chrome workaround
+ $("widgetbox").mouseup(function() {
+ // Prevent further mouseup intervention
+ $this.unbind("mouseup");
+ return false;
+ });
})
diff --git a/app/assets/stylesheets/responsive/_global_layout.scss b/app/assets/stylesheets/responsive/_global_layout.scss
index d7b24df41..b34a6af74 100644
--- a/app/assets/stylesheets/responsive/_global_layout.scss
+++ b/app/assets/stylesheets/responsive/_global_layout.scss
@@ -98,3 +98,10 @@ textarea{
padding-right: 0.9375em;
}
}
+.box {
+ padding: 1em;
+
+ @include respond-min( $main_menu-mobile_menu_cutoff ){
+ padding: 1.2em;
+ }
+}
diff --git a/app/assets/stylesheets/responsive/_global_style.scss b/app/assets/stylesheets/responsive/_global_style.scss
index 24cddc0d9..27d238962 100644
--- a/app/assets/stylesheets/responsive/_global_style.scss
+++ b/app/assets/stylesheets/responsive/_global_style.scss
@@ -84,9 +84,6 @@ dd {
dt + dd {
margin-top: 0.5em;
- > p {
- margin-top: 0;
- }
}
diff --git a/app/assets/stylesheets/responsive/_header_layout.scss b/app/assets/stylesheets/responsive/_header_layout.scss
index b3103e3a9..7c7bdfe97 100644
--- a/app/assets/stylesheets/responsive/_header_layout.scss
+++ b/app/assets/stylesheets/responsive/_header_layout.scss
@@ -131,25 +131,25 @@
}
form{
@include grid-row;
- padding-right: 1em;
+ padding: 1em 1em 0;
@include lte-ie7 {
display: inline;
}
+ @include respond-min( $main_menu-mobile_menu_cutoff ){
+ padding-top: 0;
+ }
}
input{
- @include grid-column($columns:9);
- margin:0;
+ @include grid-column($columns:10);
+ margin-right:0;
@include lte-ie7 {
width: 10.063em;
}
}
- label{
+ button[type="submit"]{
@include prefix-postfix-base;
- @include grid-column($columns:3,$float:left);
+ @include grid-column($columns:2,$float:right);
border:none;
- img{
- max-width: 100%;
- }
@include lte-ie7 {
width: 2.125em;
}
diff --git a/app/assets/stylesheets/responsive/_header_style.scss b/app/assets/stylesheets/responsive/_header_style.scss
index 9008a73a7..ec1e8ea5c 100644
--- a/app/assets/stylesheets/responsive/_header_style.scss
+++ b/app/assets/stylesheets/responsive/_header_style.scss
@@ -2,3 +2,9 @@
#navigation {
border-bottom: 1px solid #e9e9e9;
}
+
+#navigation_search {
+ button[type="submit"] {
+ background:image-url('/assets/search.png') transparent no-repeat center center;
+ }
+}
diff --git a/app/assets/stylesheets/responsive/_request_style.scss b/app/assets/stylesheets/responsive/_request_style.scss
index e6f36674a..44ca9a288 100644
--- a/app/assets/stylesheets/responsive/_request_style.scss
+++ b/app/assets/stylesheets/responsive/_request_style.scss
@@ -3,12 +3,9 @@
div.correspondence {
border: 1px solid #ccc;
margin: 0 0 1em;
- padding: 1em;
- @include respond-min( $main_menu-mobile_menu_cutoff ){
- padding: 1.5em;
- }
h2 {
+ margin-top: 0;
text-align:right;
font-size:1em;
}
@@ -31,7 +28,6 @@ div.correspondence {
div.comment_in_request {
border: 1px dotted #ccc;
margin:0 0 1em 3em;
- padding:0 0.5em;
h2 {
font-size:1em;
@@ -42,13 +38,9 @@ div.comment_in_request {
}
.event_actions {
+ margin-bottom: 0;
text-align:right;
line-height: 1em;
- margin-bottom: 1em;
-}
-
-.comment_in_request_text {
- margin:0 1.2em 0 0.9em;
}
.user_photo_on_request img {
@@ -64,7 +56,6 @@ div.comment_in_request {
height:36px;
float:left;
vertical-align:middle;
- margin-top: 0.5em;
margin-right:0.5em;
}
@@ -86,11 +77,9 @@ a img.attachment_image {
}
.describe_state_form,#other_recipients {
-
border-radius:3px;
-moz-border-radius:3px;
margin:1em 0;
- padding:0.5em 1em;
}
.describe_state_form {
diff --git a/app/assets/stylesheets/responsive/_utils.scss b/app/assets/stylesheets/responsive/_utils.scss
index 68884fa7a..e19201475 100644
--- a/app/assets/stylesheets/responsive/_utils.scss
+++ b/app/assets/stylesheets/responsive/_utils.scss
@@ -33,3 +33,18 @@ $lte-ie7: false !default;
@content;
}
}
+
+// Hide content visually, but keep it available to screen readers
+// source: http://a11yproject.com/posts/how-to-hide-content/
+.visually-hidden {
+ // http://developer.yahoo.com/blogs/ydn/posts/2012/10/clip-your-hidden-content-for-better-accessibility/
+ position: absolute !important;
+ clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
+ clip: rect(1px, 1px, 1px, 1px);
+ padding:0 !important;
+ border:0 !important;
+ height: 1px !important;
+ width: 1px !important;
+ overflow: hidden;
+}
+body:hover .visually-hidden a, body:hover .visually-hidden input, body:hover .visually-hidden button { display: none !important; }
diff --git a/app/assets/stylesheets/widget.scss b/app/assets/stylesheets/widget.scss
new file mode 100644
index 000000000..a67e1f3f0
--- /dev/null
+++ b/app/assets/stylesheets/widget.scss
@@ -0,0 +1,109 @@
+/* CSS Mini Reset */
+
+html, body, div, form, fieldset, legend, label
+{
+ margin: 0;
+ padding: 0;
+}
+
+table
+{
+ border-collapse: collapse;
+ border-spacing: 0;
+}
+
+th, td
+{
+ text-align: left;
+ vertical-align: top;
+}
+
+h1, h2, h3, h4, h5, h6, th, td, caption { font-weight:normal; }
+
+img { border: 0; }
+
+body {
+ background-color: #ffffff;
+ color: #333333;
+ padding: 0;
+ margin: 0;
+ font-family: "Helvetica Neue", Arial, Helvetica, Helmet, Freesans, sans-serif;
+ font-weight: normal;
+ font-style: normal;
+ line-height: 1.5em;
+ position: relative;
+ cursor: default;
+ font-size: 1em;
+}
+
+a:hover,
+a:focus,
+a:active {
+ color: #333;
+}
+
+.alaveteli-widget {
+ width: 318px;
+ height: 213px;
+ border: 1px solid #e9e9e9;
+ background: #e9e9e9 url("widget-base.png") top left no-repeat;
+ position: relative;
+ border: 1px solid #eee;
+}
+
+.alaveteli-widget__title {
+ position: absolute;
+ top: 1em;
+ left: 16px;
+ width: 160px;
+ height: 75px;
+ overflow: hidden;
+}
+
+.alaveteli-widget__status {
+ position: absolute;
+ top: 97px;
+ left: 16px;
+ font-weight: bold;
+ text-transform: uppercase;
+}
+
+.alaveteli-widget__status__status-label {
+ margin: 0;
+ font-weight: normal;
+ font-size: 0.875em;
+ line-height: 1.1em;
+ color: #555;
+ text-transform: capitalize;
+}
+
+.alaveteli-widget__left {
+ position: absolute;
+ width: 145px;
+}
+
+.alaveteli-widget__people-count {
+ position: absolute;
+ left: 192px;
+ top: 44px;
+ width: 100px;
+ text-align: center;
+ line-height: 1.3em;
+}
+.alaveteli-widget__count {
+ font-size: 55px;
+ line-height: 55px;
+ text-align: center;
+}
+
+.alaveteli-widget__bottom a {
+ text-decoration: none;
+}
+
+.alaveteli-widget__button {
+ position: absolute;
+ top: 173px;
+ left: 16px;
+ text-align: center;
+}
+
diff --git a/app/controllers/admin_censor_rule_controller.rb b/app/controllers/admin_censor_rule_controller.rb
index 3387fd832..6c060a610 100644
--- a/app/controllers/admin_censor_rule_controller.rb
+++ b/app/controllers/admin_censor_rule_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# app/controllers/admin_censor_rule_controller.rb:
# For modifying requests.
#
diff --git a/app/controllers/admin_comment_controller.rb b/app/controllers/admin_comment_controller.rb
index 0aafb122a..030afb645 100644
--- a/app/controllers/admin_comment_controller.rb
+++ b/app/controllers/admin_comment_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# app/controllers/admin_comment_controller.rb:
# Controller for editing comments from the admin interface.
#
@@ -15,12 +16,12 @@ class AdminCommentController < AdminController
old_body = @comment.body
old_visible = @comment.visible
- @comment.visible = params[:comment][:visible] == "true" ? true : false
+ @comment.visible = params[:comment][:visible] == "true"
if @comment.update_attributes(params[:comment])
@comment.info_request.log_event("edit_comment",
{ :comment_id => @comment.id,
- :editor => admin_current_user(),
+ :editor => admin_current_user,
:old_body => old_body,
:body => @comment.body,
:old_visible => old_visible,
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 7760c372b..400047215 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# controllers/admin.rb:
# All admin controllers are dervied from this.
#
diff --git a/app/controllers/admin_general_controller.rb b/app/controllers/admin_general_controller.rb
index f2414eeab..8efe0c7b9 100644
--- a/app/controllers/admin_general_controller.rb
+++ b/app/controllers/admin_general_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# app/controllers/admin_controller.rb:
# Controller for main admin pages.
#
@@ -7,29 +8,29 @@
class AdminGeneralController < AdminController
def index
- # 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
-
# Tasks to do
@requires_admin_requests = InfoRequest.find_in_state('requires_admin')
@error_message_requests = InfoRequest.find_in_state('error_message')
@attention_requests = InfoRequest.find_in_state('attention_requested')
- @blank_contacts = PublicBody.find(:all, :conditions => ["request_email = ''"],
- :order => "updated_at")
+ @blank_contacts = PublicBody.
+ includes(:tags, :translations).
+ where(:request_email => "").
+ order(:updated_at).
+ select { |pb| !pb.defunct? }
@old_unclassified = InfoRequest.find_old_unclassified(:limit => 20,
:conditions => ["prominence = 'normal'"])
- @holding_pen_messages = InfoRequest.holding_pen_request.incoming_messages
- @new_body_requests = PublicBodyChangeRequest.new_body_requests.open
- @body_update_requests = PublicBodyChangeRequest.body_update_requests.open
+ @holding_pen_messages = InfoRequest.
+ includes(:incoming_messages => :raw_email).
+ holding_pen_request.
+ incoming_messages
+ @new_body_requests = PublicBodyChangeRequest.
+ includes(:public_body, :user).
+ new_body_requests.
+ open
+ @body_update_requests = PublicBodyChangeRequest.
+ includes(:public_body, :user).
+ body_update_requests.
+ open
end
def timeline
diff --git a/app/controllers/admin_holiday_imports_controller.rb b/app/controllers/admin_holiday_imports_controller.rb
index 8596936f0..a740caa2b 100644
--- a/app/controllers/admin_holiday_imports_controller.rb
+++ b/app/controllers/admin_holiday_imports_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
class AdminHolidayImportsController < AdminController
def new
diff --git a/app/controllers/admin_holidays_controller.rb b/app/controllers/admin_holidays_controller.rb
index 9177ebd44..cd93a21b6 100644
--- a/app/controllers/admin_holidays_controller.rb
+++ b/app/controllers/admin_holidays_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
class AdminHolidaysController < AdminController
def index
diff --git a/app/controllers/admin_incoming_message_controller.rb b/app/controllers/admin_incoming_message_controller.rb
index bc653bf53..db7bed34c 100644
--- a/app/controllers/admin_incoming_message_controller.rb
+++ b/app/controllers/admin_incoming_message_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
class AdminIncomingMessageController < AdminController
def edit
@@ -13,7 +14,7 @@ class AdminIncomingMessageController < AdminController
if @incoming_message.save
@incoming_message.info_request.log_event('edit_incoming',
:incoming_message_id => @incoming_message.id,
- :editor => admin_current_user(),
+ :editor => admin_current_user,
:old_prominence => old_prominence,
:prominence => @incoming_message.prominence,
:old_prominence_reason => old_prominence_reason,
@@ -33,7 +34,7 @@ class AdminIncomingMessageController < AdminController
@incoming_message.fully_destroy
@incoming_message.info_request.log_event("destroy_incoming",
- { :editor => admin_current_user(), :deleted_incoming_message_id => incoming_message_id })
+ { :editor => admin_current_user, :deleted_incoming_message_id => incoming_message_id })
# expire cached files
expire_for_request(@info_request)
flash[:notice] = 'Incoming message successfully destroyed.'
@@ -63,7 +64,7 @@ class AdminIncomingMessageController < AdminController
incoming_message_id = incoming_message.id
incoming_message.info_request.log_event("redeliver_incoming", {
- :editor => admin_current_user(),
+ :editor => admin_current_user,
:destination_request => destination_request.id,
:deleted_incoming_message_id => incoming_message_id
})
diff --git a/app/controllers/admin_info_request_event_controller.rb b/app/controllers/admin_info_request_event_controller.rb
index 17d147582..6862ff116 100644
--- a/app/controllers/admin_info_request_event_controller.rb
+++ b/app/controllers/admin_info_request_event_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# app/controllers/admin_info_request_event_controller.rb:
# Controller for FOI request event manipulation from the admin interface.
#
diff --git a/app/controllers/admin_outgoing_message_controller.rb b/app/controllers/admin_outgoing_message_controller.rb
index 2ee811dc0..56e27b108 100644
--- a/app/controllers/admin_outgoing_message_controller.rb
+++ b/app/controllers/admin_outgoing_message_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
class AdminOutgoingMessageController < AdminController
def edit
@@ -11,7 +12,7 @@ class AdminOutgoingMessageController < AdminController
@outgoing_message.fully_destroy
@outgoing_message.info_request.log_event("destroy_outgoing",
- { :editor => admin_current_user(), :deleted_outgoing_message_id => outgoing_message_id })
+ { :editor => admin_current_user, :deleted_outgoing_message_id => outgoing_message_id })
flash[:notice] = 'Outgoing message successfully destroyed.'
redirect_to admin_request_url(@info_request)
@@ -29,7 +30,7 @@ class AdminOutgoingMessageController < AdminController
if @outgoing_message.save
@outgoing_message.info_request.log_event("edit_outgoing",
{ :outgoing_message_id => @outgoing_message.id,
- :editor => admin_current_user(),
+ :editor => admin_current_user,
:old_body => old_body,
:body => @outgoing_message.body,
:old_prominence => old_prominence,
diff --git a/app/controllers/admin_public_body_categories_controller.rb b/app/controllers/admin_public_body_categories_controller.rb
index a86171c76..e365255f8 100644
--- a/app/controllers/admin_public_body_categories_controller.rb
+++ b/app/controllers/admin_public_body_categories_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
class AdminPublicBodyCategoriesController < AdminController
def index
@locale = self.locale_from_params
diff --git a/app/controllers/admin_public_body_change_requests_controller.rb b/app/controllers/admin_public_body_change_requests_controller.rb
index 6ff03a2bd..be632b6cd 100644
--- a/app/controllers/admin_public_body_change_requests_controller.rb
+++ b/app/controllers/admin_public_body_change_requests_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
class AdminPublicBodyChangeRequestsController < AdminController
def edit
diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb
index 7de27121a..b3c2c1dfd 100644
--- a/app/controllers/admin_public_body_controller.rb
+++ b/app/controllers/admin_public_body_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# app/controllers/admin_public_body_controller.rb:
# Controller for editing public bodies from the admin interface.
#
@@ -11,7 +12,7 @@ class AdminPublicBodyController < AdminController
end
def show
- @locale = self.locale_from_params()
+ @locale = locale_from_params
I18n.with_locale(@locale) do
@public_body = PublicBody.find(params[:id])
@info_requests = @public_body.info_requests.paginate :order => "created_at desc",
@@ -43,7 +44,7 @@ class AdminPublicBodyController < AdminController
if params[:change_request_id]
@change_request = PublicBodyChangeRequest.find(params[:change_request_id])
end
- params[:public_body][:last_edit_editor] = admin_current_user()
+ params[:public_body][:last_edit_editor] = admin_current_user
@public_body = PublicBody.new(params[:public_body])
if @public_body.save
if @change_request
@@ -84,7 +85,7 @@ class AdminPublicBodyController < AdminController
@change_request = PublicBodyChangeRequest.find(params[:change_request_id])
end
I18n.with_locale(I18n.default_locale) do
- params[:public_body][:last_edit_editor] = admin_current_user()
+ params[:public_body][:last_edit_editor] = admin_current_user
@public_body = PublicBody.find(params[:id])
if @public_body.update_attributes(params[:public_body])
if @change_request
@@ -101,7 +102,7 @@ class AdminPublicBodyController < AdminController
end
def destroy
- @locale = self.locale_from_params()
+ @locale = locale_from_params
I18n.with_locale(@locale) do
public_body = PublicBody.find(params[:id])
@@ -158,7 +159,7 @@ class AdminPublicBodyController < AdminController
@notes = ""
@errors = ""
if request.post?
- dry_run_only = (params['commit'] == 'Upload' ? false : true)
+ dry_run_only = params['commit'] != 'Upload'
# (FIXME: both of these cases could now be changed to use
# PublicBody.import_csv_from_file.)
# Read file from params
@@ -177,7 +178,7 @@ class AdminPublicBodyController < AdminController
params[:tag],
params[:tag_behaviour],
true,
- admin_current_user(),
+ admin_current_user,
I18n.available_locales)
if errors.size == 0
@@ -191,7 +192,7 @@ class AdminPublicBodyController < AdminController
params[:tag],
params[:tag_behaviour],
false,
- admin_current_user(),
+ admin_current_user,
I18n.available_locales)
if errors.size != 0
raise "dry run mismatched real run"
@@ -234,7 +235,7 @@ class AdminPublicBodyController < AdminController
end
def lookup_query
- @locale = self.locale_from_params()
+ @locale = locale_from_params
underscore_locale = @locale.gsub '-', '_'
I18n.with_locale(@locale) do
@query = params[:query]
diff --git a/app/controllers/admin_public_body_headings_controller.rb b/app/controllers/admin_public_body_headings_controller.rb
index a7fe27390..f0568510a 100644
--- a/app/controllers/admin_public_body_headings_controller.rb
+++ b/app/controllers/admin_public_body_headings_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
class AdminPublicBodyHeadingsController < AdminController
def new
@@ -84,7 +85,7 @@ class AdminPublicBodyHeadingsController < AdminController
end
end
end
- { :success => error.nil? ? true : false, :error => error }
+ { :success => error.nil?, :error => error }
end
def reorder_categories_for_heading(heading_id, categories)
@@ -105,7 +106,7 @@ class AdminPublicBodyHeadingsController < AdminController
end
end
end
- { :success => error.nil? ? true : false, :error => error }
+ { :success => error.nil?, :error => error }
end
end
diff --git a/app/controllers/admin_raw_email_controller.rb b/app/controllers/admin_raw_email_controller.rb
index 1b3ee2871..7a802d914 100644
--- a/app/controllers/admin_raw_email_controller.rb
+++ b/app/controllers/admin_raw_email_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# app/controllers/admin_raw_email_controller.rb:
# Controller for managing raw emails from the admin interface.
#
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb
index 1e083f57e..eaf6c337d 100644
--- a/app/controllers/admin_request_controller.rb
+++ b/app/controllers/admin_request_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# app/controllers/admin_request_controller.rb:
# Controller for viewing FOI requests from the admin interface.
#
@@ -47,16 +48,16 @@ class AdminRequestController < AdminController
@info_request.title = params[:info_request][:title]
@info_request.prominence = params[:info_request][:prominence]
- @info_request.awaiting_description = params[:info_request][:awaiting_description] == "true" ? true : false
+ @info_request.awaiting_description = params[:info_request][:awaiting_description] == "true"
@info_request.allow_new_responses_from = params[:info_request][:allow_new_responses_from]
@info_request.handle_rejected_responses = params[:info_request][:handle_rejected_responses]
@info_request.tag_string = params[:info_request][:tag_string]
- @info_request.comments_allowed = params[:info_request][:comments_allowed] == "true" ? true : false
+ @info_request.comments_allowed = params[:info_request][:comments_allowed] == "true"
if @info_request.valid?
@info_request.save!
@info_request.log_event("edit",
- { :editor => admin_current_user(),
+ { :editor => admin_current_user,
:old_title => old_title, :title => @info_request.title,
:old_prominence => old_prominence, :prominence => @info_request.prominence,
:old_described_state => old_described_state, :described_state => params[:info_request][:described_state],
@@ -104,7 +105,7 @@ class AdminRequestController < AdminController
info_request.user = destination_user
info_request.save!
info_request.log_event("move_request", {
- :editor => admin_current_user(),
+ :editor => admin_current_user,
:old_user_url_name => old_user.url_name,
:user_url_name => destination_user.url_name
})
@@ -114,21 +115,14 @@ class AdminRequestController < AdminController
end
redirect_to admin_request_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])
- if destination_public_body.nil?
- flash[:error] = "Couldn't find public body '" + params[:public_body_url_name] + "'"
- else
- info_request.public_body = destination_public_body
- info_request.save!
- info_request.log_event("move_request", {
- :editor => admin_current_user(),
- :old_public_body_url_name => old_public_body.url_name,
- :public_body_url_name => destination_public_body.url_name
- })
- info_request.reindex_request_events
- flash[:notice] = "Request has been moved to new body"
+ if info_request.move_to_public_body(destination_public_body,
+ :editor => admin_current_user,
+ :reindex => true)
+ flash[:notice] = "Request has been moved to new body"
+ else
+ flash[:error] = "Couldn't find public body '#{ params[:public_body_url_name] }'"
end
redirect_to admin_request_url(info_request)
@@ -182,7 +176,7 @@ class AdminRequestController < AdminController
info_request.prominence = "requester_only"
info_request.log_event("hide", {
- :editor => admin_current_user(),
+ :editor => admin_current_user,
:reason => params[:reason],
:subject => subject,
:explanation => explanation
diff --git a/app/controllers/admin_spam_addresses_controller.rb b/app/controllers/admin_spam_addresses_controller.rb
index fff7e2a4a..d8be52bc7 100644
--- a/app/controllers/admin_spam_addresses_controller.rb
+++ b/app/controllers/admin_spam_addresses_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
class AdminSpamAddressesController < AdminController
def index
diff --git a/app/controllers/admin_track_controller.rb b/app/controllers/admin_track_controller.rb
index 63ee5c12e..e6e5835e6 100644
--- a/app/controllers/admin_track_controller.rb
+++ b/app/controllers/admin_track_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# app/controllers/admin_track_controller.rb:
# Show email alerts / RSS feeds from admin interface.
#
diff --git a/app/controllers/admin_user_controller.rb b/app/controllers/admin_user_controller.rb
index 7ef461594..8ebc450f6 100644
--- a/app/controllers/admin_user_controller.rb
+++ b/app/controllers/admin_user_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# app/controllers/admin_user_controller.rb:
# Controller for viewing user accounts from the admin interface.
#
@@ -85,8 +86,7 @@ class AdminUserController < AdminController
end
def modify_comment_visibility
- @visibility_value = params.key?(:hide_selected) ? false : true
- Comment.update_all(["visible=?", @visibility_value], :id => params[:comment_ids])
+ Comment.update_all(["visible = ?", !params[:hide_selected]], :id => params[:comment_ids])
redirect_to :back
end
diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb
index 6f83d89d6..3b8991f28 100644
--- a/app/controllers/api_controller.rb
+++ b/app/controllers/api_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
class ApiController < ApplicationController
before_filter :check_api_key
before_filter :check_external_request,
@@ -41,7 +42,7 @@ class ApiController < ApplicationController
:status => 'ready',
:message_type => 'initial_request',
:body => json["body"],
- :last_sent_at => Time.now(),
+ :last_sent_at => Time.now,
:what_doing => 'normal_sort',
:info_request => request
)
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index e80c6a823..a76e6630a 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- encoding : utf-8 -*-
# controllers/application.rb:
# Parent class of all controllers in FOI site. Filters added to this controller
# apply to all controllers in the application. Likewise, all the methods added
@@ -206,7 +206,7 @@ class ApplicationController < ActionController::Base
def foi_fragment_cache_part_path(param)
path = url_for(param)
id = param['id'] || param[:id]
- first_three_digits = id.to_s()[0..2]
+ first_three_digits = id.to_s[0..2]
path = path.sub("/request/", "/request/" + first_three_digits + "/")
return path
end
diff --git a/app/controllers/comment_controller.rb b/app/controllers/comment_controller.rb
index 890e9faaa..b5c438c95 100644
--- a/app/controllers/comment_controller.rb
+++ b/app/controllers/comment_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# app/controllers/comment_controller.rb:
# Show annotations upon a request or other object.
#
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index 380da285e..53288c2f4 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# app/controllers/general_controller.rb:
# For pages like front page, general search, that aren't specific to a
# particular model.
@@ -14,7 +15,7 @@ class GeneralController < ApplicationController
# New, improved front page!
def frontpage
medium_cache
- @locale = self.locale_from_params()
+ @locale = locale_from_params
successful_query = InfoRequestEvent.make_query_from_params( :latest_status => ['successful'] )
@track_thing = TrackThing.create_track_for_search_query(successful_query)
@feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'),
@@ -32,7 +33,7 @@ class GeneralController < ApplicationController
@feed_autodetect = []
@feed_url = AlaveteliConfiguration::blog_feed
separator = @feed_url.include?('?') ? '&' : '?'
- @feed_url = "#{@feed_url}#{separator}lang=#{self.locale_from_params()}"
+ @feed_url = "#{@feed_url}#{separator}lang=#{locale_from_params}"
@blog_items = []
if not @feed_url.empty?
content = quietly_try_to_open(@feed_url)
diff --git a/app/controllers/health_checks_controller.rb b/app/controllers/health_checks_controller.rb
index 473a1aacc..122a02193 100644
--- a/app/controllers/health_checks_controller.rb
+++ b/app/controllers/health_checks_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
class HealthChecksController < ApplicationController
def index
diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb
index 93215ccad..cfe1b6ad5 100644
--- a/app/controllers/help_controller.rb
+++ b/app/controllers/help_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# app/controllers/help_controller.rb:
# Show information about one particular request.
#
diff --git a/app/controllers/holiday_controller.rb b/app/controllers/holiday_controller.rb
index efc20701d..422612fc7 100644
--- a/app/controllers/holiday_controller.rb
+++ b/app/controllers/holiday_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# app/controllers/holiday_controller.rb:
# Calculate dates
#
diff --git a/app/controllers/info_request_batch_controller.rb b/app/controllers/info_request_batch_controller.rb
index b66658757..e1b684f30 100644
--- a/app/controllers/info_request_batch_controller.rb
+++ b/app/controllers/info_request_batch_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
class InfoRequestBatchController < ApplicationController
def show
diff --git a/app/controllers/public_body_change_requests_controller.rb b/app/controllers/public_body_change_requests_controller.rb
index 773308546..d43f9398a 100644
--- a/app/controllers/public_body_change_requests_controller.rb
+++ b/app/controllers/public_body_change_requests_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
class PublicBodyChangeRequestsController < ApplicationController
before_filter :catch_spam, :only => [:create]
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb
index 854e79a19..1b01dc837 100644
--- a/app/controllers/public_body_controller.rb
+++ b/app/controllers/public_body_controller.rb
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- encoding : utf-8 -*-
# app/controllers/public_body_controller.rb:
# Show information about a public body.
#
@@ -24,7 +24,7 @@ class PublicBodyController < ApplicationController
redirect_to :url_name => MySociety::Format.simplify_url_part(params[:url_name], 'body'), :status => :moved_permanently
return
end
- @locale = self.locale_from_params()
+ @locale = locale_from_params
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?
@@ -40,6 +40,8 @@ class PublicBodyController < ApplicationController
set_last_body(@public_body)
+ @number_of_visible_requests = @public_body.info_requests.visible.count
+
top_url = frontpage_url
@searched_to_send_request = false
referrer = request.env['HTTP_REFERER']
@@ -83,7 +85,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?
- I18n.with_locale(self.locale_from_params()) do
+ I18n.with_locale(locale_from_params) do
if params[:submitted_view_email]
if verify_recaptcha
flash.discard(:error)
@@ -106,7 +108,7 @@ class PublicBodyController < ApplicationController
@tag = params[:tag]
- @locale = self.locale_from_params
+ @locale = locale_from_params
underscore_locale = @locale.gsub '-', '_'
underscore_default_locale = I18n.default_locale.to_s.gsub '-', '_'
diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb
index a1dd53125..83474ad65 100644
--- a/app/controllers/reports_controller.rb
+++ b/app/controllers/reports_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
class ReportsController < ApplicationController
def create
@info_request = InfoRequest.find_by_url_title!(params[:request_id])
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index e847cae1e..45229fd7e 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -1,4 +1,4 @@
-# encoding: UTF-8
+# -*- encoding : utf-8 -*-
# app/controllers/request_controller.rb:
# Show information about one particular request.
#
@@ -75,7 +75,7 @@ class RequestController < ApplicationController
else
medium_cache
end
- @locale = self.locale_from_params()
+ @locale = locale_from_params
I18n.with_locale(@locale) do
# Look up by old style numeric identifiers
@@ -96,12 +96,12 @@ class RequestController < ApplicationController
set_last_request(@info_request)
# assign variables from request parameters
- @collapse_quotes = params[:unfold] ? false : true
+ @collapse_quotes = !params[:unfold]
# Don't allow status update on external requests, otherwise accept param
if @info_request.is_external?
@update_status = false
else
- @update_status = params[:update_status] ? true : false
+ @update_status = params[:update_status]
end
assign_variables_for_show_template(@info_request)
@@ -164,7 +164,7 @@ class RequestController < ApplicationController
def list
medium_cache
@view = params[:view]
- @locale = self.locale_from_params()
+ @locale = locale_from_params
@page = get_search_page_from_params if !@page # used in cache case, as perform_search sets @page as side effect
@per_page = PER_PAGE
@max_results = MAX_RESULTS
@@ -566,9 +566,9 @@ class RequestController < ApplicationController
@info_request = InfoRequest.find(params[:id].to_i)
set_last_request(@info_request)
- @collapse_quotes = params[:unfold] ? false : true
+ @collapse_quotes = !params[:unfold]
@is_owning_user = @info_request.is_owning_user?(authenticated_user)
- @gone_postal = params[:gone_postal] ? true : false
+ @gone_postal = params[:gone_postal]
if !@is_owning_user
@gone_postal = false
end
@@ -848,7 +848,7 @@ class RequestController < ApplicationController
# FOI officers can upload a response
def upload_response
- @locale = self.locale_from_params()
+ @locale = locale_from_params
I18n.with_locale(@locale) do
@info_request = InfoRequest.find_by_url_title!(params[:url_title])
@@ -914,7 +914,7 @@ class RequestController < ApplicationController
end
def download_entire_request
- @locale = self.locale_from_params()
+ @locale = locale_from_params
I18n.with_locale(@locale) do
@info_request = InfoRequest.find_by_url_title!(params[:url_title])
if authenticated?(
diff --git a/app/controllers/request_game_controller.rb b/app/controllers/request_game_controller.rb
index 7eadc1204..2915b5c2f 100644
--- a/app/controllers/request_game_controller.rb
+++ b/app/controllers/request_game_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# app/controllers/request_game_controller.rb:
# The 'categorise old requests' game
#
@@ -22,7 +23,7 @@ class RequestGameController < ApplicationController
:site_name => site_name)
end
- @league_table_28_days = RequestClassification.league_table(10, [ "created_at >= ?", Time.now() - 28.days ])
+ @league_table_28_days = RequestClassification.league_table(10, [ "created_at >= ?", Time.now - 28.days ])
@league_table_all_time = RequestClassification.league_table(10)
@play_urls = true
end
diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb
index 9b3a3396f..4d06072df 100644
--- a/app/controllers/services_controller.rb
+++ b/app/controllers/services_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# controllers/services_controller.rb:
require 'open-uri'
diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb
index 4b272797f..cbefb6291 100644
--- a/app/controllers/track_controller.rb
+++ b/app/controllers/track_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# app/controllers/track_controller.rb:
# Publically visible email alerts and RSS - think an alert system crossed with
# social bookmarking.
@@ -214,6 +215,4 @@ class TrackController < ApplicationController
redirect_to URI.parse(params[:r]).path
end
-
end
-
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index d66b4aa8e..bb4ba28d1 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# app/controllers/user_controller.rb:
# Show information about a user.
#
@@ -176,7 +177,7 @@ class UserController < ApplicationController
return
else
if !@post_redirect.nil?
- @user_signin = User.authenticate_from_form(params[:user_signin], @post_redirect.reason_params[:user_name] ? true : false)
+ @user_signin = User.authenticate_from_form(params[:user_signin], @post_redirect.reason_params[:user_name])
end
if @post_redirect.nil? || @user_signin.errors.size > 0
# Failed to authenticate
@@ -372,7 +373,7 @@ class UserController < ApplicationController
if (not session[:user_circumstance]) or (session[:user_circumstance] != "change_email")
# don't store the password in the db
params[:signchangeemail].delete(:password)
- post_redirect = PostRedirect.new(:uri => signchangeemail_url(),
+ post_redirect = PostRedirect.new(:uri => signchangeemail_url,
:post_params => params,
:circumstance => "change_email" # special login that lets you change your email
)
@@ -509,7 +510,7 @@ class UserController < ApplicationController
else
flash[:notice] = _("<p>Thanks for updating your profile photo.</p>
<p><strong>Next...</strong> You can put some text about you and your research on your profile.</p>")
- redirect_to set_profile_about_me_url()
+ redirect_to set_profile_about_me_url
end
else
render :template => 'user/set_draft_profile_photo'
@@ -595,7 +596,7 @@ class UserController < ApplicationController
else
flash[:notice] = _("<p>Thanks for changing the text about you on your profile.</p>
<p><strong>Next...</strong> You can upload a profile photograph too.</p>")
- redirect_to set_profile_photo_url()
+ redirect_to set_profile_photo_url
end
end
diff --git a/app/controllers/widgets_controller.rb b/app/controllers/widgets_controller.rb
new file mode 100644
index 000000000..333a38e86
--- /dev/null
+++ b/app/controllers/widgets_controller.rb
@@ -0,0 +1,64 @@
+# -*- encoding : utf-8 -*-
+# app/controllers/widget_controller.rb:
+# Handle widgets, if enabled
+#
+# Copyright (c) 2014 UK Citizens Online Democracy. All rights reserved.
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
+
+require 'securerandom'
+
+class WidgetsController < ApplicationController
+
+ before_filter :check_widget_config, :find_info_request, :check_prominence
+ skip_before_filter :set_x_frame_options_header, :only => [:show]
+
+ def show
+ medium_cache
+ @track_thing = TrackThing.create_track_for_request(@info_request)
+ @status = @info_request.calculate_status
+ @count = @info_request.track_things.count + @info_request.widget_votes.count + 1
+
+ if @user
+ @existing_track = TrackThing.find_existing(@user, @track_thing)
+ end
+ unless @user || cookies[:widget_vote]
+ cookies.permanent[:widget_vote] = SecureRandom.hex(10)
+ end
+ render :action => 'show', :layout => false
+ end
+
+ def new
+ long_cache
+ end
+
+ # Track interest in a request from a non-logged in user
+ def update
+ if !@user && cookies[:widget_vote]
+ @info_request.widget_votes.
+ where(:cookie => cookies[:widget_vote]).
+ first_or_create
+ end
+
+ track_thing = TrackThing.create_track_for_request(@info_request)
+ redirect_to do_track_path(track_thing), status => :temporary_redirect
+ end
+
+ private
+
+ def find_info_request
+ @info_request = InfoRequest.find(params[:request_id])
+ end
+
+ def check_widget_config
+ unless AlaveteliConfiguration::enable_widgets
+ raise ActiveRecord::RecordNotFound.new("Page not enabled")
+ end
+ end
+
+ def check_prominence
+ unless @info_request.prominence == 'normal'
+ render :nothing => true, :status => :forbidden
+ end
+ end
+
+end
diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb
index d13fea79b..9d63b1cad 100644
--- a/app/helpers/admin_helper.rb
+++ b/app/helpers/admin_helper.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
module AdminHelper
def icon(name)
content_tag(:i, "", :class => "icon-#{name}")
diff --git a/app/helpers/admin_public_body_category_helper.rb b/app/helpers/admin_public_body_category_helper.rb
index 9c5e5cc5e..2d8842562 100644
--- a/app/helpers/admin_public_body_category_helper.rb
+++ b/app/helpers/admin_public_body_category_helper.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
module AdminPublicBodyCategoryHelper
def heading_is_selected?(heading)
if params[:headings]
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 49ce94951..2f51f5684 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# app/helpers/application_helper.rb:
# Methods added to this helper will be available to all views (i.e. templates)
# in the application.
diff --git a/app/helpers/config_helper.rb b/app/helpers/config_helper.rb
index 026600ff1..9953c4fe0 100644
--- a/app/helpers/config_helper.rb
+++ b/app/helpers/config_helper.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
module ConfigHelper
def site_name
AlaveteliConfiguration::site_name
diff --git a/app/helpers/date_time_helper.rb b/app/helpers/date_time_helper.rb
index 5f129e590..09b5b2a76 100644
--- a/app/helpers/date_time_helper.rb
+++ b/app/helpers/date_time_helper.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
module DateTimeHelper
# Public: Usually-correct format for a DateTime-ish object
# To define a new new format define the `simple_date_{FORMAT}` method
diff --git a/app/helpers/health_checks_helper.rb b/app/helpers/health_checks_helper.rb
index f5769a9ba..b2f1f9de5 100644
--- a/app/helpers/health_checks_helper.rb
+++ b/app/helpers/health_checks_helper.rb
@@ -1,7 +1,8 @@
+# -*- encoding : utf-8 -*-
module HealthChecksHelper
def check_status(check)
- style = check.ok? ? {} : "color: red"
+ style = check.ok? ? '' : 'color: red'
content_tag(:b, check.message, :style => style)
end
diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb
index 44d6c6f5f..21eb39c0e 100755
--- a/app/helpers/link_to_helper.rb
+++ b/app/helpers/link_to_helper.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# app/helpers/link_to_helper.rb:
# This module is included into all controllers via controllers/application.rb
# -
diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb
index 3d4bbac71..573f7d8a8 100644
--- a/app/helpers/mailer_helper.rb
+++ b/app/helpers/mailer_helper.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
module MailerHelper
def contact_from_name_and_email
"#{AlaveteliConfiguration::contact_name} <#{AlaveteliConfiguration::contact_email}>"
diff --git a/app/helpers/public_body_helper.rb b/app/helpers/public_body_helper.rb
index 57c90a9ba..e094d98b4 100644
--- a/app/helpers/public_body_helper.rb
+++ b/app/helpers/public_body_helper.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
module PublicBodyHelper
# Public: The reasons a request can't be made to a PublicBody
@@ -40,8 +41,8 @@ module PublicBodyHelper
def type_of_authority(public_body)
first = true
types = public_body.tags.each.map do |tag|
- if PublicBodyCategory.get().by_tag().include?(tag.name)
- desc = PublicBodyCategory.get().singular_by_tag()[tag.name]
+ if PublicBodyCategory.get.by_tag.include?(tag.name)
+ desc = PublicBodyCategory.get.singular_by_tag[tag.name]
if first
desc = desc.sub(/\S/) { |m| Unicode.upcase(m) }
first = false
diff --git a/app/helpers/track_helper.rb b/app/helpers/track_helper.rb
index ca698926c..75ff784f3 100644
--- a/app/helpers/track_helper.rb
+++ b/app/helpers/track_helper.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
module TrackHelper
def already_subscribed_notice(track_thing)
diff --git a/app/helpers/widget_helper.rb b/app/helpers/widget_helper.rb
new file mode 100644
index 000000000..70353ea7c
--- /dev/null
+++ b/app/helpers/widget_helper.rb
@@ -0,0 +1,47 @@
+# -*- encoding : utf-8 -*-
+module WidgetHelper
+ def status_description(info_request, status)
+ case status
+ when 'waiting_classification'
+ _('Awaiting classification')
+ when 'waiting_response'
+ _('Awaiting response')
+ when 'waiting_response_overdue'
+ _('Delayed')
+ when 'waiting_response_very_overdue'
+ _('Long overdue')
+ when 'not_held'
+ _('Not held')
+ when 'rejected'
+ _('Rejected')
+ when 'successful'
+ _('Successful')
+ when 'partially_successful'
+ _('Partial success')
+ when 'waiting_clarification'
+ _('Awaiting clarification')
+ when 'gone_postal'
+ _('Handled by post')
+ when 'internal_review'
+ _('Internal review')
+ when 'error_message'
+ _('Delivery error')
+ when 'requires_admin'
+ _('Unusual response')
+ when 'user_withdrawn'
+ _('Withdrawn')
+ when 'attention_requested'
+ _('Needs admin attention')
+ when 'vexatious'
+ _('Vexatious')
+ when 'not_foi'
+ _('Not an FOI request')
+ else
+ if info_request.respond_to?(:theme_display_status)
+ info_request.theme_display_status(status)
+ else
+ _('Unknown')
+ end
+ end
+ end
+end
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
index d2230bb82..cfa5603fe 100644
--- a/app/mailers/application_mailer.rb
+++ b/app/mailers/application_mailer.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# models/application_mailer.rb:
# Shared code between different mailers.
#
diff --git a/app/mailers/contact_mailer.rb b/app/mailers/contact_mailer.rb
index 27e04ca4b..7c48bfd4b 100644
--- a/app/mailers/contact_mailer.rb
+++ b/app/mailers/contact_mailer.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# models/contact_mailer.rb:
# Sends contact form mails.
#
diff --git a/app/mailers/info_request_batch_mailer.rb b/app/mailers/info_request_batch_mailer.rb
index a2becfb24..ba853db95 100644
--- a/app/mailers/info_request_batch_mailer.rb
+++ b/app/mailers/info_request_batch_mailer.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# models/info_request_batch_mailer.rb:
# Emails relating to user accounts. e.g. Confirming a new account
#
diff --git a/app/mailers/outgoing_mailer.rb b/app/mailers/outgoing_mailer.rb
index 19054b4e2..78041d04b 100644
--- a/app/mailers/outgoing_mailer.rb
+++ b/app/mailers/outgoing_mailer.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# models/outgoing_mailer.rb:
# Emails which go to public bodies on behalf of users.
#
@@ -40,7 +41,7 @@ class OutgoingMailer < ApplicationMailer
# TODO: also OutgoingMessage.get_salutation
# TODO: these look like they should be members of IncomingMessage, but logically they
# need to work even when IncomingMessage is nil
- def OutgoingMailer.name_and_email_for_followup(info_request, incoming_message_followup)
+ def self.name_and_email_for_followup(info_request, incoming_message_followup)
if incoming_message_followup.nil? || !incoming_message_followup.valid_to_reply_to?
return info_request.recipient_name_and_email
else
@@ -50,7 +51,7 @@ class OutgoingMailer < ApplicationMailer
end
end
# Used in the preview of followup
- def OutgoingMailer.name_for_followup(info_request, incoming_message_followup)
+ def self.name_for_followup(info_request, incoming_message_followup)
if incoming_message_followup.nil? || !incoming_message_followup.valid_to_reply_to?
return info_request.public_body.name
else
@@ -59,7 +60,7 @@ class OutgoingMailer < ApplicationMailer
end
end
# Used when making list of followup places to remove duplicates
- def OutgoingMailer.email_for_followup(info_request, incoming_message_followup)
+ def self.email_for_followup(info_request, incoming_message_followup)
if incoming_message_followup.nil? || !incoming_message_followup.valid_to_reply_to?
return info_request.recipient_email
else
@@ -67,7 +68,7 @@ class OutgoingMailer < ApplicationMailer
end
end
# Subject to use for followup
- def OutgoingMailer.subject_for_followup(info_request, outgoing_message, options = {})
+ def self.subject_for_followup(info_request, outgoing_message, options = {})
if outgoing_message.what_doing == 'internal_review'
return "Internal review of " + info_request.email_subject_request(:html => options[:html])
else
@@ -76,7 +77,7 @@ class OutgoingMailer < ApplicationMailer
end
end
# Whether we have a valid email address for a followup
- def OutgoingMailer.is_followupable?(info_request, incoming_message_followup)
+ def self.is_followupable?(info_request, incoming_message_followup)
if incoming_message_followup.nil? || !incoming_message_followup.valid_to_reply_to?
return info_request.recipient_email_valid_for_followup?
else
@@ -85,7 +86,7 @@ class OutgoingMailer < ApplicationMailer
end
end
# Message-ID to use
- def OutgoingMailer.id_for_message(outgoing_message)
+ def self.id_for_message(outgoing_message)
message_id = "ogm-" + outgoing_message.id.to_s
t = Time.now
message_id += "+" + '%08x%05x-%04x' % [t.to_i, t.tv_usec, rand(0xffff)]
diff --git a/app/mailers/request_mailer.rb b/app/mailers/request_mailer.rb
index 252df861c..f12b4a0d6 100644
--- a/app/mailers/request_mailer.rb
+++ b/app/mailers/request_mailer.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# models/request_mailer.rb:
# Alerts relating to requests.
#
@@ -64,7 +65,7 @@ class RequestMailer < ApplicationMailer
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).html_safe)
+ :subject => _("FOI response requires admin ({{reason}}) - {{title}}", :reason => info_request.described_state, :title => info_request.title.html_safe))
end
# Tell the requester that a new response has arrived
@@ -80,7 +81,7 @@ class RequestMailer < ApplicationMailer
mail(:from => contact_from_name_and_email,
:to => info_request.user.name_and_email,
- :subject => (_("New response to your FOI request - ") + info_request.title).html_safe,
+ :subject => _("New response to your FOI request - ") + info_request.title.html_safe,
:charset => "UTF-8",
# not much we can do if the user's email is broken
:reply_to => contact_from_name_and_email)
@@ -99,13 +100,8 @@ class RequestMailer < ApplicationMailer
@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')
-
- mail(:from => contact_from_name_and_email,
- :to => user.name_and_email,
- :subject => (_("Delayed response to your FOI request - ") + info_request.title).html_safe)
+ auto_generated_headers
+ mail_user_with_info_request_title(user, _("Delayed response to your FOI request - "), info_request)
end
# Tell the requester that the public body is very late in replying
@@ -119,13 +115,8 @@ class RequestMailer < ApplicationMailer
@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')
-
- 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)
+ auto_generated_headers
+ mail_user_with_info_request_title(user, _("You're long overdue a response to your FOI request - "), info_request)
end
# Tell the requester that they need to say if the new response
@@ -141,13 +132,8 @@ class RequestMailer < ApplicationMailer
@incoming_message = incoming_message
@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')
-
- 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?"))
+ auto_generated_headers
+ mail_user(info_request.user, _("Was the response you got to your FOI request any good?"))
end
# Tell the requester that someone updated their old unclassified request
@@ -155,13 +141,8 @@ class RequestMailer < ApplicationMailer
@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')
-
- mail(:from => contact_from_name_and_email,
- :to => info_request.user.name_and_email,
- :subject => _("Someone has updated the status of your request"))
+ auto_generated_headers
+ mail_user(info_request.user, _("Someone has updated the status of your request"))
end
# Tell the requester that they need to clarify their request
@@ -177,13 +158,8 @@ class RequestMailer < ApplicationMailer
@incoming_message = incoming_message
@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')
-
- mail(:from => contact_from_name_and_email,
- :to => info_request.user.name_and_email,
- :subject => (_("Clarify your FOI request - ") + info_request.title).html_safe)
+ auto_generated_headers
+ mail_user_with_info_request_title(info_request.user, _("Clarify your FOI request - "), info_request)
end
# Tell requester that somebody add an annotation to their request
@@ -191,25 +167,15 @@ class RequestMailer < ApplicationMailer
@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')
-
- 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)
+ auto_generated_headers
+ mail_user_with_info_request_title(info_request.user, _("Somebody added a note to your FOI request - "), info_request)
end
def comment_on_alert_plural(info_request, count, earliest_unalerted_comment)
@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')
-
- 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)
+ auto_generated_headers
+ mail_user_with_info_request_title(info_request.user, _("Some notes have been added to your FOI request - "), info_request)
end
# Class function, called by script/mailin with all incoming responses.
@@ -268,7 +234,7 @@ class RequestMailer < ApplicationMailer
end
# Send email alerts for overdue requests
- def self.alert_overdue_requests()
+ def self.alert_overdue_requests
info_requests = InfoRequest.find(:all,
:conditions => [
"described_state = 'waiting_response'
@@ -372,8 +338,8 @@ class RequestMailer < ApplicationMailer
# Send email alerts for requests which need clarification. Goes out 3 days
# after last update of event.
- def self.alert_not_clarified_request()
- info_requests = InfoRequest.find(:all, :conditions => [ "awaiting_description = ? and described_state = 'waiting_clarification' and info_requests.updated_at < ?", false, Time.now() - 3.days ], :include => [ :user ], :order => "info_requests.id" )
+ def self.alert_not_clarified_request
+ info_requests = InfoRequest.find(:all, :conditions => [ "awaiting_description = ? and described_state = 'waiting_clarification' and info_requests.updated_at < ?", false, Time.now - 3.days ], :include => [ :user ], :order => "info_requests.id" )
for info_request in info_requests
alert_event_id = info_request.get_last_public_response_event_id
last_response_message = info_request.get_last_public_response
@@ -400,7 +366,7 @@ class RequestMailer < ApplicationMailer
end
# Send email alert to request submitter for new comments on the request.
- def self.alert_comment_on_request()
+ def self.alert_comment_on_request
# We only check comments made in the last month - this means if the
# cron jobs broke for more than a month events would be lost, but no
@@ -467,7 +433,27 @@ class RequestMailer < ApplicationMailer
end
end
+ private
-end
+ def auto_generated_headers
+ 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',
+ })
+ end
+ def mail_user_with_info_request_title(user, subject, info_request)
+ mail_user(user, subject + info_request.title.html_safe)
+ end
+
+ def mail_user(user, subject)
+ mail({
+ :from => contact_from_name_and_email,
+ :to => user.name_and_email,
+ :subject => subject,
+ })
+ end
+end
diff --git a/app/mailers/track_mailer.rb b/app/mailers/track_mailer.rb
index 8e9beded6..3f5de6a1b 100644
--- a/app/mailers/track_mailer.rb
+++ b/app/mailers/track_mailer.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# models/track_mailer.rb:
# Emails which go to users who are tracking things.
#
@@ -38,7 +39,7 @@ class TrackMailer < ApplicationMailer
# User.find(:all, :conditions => [ "last_daily_track_email < ?", Time.now - 1.day ]).size
def self.alert_tracks
done_something = false
- now = Time.now()
+ now = Time.now
one_week_ago = now - 7.days
User.find_each(:conditions => [ "last_daily_track_email < ?",
now - 1.day ]) do |user|
diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb
index a351147f9..a6fed693e 100644
--- a/app/mailers/user_mailer.rb
+++ b/app/mailers/user_mailer.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# models/user_mailer.rb:
# Emails relating to user accounts. e.g. Confirming a new account
#
diff --git a/app/models/about_me_validator.rb b/app/models/about_me_validator.rb
index 8c24cfd67..8465b0716 100644
--- a/app/models/about_me_validator.rb
+++ b/app/models/about_me_validator.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# models/about_me_validator.rb:
# Validates editing about me text on user profile pages.
#
@@ -9,20 +10,11 @@ class AboutMeValidator
attr_accessor :about_me
- # TODO: Switch to built in validations
- validate :length_of_about_me
+ validates_length_of :about_me, :maximum => 500, :message => _("Please keep it shorter than 500 characters")
def initialize(attributes = {})
attributes.each do |name, value|
send("#{name}=", value)
end
end
-
- private
-
- def length_of_about_me
- if !about_me.blank? && about_me.size > 500
- errors.add(:about_me, _("Please keep it shorter than 500 characters"))
- end
- end
end
diff --git a/app/models/censor_rule.rb b/app/models/censor_rule.rb
index 3b5c2d805..f1f1a0d70 100644
--- a/app/models/censor_rule.rb
+++ b/app/models/censor_rule.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: censor_rules
@@ -22,6 +23,7 @@
# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class CensorRule < ActiveRecord::Base
+ include AdminColumn
belongs_to :info_request
belongs_to :user
belongs_to :public_body
@@ -42,6 +44,11 @@ class CensorRule < ActiveRecord::Base
:user_id => nil,
:public_body_id => nil } }
+ def apply_to_text(text_to_censor)
+ return nil if text_to_censor.nil?
+ text_to_censor.gsub(to_replace, replacement)
+ end
+
def apply_to_text!(text_to_censor)
return nil if text_to_censor.nil?
text_to_censor.gsub!(to_replace, replacement)
@@ -52,12 +59,6 @@ class CensorRule < ActiveRecord::Base
binary_to_censor.gsub!(to_replace) { |match| match.gsub(/./, 'x') }
end
- def for_admin_column
- self.class.content_columns.each do |column|
- yield(column.human_name, send(column.name), column.type.to_s, column.name)
- end
- end
-
def is_global?
info_request_id.nil? && user_id.nil? && public_body_id.nil?
end
diff --git a/app/models/change_email_validator.rb b/app/models/change_email_validator.rb
index 65f2fd81c..f5b31f038 100644
--- a/app/models/change_email_validator.rb
+++ b/app/models/change_email_validator.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# models/changeemail_validator.rb:
# Validates email change form submissions.
#
diff --git a/app/models/comment.rb b/app/models/comment.rb
index cc8d0e94b..59f91ffb7 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: comments
@@ -20,6 +21,7 @@
# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class Comment < ActiveRecord::Base
+ include AdminColumn
strip_attributes!
belongs_to :user
@@ -31,6 +33,8 @@ class Comment < ActiveRecord::Base
validate :check_body_has_content,
:check_body_uses_mixed_capitals
+ scope :visible, where(:visible => true)
+
after_save :event_xapian_update
# When posting a new comment, use this to check user hasn't double
@@ -57,10 +61,6 @@ class Comment < ActiveRecord::Base
ret
end
- def raw_body
- read_attribute(:body)
- end
-
# So when takes changes it updates, or when made invisble it vanishes
def event_xapian_update
info_request_events.each { |event| event.xapian_mark_needs_index }
@@ -75,12 +75,6 @@ class Comment < ActiveRecord::Base
text.html_safe
end
- def for_admin_column
- self.class.content_columns.each do |column|
- yield(column.human_name, send(column.name), column.type.to_s, column.name)
- end
- end
-
private
def check_body_has_content
diff --git a/app/models/concerns/admin_column.rb b/app/models/concerns/admin_column.rb
new file mode 100644
index 000000000..6e19f5aa5
--- /dev/null
+++ b/app/models/concerns/admin_column.rb
@@ -0,0 +1,17 @@
+module AdminColumn
+ extend ActiveSupport::Concern
+
+ included do
+ class << self
+ attr_reader :non_admin_columns
+ end
+
+ @non_admin_columns = []
+ end
+
+ def for_admin_column
+ self.class.content_columns.reject { |c| self.class.non_admin_columns.include?(c.name) }.each do |column|
+ yield(column.human_name, send(column.name), column.type.to_s, column.name)
+ end
+ end
+end
diff --git a/app/models/concerns/translatable.rb b/app/models/concerns/translatable.rb
new file mode 100644
index 000000000..bc89e4c3b
--- /dev/null
+++ b/app/models/concerns/translatable.rb
@@ -0,0 +1,43 @@
+module Translatable
+ extend ActiveSupport::Concern
+
+ included do
+ accepts_nested_attributes_for :translations, :reject_if => :empty_translation_in_params?
+ end
+
+ def find_translation_by_locale(locale)
+ translations.find_by_locale(locale)
+ end
+
+ def translated_versions
+ translations
+ end
+
+ def ordered_translations
+ translations.select do |translation|
+ I18n.available_locales.include?(translation.locale)
+ end.sort_by do |translation|
+ I18n.available_locales.index(translation.locale)
+ end
+ end
+
+ def build_all_translations
+ I18n.available_locales.each do |locale|
+ if translations.none? { |translation| translation.locale == locale }
+ translations.build(:locale => locale)
+ end
+ end
+ end
+
+ def translated_versions=(translation_attrs)
+ warn "[DEPRECATION] #{self.class.name}#translated_versions= will be replaced " \
+ "by #{self.class.name}#translations_attributes= as of release 0.22"
+ self.translations_attributes = translation_attrs
+ end
+
+ private
+
+ def empty_translation_in_params?(attributes)
+ attributes.select { |k, v| v.present? && k.to_s != 'locale' }.empty?
+ end
+end
diff --git a/app/models/contact_validator.rb b/app/models/contact_validator.rb
index 8d7e4ff08..1d50bf603 100644
--- a/app/models/contact_validator.rb
+++ b/app/models/contact_validator.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# models/contact_validator.rb:
# Validates contact form submissions.
#
diff --git a/app/models/foi_attachment.rb b/app/models/foi_attachment.rb
index a8d105f52..0af47b26e 100644
--- a/app/models/foi_attachment.rb
+++ b/app/models/foi_attachment.rb
@@ -1,4 +1,4 @@
-# encoding: UTF-8
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: foi_attachments
@@ -244,36 +244,32 @@ class FoiAttachment < ActiveRecord::Base
# The full list of supported types can be found at
# https://docs.google.com/support/bin/answer.py?hl=en&answer=1189935
def has_google_docs_viewer?
- return !! {
- "application/pdf" => true, # .pdf
- "image/tiff" => true, # .tiff
+ [
+ "application/pdf", # .pdf
+ "image/tiff", # .tiff
- "application/vnd.ms-word" => true, # .doc
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document" => true, # .docx
+ "application/vnd.ms-word", # .doc
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document", # .docx
- "application/vnd.ms-powerpoint" => true, # .ppt
- "application/vnd.openxmlformats-officedocument.presentationml.presentation" => true, # .pptx
+ "application/vnd.ms-powerpoint", # .ppt
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation", # .pptx
- "application/vnd.ms-excel" => true, # .xls
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" => true, # .xlsx
-
- } [self.content_type]
+ "application/vnd.ms-excel", # .xls
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", # .xlsx
+ ].include?(content_type)
end
# Whether this type has a "View as HTML"
def has_body_as_html?
- return (
- !!{
- "text/plain" => true,
- "application/rtf" => true,
- }[self.content_type] or
- self.has_google_docs_viewer?
- )
+ [
+ "text/plain",
+ "application/rtf",
+ ].include?(content_type) || has_google_docs_viewer?
end
# Name of type of attachment type - only valid for things that has_body_as_html?
def name_of_content_type
- return {
+ {
"text/plain" => "Text file",
'application/rtf' => "RTF file",
diff --git a/app/models/holiday.rb b/app/models/holiday.rb
index 34044683a..538e77051 100644
--- a/app/models/holiday.rb
+++ b/app/models/holiday.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: holidays
diff --git a/app/models/holiday_import.rb b/app/models/holiday_import.rb
index 98a9b96fc..58ea0b1f7 100644
--- a/app/models/holiday_import.rb
+++ b/app/models/holiday_import.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
class HolidayImport
include ActiveModel::Validations
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 4feee7637..dff516f0e 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -1,4 +1,4 @@
-# coding: utf-8
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: incoming_messages
@@ -38,6 +38,7 @@ require 'zip/zip'
require 'iconv' unless String.method_defined?(:encode)
class IncomingMessage < ActiveRecord::Base
+ include AdminColumn
extend MessageProminence
belongs_to :info_request
validates_presence_of :info_request
@@ -725,7 +726,7 @@ class IncomingMessage < ActiveRecord::Base
end
# Search all info requests for
- def IncomingMessage.find_all_unknown_mime_types
+ def self.find_all_unknown_mime_types
for incoming_message in IncomingMessage.find(:all)
for attachment in incoming_message.get_attachments_for_display
raise "internal error incoming_message " + incoming_message.id.to_s if attachment.content_type.nil?
@@ -751,16 +752,9 @@ class IncomingMessage < ActiveRecord::Base
return ret.keys.join(" ")
end
# Return space separated list of all file extensions known
- def IncomingMessage.get_all_file_extensions
+ def self.get_all_file_extensions
return AlaveteliFileTypes.all_extensions.join(" ")
end
-
- def for_admin_column
- self.class.content_columns.each do |column|
- yield(column.human_name, self.send(column.name), column.type.to_s, column.name)
- end
- end
-
end
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index c203f75c3..3ce0e3cd2 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -1,4 +1,4 @@
-# encoding: utf-8
+# -*- encoding : utf-8 -*-
# == Schema Information
# Schema version: 20131024114346
#
@@ -28,8 +28,11 @@
require 'digest/sha1'
class InfoRequest < ActiveRecord::Base
+ include AdminColumn
include Rails.application.routes.url_helpers
+ @non_admin_columns = %w(title url_title)
+
strip_attributes!
validates_presence_of :title, :message => N_("Please enter a summary of your request")
@@ -50,6 +53,7 @@ class InfoRequest < ActiveRecord::Base
has_many :info_request_events, :order => 'created_at'
has_many :user_info_request_sent_alerts
has_many :track_things, :order => 'created_at desc'
+ has_many :widget_votes
has_many :comments, :order => 'created_at'
has_many :censor_rules, :order => 'created_at desc'
has_many :mail_server_logs, :order => 'mail_server_log_done_id'
@@ -193,23 +197,12 @@ class InfoRequest < ActiveRecord::Base
rescue MissingSourceFile, NameError
end
- # only check on create, so existing models with mixed case are allowed
- def validate_on_create
- 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
-
OLD_AGE_IN_DAYS = 21.days
def visible_comments
- self.comments.find(:all, :conditions => 'visible')
+ warn %q([DEPRECATION] InfoRequest#visible_comments will be replaced with
+ InfoRequest#comments.visible as of 0.23).squish
+ comments.visible
end
# If the URL name has changed, then all request: queries will break unless
@@ -345,7 +338,7 @@ public
# only they are sent the email address with the has in it. (We don't check
# the prefix and domain, as sometimes those change, or might be elided by
# copying an email, and that doesn't matter)
- def InfoRequest.find_by_incoming_email(incoming_email)
+ def self.find_by_incoming_email(incoming_email)
id, hash = InfoRequest._extract_id_hash_from_email(incoming_email)
if hash_from_id(id) == hash
# Not using find(id) because we don't exception raised if nothing found
@@ -355,7 +348,7 @@ public
# Return list of info requests which *might* be right given email address
# e.g. For the id-hash email addresses, don't match the hash.
- def InfoRequest.guess_by_incoming_email(incoming_message)
+ def self.guess_by_incoming_email(incoming_message)
guesses = []
# 1. Try to guess based on the email address(es)
incoming_message.addresses.each do |address|
@@ -367,7 +360,7 @@ public
end
# Internal function used by find_by_magic_email and guess_by_incoming_email
- def InfoRequest._extract_id_hash_from_email(incoming_email)
+ def self._extract_id_hash_from_email(incoming_email)
# Match case insensitively, FOI officers often write Request with capital R.
incoming_email = incoming_email.downcase
@@ -394,7 +387,7 @@ public
# repeated requests, say once a quarter for time information, then might need to do that.
# TODO: this *should* also check outgoing message joined to is an initial
# request (rather than follow up)
- def InfoRequest.find_existing(title, public_body_id, body)
+ def self.find_existing(title, public_body_id, body)
return InfoRequest.find(:first, :conditions => [ "title = ? and public_body_id = ? and outgoing_messages.body = ?", title, public_body_id, body ], :include => [ :outgoing_messages ] )
end
@@ -534,7 +527,7 @@ public
# The "holding pen" is a special request which stores incoming emails whose
# destination request is unknown.
- def InfoRequest.holding_pen_request
+ def self.holding_pen_request
ir = InfoRequest.find_by_url_title("holding_pen")
if ir.nil?
ir = InfoRequest.new(
@@ -549,7 +542,7 @@ public
:status => 'ready',
:message_type => 'initial_request',
:body => 'This is the holding pen request. It shows responses that were sent to invalid addresses, and need moving to the correct request by an adminstrator.',
- :last_sent_at => Time.now(),
+ :last_sent_at => Time.now,
:what_doing => 'normal_sort'
})
@@ -564,7 +557,7 @@ public
# states which require administrator action (hence email administrators
# when they are entered, and offer state change dialog to them)
- def InfoRequest.requires_admin_states
+ def self.requires_admin_states
return ['requires_admin', 'error_message', 'attention_requested']
end
@@ -665,11 +658,11 @@ public
if !curr_state.nil? && event.event_type == 'response'
if event.calculated_state != curr_state
event.calculated_state = curr_state
- event.last_described_at = Time.now()
+ event.last_described_at = Time.now
event.save!
end
if event.last_described_at.nil? # TODO: actually maybe this isn't needed
- event.last_described_at = Time.now()
+ event.last_described_at = Time.now
event.save!
end
curr_state = nil
@@ -681,7 +674,7 @@ public
# indexed.
if event.calculated_state != event.described_state
event.calculated_state = event.described_state
- event.last_described_at = Time.now()
+ event.last_described_at = Time.now
event.save!
end
@@ -698,7 +691,7 @@ public
# case there is a preceding response that the described state should be applied to.
if event.calculated_state != event.described_state
event.calculated_state = event.described_state
- event.last_described_at = Time.now()
+ event.last_described_at = Time.now
event.save!
end
end
@@ -783,7 +776,14 @@ public
end
def public_response_events
- self.info_request_events.select{|e| e.response? && e.incoming_message.all_can_view? }
+ condition = <<-SQL
+ info_request_events.event_type = ?
+ AND incoming_messages.prominence = ?
+ SQL
+
+ info_request_events.
+ joins(:incoming_message).
+ where(condition, 'response', 'normal')
end
# The last public response is the default one people might want to reply to
@@ -810,8 +810,9 @@ public
# Text from the the initial request, for use in summary display
def initial_request_text
- return '' if outgoing_messages.empty? # mainly for use with incomplete fixtures
- outgoing_messages.first.get_text_for_indexing
+ return '' if outgoing_messages.empty?
+ body_opts = { :censor_rules => applicable_censor_rules }
+ outgoing_messages.first.try(:get_text_for_indexing, true, body_opts) or ''
end
# Returns index of last event which is described or nil if none described.
@@ -873,7 +874,7 @@ public
# Display version of status
- def InfoRequest.get_status_description(status)
+ def self.get_status_description(status)
descriptions = {
'waiting_classification' => _("Awaiting classification."),
'waiting_response' => _("Awaiting response."),
@@ -908,21 +909,24 @@ public
# Completely delete this request and all objects depending on it
def fully_destroy
- self.track_things.each do |track_thing|
+ track_things.each do |track_thing|
track_thing.track_things_sent_emails.each { |a| a.destroy }
track_thing.destroy
end
- self.user_info_request_sent_alerts.each { |a| a.destroy }
- self.info_request_events.each do |info_request_event|
+ user_info_request_sent_alerts.each { |a| a.destroy }
+ info_request_events.each do |info_request_event|
info_request_event.track_things_sent_emails.each { |a| a.destroy }
info_request_event.destroy
end
- self.mail_server_logs.each do |mail_server_log|
+ mail_server_logs.each do |mail_server_log|
mail_server_log.destroy
end
- self.outgoing_messages.each { |a| a.destroy }
- self.incoming_messages.each { |a| a.destroy }
- self.destroy
+ outgoing_messages.each { |a| a.destroy }
+ incoming_messages.each { |a| a.destroy }
+ comments.each { |comment| comment.destroy }
+ censor_rules.each{ |censor_rule| censor_rule.destroy }
+
+ destroy
end
# Called by incoming_email - and used to be called to generate separate
@@ -932,7 +936,7 @@ public
return InfoRequest.magic_email_for_id(prefix_part, self.id)
end
- def InfoRequest.magic_email_for_id(prefix_part, id)
+ def self.magic_email_for_id(prefix_part, id)
magic_email = AlaveteliConfiguration::incoming_email_prefix
magic_email += prefix_part + id.to_s
magic_email += "-" + InfoRequest.hash_from_id(id)
@@ -946,7 +950,7 @@ public
self.idhash = InfoRequest.hash_from_id(self.id)
end
- def InfoRequest.create_from_attributes(info_request_atts, outgoing_message_atts, user=nil)
+ def self.create_from_attributes(info_request_atts, outgoing_message_atts, user=nil)
info_request = new(info_request_atts)
default_message_params = {
:status => 'ready',
@@ -960,12 +964,12 @@ public
info_request
end
- def InfoRequest.hash_from_id(id)
+ def self.hash_from_id(id)
return Digest::SHA1.hexdigest(id.to_s + AlaveteliConfiguration::incoming_email_secret)[0,8]
end
# Used to find when event last changed
- def InfoRequest.last_event_time_clause(event_type=nil, join_table=nil, join_clause=nil)
+ def self.last_event_time_clause(event_type=nil, join_table=nil, join_clause=nil)
event_type_clause = ''
event_type_clause = " AND info_request_events.event_type = '#{event_type}'" if event_type
tables = ['info_request_events']
@@ -980,20 +984,20 @@ public
LIMIT 1)"
end
- def InfoRequest.last_public_response_clause()
+ def self.last_public_response_clause
join_clause = "incoming_messages.id = info_request_events.incoming_message_id
AND incoming_messages.prominence = 'normal'"
last_event_time_clause('response', 'incoming_messages', join_clause)
end
- def InfoRequest.old_unclassified_params(extra_params, include_last_response_time=false)
- last_response_created_at = last_public_response_clause()
+ def self.old_unclassified_params(extra_params, include_last_response_time=false)
+ last_response_created_at = last_public_response_clause
age = extra_params[:age_in_days] ? extra_params[:age_in_days].days : OLD_AGE_IN_DAYS
params = { :conditions => ["awaiting_description = ?
AND #{last_response_created_at} < ?
AND url_title != 'holding_pen'
AND user_id IS NOT NULL",
- true, Time.now() - age] }
+ true, Time.now - age] }
if include_last_response_time
params[:select] = "*, #{last_response_created_at} AS last_response_time"
params[:order] = 'last_response_time'
@@ -1001,29 +1005,21 @@ public
return params
end
- def InfoRequest.count_old_unclassified(extra_params={})
+ def self.count_old_unclassified(extra_params={})
params = old_unclassified_params(extra_params)
- if extra_params[:conditions]
- condition_string = extra_params[:conditions].shift
- params[:conditions][0] += " AND #{condition_string}"
- params[:conditions] += extra_params[:conditions]
- end
+ add_conditions_from_extra_params(params, extra_params)
count(:all, params)
end
- def InfoRequest.get_random_old_unclassified(limit, extra_params)
+ def self.get_random_old_unclassified(limit, extra_params)
params = old_unclassified_params({})
- if extra_params[:conditions]
- condition_string = extra_params[:conditions].shift
- params[:conditions][0] += " AND #{condition_string}"
- params[:conditions] += extra_params[:conditions]
- end
+ add_conditions_from_extra_params(params, extra_params)
params[:limit] = limit
params[:order] = "random()"
find(:all, params)
end
- def InfoRequest.find_old_unclassified(extra_params={})
+ def self.find_old_unclassified(extra_params={})
params = old_unclassified_params(extra_params, include_last_response_time=true)
[:limit, :include, :offset].each do |extra|
params[extra] = extra_params[extra] if extra_params[extra]
@@ -1032,15 +1028,11 @@ public
params[:order] = extra_params[:order]
params.delete(:select)
end
- if extra_params[:conditions]
- condition_string = extra_params[:conditions].shift
- params[:conditions][0] += " AND #{condition_string}"
- params[:conditions] += extra_params[:conditions]
- end
+ add_conditions_from_extra_params(params, extra_params)
find(:all, params)
end
- def InfoRequest.download_zip_dir()
+ def self.download_zip_dir
File.join(Rails.root, "cache", "zips", "#{Rails.env}")
end
@@ -1058,7 +1050,7 @@ public
end
def request_dirs
- first_three_digits = id.to_s()[0..2]
+ first_three_digits = id.to_s[0..2]
File.join(first_three_digits.to_s, id.to_s)
end
@@ -1067,7 +1059,7 @@ public
end
def make_zip_cache_path(user)
- cache_file_dir = File.join(InfoRequest.download_zip_dir(),
+ cache_file_dir = File.join(InfoRequest.download_zip_dir,
"download",
request_dirs,
last_update_hash)
@@ -1191,7 +1183,7 @@ public
end
# This is called from cron regularly.
- def InfoRequest.stop_new_responses_on_old_requests
+ def self.stop_new_responses_on_old_requests
# 6 months since last change to request, only allow new incoming messages from authority domains
InfoRequest.update_all "allow_new_responses_from = 'authority_only' where updated_at < (now() - interval '6 months') and allow_new_responses_from = 'anybody' and url_title <> 'holding_pen'"
# 1 year since last change requests, don't allow any new incoming messages
@@ -1240,7 +1232,7 @@ public
:model => self.class.base_class.to_s,
:model_id => self.id)
end
- req.save()
+ req.save
end
end
@@ -1270,13 +1262,6 @@ public
PublicBody.set_callback(:save, :after, :purge_in_cache)
end
- def for_admin_column
- self.class.content_columns.map{|c| c unless %w(title url_title).include?(c.name) }.compact.each do |column|
- yield(column.human_name, self.send(column.name), column.type.to_s, column.name)
- end
- end
-
-
# Get requests that have similar important terms
def similar_requests(limit=10)
xapian_similar = nil
@@ -1292,7 +1277,7 @@ public
return [xapian_similar, xapian_similar_more]
end
- def InfoRequest.request_list(filters, page, per_page, max_results)
+ def self.request_list(filters, page, per_page, max_results)
xapian_object = ActsAsXapian::Search.new([InfoRequestEvent],
InfoRequestEvent.make_query_from_params(filters),
:offset => (page - 1) * per_page,
@@ -1309,7 +1294,7 @@ public
:show_no_more_than => show_no_more_than }
end
- def InfoRequest.recent_requests
+ def self.recent_requests
request_events = []
request_events_all_successful = false
# Get some successful requests
@@ -1356,12 +1341,45 @@ public
return [request_events, request_events_all_successful]
end
- def InfoRequest.find_in_state(state)
+ def self.find_in_state(state)
select("*, #{ last_event_time_clause } as last_event_time").
where(:described_state => state).
order('last_event_time')
end
+ def move_to_public_body(destination_public_body, opts = {})
+ old_body = public_body
+ editor = opts.fetch(:editor)
+
+ attrs = { :public_body => destination_public_body }
+
+ if destination_public_body
+ attrs.merge!({
+ :law_used => destination_public_body.law_only_short.downcase
+ })
+ end
+
+ if update_attributes(attrs)
+ log_event('move_request',
+ :editor => editor,
+ :public_body_url_name => public_body.url_name,
+ :old_public_body_url_name => old_body.url_name)
+
+ reindex_request_events
+
+ public_body
+ end
+ end
+
+ # The DateTime of the last InfoRequestEvent belonging to the InfoRequest
+ # Only available if the last_event_time attribute has been set. This is
+ # currentlt only set through .find_in_state
+ #
+ # Returns a DateTime
+ def last_event_time
+ attributes['last_event_time'].try(:to_datetime)
+ end
+
private
def set_defaults
@@ -1370,11 +1388,12 @@ public
self.described_state = 'waiting_response'
end
rescue ActiveModel::MissingAttributeError
- # this should only happen on Model.exists?() call. It can be safely ignored.
+ # 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?
+ if new_record? && public_body && public_body.eir_only?
self.law_used = 'eir'
end
end
@@ -1390,5 +1409,13 @@ public
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
+
+ def self.add_conditions_from_extra_params(params, extra_params)
+ if extra_params[:conditions]
+ condition_string = extra_params[:conditions].shift
+ params[:conditions][0] += " AND #{condition_string}"
+ params[:conditions] += extra_params[:conditions]
+ end
+ end
end
diff --git a/app/models/info_request_batch.rb b/app/models/info_request_batch.rb
index 8a5ebeaba..684467c61 100644
--- a/app/models/info_request_batch.rb
+++ b/app/models/info_request_batch.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: info_request_batches
@@ -21,7 +22,7 @@ class InfoRequestBatch < ActiveRecord::Base
validates_presence_of :body
# When constructing a new batch, use this to check user hasn't double submitted.
- def InfoRequestBatch.find_existing(user, title, body, public_body_ids)
+ def self.find_existing(user, title, body, public_body_ids)
find(:first, :conditions => ['user_id = ?
AND title = ?
AND body = ?
@@ -69,7 +70,7 @@ class InfoRequestBatch < ActiveRecord::Base
info_request
end
- def InfoRequestBatch.send_batches()
+ def self.send_batches
find_each(:conditions => "sent_at IS NULL") do |info_request_batch|
unrequestable = info_request_batch.create_batch!
mail_message = InfoRequestBatchMailer.batch_sent(info_request_batch,
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb
index 635ba8f58..29c1ce965 100644
--- a/app/models/info_request_event.rb
+++ b/app/models/info_request_event.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: info_request_events
@@ -21,7 +22,7 @@
# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class InfoRequestEvent < ActiveRecord::Base
-
+ include AdminColumn
extend XapianQueries
belongs_to :info_request
@@ -278,9 +279,15 @@ class InfoRequestEvent < ActiveRecord::Base
end
self.params_yaml = params.to_yaml
end
+
def params
- YAML.load(self.params_yaml)
+ param_hash = YAML.load(params_yaml)
+ param_hash.each do |key, value|
+ param_hash[key] = value.force_encoding('UTF-8') if value.respond_to?(:force_encoding)
+ end
+ param_hash
end
+
def params_yaml_as_html
ret = ''
# split out parameters into old/new diffs, and other ones
@@ -319,9 +326,17 @@ class InfoRequestEvent < ActiveRecord::Base
end
- def is_incoming_message?() not self.incoming_message_selective_columns("incoming_messages.id").nil? end
- def is_outgoing_message?() not self.outgoing_message.nil? end
- def is_comment?() not self.comment.nil? end
+ def is_incoming_message?
+ !self.incoming_message_selective_columns("incoming_messages.id").nil?
+ end
+
+ def is_outgoing_message?
+ !self.outgoing_message.nil?
+ end
+
+ def is_comment?
+ !self.comment.nil?
+ end
# Display version of status
def display_status
@@ -412,11 +427,4 @@ class InfoRequestEvent < ActiveRecord::Base
return ret
end
-
- def for_admin_column
- self.class.content_columns.each do |column|
- yield(column.human_name, self.send(column.name), column.type.to_s, column.name)
- end
- end
-
end
diff --git a/app/models/mail_server_log.rb b/app/models/mail_server_log.rb
index 07d2fdac0..64a740e1d 100644
--- a/app/models/mail_server_log.rb
+++ b/app/models/mail_server_log.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: mail_server_logs
@@ -25,7 +26,7 @@ class MailServerLog < ActiveRecord::Base
# Doesn't do anything if file hasn't been modified since it was last loaded.
# Note: If you do use rotated log files (rather than files named by date), at some
# point old loaded log lines will get deleted in the database.
- def MailServerLog.load_file(file_name)
+ def self.load_file(file_name)
is_gz = file_name.include?(".gz")
file_name_db = is_gz ? file_name.gsub(".gz", "") : file_name
@@ -62,23 +63,16 @@ class MailServerLog < ActiveRecord::Base
end
# Scan the file
- def MailServerLog.load_exim_log_data(f, done)
+ def self.load_exim_log_data(f, done)
order = 0
f.each do |line|
order = order + 1
emails = email_addresses_on_line(line)
- for email in emails
- info_request = InfoRequest.find_by_incoming_email(email)
- if info_request
- info_request.mail_server_logs.create!(:line => line, :order => order, :mail_server_log_done => done)
- else
- puts "Warning: Could not find request with email #{email}"
- end
- end
+ create_mail_server_logs(emails, line, order, done)
end
end
- def MailServerLog.load_postfix_log_data(f, done)
+ def self.load_postfix_log_data(f, done)
order = 0
emails = scan_for_postfix_queue_ids(f)
# Go back to the beginning of the file
@@ -87,19 +81,12 @@ class MailServerLog < ActiveRecord::Base
order = order + 1
queue_id = extract_postfix_queue_id_from_syslog_line(line)
if emails.has_key?(queue_id)
- emails[queue_id].each do |email|
- info_request = InfoRequest.find_by_incoming_email(email)
- if info_request
- info_request.mail_server_logs.create!(:line => line, :order => order, :mail_server_log_done => done)
- else
- puts "Warning: Could not find request with email #{email}"
- end
- end
+ create_mail_server_logs(emails[queue_id], line, order, done)
end
end
end
- def MailServerLog.scan_for_postfix_queue_ids(f)
+ def self.scan_for_postfix_queue_ids(f)
result = {}
f.each do |line|
emails = email_addresses_on_line(line)
@@ -111,7 +98,7 @@ class MailServerLog < ActiveRecord::Base
end
# Retuns nil if there is no queue id
- def MailServerLog.extract_postfix_queue_id_from_syslog_line(line)
+ def self.extract_postfix_queue_id_from_syslog_line(line)
# Assume the log file was written using syslog and parse accordingly
m = SyslogProtocol.parse("<13>" + line).content.match(/^\S+: (\S+):/)
m[1] if m
@@ -119,13 +106,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)
+ def self.email_addresses_on_line(line)
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)
+ def self.request_sent?(ir)
case(AlaveteliConfiguration::mta_log_type.to_sym)
when :exim
request_exim_sent?(ir)
@@ -137,7 +124,7 @@ class MailServerLog < ActiveRecord::Base
end
# Look at the log for a request and check that an email was delivered
- def MailServerLog.request_exim_sent?(ir)
+ def self.request_exim_sent?(ir)
# Look for line showing request was sent
found = false
ir.mail_server_logs.each do |mail_server_log|
@@ -156,7 +143,7 @@ class MailServerLog < ActiveRecord::Base
found
end
- def MailServerLog.request_postfix_sent?(ir)
+ def self.request_postfix_sent?(ir)
# dsn=2.0.0 is the magic word that says that postfix delivered the email
# See http://tools.ietf.org/html/rfc3464
ir.mail_server_logs.any? { |l| l.line.include?("dsn=2.0.0") }
@@ -173,11 +160,11 @@ class MailServerLog < ActiveRecord::Base
# NB: There can be several emails involved in a request. This just checks that
# at least one of them has been succesfully sent.
#
- def MailServerLog.check_recent_requests_have_been_sent
+ def self.check_recent_requests_have_been_sent
# Get all requests sent for from 2 to 10 days ago. The 2 day gap is
# because we load mail server log lines via cron at best an hour after they
# are made)
- irs = InfoRequest.find(:all, :conditions => [ "created_at < ? and created_at > ? and user_id is not null", Time.now() - 2.day, Time.now() - 10.days ] )
+ irs = InfoRequest.find(:all, :conditions => [ "created_at < ? and created_at > ? and user_id is not null", Time.now - 2.day, Time.now - 10.days ] )
# Go through each request and check it
ok = true
@@ -192,7 +179,17 @@ class MailServerLog < ActiveRecord::Base
ok
end
-end
-
+ private
+ def self.create_mail_server_logs(emails, line, order, done)
+ emails.each do |email|
+ info_request = InfoRequest.find_by_incoming_email(email)
+ if info_request
+ info_request.mail_server_logs.create!(:line => line, :order => order, :mail_server_log_done => done)
+ else
+ puts "Warning: Could not find request with email #{email}"
+ end
+ end
+ end
+end
diff --git a/app/models/mail_server_log_done.rb b/app/models/mail_server_log_done.rb
index 1bbb23ac4..542c3db3a 100644
--- a/app/models/mail_server_log_done.rb
+++ b/app/models/mail_server_log_done.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: mail_server_log_dones
diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb
index c2c8ef4f2..2e1b27fba 100644
--- a/app/models/outgoing_message.rb
+++ b/app/models/outgoing_message.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# == Schema Information
# Schema version: 20131024114346
#
@@ -25,6 +26,7 @@
# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class OutgoingMessage < ActiveRecord::Base
+ include AdminColumn
extend MessageProminence
include Rails.application.routes.url_helpers
include LinkToHelper
@@ -140,22 +142,28 @@ class OutgoingMessage < ActiveRecord::Base
end
end
- def body
- ret = read_attribute(:body)
- if ret.nil?
- return ret
+ # Public: The body text of the OutgoingMessage. The text is cleaned and
+ # CensorRules are applied.
+ #
+ # options - Hash of options
+ # :censor_rules - Array of CensorRules to apply. Defaults to the
+ # applicable_censor_rules of the associated
+ # InfoRequest. (optional)
+ #
+ # Returns a String
+ def body(options = {})
+ text = raw_body.dup
+ return text if text.nil?
+
+ text = clean_text(text)
+
+ # Use the given censor_rules; otherwise fetch them from the associated
+ # info_request
+ censor_rules = options.fetch(:censor_rules) do
+ info_request.try(:applicable_censor_rules) or []
end
- ret = ret.dup
- ret.strip!
- ret.gsub!(/(?:\n\s*){2,}/, "\n\n") # remove excess linebreaks that unnecessarily space it out
-
- # Remove things from censor rules
- unless info_request.nil?
- self.info_request.apply_censor_rules_to_text!(ret)
- end
-
- ret
+ censor_rules.reduce(text) { |text, rule| rule.apply_to_text(text) }
end
def raw_body
@@ -227,8 +235,12 @@ class OutgoingMessage < ActiveRecord::Base
end
# Returns text for indexing / text display
- def get_text_for_indexing(strip_salutation = true)
- text = body.strip
+ def get_text_for_indexing(strip_salutation = true, opts = {})
+ if opts.empty?
+ text = body.strip
+ else
+ text = body(opts).strip
+ end
# Remove salutation
text.sub!(/Dear .+,/, "") if strip_salutation
@@ -272,12 +284,6 @@ class OutgoingMessage < ActiveRecord::Base
info_request.purge_in_cache
end
- def for_admin_column
- self.class.content_columns.each do |column|
- yield(column.human_name, self.send(column.name), column.type.to_s, column.name)
- end
- end
-
def xapian_reindex_after_update
if changes.include?('body')
info_request_events.each do |event|
@@ -332,6 +338,11 @@ class OutgoingMessage < ActiveRecord::Base
errors.add(:what_doing_dummy, _('Please choose what sort of reply you are making.'))
end
end
+
+ # remove excess linebreaks that unnecessarily space it out
+ def clean_text(text)
+ text.strip.gsub(/(?:\n\s*){2,}/, "\n\n")
+ end
end
diff --git a/app/models/post_redirect.rb b/app/models/post_redirect.rb
index 8049349d0..3cdc69995 100644
--- a/app/models/post_redirect.rb
+++ b/app/models/post_redirect.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: post_redirects
@@ -71,7 +72,11 @@ class PostRedirect < ActiveRecord::Base
end
def reason_params
- YAML.load(reason_params_yaml)
+ param_hash = YAML.load(reason_params_yaml)
+ param_hash.each do |key, value|
+ param_hash[key] = value.force_encoding('UTF-8') if value.respond_to?(:force_encoding)
+ end
+ param_hash
end
# Extract just local path part, without domain or #
diff --git a/app/models/profile_photo.rb b/app/models/profile_photo.rb
index 61f88faf3..94edc2967 100644
--- a/app/models/profile_photo.rb
+++ b/app/models/profile_photo.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: profile_photos
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 232c0ffa1..fec1cefb6 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- encoding : utf-8 -*-
# == Schema Information
# Schema version: 20131024114346
#
@@ -32,6 +32,10 @@ require 'securerandom'
require 'set'
class PublicBody < ActiveRecord::Base
+ include AdminColumn
+
+ @non_admin_columns = %w(name last_edit_comment)
+
strip_attributes!
validates_presence_of :name, :message => N_("Name can't be blank")
@@ -64,7 +68,6 @@ class PublicBody < ActiveRecord::Base
}
translates :name, :short_name, :request_email, :url_name, :notes, :first_letter, :publication_scheme
- accepts_nested_attributes_for :translations, :reject_if => :empty_translation_in_params?
# Default fields available for importing from CSV, in the format
# [field_name, 'short description of field (basic html allowed)']
@@ -96,6 +99,8 @@ class PublicBody < ActiveRecord::Base
self.non_versioned_columns << 'info_requests_not_held_count' << 'info_requests_overdue'
self.non_versioned_columns << 'info_requests_overdue_count'
+ include Translatable
+
# Public: Search for Public Bodies whose name, short_name, request_email or
# tags contain the given query
#
@@ -124,11 +129,6 @@ class PublicBody < ActiveRecord::Base
uniq
end
- # Convenience methods for creating/editing translations via forms
- def find_translation_by_locale(locale)
- self.translations.find_by_locale(locale)
- end
-
# TODO: - Don't like repeating this!
def calculate_cached_fields(t)
PublicBody.set_first_letter(t)
@@ -138,7 +138,7 @@ class PublicBody < ActiveRecord::Base
end
# Set the first letter on a public body or translation
- def PublicBody.set_first_letter(instance)
+ def self.set_first_letter(instance)
unless instance.name.nil? or instance.name.empty?
# we use a regex to ensure it works with utf-8/multi-byte
first_letter = Unicode.upcase instance.name.scan(/^./mu)[0]
@@ -148,28 +148,6 @@ class PublicBody < ActiveRecord::Base
end
end
- def translated_versions
- translations
- end
-
- def ordered_translations
- translations.
- select { |t| I18n.available_locales.include?(t.locale) }.
- sort_by { |t| I18n.available_locales.index(t.locale) }
- end
-
- def build_all_translations
- I18n.available_locales.each do |locale|
- translations.build(:locale => locale) unless translations.detect{ |t| t.locale == locale }
- end
- end
-
- def translated_versions=(translation_attrs)
- warn "[DEPRECATION] PublicBody#translated_versions= will be replaced " \
- "by PublicBody#translations_attributes= as of release 0.22"
- self.translations_attributes = translation_attrs
- end
-
def set_default_publication_scheme
# Make sure publication_scheme gets the correct default value.
# (This would work automatically, were publication_scheme not a translated attribute)
@@ -339,23 +317,24 @@ class PublicBody < ActiveRecord::Base
# Are all requests to this body under the Environmental Information Regulations?
def eir_only?
- return self.has_tag?('eir_only')
+ has_tag?('eir_only')
end
+
def law_only_short
- if self.eir_only?
- return "EIR"
- else
- return "FOI"
- end
+ eir_only? ? 'EIR' : 'FOI'
end
# Schools are allowed more time in holidays, so we change some wordings
def is_school?
- return self.has_tag?('school')
+ has_tag?('school')
+ end
+
+ def site_administration?
+ has_tag?('site_administration')
end
# The "internal admin" is a special body for internal use.
- def PublicBody.internal_admin_body
+ def self.internal_admin_body
# Use find_by_sql to avoid the search being specific to a
# locale, since url_name is a translated field:
sql = "SELECT * FROM public_bodies WHERE url_name = 'internal_admin_authority'"
@@ -379,10 +358,6 @@ class PublicBody < ActiveRecord::Base
end
end
- def site_administration?
- has_tag?('site_administration')
- end
-
class ImportCSVDryRun < StandardError
end
@@ -412,7 +387,7 @@ class PublicBody < ActiveRecord::Base
# matching names won't work afterwards, and we'll create new bodies instead
# of updating them
bodies_by_name = {}
- set_of_existing = Set.new()
+ set_of_existing = Set.new
internal_admin_body_id = PublicBody.internal_admin_body.id
I18n.with_locale(I18n.default_locale) do
bodies = (tag.nil? || tag.empty?) ? PublicBody.find(:all, :include => :translations) : PublicBody.find_by_tag(tag)
@@ -425,7 +400,7 @@ class PublicBody < ActiveRecord::Base
end
end
- set_of_importing = Set.new()
+ set_of_importing = Set.new
# Default values in case no field list is given
field_names = { 'name' => 1, 'request_email' => 2 }
line = 0
@@ -577,17 +552,11 @@ class PublicBody < ActiveRecord::Base
return self.request_email_domain
end
- # Returns nil if configuration variable not set
- def override_request_email
- e = AlaveteliConfiguration::override_all_public_body_request_emails
- e if e != ""
- end
-
def request_email
- if override_request_email
- override_request_email
- else
+ if AlaveteliConfiguration::override_all_public_body_request_emails.blank? || read_attribute(:request_email).blank?
read_attribute(:request_email)
+ else
+ AlaveteliConfiguration::override_all_public_body_request_emails
end
end
@@ -598,7 +567,7 @@ class PublicBody < ActiveRecord::Base
# Return the domain part of an email address, canonicalised and with common
# extra UK Government server name parts removed.
- def PublicBody.extract_domain_from_email(email)
+ def self.extract_domain_from_email(email)
email =~ /@(.*)/
if $1.nil?
return nil
@@ -656,12 +625,6 @@ class PublicBody < ActiveRecord::Base
self.info_requests.each {|x| x.purge_in_cache}
end
- def for_admin_column
- self.class.content_columns.map{|c| c unless %w(name last_edit_comment).include?(c.name)}.compact.each do |column|
- yield(column.human_name, self.send(column.name), column.type.to_s, column.name)
- end
- end
-
def self.where_clause_for_stats(minimum_requests, total_column)
# When producing statistics for public bodies, we want to
# exclude any that are tagged with 'test' - we use a
@@ -773,13 +736,6 @@ class PublicBody < ActiveRecord::Base
end
end
- def empty_translation_in_params?(attributes)
- attrs_with_values = attributes.select do |key, value|
- value != '' and key.to_s != 'locale'
- end
- attrs_with_values.empty?
- end
-
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/public_body_category.rb b/app/models/public_body_category.rb
index b88c683de..0a64172c1 100644
--- a/app/models/public_body_category.rb
+++ b/app/models/public_body_category.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: public_body_categories
@@ -17,13 +18,14 @@ class PublicBodyCategory < ActiveRecord::Base
has_many :public_body_headings, :through => :public_body_category_links
translates :title, :description
- accepts_nested_attributes_for :translations, :reject_if => :empty_translation_in_params?
validates_uniqueness_of :category_tag, :message => 'Tag is already taken'
validates_presence_of :title, :message => "Title can't be blank"
validates_presence_of :category_tag, :message => "Tag can't be blank"
validates_presence_of :description, :message => "Description can't be blank"
+ include Translatable
+
def self.get
locale = I18n.locale.to_s || default_locale.to_s || ""
categories = CategoryCollection.new
@@ -51,43 +53,6 @@ class PublicBodyCategory < ActiveRecord::Base
) |
PublicBodyCategory.find_by_sql(sql)
end
-
- # Convenience methods for creating/editing translations via forms
- def find_translation_by_locale(locale)
- translations.find_by_locale(locale)
- end
-
- def translated_versions
- translations
- end
-
- def translated_versions=(translation_attrs)
- warn "[DEPRECATION] PublicBodyCategory#translated_versions= will be replaced " \
- "by PublicBodyCategory#translations_attributes= as of release 0.22"
- self.translations_attributes = translation_attrs
- end
-
- def ordered_translations
- translations.
- select { |t| I18n.available_locales.include?(t.locale) }.
- sort_by { |t| I18n.available_locales.index(t.locale) }
- end
-
- def build_all_translations
- I18n.available_locales.each do |locale|
- translations.build(:locale => locale) unless translations.detect{ |t| t.locale == locale }
- end
- end
-
- private
-
- def empty_translation_in_params?(attributes)
- attrs_with_values = attributes.select do |key, value|
- value != '' and key.to_s != 'locale'
- end
- attrs_with_values.empty?
- end
-
end
PublicBodyCategory::Translation.class_eval do
diff --git a/app/models/public_body_category/category_collection.rb b/app/models/public_body_category/category_collection.rb
index 8286e2710..7d5732a82 100644
--- a/app/models/public_body_category/category_collection.rb
+++ b/app/models/public_body_category/category_collection.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# replicate original file-based PublicBodyCategories functionality
class PublicBodyCategory::CategoryCollection
include Enumerable
@@ -13,19 +14,19 @@ class PublicBodyCategory::CategoryCollection
end
def with_description
- @categories.select() { |a| a.instance_of?(Array) }
+ @categories.select { |a| a.instance_of?(Array) }
end
def tags
- tags = with_description.map() { |a| a[0] }
+ tags = with_description.map { |a| a[0] }
end
def by_tag
- Hash[*with_description.map() { |a| a[0..1] }.flatten]
+ Hash[*with_description.map { |a| a[0..1] }.flatten]
end
def singular_by_tag
- Hash[*with_description.map() { |a| [a[0],a[2]] }.flatten]
+ Hash[*with_description.map { |a| [a[0],a[2]] }.flatten]
end
def by_heading
diff --git a/app/models/public_body_category_link.rb b/app/models/public_body_category_link.rb
index 8c3eb8060..be73a9afa 100644
--- a/app/models/public_body_category_link.rb
+++ b/app/models/public_body_category_link.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: public_body_category_links
diff --git a/app/models/public_body_change_request.rb b/app/models/public_body_change_request.rb
index 0e59cbecc..88a24dbd9 100644
--- a/app/models/public_body_change_request.rb
+++ b/app/models/public_body_change_request.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: public_body_change_requests
diff --git a/app/models/public_body_heading.rb b/app/models/public_body_heading.rb
index 8c160ba8b..d49b388bb 100644
--- a/app/models/public_body_heading.rb
+++ b/app/models/public_body_heading.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: public_body_headings
@@ -15,7 +16,6 @@ class PublicBodyHeading < ActiveRecord::Base
default_scope order('display_order ASC')
translates :name
- accepts_nested_attributes_for :translations, :reject_if => :empty_translation_in_params?
validates_uniqueness_of :name, :message => 'Name is already taken'
validates_presence_of :name, :message => 'Name can\'t be blank'
@@ -28,32 +28,7 @@ class PublicBodyHeading < ActiveRecord::Base
end
end
- # Convenience methods for creating/editing translations via forms
- def find_translation_by_locale(locale)
- translations.find_by_locale(locale)
- end
-
- def translated_versions
- translations
- end
-
- def translated_versions=(translation_attrs)
- warn "[DEPRECATION] PublicBodyHeading#translated_versions= will be replaced " \
- "by PublicBodyHeading#translations_attributes= as of release 0.22"
- self.translations_attributes = translation_attrs
- end
-
- def ordered_translations
- translations.
- select { |t| I18n.available_locales.include?(t.locale) }.
- sort_by { |t| I18n.available_locales.index(t.locale) }
- end
-
- def build_all_translations
- I18n.available_locales.each do |locale|
- translations.build(:locale => locale) unless translations.detect{ |t| t.locale == locale }
- end
- end
+ include Translatable
def add_category(category)
unless public_body_categories.include?(category)
@@ -68,14 +43,4 @@ class PublicBodyHeading < ActiveRecord::Base
0
end
end
-
- private
-
- def empty_translation_in_params?(attributes)
- attrs_with_values = attributes.select do |key, value|
- value != '' and key.to_s != 'locale'
- end
- attrs_with_values.empty?
- end
-
end
diff --git a/app/models/purge_request.rb b/app/models/purge_request.rb
index 81980188d..39dae6a74 100644
--- a/app/models/purge_request.rb
+++ b/app/models/purge_request.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: purge_requests
diff --git a/app/models/raw_email.rb b/app/models/raw_email.rb
index 907d3c7a0..58ae29a3b 100644
--- a/app/models/raw_email.rb
+++ b/app/models/raw_email.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: raw_emails
diff --git a/app/models/request_classification.rb b/app/models/request_classification.rb
index 478a543d3..ab0cd1f21 100644
--- a/app/models/request_classification.rb
+++ b/app/models/request_classification.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: request_classifications
@@ -15,7 +16,7 @@ class RequestClassification < ActiveRecord::Base
# return classification instances representing the top n
# users, with a 'cnt' attribute representing the number
# of classifications the user has made.
- def RequestClassification.league_table(size, conditions=[])
+ def self.league_table(size, conditions=[])
find(:all, :select => 'user_id, count(*) as cnt',
:conditions => conditions,
:group => 'user_id',
diff --git a/app/models/spam_address.rb b/app/models/spam_address.rb
index 2c84beaa0..893826a96 100644
--- a/app/models/spam_address.rb
+++ b/app/models/spam_address.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: spam_addresses
diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb
index cd90c4a9e..aad7cc51b 100644
--- a/app/models/track_thing.rb
+++ b/app/models/track_thing.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: track_things
diff --git a/app/models/track_things_sent_email.rb b/app/models/track_things_sent_email.rb
index 072d3bdea..d4f3f3f04 100644
--- a/app/models/track_things_sent_email.rb
+++ b/app/models/track_things_sent_email.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: track_things_sent_emails
diff --git a/app/models/user.rb b/app/models/user.rb
index 8fd7851e0..d50000aba 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -39,6 +39,7 @@ class User < ActiveRecord::Base
has_one :profile_photo
has_many :censor_rules, :order => 'created_at desc'
has_many :info_request_batches, :order => 'created_at desc'
+ has_many :request_classifications
validates_presence_of :email, :message => _("Please enter your email address")
validates_presence_of :name, :message => _("Please enter your name")
@@ -197,7 +198,9 @@ class User < ActiveRecord::Base
end
def visible_comments
- comments.find(:all, :conditions => 'visible')
+ warn %q([DEPRECATION] User#visible_comments will be replaced with
+ User#comments.visible as of 0.23).squish
+ comments.visible
end
# Don't display any leading/trailing spaces
diff --git a/app/models/user_info_request_sent_alert.rb b/app/models/user_info_request_sent_alert.rb
index cd163d14b..e6a6405ef 100644
--- a/app/models/user_info_request_sent_alert.rb
+++ b/app/models/user_info_request_sent_alert.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: user_info_request_sent_alerts
diff --git a/app/models/widget_vote.rb b/app/models/widget_vote.rb
new file mode 100644
index 000000000..dda77007f
--- /dev/null
+++ b/app/models/widget_vote.rb
@@ -0,0 +1,20 @@
+# -*- encoding : utf-8 -*-
+# == Schema Information
+#
+# Table name: widget_votes
+#
+# id :integer not null, primary key
+# cookie :string(255)
+# info_request_id :integer not null
+# created_at :datetime not null
+# updated_at :datetime not null
+#
+
+class WidgetVote < ActiveRecord::Base
+ belongs_to :info_request
+ validates :info_request, :presence => true
+
+ attr_accessible :cookie
+ validates :cookie, :length => { :is => 20 }
+ validates_uniqueness_of :cookie, :scope => :info_request_id
+end
diff --git a/app/views/admin_general/index.html.erb b/app/views/admin_general/index.html.erb
index ba0563bb6..8840bce74 100644
--- a/app/views/admin_general/index.html.erb
+++ b/app/views/admin_general/index.html.erb
@@ -2,17 +2,10 @@
<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>
+ <h1><%= @title %></h1>
+ <p>
+ <%= link_to 'Summary stats have moved →', admin_stats_path %>
+ </p>
</div>
</div>
@@ -28,8 +21,14 @@
<% 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>
+ <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>
@@ -39,11 +38,13 @@
<% if message.get_body_for_quoting.strip.size == 0 %>
<%= link_to "(no body)", admin_raw_email_path(message.raw_email_id) %>
<% else %>
- <%= link_to excerpt(message.get_body_for_quoting, "", :radius => 60), admin_raw_email_path(message.raw_email_id) %>
+ <%= link_to admin_raw_email_path(message.raw_email_id) do %>
+ <%= excerpt(message.get_body_for_quoting, "", :radius => 60) %>
+ <% end %>
<% end %>
</td>
<td class="span2">
- <%=simple_date(message.sent_at)%>
+ <%= simple_date(message.sent_at) %>
</td>
</tr>
<% end %>
@@ -67,7 +68,7 @@
<%= request_both_links(@request) %>
</td>
<td class="span2">
- <%=simple_date(@request.info_request_events.last.created_at)%>
+ <%= simple_date(@request.last_event_time) %>
</td>
</tr>
<% end %>
@@ -92,7 +93,7 @@
<%= request_both_links(@request) %>
</td>
<td class="span2">
- <%=simple_date(@request.info_request_events.last.created_at)%>
+ <%= simple_date(@request.last_event_time) %>
</td>
</tr>
<% end %>
@@ -116,7 +117,7 @@
<%= request_both_links(@request) %>
</td>
<td class="span2">
- <%=simple_date(@request.info_request_events.last.created_at)%>
+ <%= simple_date(@request.last_event_time) %>
</td>
</tr>
<% end %>
@@ -178,18 +179,33 @@
<% if @new_body_requests.size > 0 %>
<div class="accordion-group">
<div class="accordion-heading">
- <a class="accordion-toggle" href="#new-authorities" data-toggle="collapse" data-parent="things-to-do"><span class="label label-important"><%= @new_body_requests.size %></span><%= chevron_right %> Add new authorities</a>
+ <a class="accordion-toggle" href="#new-authorities" data-toggle="collapse" data-parent="things-to-do">
+ <span class="label label-important">
+ <%= @new_body_requests.size %>
+ </span>
+ <%= chevron_right %> Add new authorities
+ </a>
</div>
+
<div id="new-authorities" class="accordion-body collapse">
- <% for @change_request in @new_body_requests %>
- <%= render :partial => 'change_request_summary'%>
- <%= form_tag admin_change_request_path(@change_request), :method => 'put', :class => "form form-horizontal" do %>
- <%= submit_tag 'Close', :class => "btn btn-danger" %>
- <%= link_to("Close and respond", edit_admin_change_request_path(@change_request), :class => 'btn') %>
- <%= link_to("Add authority", new_admin_body_path(:change_request_id => @change_request.id), :class => 'btn btn-primary') %>
- <% end %>
+ <% for @change_request in @new_body_requests %>
+ <%= render :partial => 'change_request_summary'%>
- <% end %>
+ <%= form_tag admin_change_request_path(@change_request),
+ :method => 'put',
+ :class => "form form-horizontal" do %>
+
+ <%= submit_tag 'Close', :class => "btn btn-danger" %>
+
+ <%= link_to "Close and respond",
+ edit_admin_change_request_path(@change_request),
+ :class => 'btn' %>
+
+ <%= link_to "Add authority",
+ new_admin_body_path(:change_request_id => @change_request.id),
+ :class => 'btn btn-primary' %>
+ <% end %>
+ <% end %>
</div>
</div>
<% end %>
@@ -197,17 +213,34 @@
<% if @body_update_requests.size > 0 %>
<div class="accordion-group">
<div class="accordion-heading">
- <a class="accordion-toggle" href="#update-authorities" data-toggle="collapse" data-parent="things-to-do"><span class="label label-important"><%= @body_update_requests.size %></span><%= chevron_right %> Update authorities</a>
+ <a class="accordion-toggle" href="#update-authorities" data-toggle="collapse" data-parent="things-to-do">
+ <span class="label label-important">
+ <%= @body_update_requests.size %>
+ </span>
+ <%= chevron_right %> Update authorities
+ </a>
</div>
+
<div id="update-authorities" class="accordion-body collapse">
<% for @change_request in @body_update_requests %>
- <%= render :partial => 'change_request_summary' %>
- <%= form_tag admin_change_request_path(@change_request), :class => "form form-horizontal", :method => 'put' do %>
- <%= submit_tag 'Close', :class => "btn btn-danger" %>
- <%= link_to("Close and respond", edit_admin_change_request_path(@change_request), :class => 'btn') %>
- <%= link_to("Make update", edit_admin_body_path(@change_request.public_body, :change_request_id => @change_request.id), :class => 'btn btn-primary') %>
- <% end %>
+ <%= render :partial => 'change_request_summary' %>
+
+ <%= form_tag admin_change_request_path(@change_request),
+ :class => "form form-horizontal",
+ :method => 'put' do %>
+
+ <%= submit_tag 'Close', :class => "btn btn-danger" %>
+
+ <%= link_to "Close and respond",
+ edit_admin_change_request_path(@change_request),
+ :class => 'btn' %>
+
+ <%= link_to "Make update",
+ edit_admin_body_path(@change_request.public_body,
+ :change_request_id => @change_request.id),
+ :class => 'btn btn-primary' %>
<% end %>
+ <% end %>
</div>
</div>
<% end %>
diff --git a/app/views/admin_public_body/edit.html.erb b/app/views/admin_public_body/edit.html.erb
index dcafbd270..fc9c25e8f 100644
--- a/app/views/admin_public_body/edit.html.erb
+++ b/app/views/admin_public_body/edit.html.erb
@@ -13,7 +13,7 @@
<div class="row">
<div class="span8">
<div class="well">
- <%= link_to 'Show', admin_bodies_path(@public_body), :class => "btn" %>
+ <%= link_to 'Show', admin_body_path(@public_body), :class => "btn" %>
<%= link_to 'List all', admin_bodies_path, :class => "btn" %>
</div>
</div>
diff --git a/app/views/comment/_comment_form.html.erb b/app/views/comment/_comment_form.html.erb
index 6ca3f4c9f..0a6712af5 100644
--- a/app/views/comment/_comment_form.html.erb
+++ b/app/views/comment/_comment_form.html.erb
@@ -5,7 +5,7 @@
<% if !TrackThing.find_existing(@user, track_thing) && (!@user || @info_request.user != @user) %>
<p>
- <%= check_box_tag 'subscribe_to_request', "1", params[:subscribe_to_request] ? true : false %> <label for="subscribe_to_request"><%= _('Email me future updates to this request') %></label>
+ <%= check_box_tag 'subscribe_to_request', "1", params[:subscribe_to_request] %> <label for="subscribe_to_request"><%= _('Email me future updates to this request') %></label>
</p>
<% end %>
diff --git a/app/views/comment/_single_comment.html.erb b/app/views/comment/_single_comment.html.erb
index 07017dabf..badc39d9a 100644
--- a/app/views/comment/_single_comment.html.erb
+++ b/app/views/comment/_single_comment.html.erb
@@ -1,4 +1,4 @@
-<div class="comment_in_request" id="comment-<%=comment.id.to_s%>">
+<div class="comment_in_request box" id="comment-<%=comment.id.to_s%>">
<% if comment.user && comment.user.profile_photo && !@render_to_file %>
<div class="user_photo_on_comment">
<img src="<%= get_profile_photo_url(:url_name => comment.user.url_name) %>" alt="">
diff --git a/app/views/general/_responsive_topnav.html.erb b/app/views/general/_responsive_topnav.html.erb
index 0af6629c8..c99864cab 100644
--- a/app/views/general/_responsive_topnav.html.erb
+++ b/app/views/general/_responsive_topnav.html.erb
@@ -21,11 +21,16 @@
</li>
<li id="navigation_search">
- <form id="navigation_search_form" method="get" action="<%= search_redirect_path %>">
- <label for="navigation_search_button">
- <img src="/assets/search.png" alt="Search:">
+ <form id="navigation_search_form" method="get" action="<%= search_redirect_path %>" role="search">
+ <label class="visually-hidden" for="navigation_search_button">
+ <%= _("Search") %>
</label>
- <%= text_field_tag 'query', params[:query], { :id => "navigation_search_button", :title => "type your search term here" } %>
+ <%= text_field_tag 'query', params[:query], { :id => "navigation_search_button", :type => "search", :placeholder => _("Search"), :title => _("type your search term here") } %>
+ <button type="submit">
+ <span class="visually-hidden">
+ <%= _("Submit Search") %>
+ </span>
+ </button>
</form>
</li>
</ul>
diff --git a/app/views/help/unhappy.html.erb b/app/views/help/unhappy.html.erb
index 79e3f8273..c0444fb54 100644
--- a/app/views/help/unhappy.html.erb
+++ b/app/views/help/unhappy.html.erb
@@ -101,9 +101,8 @@ contact any registered user from their page. There may be an Internet
forum or group that they hang out in. If it is a local matter, use <a
href="http://www.groupsnearyou.com">GroupsNearYou</a> to find such a
forum.</li>
-<li><strong>Start a pledge</strong> on <a href="http://www.pledgebank.com">PledgeBank</a> to get
-others to act together with you. For example, you could arrange a meeting with
-staff from the authority. Or you could form a small local campaigns group.
+<li>You could form a small local campaign group and arrange a meeting
+with staff from the authority.</li>
</ul>
diff --git a/app/views/public_body/show.html.erb b/app/views/public_body/show.html.erb
index 016c2460d..9dd3dc7cb 100644
--- a/app/views/public_body/show.html.erb
+++ b/app/views/public_body/show.html.erb
@@ -42,12 +42,12 @@
</div>
<% end %>
- <% if @public_body.info_requests.size > 0 %>
+ <% if @number_of_visible_requests > 0 %>
<div class="authority__header__stats">
<%= n_('{{count}} request',
'{{count}} requests',
- @public_body.info_requests.size,
- :count => @public_body.info_requests.size) %>
+ @number_of_visible_requests,
+ :count => @number_of_visible_requests) %>
</div>
<% end %>
@@ -81,7 +81,7 @@
<div class="authority__body">
<div class="authority__body__foi-results">
- <% if @public_body.info_requests.size == 0 %>
+ <% if @number_of_visible_requests == 0 %>
<% if @public_body.is_requestable? or @public_body.not_requestable_reason != 'defunct' %>
<% if @public_body.eir_only? %>
<h2><%= _('Environmental Information Regulations requests made using this site') %></h2>
@@ -99,7 +99,7 @@
<% end %>
<a name="results"></a>
- <% if @public_body.info_requests.size > 4 %>
+ <% if @number_of_visible_requests > 4 %>
<%= render :partial => 'request/request_filter_form' %>
<% end %>
<% end %>
@@ -132,7 +132,7 @@
</div>
<div class="authority__body__sidebar">
- <% if @public_body.info_requests.size > 4 %>
+ <% if @number_of_visible_requests > 4 %>
<%= render :partial => 'request/request_search_form' %>
<% end %>
<%= render :partial => 'more_info', :locals => { :public_body => @public_body } %>
diff --git a/app/views/public_body_change_requests/new.html.erb b/app/views/public_body_change_requests/new.html.erb
index b52d583be..9abe03732 100644
--- a/app/views/public_body_change_requests/new.html.erb
+++ b/app/views/public_body_change_requests/new.html.erb
@@ -12,7 +12,7 @@
<p>
<label class="form_label" for="user_email">
- <%= ("Your email:") %>
+ <%= _("Your email:") %>
</label>
<%= f.text_field :user_email %>
</p>
diff --git a/app/views/request/_act.html.erb b/app/views/request/_act.html.erb
index 878cdf4ff..c7bbd287f 100644
--- a/app/views/request/_act.html.erb
+++ b/app/views/request/_act.html.erb
@@ -20,3 +20,8 @@
<% end %>
<%= link_to _("Start your own blog"), "http://wordpress.com/"%>
</div>
+<% if AlaveteliConfiguration::enable_widgets %>
+ <div class="act_link">
+ <%= link_to _("Create a widget for this request"), new_request_widget_path(@info_request) %>
+ </div>
+<% end %>
diff --git a/app/views/request/_followup.html.erb b/app/views/request/_followup.html.erb
index 2643b767f..24cede824 100644
--- a/app/views/request/_followup.html.erb
+++ b/app/views/request/_followup.html.erb
@@ -20,7 +20,7 @@
</h2>
<% end %>
<% if @info_request.who_can_followup_to(incoming_message).count > 0 %>
-<div id="other_recipients">
+<div id="other_recipients" class="box">
<%= _("Don't want to address your message to {{person_or_body}}? You can also write to:", :person_or_body => name_for_followup) %>
<ul>
<% @info_request.who_can_followup_to(incoming_message).each do |name, email, id| %>
diff --git a/app/views/request/_incoming_correspondence.html.erb b/app/views/request/_incoming_correspondence.html.erb
index 70bd25c7f..9d205204e 100644
--- a/app/views/request/_incoming_correspondence.html.erb
+++ b/app/views/request/_incoming_correspondence.html.erb
@@ -1,4 +1,4 @@
-<div class="incoming correspondence <%= incoming_message.prominence %>" id="incoming-<%=incoming_message.id.to_s%>">
+<div class="incoming correspondence box <%= incoming_message.prominence %>" id="incoming-<%=incoming_message.id.to_s%>">
<%- if not incoming_message.user_can_view?(@user) %>
<%= render :partial => 'request/hidden_correspondence', :locals => { :message => incoming_message }%>
<%- else %>
diff --git a/app/views/request/_outgoing_correspondence.html.erb b/app/views/request/_outgoing_correspondence.html.erb
index dced5c94c..3b85cae7f 100644
--- a/app/views/request/_outgoing_correspondence.html.erb
+++ b/app/views/request/_outgoing_correspondence.html.erb
@@ -1,4 +1,4 @@
-<div class="outgoing correspondence" id="outgoing-<%=outgoing_message.id.to_s%>">
+<div class="outgoing correspondence box" id="outgoing-<%=outgoing_message.id.to_s%>">
<%- if not outgoing_message.user_can_view?(@user) %>
<%= render :partial => 'request/hidden_correspondence', :locals => { :message => outgoing_message }%>
<%- else %>
diff --git a/app/views/request/_resent_outgoing_correspondence.html.erb b/app/views/request/_resent_outgoing_correspondence.html.erb
index 17b6b635b..287a5cac5 100644
--- a/app/views/request/_resent_outgoing_correspondence.html.erb
+++ b/app/views/request/_resent_outgoing_correspondence.html.erb
@@ -1,4 +1,4 @@
-<div class="outgoing correspondence" id="outgoing-<%=outgoing_message.id.to_s%>">
+<div class="outgoing correspondence box" id="outgoing-<%=outgoing_message.id.to_s%>">
<h2>
<%= simple_date(info_request_event.created_at) %>
</h2>
diff --git a/app/views/request/new.html.erb b/app/views/request/new.html.erb
index 486a89d45..23f7ad76a 100644
--- a/app/views/request/new.html.erb
+++ b/app/views/request/new.html.erb
@@ -144,7 +144,7 @@
<% 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_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) %>
+ <%= _("Browse <a href='{{url}}'>other requests</a> for examples of how to word your request.", :url=>request_list_successful_url) %>
<% end %>
</p>
<% end %>
@@ -156,7 +156,7 @@
this website <a href="{{url}}">forever</a>', :url => (help_privacy_path+"#public_request").html_safe)) %>.
</p>
<p>
- <%= raw(_('<a href="{{url}}">Thinking of using a pseudonym?</a>.', :url => (help_privacy_path+"#real_name").html_safe)) %>
+ <%= raw(_('<a href="{{url}}">Thinking of using a pseudonym?</a>', :url => (help_privacy_path+"#real_name").html_safe)) %>
</p>
<% else %>
<p>
diff --git a/app/views/request/new_bad_contact.html.erb b/app/views/request/new_bad_contact.html.erb
index 56f3f4168..f9881b62b 100644
--- a/app/views/request/new_bad_contact.html.erb
+++ b/app/views/request/new_bad_contact.html.erb
@@ -5,6 +5,6 @@
<p><%= _('Unfortunately, we do not have a working {{info_request_law_used_full}}
address for', :info_request_law_used_full => @info_request.law_used_full) %> <%=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="{{help_url}}">send it to us</a>.', :help_url => help_contact_path) %>
+to find one, then please <a href="{{help_url}}">send it to us</a>.', :help_url => new_change_request_path(:body => @info_request.public_body.url_name)) %>
</p>
diff --git a/app/views/request/show.html.erb b/app/views/request/show.html.erb
index 78e022aa9..5862413de 100644
--- a/app/views/request/show.html.erb
+++ b/app/views/request/show.html.erb
@@ -22,7 +22,7 @@
<% if ( @update_status || @info_request.awaiting_description ) && ! @info_request.is_external? %>
- <div class="describe_state_form" id="describe_state_form_1">
+ <div class="describe_state_form box" id="describe_state_form_1">
<%= render :partial => 'describe_state', :locals => { :id_suffix => "1" } %>
</div>
<% end %>
@@ -146,7 +146,7 @@
<% end %>
<% if @info_request.awaiting_description && ! @info_request.is_external? %>
- <div class="describe_state_form" id="describe_state_form_2">
+ <div class="describe_state_form box" id="describe_state_form_2">
<%= render :partial => 'describe_state', :locals => { :id_suffix => "2" } %>
</div>
<% end %>
diff --git a/app/views/request_game/play.html.erb b/app/views/request_game/play.html.erb
index 471a0e09e..44fe641f9 100644
--- a/app/views/request_game/play.html.erb
+++ b/app/views/request_game/play.html.erb
@@ -2,7 +2,12 @@
<div id="game_sidebar">
<p style="text-align: center">
- <img width=250 height=125 src="http://chart.apis.google.com/chart?chs=250x125&cht=gom&chd=t:<%=@percentage%>" alt="<%=@percentage%>% of requests have been categorised">
+ <%=
+ image_tag "https://chart.googleapis.com/chart?chs=250x125&cht=gom&chd=t:#{@percentage}",
+ :size => "250x125",
+ :alt => "A chart showing #{@percentage}% of requests have been categorised",
+ :title => "#{@percentage}% of requests have been categorised"
+ %>
<br><%=pluralize(@missing, 'request')%> left to categorise / <%=@total %> total
</p>
diff --git a/app/views/user/_user_listing_single.html.erb b/app/views/user/_user_listing_single.html.erb
index 3cb0d283f..03ac7347b 100644
--- a/app/views/user/_user_listing_single.html.erb
+++ b/app/views/user/_user_listing_single.html.erb
@@ -17,7 +17,7 @@ end %>
<span class="bottomline">
<%= pluralize(display_user.info_requests.size, "request") %> <%= _('made.')%>
- <%= pluralize(display_user.visible_comments.size, "annotation") %> <%= _('made.')%>
+ <%= pluralize(display_user.comments.visible.size, "annotation") %> <%= _('made.')%>
<%= _('Joined in')%> <%= display_user.created_at.year %>.
</span>
diff --git a/app/views/user/show.html.erb b/app/views/user/show.html.erb
index 78b513d6a..a67663389 100644
--- a/app/views/user/show.html.erb
+++ b/app/views/user/show.html.erb
@@ -173,7 +173,7 @@
<% end %>
<% else %>
<h2 id="annotations">
- <%= @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) %>
+ <%= @is_you ? n_('Your {{count}} annotation', 'Your {{count}} annotations', @display_user.comments.visible.size, :count => @display_user.comments.visible.size) : n_("This person's {{count}} annotation", "This person's {{count}} annotations", @display_user.comments.visible.size, :count => @display_user.comments.visible.size) %>
<!-- matches_estimated <%=@xapian_comments.matches_estimated%> -->
<%= @page_desc %>
</h2>
@@ -182,7 +182,7 @@
<%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model] } %>
<% end %>
- <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @display_user.visible_comments.size) %>
+ <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @display_user.comments.visible.size) %>
<% end %>
<% end %>
diff --git a/app/views/widgets/new.html.erb b/app/views/widgets/new.html.erb
new file mode 100644
index 000000000..c706155a5
--- /dev/null
+++ b/app/views/widgets/new.html.erb
@@ -0,0 +1,15 @@
+<h1>Add a widget</h1>
+
+<p>
+To add a widget for <b><%= @info_request.title %></b>, copy and paste the
+following code to your web page:
+<textarea autofocus readonly rows='4' cols='60' id='widgetbox'>
+<iframe src='<%= request_widget_url(@info_request) %>' width='320' height='215' frameborder='0' marginwidth='0' marginheight='0'></iframe>
+</textarea>
+</p>
+
+<p>
+The widget will look like this:
+<br>
+<iframe src='<%= request_widget_url(@info_request) %>' width='320' height='215' frameborder='0' marginwidth='0' marginheight='0'></iframe>
+</p>
diff --git a/app/views/widgets/show.html.erb b/app/views/widgets/show.html.erb
new file mode 100644
index 000000000..07c7b1908
--- /dev/null
+++ b/app/views/widgets/show.html.erb
@@ -0,0 +1,48 @@
+<head>
+ <%= stylesheet_link_tag "widget" %>
+</head>
+<body>
+ <div class="alaveteli-widget">
+ <div class="alaveteli-widget__top">
+ <div class="alaveteli-widget__left">
+ <div class="alaveteli-widget__title">
+ <%= link_to @info_request.title, request_path(@info_request), :target => "_top" %>
+ </div>
+ <div class="alaveteli-widget__status <%= @status %>">
+ <p class="alaveteli-widget__status__status-label">Status</p>
+ <%= status_description(@info_request, @status) %>
+ </div>
+ </div>
+ <div class="alaveteli-widget__people-count">
+ <%= n_('<div class="alaveteli-widget__count">{{count}}</div> person wants to know', '<div class="alaveteli-widget__count">{{count}}</div> people want to know', @count, :count => @count) %>
+ </div>
+ </div>
+
+
+ <div class="alaveteli-widget__bottom">
+ <% if @info_request.user && @info_request.user == @user %>
+ <div class="alaveteli-widget__button alaveteli-widget__button--down">
+ <%= _('This is your request') %>
+ </div>
+ <% elsif @existing_track %>
+ <a href="<%= url_for :controller => 'track', :action => 'update', :track_id => @existing_track.id, :track_medium => "delete", :r => request.fullpath %>">
+ <div class="alaveteli-widget__button--down">
+ <%= _('You are tracking this request') %>
+ </div>
+ </a>
+ <% else %>
+ <% if @user %>
+ <a href="<%= url_for do_track_path(@track_thing) %>" target="_blank">
+ <div class="alaveteli-widget__button">
+ <%= _('I also want to know!') %>
+ </div>
+ </a>
+ <% else %>
+ <%= form_tag request_widget_url(@info_request), :method => 'put', :target => '_blank' do %>
+ <%= submit_tag _('I also want to know!'), :class => 'alaveteli-widget__button' %>
+ <% end %>
+ <% end %>
+ <% end %>
+ </div>
+ </div>
+</body>