aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/responsive/_global_style.scss4
-rw-r--r--app/assets/stylesheets/responsive/_lists_layout.scss6
-rw-r--r--app/helpers/public_body_helper.rb35
-rw-r--r--app/models/public_body.rb33
-rw-r--r--app/views/general/search.html.erb6
-rw-r--r--app/views/public_body/_body_listing_single.html.erb35
-rw-r--r--app/views/public_body/_search_ahead.html.erb4
-rw-r--r--app/views/public_body/show.html.erb40
-rw-r--r--app/views/public_body/view_email.html.erb2
-rw-r--r--app/views/request/new.html.erb6
10 files changed, 106 insertions, 65 deletions
diff --git a/app/assets/stylesheets/responsive/_global_style.scss b/app/assets/stylesheets/responsive/_global_style.scss
index 0ffa875ab..ef755c01e 100644
--- a/app/assets/stylesheets/responsive/_global_style.scss
+++ b/app/assets/stylesheets/responsive/_global_style.scss
@@ -116,7 +116,7 @@ dt + dd {
}
/* Notices to the user (usually on action completion) */
-#notice, #error {
+#notice, #error, .warning {
font-size:1em;
border-radius:3px;
margin:1em 0;
@@ -136,7 +136,7 @@ dt + dd {
background-color: lighten(#62b356, 23%);
}
-#error {
+#error, .warning {
background-color: lighten(#b05460, 23%);
}
diff --git a/app/assets/stylesheets/responsive/_lists_layout.scss b/app/assets/stylesheets/responsive/_lists_layout.scss
index 69237ae91..6a874e8fe 100644
--- a/app/assets/stylesheets/responsive/_lists_layout.scss
+++ b/app/assets/stylesheets/responsive/_lists_layout.scss
@@ -81,4 +81,8 @@
}
}
-
+/* .make-request-quick-button displays in the typeahead search results in the 'make request' process */
+.make-request-quick-button {
+ margin-bottom: 1em;
+ margin-top: -0.5em;
+}
diff --git a/app/helpers/public_body_helper.rb b/app/helpers/public_body_helper.rb
new file mode 100644
index 000000000..d8a5d57b5
--- /dev/null
+++ b/app/helpers/public_body_helper.rb
@@ -0,0 +1,35 @@
+module PublicBodyHelper
+
+ # Public: The reasons a request can't be made to a PublicBody
+ # The returned reasons are ordered by priority. For example, if the body no
+ # longer exists there is no reason to ask for its contact details if we don't
+ # have an email for it.
+ #
+ # public_body - Instance of a PublicBody
+ #
+ # Returns an Array
+ def public_body_not_requestable_reasons(public_body)
+ reasons = []
+
+ if public_body.defunct?
+ reasons.push _('This authority no longer exists, so you cannot make a request to it.')
+ end
+
+ if public_body.not_apply?
+ reasons.push _('Freedom of Information law does not apply to this authority, so you cannot make a request to it.')
+ end
+
+ unless public_body.has_request_email?
+ # Make the authority appear requestable to encourage users to help find
+ # the authroty's email address
+ msg = link_to _("Make a request to this authority"),
+ new_request_to_body_path(:url_name => public_body.url_name),
+ :class => "link_button_green"
+
+ reasons.push(msg)
+ end
+
+ reasons.compact
+ end
+
+end
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index b8163b07d..5e5b35c5b 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -235,39 +235,38 @@ class PublicBody < ActiveRecord::Base
return self.has_tag?('defunct')
end
- # Can an FOI (etc.) request be made to this body, and if not why not?
+ # Can an FOI (etc.) request be made to this body?
def is_requestable?
- if self.defunct?
- return false
- end
- if self.not_apply?
- return false
- end
- if self.request_email.nil?
- return false
- end
- return !self.request_email.empty? && self.request_email != 'blank'
+ has_request_email? && !defunct? && !not_apply?
end
+
# Strict superset of is_requestable?
def is_followupable?
- if self.request_email.nil?
- return false
- end
- return !self.request_email.empty? && self.request_email != 'blank'
+ has_request_email?
+ end
+
+ def has_request_email?
+ !request_email.blank? && request_email != 'blank'
end
+
# Also used as not_followable_reason
def not_requestable_reason
if self.defunct?
return 'defunct'
elsif self.not_apply?
return 'not_apply'
- elsif self.request_email.nil? or self.request_email.empty? or self.request_email == 'blank'
+ elsif !has_request_email?
return 'bad_contact'
else
- raise "requestable_failure_reason called with type that has no reason"
+ raise "not_requestable_reason called with type that has no reason"
end
end
+ def special_not_requestable_reason?
+ self.defunct? || self.not_apply?
+ end
+
+
class Version
def last_edit_comment_for_html_display
diff --git a/app/views/general/search.html.erb b/app/views/general/search.html.erb
index 4f9ef5b68..c5ff8e9fd 100644
--- a/app/views/general/search.html.erb
+++ b/app/views/general/search.html.erb
@@ -1,7 +1,5 @@
<% @show_tips = @xapian_requests.nil? || (@total_hits == 0) %>
-<% @include_request_link_in_authority_listing = true %>
-
<%= render :partial => 'localised_datepicker' %>
<% if @query.nil? %>
@@ -157,7 +155,9 @@
<div class="results_block">
<% for result in @xapian_bodies.results %>
- <%= render :partial => 'public_body/body_listing_single', :locals => { :public_body => result[:model] } %>
+ <%= render :partial => 'public_body/body_listing_single',
+ :locals => { :public_body => result[:model],
+ :request_link => true } %>
<% end %>
</div>
diff --git a/app/views/public_body/_body_listing_single.html.erb b/app/views/public_body/_body_listing_single.html.erb
index 91a07d09c..b343c20e1 100644
--- a/app/views/public_body/_body_listing_single.html.erb
+++ b/app/views/public_body/_body_listing_single.html.erb
@@ -1,6 +1,10 @@
-<% if @highlight_words.nil?
- @highlight_words = []
- end %>
+<%
+ if @highlight_words.nil?
+ @highlight_words = []
+ end
+
+ request_link = false unless defined?(request_link)
+%>
<div class="body_listing">
<span class="head">
@@ -16,23 +20,28 @@
<% end %>
<br>
<% end %>
- </span>
+ </span>
<span class="bottomline">
<%= n_('{{count}} request made.', '{{count}} requests made.', public_body.info_requests.size,
:count => public_body.info_requests.size) %>
- <% if !public_body.is_requestable? && public_body.not_requestable_reason != 'bad_contact' %>
- <% if public_body.not_requestable_reason == 'defunct' %>
- <%= _('Defunct.') %>
- <% end %>
- <% else %>
- <% if !@include_request_link_in_authority_listing.nil? %>
- <%= link_to _("Make your own request"), public_body_path(public_body) %>.
- <% end %>
- <% end %>
<br>
<span class="date_added">
<%= _("Added on {{date}}", :date => simple_date(public_body.created_at)) %>.
</span>
+ <br>
+ <% if public_body.special_not_requestable_reason? %>
+ <% if public_body.not_requestable_reason == 'not_apply' %>
+ <%= _('FOI law does not apply to this authority.')%>
+ <% elsif public_body.not_requestable_reason == 'defunct' %>
+ <%= _('Defunct.')%>
+ <% end %>
+ <% end %>
</span>
+
+ <% if request_link && !public_body.special_not_requestable_reason? %>
+ <div class="make-request-quick-button">
+ <%= link_to _("Make a request"), new_request_to_body_path(:url_name => public_body.url_name), :class => "link_button_green" %>
+ </div>
+ <% end %>
</div>
diff --git a/app/views/public_body/_search_ahead.html.erb b/app/views/public_body/_search_ahead.html.erb
index b5632bccd..b06ed5efa 100644
--- a/app/views/public_body/_search_ahead.html.erb
+++ b/app/views/public_body/_search_ahead.html.erb
@@ -7,7 +7,9 @@
<% end %>
<div id="authority_search_ahead_results">
<% for result in @xapian_requests.results %>
- <%= render :partial => 'public_body/body_listing_single', :locals => { :public_body => result[:model] } %>
+ <%= render :partial => 'public_body/body_listing_single',
+ :locals => { :public_body => result[:model],
+ :request_link => true } %>
<% end %>
</div>
<%= will_paginate WillPaginate::Collection.new(@page, @per_page, @xapian_requests.matches_estimated), :params => {:controller=>"request", :action => "select_authority"} %>
diff --git a/app/views/public_body/show.html.erb b/app/views/public_body/show.html.erb
index 403216c6c..e7c5fa2b6 100644
--- a/app/views/public_body/show.html.erb
+++ b/app/views/public_body/show.html.erb
@@ -39,36 +39,22 @@
<% end %>
</p>
- <% if @public_body.is_requestable? || @public_body.not_requestable_reason == 'bad_contact' %>
- <% if @public_body.has_notes? %>
- <p><%= @public_body.notes_as_html.html_safe %></p>
- <% end %>
- <% if @public_body.eir_only? %>
- <p><%= _('You can only request information about the environment from this authority.')%></p>
- <% end %>
- <% else %>
- <% if @public_body.not_requestable_reason == 'not_apply' %>
- <p><%= _('Freedom of Information law does not apply to this authority, so you cannot make
- a request to it.')%></p>
- <% elsif @public_body.not_requestable_reason == 'defunct' %>
- <p><%= _('This authority no longer exists, so you cannot make a request to it.')%></p>
- <% else %>
- <p><%= _('For an unknown reason, it is not possible to make a request to this authority.')%></p>
- <% end %>
- <% end %>
-
<div id="stepwise_make_request">
- <% if @public_body.is_requestable? || @public_body.not_requestable_reason == 'bad_contact' %>
- <%= link_to _("Make a request to this authority"), new_request_to_body_path(:url_name => @public_body.url_name), :class => "link_button_green" %>
- <% elsif @public_body.has_notes? %>
- <%= @public_body.notes_as_html.html_safe %>
- <% end %>
+ <% if @public_body.has_notes? %>
+ <%= @public_body.notes_as_html.html_safe %>
+ <% end %>
- <% if @public_body.override_request_email %>
- <p>
- <%= _("<strong>Note:</strong> Because we're testing, requests are being sent to {{email}} rather than to the actual authority.", :email => @public_body.override_request_email) %>
- </p>
+ <% if @public_body.is_requestable? %>
+ <% if @public_body.eir_only? %>
+ <p><%= _('You can only request information about the environment from this authority.')%></p>
<% end %>
+
+ <%= link_to _("Make a request to this authority"),
+ new_request_to_body_path(:url_name => @public_body.url_name),
+ :class => "link_button_green" %>
+ <% else %>
+ <p><%= public_body_not_requestable_reasons(@public_body).first %></p>
+ <% end %>
</div>
</div>
diff --git a/app/views/public_body/view_email.html.erb b/app/views/public_body/view_email.html.erb
index 5f4bc95f4..399caaa61 100644
--- a/app/views/public_body/view_email.html.erb
+++ b/app/views/public_body/view_email.html.erb
@@ -24,7 +24,7 @@
</p>
<p>
- <% if @public_body.is_requestable? || @public_body.not_requestable_reason != 'bad_contact' %>
+ <% if @public_body.has_request_email? %>
<%= raw(_('If the address is wrong, or you know a better address, please <a href="{{url}}">contact us</a>.', :url => help_contact_path.html_safe)) %>
<% else %>
<%= raw(_(' If you know the address to use, then please <a href="{{url}}">send it to us</a>.
diff --git a/app/views/request/new.html.erb b/app/views/request/new.html.erb
index 51224129e..688d9e87b 100644
--- a/app/views/request/new.html.erb
+++ b/app/views/request/new.html.erb
@@ -99,6 +99,12 @@
</div>
<% end %>
+ <% if @info_request.public_body.override_request_email %>
+ <div class="warning">
+ <%= _("<strong>Note:</strong> Because we're testing, requests are being sent to {{email}} rather than to the actual authority.", :email => @info_request.public_body.override_request_email) %>
+ </div>
+ <% end %>
+
<% if @info_request.public_body.eir_only? %>
<h3><%= _('Please ask for environmental information only') %></h3>