diff options
-rw-r--r-- | app/controllers/request_controller.rb | 12 | ||||
-rw-r--r-- | app/models/info_request.rb | 3 | ||||
-rw-r--r-- | app/models/track_thing.rb | 6 | ||||
-rw-r--r-- | app/models/user.rb | 4 | ||||
-rw-r--r-- | app/views/request/show.rhtml | 12 | ||||
-rw-r--r-- | todo.txt | 3 |
6 files changed, 26 insertions, 14 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 693352c91..b16fc93cf 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -4,7 +4,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: request_controller.rb,v 1.71 2008-04-04 01:59:40 francis Exp $ +# $Id: request_controller.rb,v 1.72 2008-04-04 02:29:09 francis Exp $ class RequestController < ApplicationController @@ -30,6 +30,11 @@ class RequestController < ApplicationController @last_info_request_event_id = last_event.nil? ? nil : last_event.id @new_responses_count = @events_needing_description.select {|i| i.event_type == 'response'}.size + # Sidebar stuff + @info_requests_same_user_same_body = InfoRequest.find(:all, :order => "created_at desc", + :conditions => ["prominence = 'normal' and user_id = ? and public_body_id = ? and id <> ?", @info_request.user_id, @info_request.public_body_id, @info_request.id], + :limit => 5) + # Already tracking? @track_thing = TrackThing.create_track_for_request(@info_request) if @user @@ -37,11 +42,6 @@ class RequestController < ApplicationController else @existing_track = nil end - - # Sidebar stuff - @info_requests_same_user_same_body = InfoRequest.find(:all, :order => "created_at desc", - :conditions => ["prominence = 'normal' and user_id = ? and public_body_id = ? and id <> ?", @info_request.user_id, @info_request.public_body_id, @info_request.id], - :limit => 5) end def list diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 2ec8ead1f..a1f2dcd7e 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -22,7 +22,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: info_request.rb,v 1.81 2008-04-04 01:44:41 francis Exp $ +# $Id: info_request.rb,v 1.82 2008-04-04 02:29:09 francis Exp $ require 'digest/sha1' @@ -40,6 +40,7 @@ class InfoRequest < ActiveRecord::Base has_many :incoming_messages has_many :info_request_events has_many :user_info_request_sent_alerts + has_many :track_things, :order => 'created_at desc' # user described state (also update in info_request_event, admin_request/edit.rhtml) validates_inclusion_of :described_state, :in => [ diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb index c71dd6f4c..778252c53 100644 --- a/app/models/track_thing.rb +++ b/app/models/track_thing.rb @@ -21,16 +21,16 @@ # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: track_thing.rb,v 1.6 2008-04-04 01:59:40 francis Exp $ +# $Id: track_thing.rb,v 1.7 2008-04-04 02:29:09 francis Exp $ class TrackThing < ActiveRecord::Base - belongs_to :user, :foreign_key => 'tracking_user_id' + belongs_to :tracking_user, :class_name => 'User' validates_presence_of :track_query validates_presence_of :track_type belongs_to :info_request belongs_to :public_body - belongs_to :user, :foreign_key => 'tracked_user_id' + belongs_to :tracked_user, :class_name => 'User' has_many :track_things_sent_emails diff --git a/app/models/user.rb b/app/models/user.rb index 3d2ae91d3..ca72ea254 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -21,7 +21,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: user.rb,v 1.46 2008-04-04 01:44:41 francis Exp $ +# $Id: user.rb,v 1.47 2008-04-04 02:29:09 francis Exp $ require 'digest/sha1' @@ -36,7 +36,7 @@ class User < ActiveRecord::Base has_many :info_requests has_many :user_info_request_sent_alerts has_many :post_redirects - has_many :track_things, :foreign_key => 'tracking_user_id' + has_many :track_things, :foreign_key => 'tracking_user_id', :order => 'created_at desc' attr_accessor :password_confirmation validates_confirmation_of :password, :message =>"^Please enter the same password twice" diff --git a/app/views/request/show.rhtml b/app/views/request/show.rhtml index 7c6a020a8..6e9cad82f 100644 --- a/app/views/request/show.rhtml +++ b/app/views/request/show.rhtml @@ -66,7 +66,17 @@ </div> <div id="request_sidebar"> - <h2>Follow this request</h2> + <% if @info_request.track_things.size > 0 %> + <h2>People following this request</h2> + <ul> + <% for track_thing in @info_request.track_things %> + <li><%=user_link(track_thing.tracking_user)%></li> + <% end %> + </ul> + <% else %> + <h2>Follow this request</h2> + <% end %> + <p> <% if @existing_track %> You are already tracking this request. @@ -4,7 +4,6 @@ Add unsubscribe / manage tracks page. Link from email Link from user page Link from "already tracking" text -Show on request who is tracking it Improve "you are now tracking this request!" flash @@ -63,6 +62,8 @@ Wrapping long URLs in emails breaks the h off http off the beginning nastily Use :order in the info_request.events belongs_to clause instead of each time it is queried Also sort user.info_requests for user pages +Also see in request_controller.rb: @info_request_events.sort! { |a,b| a.created_at <=> b.created_at } +Go through all has_many and pick something sane Offer search on 404s |