MS fixed log view; also, now pagination is now working, check out the new method which returns plucky queries instead of arrays

This commit is contained in:
maxwell 2010-09-06 17:46:09 +02:00
parent 9a4edc419c
commit 919d7d23c0
5 changed files with 18 additions and 9 deletions

View file

@ -12,15 +12,11 @@ class PeopleController < ApplicationController
def show
@person = current_user.visible_person_by_id(params[:id])
@profile = @person.profile
@groups_with_person = current_user.groups_with_person(@person)
@groups_dropdown_array = current_user.groups.collect{|x| [x.to_s, x.id]}
@posts = Post.where(:person_id => @person.id, :_id.in => current_user.visible_post_ids).paginate :page => params[:page], :order => 'created_at DESC'
@posts = current_user.posts_visible_to_me(:from => @person).paginate :page => params[:page], :order => 'created_at DESC'
@latest_status_message = current_user.raw_visible_posts.find_all_by__type_and_person_id("StatusMessage", params[:id]).last
@post_count = @posts.count
respond_with @person
end

View file

@ -61,6 +61,18 @@ class User
false
end
##querying with permissions
def posts_visible_to_me(opts ={})
if opts[:from].class == Person
Post.where(:person_id => opts[:from].id, :_id.in => self.visible_post_ids)
elsif opts[:from].class == Group
Post.where(:_id.in => opts[:from].post_ids) unless opts[:from].user != self
else
Post.where(:_id.in => self.visible_post_ids)
end
end
######## Posting ########
def post(class_name, options = {})
options[:person] = self.person
@ -166,7 +178,7 @@ class User
###### Receiving #######
def receive xml
object = Diaspora::Parser.from_xml(xml)
Rails.logger.debug("Receiving object:\n#{object.inspect}")
Rails.logger.debug("Receiving object for #{self.real_name}:\n#{object.inspect}")
Rails.logger.debug("From: #{object.person.inspect}") if object.person
raise "In receive for #{self.real_name}, signature was not valid on: #{object.inspect}" unless object.signature_valid?

View file

@ -18,7 +18,7 @@
%i= "friends since: #{how_long_ago(@person)}"
%li
= form_tag move_friend_path
= select :to, :to, @groups_dropdown_array, :selected_value => @groups_with_person.first.id
= select :to, :to, @groups_dropdown_array, :selected => @groups_with_person.first.id
= hidden_field_tag :from, :from, :value => @groups_with_person.first.id
= hidden_field_tag :friend_id, :friend_id, :value => @person.id
= submit_tag "save"

View file

@ -0,0 +1 @@
= @log.to_s

View file

@ -3,7 +3,7 @@ require 'config/environment'
host = "localhost:3000"
url = "http://#{host}/"
# Create seed user
user = User.create!( :email => "tom@tom.joindiaspora.com",
user = User.instantiate!( :email => "tom@tom.joindiaspora.com",
:password => "evankorth",
:person => Person.new(
:email => "tom@tom.joindiaspora.com",
@ -12,7 +12,7 @@ user = User.create!( :email => "tom@tom.joindiaspora.com",
)
user.person.save!
user2 = User.create!( :email => "korth@tom.joindiaspora.com",
user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com",
:password => "evankorth",
:person => Person.new( :email => "korth@tom.joindiaspora.com",
:url => url,