DG MS trying to finish statusmessage refactor
This commit is contained in:
parent
ea7bdfde28
commit
769c0e1055
8 changed files with 11 additions and 12 deletions
|
|
@ -142,11 +142,7 @@ GEM
|
|||
childprocess (0.1.4)
|
||||
ffi (~> 0.6.3)
|
||||
closure-compiler (0.3.3)
|
||||
<<<<<<< HEAD
|
||||
cloudfiles (1.4.10)
|
||||
=======
|
||||
cloudfiles (1.4.9)
|
||||
>>>>>>> DG MS; status messages can now have photos.
|
||||
mime-types (>= 1.16)
|
||||
columnize (0.3.2)
|
||||
configuration (1.2.0)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class AspectsController < ApplicationController
|
|||
respond_to :json, :only => :show
|
||||
|
||||
def index
|
||||
@posts = current_user.visible_posts.paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC'
|
||||
@posts = current_user.visible_posts(:_type => "StatusMessage").paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC'
|
||||
@aspect = :all
|
||||
|
||||
if current_user.getting_started == true
|
||||
|
|
@ -51,7 +51,7 @@ class AspectsController < ApplicationController
|
|||
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
|
||||
else
|
||||
@aspect_contacts = @aspect.contacts
|
||||
@posts = current_user.visible_posts( :by_members_of => @aspect ).paginate :per_page => 15, :order => 'created_at DESC'
|
||||
@posts = current_user.visible_posts( :by_members_of => @aspect, :_type => "StatusMessage" ).paginate :per_page => 15, :order => 'created_at DESC'
|
||||
respond_with @aspect
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class PeopleController < ApplicationController
|
|||
@pending_request = current_user.request_for(@person)
|
||||
end
|
||||
|
||||
@posts = current_user.visible_posts(:person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC'
|
||||
@posts = current_user.visible_posts(:person_id => @person.id, :_type => "StatusMessage").paginate :page => params[:page], :order => 'created_at DESC'
|
||||
respond_with @person, :locals => {:post_type => :all}
|
||||
|
||||
else
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ class StatusMessagesController < ApplicationController
|
|||
if @status_message.save(:safe => true)
|
||||
raise 'MongoMapper failed to catch a failed save' unless @status_message.id
|
||||
|
||||
@status_message.photos += photos unless photos.nil?
|
||||
current_user.dispatch_post(@status_message, :to => params[:status_message][:to])
|
||||
|
||||
@status_message.photos += photos unless photos.nil?
|
||||
for photo in photos
|
||||
current_user.dispatch_post(photo, :to => params[:status_message][:to])
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ class Photo < Post
|
|||
key :remote_photo_path
|
||||
key :remote_photo_name
|
||||
key :random_string
|
||||
|
||||
key :status_message_id, ObjectId
|
||||
|
||||
timestamps!
|
||||
|
||||
|
|
@ -25,7 +27,6 @@ class Photo < Post
|
|||
|
||||
before_destroy :ensure_user_picture
|
||||
|
||||
|
||||
def ownership_of_status_message
|
||||
message = StatusMessage.find_by_id(self.status_message_id)
|
||||
if status_message_id && message
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ class Post
|
|||
include ApplicationHelper
|
||||
include ROXML
|
||||
include Diaspora::Webhooks
|
||||
include Diaspora::Socketable
|
||||
|
||||
xml_reader :_id
|
||||
xml_reader :diaspora_handle
|
||||
xml_reader :public
|
||||
xml_reader :created_at
|
||||
|
||||
|
||||
key :public, Boolean, :default => false
|
||||
|
||||
key :diaspora_handle, String
|
||||
|
|
|
|||
|
|
@ -3,13 +3,14 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
class StatusMessage < Post
|
||||
include Diaspora::Socketable
|
||||
|
||||
validates_length_of :message, :maximum => 1000, :message => "please make your status messages less than 1000 characters"
|
||||
xml_name :status_message
|
||||
xml_reader :message
|
||||
|
||||
key :message, String
|
||||
many :photos, :class => Photo
|
||||
many :photos, :class => Photo, :foreign_key => :status_message_id
|
||||
validates_presence_of :message
|
||||
|
||||
attr_accessible :message
|
||||
|
|
|
|||
|
|
@ -13,10 +13,11 @@ module Diaspora
|
|||
def visible_posts( opts = {} )
|
||||
opts[:order] ||= 'created_at DESC'
|
||||
opts[:pending] ||= false
|
||||
opts[:_type] ||= ["StatusMessage","Photo"]
|
||||
|
||||
if opts[:by_members_of] && opts[:by_members_of] != :all
|
||||
aspect = self.aspects.find_by_id( opts[:by_members_of].id )
|
||||
aspect.posts.find_all_by_pending(opts[:pending], :order => opts[:order])
|
||||
aspect.posts.find_all_by_pending_and__type(opts[:pending], opts[:_type], :order => opts[:order])
|
||||
else
|
||||
self.raw_visible_posts.all(opts)
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue