aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/public_body_controller.rb7
-rw-r--r--app/helpers/application_helper.rb8
-rw-r--r--app/models/track_mailer.rb8
-rw-r--r--app/models/user.rb30
-rw-r--r--app/views/admin_public_body/_form.rhtml20
-rw-r--r--app/views/general/frontpage.rhtml2
-rw-r--r--app/views/layouts/default.rhtml11
-rw-r--r--app/views/layouts/no_chrome.rhtml6
-rw-r--r--app/views/request/_search_ahead.rhtml11
-rw-r--r--app/views/request/new.rhtml11
10 files changed, 81 insertions, 33 deletions
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb
index 0e58b7055..79ca58d13 100644
--- a/app/controllers/public_body_controller.rb
+++ b/app/controllers/public_body_controller.rb
@@ -91,7 +91,10 @@ class PublicBodyController < ApplicationController
@tag = params[:tag]
@locale = self.locale_from_params()
- locale_condition = "(upper(public_body_translations.name) LIKE upper(?) OR upper(public_body_translations.notes) LIKE upper (?)) AND public_body_translations.locale = ?"
+ locale_condition = "(upper(public_body_translations.name) LIKE upper(?)
+ OR upper(public_body_translations.notes) LIKE upper (?))
+ AND public_body_translations.locale = ?
+ AND public_bodies.id <> #{PublicBody.internal_admin_body.id}"
if @tag.nil? or @tag == "all"
@tag = "all"
conditions = [locale_condition, @query, @query, @locale]
@@ -123,7 +126,7 @@ class PublicBodyController < ApplicationController
@description = @tag
end
end
- PublicBody.with_locale(@locale) do
+ PublicBody.with_locale(@locale) do
@public_bodies = PublicBody.paginate(
:order => "public_body_translations.name", :page => params[:page], :per_page => 1000, # fit all councils on one page
:conditions => conditions,
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index d12238582..a0f16dfaf 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -105,8 +105,12 @@ module ApplicationHelper
method_name.sub(/\?$/, "")
end
- def form_tag_id(object_name, method_name)
- return "#{sanitized_object_name(object_name.to_s)}_#{sanitized_method_name(method_name.to_s)}"
+ def form_tag_id(object_name, method_name, locale=nil)
+ if locale.nil?
+ return "#{sanitized_object_name(object_name.to_s)}_#{sanitized_method_name(method_name.to_s)}"
+ else
+ return "#{sanitized_object_name(object_name.to_s)}_#{sanitized_method_name(method_name.to_s)}__#{locale.to_s}"
+ end
end
end
diff --git a/app/models/track_mailer.rb b/app/models/track_mailer.rb
index f8bef4d61..85b1fedd8 100644
--- a/app/models/track_mailer.rb
+++ b/app/models/track_mailer.rb
@@ -26,6 +26,12 @@ class TrackMailer < ApplicationMailer
@body = { :user => user, :email_about_things => email_about_things, :unsubscribe_url => unsubscribe_url }
end
+ def contact_from_name_and_email
+ contact_name = MySociety::Config.get("TRACK_SENDER_NAME", 'Alaveteli')
+ contact_email = MySociety::Config.get("TRACK_SENDER_EMAIL", 'contact@localhost')
+ return "#{contact_name} <#{contact_email}>"
+ end
+
# Send email alerts for tracked things. Never more than one email
# a day, nor about events which are more than a week old, nor
# events about which emails have been sent within the last two
@@ -40,6 +46,8 @@ class TrackMailer < ApplicationMailer
return false
end
for user in users
+ next if !user.should_be_emailed?
+
email_about_things = []
track_things = TrackThing.find(:all, :conditions => [ "tracking_user_id = ? and track_medium = ?", user.id, 'email_daily' ])
for track_thing in track_things
diff --git a/app/models/user.rb b/app/models/user.rb
index c3c3da6f7..e98d777b1 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -16,6 +16,8 @@
# admin_level :string(255) default("none"), not null
# ban_text :text default(""), not null
# about_me :text default(""), not null
+# email_bounced_at :datetime
+# email_bounce_message :text default(""), not null
#
# models/user.rb:
@@ -350,15 +352,37 @@ class User < ActiveRecord::Base
}
end
+ def record_bounce(message)
+ self.email_bounced_at = Time.now
+ self.email_bounce_message = message
+ self.save!
+ end
+
+ def should_be_emailed?
+ return (self.email_confirmed && self.email_bounced_at.nil?)
+ end
+
+ ## Private instance methods
private
+ def create_new_salt
+ self.salt = self.object_id.to_s + rand.to_s
+ end
+
+ ## Class methods
def User.encrypted_password(password, salt)
string_to_hash = password + salt # XXX need to add a secret here too?
Digest::SHA1.hexdigest(string_to_hash)
end
-
- def create_new_salt
- self.salt = self.object_id.to_s + rand.to_s
+
+ def User.record_bounce_for_email(email, message)
+ user = User.find_user_by_email(email)
+ return false if user.nil?
+
+ if user.email_bounced_at.nil?
+ user.record_bounce(message)
+ end
+ return true
end
end
diff --git a/app/views/admin_public_body/_form.rhtml b/app/views/admin_public_body/_form.rhtml
index 6a9013071..1cdc9b3fe 100644
--- a/app/views/admin_public_body/_form.rhtml
+++ b/app/views/admin_public_body/_form.rhtml
@@ -26,20 +26,20 @@
<div id="div-locale-<%=locale.to_s%>">
<%= t.hidden_field :locale, :value => locale.to_s %>
- <p><label for="<%= form_tag_id(t.object_name, :name) %>">Name</label><br/>
- <%= t.text_field :name, :size => 60, :id => form_tag_id(t.object_name, :name) %></p>
+ <p><label for="<%= form_tag_id(t.object_name, :name, locale) %>">Name</label><br/>
+ <%= t.text_field :name, :size => 60, :id => form_tag_id(t.object_name, :name, locale) %></p>
- <p><label for="<%= form_tag_id(t.object_name, :short_name) %>">Short name <small>(only put in abbreviations which are really used, otherwise leave blank. Short or long name is used in the URL - don't worry about breaking URLs through renaming, as the history is used to redirect)</small></label><br/>
- <%= t.text_field :short_name, :size => 60, :id => form_tag_id(t.object_name, :short_name) %></p>
+ <p><label for="<%= form_tag_id(t.object_name, :short_name, locale) %>">Short name <small>(only put in abbreviations which are really used, otherwise leave blank. Short or long name is used in the URL - don't worry about breaking URLs through renaming, as the history is used to redirect)</small></label><br/>
+ <%= t.text_field :short_name, :size => 60, :id => form_tag_id(t.object_name, :short_name, locale) %></p>
- <p><label for="<%= form_tag_id(t.object_name, :request_email) %>">Request email <small>(set to <strong>blank</strong> (empty string) if can't find an address; these emails are <strong>public</strong> as anyone can view with a CAPTCHA)</small></label><br/>
- <%= t.text_field :request_email, :size => 40, :id => form_tag_id(t.object_name, :request_email) %></p>
+ <p><label for="<%= form_tag_id(t.object_name, :request_email, locale) %>">Request email <small>(set to <strong>blank</strong> (empty string) if can't find an address; these emails are <strong>public</strong> as anyone can view with a CAPTCHA)</small></label><br/>
+ <%= t.text_field :request_email, :size => 40, :id => form_tag_id(t.object_name, :request_email, locale) %></p>
- <p><label for="<%= form_tag_id(t.object_name, :publication_scheme) %>">Publication scheme URL</label><br/>
- <%= t.text_field :publication_scheme, :size => 60, :id => form_tag_id(t.object_name, :publication_scheme) %></p>
+ <p><label for="<%= form_tag_id(t.object_name, :publication_scheme, locale) %>">Publication scheme URL</label><br/>
+ <%= t.text_field :publication_scheme, :size => 60, :id => form_tag_id(t.object_name, :publication_scheme, locale) %></p>
- <p><label for="<%= form_tag_id(t.object_name, :notes) %>">Public notes</label> <small>(HTML, for users to consider when making FOI requests to the authority)</small><br/>
- <%= t.text_area :notes, :rows => 3, :cols => 60, :id => form_tag_id(t.object_name, :notes) %></p>
+ <p><label for="<%= form_tag_id(t.object_name, :notes, locale) %>">Public notes</label> <small>(HTML, for users to consider when making FOI requests to the authority)</small><br/>
+ <%= t.text_area :notes, :rows => 3, :cols => 60, :id => form_tag_id(t.object_name, :notes, locale) %></p>
</div>
<%
end
diff --git a/app/views/general/frontpage.rhtml b/app/views/general/frontpage.rhtml
index 55b00b753..215288791 100644
--- a/app/views/general/frontpage.rhtml
+++ b/app/views/general/frontpage.rhtml
@@ -58,7 +58,7 @@
<ul>
<% for event in @request_events %>
<li>
- <%= public_body_link(event.info_request.public_body) %> answered a request about
+ <%= public_body_link(event.info_request.public_body) %> <%= _('answered a request about') %>
<%=link_to h(event.info_request.title), request_url(event.info_request)%>
<%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(event.described_at)) %>
<p class="excerpt" onclick="document.location.href='<%=request_url(event.info_request)%>'"><%= excerpt(event.info_request.title, "", 200) %></p>
diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml
index 1075ffc03..bd96f1528 100644
--- a/app/views/layouts/default.rhtml
+++ b/app/views/layouts/default.rhtml
@@ -32,9 +32,10 @@
<style type="text/css">@import url("/stylesheets/ie7.css");</style>
<![endif]-->
<%= stylesheet_link_tag 'custom', :title => "Main", :rel => "stylesheet" %>
- <!-- XXX: add conditional include -->
+ <% if force_registration_on_new_request %>
<%= stylesheet_link_tag 'jquery.fancybox-1.3.4', :rel => "stylesheet" %>
-
+ <% end %>
+
<% if @feed_autodetect %>
<% for feed in @feed_autodetect %>
<link rel="alternate" type="application/atom+xml" title="<%=h feed[:title] %>" href="<%=h feed[:url]%>">
@@ -62,8 +63,8 @@
$(document).ready(function() {
$("#make-request-link").fancybox({
'modal': false,
- 'width': 800,
- 'height': 500,
+ 'width': 900,
+ 'height': 400,
'type': 'iframe',
'href': '/en/profile/sign_in?modal=1',
'onClosed': function() {
@@ -132,9 +133,7 @@
</div>
</div>
<div id="wrapper">
-
<div id="content">
-
<% if flash[:notice] %>
<div id="notice"><%= flash[:notice] %></div>
<% end %>
diff --git a/app/views/layouts/no_chrome.rhtml b/app/views/layouts/no_chrome.rhtml
index c314dfbd3..74c79b701 100644
--- a/app/views/layouts/no_chrome.rhtml
+++ b/app/views/layouts/no_chrome.rhtml
@@ -11,7 +11,9 @@
<script type="text/javascript" src="/javascripts/jquery.js"></script>
- <%= stylesheet_link_tag 'main', :title => "Main", :rel => "stylesheet" %>
+ <%= stylesheet_link_tag 'main', :title => "Main", :rel => "stylesheet" %>
+ <%= stylesheet_link_tag 'fonts', :rel => "stylesheet" %>
+ <%= stylesheet_link_tag 'theme', :rel => "stylesheet" %>
<!--[if LT IE 7]>
<style type="text/css">@import url("/stylesheets/ie6.css");</style>
<![endif]-->
@@ -21,7 +23,7 @@
<%= stylesheet_link_tag 'custom', :title => "Main", :rel => "stylesheet" %>
</head>
<body>
- <div class="entirebody">
+ <div class="entirebody">
<div id="content">
<% if flash[:notice] %>
<div id="notice"><%= flash[:notice] %></div>
diff --git a/app/views/request/_search_ahead.rhtml b/app/views/request/_search_ahead.rhtml
index b8ef7437e..9c49680c3 100644
--- a/app/views/request/_search_ahead.rhtml
+++ b/app/views/request/_search_ahead.rhtml
@@ -1,13 +1,12 @@
-<p>
- <div id="request_search_ahead_results">
+<div id="request_search_ahead_results">
<% if @xapian_requests.results.size > 0 %>
<h3><%= _("Possibly related requests:") %></h3>
<% end %>
<% for result in @xapian_requests.results %>
<%= render :partial => 'request/request_listing_short_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
<% end %>
- </div>
-</p>
-
-
+ <p>
+ <a id="body-site-search-link" target="_blank"><%= _("Or search in their website for this information.") %></a>
+ </p>
+</div>
diff --git a/app/views/request/new.rhtml b/app/views/request/new.rhtml
index 8dae8467a..355641b63 100644
--- a/app/views/request/new.rhtml
+++ b/app/views/request/new.rhtml
@@ -4,8 +4,16 @@
// Avoid triggering too often (on each keystroke) by using the debounce jQuery plugin:
// http://benalman.com/projects/jquery-throttle-debounce-plugin/
$("#typeahead_search").keypress($.debounce( 300, function() {
- $("#typeahead_response").load("<%=search_ahead_url%>?q="+encodeURI(this.value));
+ $("#typeahead_response").load("<%=search_ahead_url%>?q="+encodeURI(this.value), function() {
+ // When following links in typeahead results, open new tab/window
+ $("#typeahead_response a").attr("target","_blank");
+
+ // Update the public body site search link
+ $("#body-site-search-link").attr("href", "http://www.google.com/#q="+encodeURI($("#typeahead_search").val())+
+ "+site:<%= @info_request.public_body.calculated_home_page %>");
+ });
}));
+
});
</script>
@@ -84,6 +92,7 @@
<% end %>
)
</div>
+
<div id="typeahead_response">
</div>
</div>