diff options
-rw-r--r-- | Gemfile | 4 | ||||
-rw-r--r-- | Gemfile.lock | 10 | ||||
-rw-r--r-- | app/models/info_request.rb | 10 | ||||
-rw-r--r-- | app/views/general/search.html.erb | 1 | ||||
-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/_sidebar.html.erb | 1 | ||||
-rw-r--r-- | app/views/request/list.html.erb | 7 | ||||
-rw-r--r-- | app/views/request/show.html.erb | 19 | ||||
-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/integration/alaveteli_dsl.rb | 17 |
15 files changed, 118 insertions, 120 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/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/public_body/show.html.erb b/app/views/public_body/show.html.erb index 5ac637a78..1dad1deb6 100644 --- a/app/views/public_body/show.html.erb +++ b/app/views/public_body/show.html.erb @@ -12,6 +12,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> @@ -91,7 +92,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/_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 3fb66c773..78e022aa9 100644 --- a/app/views/request/show.html.erb +++ b/app/views/request/show.html.erb @@ -56,19 +56,20 @@ <p id="request_status" class="request_icon_line icon_<%= @info_request.calculate_status %>"> <% if @info_request.awaiting_description %> <% if @is_owning_user && !@info_request.is_external? && !@render_to_file %> - <%= _('Please <strong>answer the question above</strong> so we know whether the ')%> - <%= MySociety::Format.fancy_pluralize(@new_responses_count, 'recent response contains', 'recent responses contain') %> <%= _('useful information.') %> + <%= n_('Please <strong>answer the question above</strong> so we know whether the recent response contains useful information.', + 'Please <strong>answer the question above</strong> so we know whether the recent responses contain useful information.', + @new_responses_count) %> <% else %> <%= _('This request has an <strong>unknown status</strong>.') %> <% if @old_unclassified %> - <%= _('We\'re waiting for someone to read') %> - <%= MySociety::Format.fancy_pluralize(@new_responses_count, 'a recent response', 'recent responses') %> - <%= _('and update the status accordingly. Perhaps <strong>you</strong> might like to help out by doing that?') %> + <%= n_("We're waiting for someone to read a recent response and update the status accordingly. Perhaps <strong>you</strong> might like to help out by doing that?", + "We're waiting for someone to read recent responses and update the status accordingly. Perhaps <strong>you</strong> might like to help out by doing that?", + @new_responses_count) %> <% else %> - <%= _('We\'re waiting for') %> - <%= user_link_for_request(@info_request) %> <%= _('to read') %> - <%= MySociety::Format.fancy_pluralize(@new_responses_count, 'a recent response', 'recent responses') %> - <%= _('and update the status.') %> + <%= n_("We're waiting for {{user}} to read a recent response and update the status.", + "We're waiting for {{user}} to read recent responses and update the status.", + @new_responses_count, + :user => user_link_for_request(@info_request)) %> <% end %> <% end %> <% elsif @status == 'waiting_response' %> 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/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 |