diff options
-rw-r--r-- | Gemfile | 4 | ||||
-rw-r--r-- | Gemfile.lock | 10 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 16 | ||||
-rw-r--r-- | app/models/info_request.rb | 10 | ||||
-rw-r--r-- | app/views/general/search.html.erb | 1 | ||||
-rw-r--r-- | app/views/info_request_batch/_batch_sent.html.erb | 18 | ||||
-rw-r--r-- | app/views/info_request_batch/show.html.erb | 5 | ||||
-rw-r--r-- | app/views/public_body/show.html.erb | 4 | ||||
-rw-r--r-- | app/views/request/_request_filter_form.html.erb | 59 | ||||
-rw-r--r-- | app/views/request/_request_search_form.html.erb | 35 | ||||
-rw-r--r-- | app/views/request/_request_sent.html.erb | 19 | ||||
-rw-r--r-- | app/views/request/_sidebar.html.erb | 1 | ||||
-rw-r--r-- | app/views/request/list.html.erb | 7 | ||||
-rw-r--r-- | app/views/request/show.html.erb | 5 | ||||
-rw-r--r-- | app/views/track/_rss_feed.html.erb | 4 | ||||
-rw-r--r-- | app/views/track/_tracking_links.html.erb | 5 | ||||
-rw-r--r-- | app/views/user/show.html.erb | 1 | ||||
-rw-r--r-- | app/views/user/sign.html.erb | 61 | ||||
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 15 | ||||
-rw-r--r-- | spec/integration/alaveteli_dsl.rb | 17 |
20 files changed, 170 insertions, 127 deletions
@@ -2,7 +2,7 @@ source 'https://rubygems.org' gem 'rails', '3.2.21' -gem 'pg' +gem 'pg', '~> 0.17.1' # New gem releases aren't being done. master is newer and supports Rails > 3.0 gem 'acts_as_versioned', :git => 'git://github.com/technoweenie/acts_as_versioned.git' @@ -14,7 +14,7 @@ gem 'foundation-rails' gem 'icalendar', '1.4.3' gem 'jquery-rails', '~> 3.0.4' gem 'jquery-ui-rails' -gem 'json' +gem 'json', '~> 1.8.1' gem 'holidays' gem 'iso_country_codes' gem 'mahoro' diff --git a/Gemfile.lock b/Gemfile.lock index 3e640ad77..4a41129f2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -135,7 +135,7 @@ GEM thor (>= 0.14, < 2.0) jquery-ui-rails (4.1.0) railties (>= 3.1.0) - json (1.8.1) + json (1.8.2) libv8 (3.16.14.3) linecache (0.46) rbx-require-relative (> 0.0.4) @@ -170,7 +170,7 @@ GEM paper_trail (2.7.2) activerecord (~> 3.0) railties (~> 3.0) - pg (0.15.1) + pg (0.17.1) polyglot (0.3.5) quiet_assets (1.0.2) railties (>= 3.1, < 5.0) @@ -204,7 +204,7 @@ GEM rbx-require-relative (0.0.9) rdoc (3.12.2) json (~> 1.4) - recaptcha (0.3.5) + recaptcha (0.3.6) ref (1.0.5) rest-client (1.6.7) mime-types (>= 1.16) @@ -314,7 +314,7 @@ DEPENDENCIES iso_country_codes jquery-rails (~> 3.0.4) jquery-ui-rails - json + json (~> 1.8.1) locale mahoro mailcatcher @@ -323,7 +323,7 @@ DEPENDENCIES net-purge newrelic_rpm nokogiri - pg + pg (~> 0.17.1) quiet_assets rack rails (= 3.2.21) diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index f1076f0bc..081c14d7f 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -245,13 +245,8 @@ class RequestController < ApplicationController :body => params[:outgoing_message][:body], :public_bodies => @public_bodies, :user => authenticated_user) - flash[:notice] = _("<p>Your {{law_used_full}} requests will be <strong>sent</strong> shortly!</p> - <p><strong>We will email you</strong> when they have been sent. - We will also email you when there is a response to any of them, or after {{late_number_of_days}} working days if the authorities still haven't - replied by then.</p> - <p>If you write about these requests (for example in a forum or a blog) please link to this page.</p>", - :law_used_full=>@info_request.law_used_full, - :late_number_of_days => AlaveteliConfiguration::reply_late_after_days) + + flash[:batch_sent] = true redirect_to info_request_batch_path(@info_request_batch) end @@ -379,12 +374,7 @@ class RequestController < ApplicationController ) end - flash[:notice] = _("<p>Your {{law_used_full}} request has been <strong>sent on its way</strong>!</p> - <p><strong>We will email you</strong> when there is a response, or after {{late_number_of_days}} working days if the authority still hasn't - replied by then.</p> - <p>If you write about this request (for example in a forum or a blog) please link to this page, and add an - annotation below telling people about your writing.</p>",:law_used_full=>@info_request.law_used_full, - :late_number_of_days => AlaveteliConfiguration::reply_late_after_days) + flash[:request_sent] = true redirect_to show_new_request_path(:url_title => @info_request.url_title) end diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 2b60e13d8..8d455e488 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -210,16 +210,6 @@ class InfoRequest < ActiveRecord::Base OLD_AGE_IN_DAYS = 21.days - def after_initialize - if self.described_state.nil? - self.described_state = 'waiting_response' - end - # FOI or EIR? - if !self.public_body.nil? && self.public_body.eir_only? - self.law_used = 'eir' - end - end - def visible_comments self.comments.find(:all, :conditions => 'visible') end diff --git a/app/views/general/search.html.erb b/app/views/general/search.html.erb index 3914a2f30..96c91b791 100644 --- a/app/views/general/search.html.erb +++ b/app/views/general/search.html.erb @@ -131,6 +131,7 @@ <div id="header_right"> <h2><%= _('Track this search')%></h2> <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => false, :location => 'main' } %> + <%= render :partial => 'track/rss_feed', :locals => { :track_thing => @track_thing, :location => 'main' } %> </div> <% end %> diff --git a/app/views/info_request_batch/_batch_sent.html.erb b/app/views/info_request_batch/_batch_sent.html.erb new file mode 100644 index 000000000..1bf51962f --- /dev/null +++ b/app/views/info_request_batch/_batch_sent.html.erb @@ -0,0 +1,18 @@ +<div id="notice"> + <p> + <%= _("Your requests will be <strong>sent</strong> shortly!") %> + </p> + + <p> + <%= _("<strong>We will email you</strong> when they have been sent. " \ + "We will also email you when there is a response to any of them, or " \ + "after {{late_number_of_days}} working days if the authorities still" \ + "haven't replied by then.", + :late_number_of_days => AlaveteliConfiguration::reply_late_after_days) %> + </p> + + <p> + <%= _("If you write about these requests (for example in a forum or a blog) " \ + "please link to this page.") %> + </p> +</div> diff --git a/app/views/info_request_batch/show.html.erb b/app/views/info_request_batch/show.html.erb index 8bb834b3c..b5db4ac52 100644 --- a/app/views/info_request_batch/show.html.erb +++ b/app/views/info_request_batch/show.html.erb @@ -1,4 +1,9 @@ <% @title = _("{{title}} - a batch request", :title => @info_request_batch.title) %> + +<% if flash[:batch_sent] %> + <%= render :partial => 'batch_sent' } %> +<% end %> + <div class="info_request_batch_intro"> <h1><%= @title %></h1> <% if @info_request_batch.sent_at %> diff --git a/app/views/public_body/show.html.erb b/app/views/public_body/show.html.erb index a9fd8443a..403216c6c 100644 --- a/app/views/public_body/show.html.erb +++ b/app/views/public_body/show.html.erb @@ -23,6 +23,7 @@ </p> <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => false, :location => 'sidebar' } %> + <%= render :partial => 'track/rss_feed', :locals => { :track_thing => @track_thing, :location => 'sidebar' } %> <%= render :partial => 'more_info', :locals => { :public_body => @public_body } %> </div> @@ -102,7 +103,8 @@ <a name="results"></a> <% if @public_body.info_requests.size > 4 %> - <%= render :partial => 'request/request_filter_form' %> + <%= render :partial => 'request/request_search_form', + :locals => { :after_form_fields => render(:partial => 'request/request_filter_form') } %> <% end %> <% end %> diff --git a/app/views/request/_request_filter_form.html.erb b/app/views/request/_request_filter_form.html.erb index 090db01df..0983c8c57 100644 --- a/app/views/request/_request_filter_form.html.erb +++ b/app/views/request/_request_filter_form.html.erb @@ -1,41 +1,14 @@ -<%= render :partial => 'general/localised_datepicker' %> - -<div id="list-filter"> - <%= form_tag(request.path, :method => "get", :id=>"filter_requests_form") do %> - <div class="list-filter-item"> - <%= label_tag(:query, _("Keywords"), :class=>"form_label title") %> - <%= text_field_tag(:query, params[:query]) %> - </div> -<% if false # don't think we want this, but leaving as an example %> - <div class="list-filter-item"> - <%= _("Search for words in:") %> <br/> - <% [["sent", _("messages from users")], - ["response", _("messages from authorities")], - ["comment", _("comments")]].each_with_index do |item, index| - variety, title = item %> - - <%= check_box_tag "request_variety[]", variety, params[:request_variety].nil? ? true : params[:request_variety].include?(variety), :id => "request_variety_#{index}" %> - <%= label_tag("request_variety_#{index}", title) %> <br/> - <% end %> - </div> -<% end %> - <div class="list-filter-item"> - <%= label_tag(:query, _("Made between"), :class=>"form_label title") %> - <%= text_field_tag(:request_date_after, params[:request_date_after], {:class => "use-datepicker", :size => 10}) %> - <%= label_tag(:query, _("and"), :class=>"form_label") %> - <%= text_field_tag(:request_date_before, params[:request_date_before], {:class => "use-datepicker", :size => 10}) %> - </div> - <div class="list-filter-item"> - <h3 class="title"><%= _("Showing") %></h3> - <div class="filter-request-types"> - <% statuses = [["all", _("all requests")], - ["successful", _("successful requests")], - ["unsuccessful", _("unsuccessful requests")], - ["awaiting", _("unresolved requests")]] %> - <% for status, label in statuses %> - <% if params[:view] != status %> - <% if params[:controller] == "public_body" %> - <%= link_to label, url_for(:controller => "public_body", :action => "show", :view => status, :url_name => @public_body.url_name) + "?" + request.query_string + '#results' %> +<div class="list-filter-item"> + <h3 class="title"><%= _("Showing") %></h3> + <div class="filter-request-types"> + <% statuses = [["all", _("all requests")], + ["successful", _("successful requests")], + ["unsuccessful", _("unsuccessful requests")], + ["awaiting", _("unresolved requests")]] %> + <% statuses.each do |status, label| %> + <% if params[:view] != status %> + <% if params[:controller] == "public_body" %> + <%= link_to label, url_for(:controller => "public_body", :action => "show", :view => status, :url_name => @public_body.url_name) + "?" + request.query_string + '#results' %> <% else %> <%= link_to label, url_for(:controller => "request", :action => "list", :view => status) + "?" + request.query_string + '#results' %> <% end %> @@ -43,12 +16,6 @@ <%= label %> <% end %> <%= "|" unless statuses.last[0] == status %> - <% end %> - </div> - </div> - - <div class="list-filter-item"> - <%= submit_tag(_("Search")) %> - </div> -<% end %> + <% end %> + </div> </div> diff --git a/app/views/request/_request_search_form.html.erb b/app/views/request/_request_search_form.html.erb new file mode 100644 index 000000000..3f2f66950 --- /dev/null +++ b/app/views/request/_request_search_form.html.erb @@ -0,0 +1,35 @@ +<%= render :partial => 'general/localised_datepicker' %> + +<div id="list-filter"> + <%= form_tag(request.path, :method => "get", :id=>"filter_requests_form") do %> + <div class="list-filter-item"> + <%= label_tag(:query, _("Keywords"), :class=>"form_label title") %> + <%= text_field_tag(:query, params[:query]) %> + </div> +<% if false # don't think we want this, but leaving as an example %> + <div class="list-filter-item"> + <%= _("Search for words in:") %> <br/> + <% [["sent", _("messages from users")], + ["response", _("messages from authorities")], + ["comment", _("comments")]].each_with_index do |item, index| + variety, title = item %> + + <%= check_box_tag "request_variety[]", variety, params[:request_variety].nil? ? true : params[:request_variety].include?(variety), :id => "request_variety_#{index}" %> + <%= label_tag("request_variety_#{index}", title) %> <br/> + <% end %> + </div> +<% end %> + <div class="list-filter-item"> + <%= label_tag(:query, _("Made between"), :class=>"form_label title") %> + <%= text_field_tag(:request_date_after, params[:request_date_after], {:class => "use-datepicker", :size => 10}) %> + <%= label_tag(:query, _("and"), :class=>"form_label") %> + <%= text_field_tag(:request_date_before, params[:request_date_before], {:class => "use-datepicker", :size => 10}) %> + </div> + + <%= after_form_fields if defined?(after_form_fields) -%> + + <div class="list-filter-item"> + <%= submit_tag(_("Search")) %> + </div> +<% end %> +</div> diff --git a/app/views/request/_request_sent.html.erb b/app/views/request/_request_sent.html.erb new file mode 100644 index 000000000..5ce6f5317 --- /dev/null +++ b/app/views/request/_request_sent.html.erb @@ -0,0 +1,19 @@ +<div id="notice"> + <p> + <%= _("Your {{law_used_full}} request has been <strong>sent on its way</strong>!", + :law_used_full => @info_request.law_used_full) %> + </p> + + <p> + <%= _("<strong>We will email you</strong> when there is a response, or after " \ + "{{late_number_of_days}} working days if the authority still hasn't " \ + "replied by then.", + :late_number_of_days => AlaveteliConfiguration.reply_late_after_days) %> + </p> + + <p> + <%= _("If you write about this request (for example in a forum or a blog) " \ + "please link to this page, and add an annotation below telling people " \ + "about your writing.") %> + </p> +</div> diff --git a/app/views/request/_sidebar.html.erb b/app/views/request/_sidebar.html.erb index 0f7965ffa..0d81ef111 100644 --- a/app/views/request/_sidebar.html.erb +++ b/app/views/request/_sidebar.html.erb @@ -10,6 +10,7 @@ :count => follower_count) %> </p> <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => @info_request.user && @info_request.user == @user, :location => 'sidebar' } %> + <%= render :partial => 'track/rss_feed', :locals => { :track_thing => @track_thing, :location => 'sidebar' } %> </div> <% if @info_request.described_state != "attention_requested" %> <h2><%= _('Offensive? Unsuitable?') %></h2> diff --git a/app/views/request/list.html.erb b/app/views/request/list.html.erb index a465f03ba..75cb463ef 100644 --- a/app/views/request/list.html.erb +++ b/app/views/request/list.html.erb @@ -1,13 +1,14 @@ - <div id="header_left"> - <h1><%=@title%></h1> - <%= render :partial => 'request/request_filter_form' %> + <h1><%= @title %></h1> + <%= render :partial => 'request/request_search_form', + :locals => { :after_form_fields => render(:partial => 'request/request_filter_form') } %> </div> <div id="header_right"> <h2><%= _("Follow these requests") %></h2> <% if @track_thing %> <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => false, :location => 'main' } %> + <%= render :partial => 'track/rss_feed', :locals => { :track_thing => @track_thing, :location => 'main' } %> <% end %> </div> diff --git a/app/views/request/show.html.erb b/app/views/request/show.html.erb index 89a4c53b8..78e022aa9 100644 --- a/app/views/request/show.html.erb +++ b/app/views/request/show.html.erb @@ -2,6 +2,11 @@ :title => h(@info_request.title), :public_body => (@info_request.public_body.name)) %> +<% if flash[:request_sent] %> + <%= render :partial => 'request_sent', + :locals => { :info_request => @info_request } %> +<% end %> + <% if @info_request.prominence == 'hidden' %> <p id="hidden_request"> <%= _('This request has prominence \'hidden\'. You can only see it because you are logged diff --git a/app/views/track/_rss_feed.html.erb b/app/views/track/_rss_feed.html.erb new file mode 100644 index 000000000..4be46ffa9 --- /dev/null +++ b/app/views/track/_rss_feed.html.erb @@ -0,0 +1,4 @@ +<div class="feed_link feed_link_<%= location %>"> + <%= link_to image_tag('feed-16.png', :alt => "RSS icon"), do_track_path(track_thing, 'feed') %> + <%= link_to (location == 'sidebar' ? _('RSS feed of updates') : _('RSS feed')), do_track_path(track_thing, 'feed') %> +</div> diff --git a/app/views/track/_tracking_links.html.erb b/app/views/track/_tracking_links.html.erb index 5419ec605..8e0b07167 100644 --- a/app/views/track/_tracking_links.html.erb +++ b/app/views/track/_tracking_links.html.erb @@ -19,11 +19,6 @@ <%= link_to _("Follow"), do_track_path(track_thing), :class => "link_button_green" %> <% end %> </div> - - <div class="feed_link feed_link_<%=location%>"> - <%= link_to image_tag('feed-16.png', :alt => "RSS icon"), do_track_path(track_thing, 'feed') %> - <%= link_to (location == 'sidebar' ? _('RSS feed of updates') : _('RSS feed')), do_track_path(track_thing, 'feed') %> - </div> <% end %> diff --git a/app/views/user/show.html.erb b/app/views/user/show.html.erb index 51882b8ef..7c8d52568 100644 --- a/app/views/user/show.html.erb +++ b/app/views/user/show.html.erb @@ -34,6 +34,7 @@ <% if !@track_thing.nil? %> <h2><%= _('Track this person')%></h2> <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => false, :location => 'sidebar' } %> + <%= render :partial => 'track/rss_feed', :locals => { :track_thing => @track_thing, :location => 'sidebar' } %> <% end %> <% if !@xapian_requests.nil? %> <h2><%= _('On this page')%></h2> diff --git a/app/views/user/sign.html.erb b/app/views/user/sign.html.erb index e8c5d5a58..5536e6c73 100644 --- a/app/views/user/sign.html.erb +++ b/app/views/user/sign.html.erb @@ -1,52 +1,51 @@ - <% if !@post_redirect.nil? && @post_redirect.reason_params[:user_name] %> <% @title = _("Sign in") %> <div id="sign_alone"> - <p id="sign_in_reason"> - <% if @post_redirect.reason_params[:web].empty? %> - <%= _('Please sign in as ')%><%= link_to h(@post_redirect.reason_params[:user_name]), @post_redirect.reason_params[:user_url] %>. - <% else %> - <%= @post_redirect.reason_params[:web] %>, - <%= _('please sign in as ')%><%= link_to h(@post_redirect.reason_params[:user_name]), @post_redirect.reason_params[:user_url] %>. - <% end %> - </p> - <% if @post_redirect.post_params["controller"] == "admin_general" %> - <% unless AlaveteliConfiguration::disable_emergency_user %> - <p id="superuser_message"><%= _("Don't have a superuser account yet?") %> <%= link_to _("Sign in as the emergency user"), @post_redirect.uri + "?emergency=1" %></p> + <p id="sign_in_reason"> + <% if @post_redirect.reason_params[:web].empty? %> + <%= _('Please sign in as ')%><%= link_to h(@post_redirect.reason_params[:user_name]), @post_redirect.reason_params[:user_url] %>. + <% else %> + <%= @post_redirect.reason_params[:web] %>, + <%= _('please sign in as ')%><%= link_to h(@post_redirect.reason_params[:user_name]), @post_redirect.reason_params[:user_url] %>. <% end %> - <% end %> + </p> - <%= render :partial => 'signin', :locals => { :sign_in_as_existing_user => true } %> + <% if @post_redirect.post_params["controller"] == "admin_general" %> + <% unless AlaveteliConfiguration::disable_emergency_user %> + <p id="superuser_message"><%= _("Don't have a superuser account yet?") %> <%= link_to _("Sign in as the emergency user"), @post_redirect.uri + "?emergency=1" %></p> + <% end %> + <% end %> + <%= render :partial => 'signin', :locals => { :sign_in_as_existing_user => true } %> </div> - <% else %> <% @title = _('Sign in or make a new account') %> <div id="sign_together"> - <% if !@post_redirect.nil? %> - <p id="sign_in_reason"> - <% if @post_redirect.reason_params[:web].empty? %> - <%= _('Please sign in or make a new account.') %> - <% else %> - <%= _('{{reason}}, please sign in or make a new account.', :reason => @post_redirect.reason_params[:web]) %> - <% end %> - </p> - <% end %> + <% if !@post_redirect.nil? %> + <p id="sign_in_reason"> + <% if @post_redirect.reason_params[:web].empty? %> + <%= _('Please sign in or make a new account.') %> + <% else %> + <%= _('{{reason}}, please sign in or make a new account.', :reason => @post_redirect.reason_params[:web]) %> + <% end %> + </p> + <% end %> <div id="left_half"> - <h1><%= _('Sign in') %></h1> - <%= render :partial => 'signin', :locals => { :sign_in_as_existing_user => false } %> + <h1><%= _('Sign up') %></h1> + <%= render :partial => 'signup' %> </div> + <div id="middle_strip"> - <%= _('- or -') %> + <%= _('- or -') %> </div> + <div id="right_half"> - <h1><%= _('Sign up') %></h1> - <%= render :partial => 'signup' %> + <h1><%= _('Sign in') %></h1> + <%= render :partial => 'signin', :locals => { :sign_in_as_existing_user => false } %> </div> + <div style="clear:both"></div> </div> - <% end %> - diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 1a2992611..02237b29d 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -1087,6 +1087,16 @@ describe RequestController, "when creating a new request" do response.redirect_url.should =~ /request\/why_is_your_quango_called_gerald\/new$/ end + it "sets the request_sent flash to true if successful" do + session[:user_id] = @user.id + post :new, :info_request => { :public_body_id => @body.id, + :title => "Why is your quango called Geraldine?", :tag_string => "" }, + :outgoing_message => { :body => "This is a silly letter. It is too short to be interesting." }, + :submitted_new_request => 1, :preview => 0 + + expect(flash[:request_sent]).to be_true + end + it "should give an error if the same request is submitted twice" do session[:user_id] = @user.id @@ -2568,10 +2578,9 @@ describe RequestController, "#new_batch" do assigns[:existing_batch].should_not be_nil end - it 'should display a success notice' do + it 'sets the batch_sent flash to true' do make_request - notice_text = "<p>Your Freedom of Information requests will be <strong>sent</strong> shortly!" - flash[:notice].should match notice_text + expect(flash[:batch_sent]).to be_true end end diff --git a/spec/integration/alaveteli_dsl.rb b/spec/integration/alaveteli_dsl.rb index 1d56abbdf..b408bc4c6 100644 --- a/spec/integration/alaveteli_dsl.rb +++ b/spec/integration/alaveteli_dsl.rb @@ -33,15 +33,16 @@ def login(user) sess.reset! sess.extend(AlaveteliDsl) - if user.is_a? User - u = user - else - u = users(user) - end + u = user.is_a?(User) ? user : users(user) + sess.visit signin_path - sess.fill_in "Your e-mail:", :with => u.email - sess.fill_in "Password:", :with => "jonespassword" - sess.click_button "Sign in" + + sess.within '#signin_form' do + sess.fill_in "Your e-mail:", :with => u.email + sess.fill_in "Password:", :with => "jonespassword" + sess.click_button "Sign in" + end + assert sess.session[:user_id] == u.id end end |