aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/public_body_controller.rb2
-rw-r--r--app/controllers/request_controller.rb6
-rw-r--r--app/controllers/user_controller.rb58
3 files changed, 39 insertions, 27 deletions
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb
index 62229a441..c31134641 100644
--- a/app/controllers/public_body_controller.rb
+++ b/app/controllers/public_body_controller.rb
@@ -129,7 +129,7 @@ class PublicBodyController < ApplicationController
end
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
+ :order => "public_body_translations.name", :page => params[:page], :per_page => 100,
:conditions => conditions,
:joins => :translations
)
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index dad5e81cd..f3bbd6708 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -35,9 +35,8 @@ class RequestController < ApplicationController
# do nothing - as "authenticated?" has done the redirect to signin page for us
return
end
-
if !params[:query].nil?
- query = params[:query] + '*'
+ query = params[:query]
query = query.split(' ').join(' OR ') # XXX: HACK for OR instead of default AND!
@xapian_requests = perform_search([PublicBody], query, 'relevant', nil, 5)
end
@@ -815,7 +814,8 @@ class RequestController < ApplicationController
for message in info_request.incoming_messages
attachments = message.get_attachments_for_display
for attachment in attachments
- zipfile.get_output_stream(attachment.display_filename) { |f|
+ filename = "#{attachment.url_part_number}_#{attachment.display_filename}"
+ zipfile.get_output_stream(filename) { |f|
f.puts(attachment.body)
}
end
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index 96dbfba74..fc29a847c 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -23,7 +23,17 @@ class UserController < ApplicationController
redirect_to :url_name => MySociety::Format.simplify_url_part(params[:url_name], 'user', 32), :status => :moved_permanently
return
end
-
+ if params[:view].nil?
+ @show_requests = true
+ @show_profile = true
+ elsif params[:view] == 'profile'
+ @show_profile = true
+ @show_requests = false
+ elsif params[:view] == 'requests'
+ @show_profile = false
+ @show_requests = true
+ end
+
@display_user = User.find(:first, :conditions => [ "url_name = ? and email_confirmed = ?", params[:url_name], true ])
if not @display_user
raise ActiveRecord::RecordNotFound.new("user not found, url_name=" + params[:url_name])
@@ -34,31 +44,33 @@ class UserController < ApplicationController
# Use search query for this so can collapse and paginate easily
# XXX really should just use SQL query here rather than Xapian.
- begin
- requests_query = 'requested_by:' + @display_user.url_name
- comments_query = 'commented_by:' + @display_user.url_name
- if !params[:user_query].nil?
- requests_query += " " + params[:user_query]
- comments_query += " " + params[:user_query]
- @match_phrase = _("{{search_results}} matching '{{query}}'", :search_results => "", :query => params[:user_query])
- end
- @xapian_requests = perform_search([InfoRequestEvent], requests_query, 'newest', 'request_collapse')
- @xapian_comments = perform_search([InfoRequestEvent], comments_query, 'newest', nil)
-
- if (@page > 1)
- @page_desc = " (page " + @page.to_s + ")"
- else
- @page_desc = ""
+ if @show_requests
+ begin
+ requests_query = 'requested_by:' + @display_user.url_name
+ comments_query = 'commented_by:' + @display_user.url_name
+ if !params[:user_query].nil?
+ requests_query += " " + params[:user_query]
+ comments_query += " " + params[:user_query]
+ @match_phrase = _("{{search_results}} matching '{{query}}'", :search_results => "", :query => params[:user_query])
+ end
+ @xapian_requests = perform_search([InfoRequestEvent], requests_query, 'newest', 'request_collapse')
+ @xapian_comments = perform_search([InfoRequestEvent], comments_query, 'newest', nil)
+
+ if (@page > 1)
+ @page_desc = " (page " + @page.to_s + ")"
+ else
+ @page_desc = ""
+ end
+ rescue
+ @xapian_requests = nil
+ @xapian_comments = nil
end
- rescue
- @xapian_requests = nil
- @xapian_comments = nil
- end
- # Track corresponding to this page
- @track_thing = TrackThing.create_track_for_user(@display_user)
- @feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss], :has_json => true } ]
+ # Track corresponding to this page
+ @track_thing = TrackThing.create_track_for_user(@display_user)
+ @feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss], :has_json => true } ]
+ end
# All tracks for the user
if @is_you
@track_things = TrackThing.find(:all, :conditions => ["tracking_user_id = ? and track_medium = ?", @display_user.id, 'email_daily'], :order => 'created_at desc')