Merge branch 'master' of github.com:diaspora/diaspora

This commit is contained in:
maxwell 2010-11-26 16:10:56 -08:00
commit 119680d209
9 changed files with 28 additions and 20 deletions

View file

@ -34,6 +34,11 @@ class PhotosController < ApplicationController
def create
begin
if params[:photo][:aspect_ids] == "all"
params[:photo][:aspect_ids] = current_user.aspects.collect{|x| x.id}
end
params[:photo][:user_file] = file_handler(params)
@photo = current_user.build_post(:photo, params[:photo])
@ -41,7 +46,7 @@ class PhotosController < ApplicationController
if @photo.save
raise 'MongoMapper failed to catch a failed save' unless @photo.id
current_user.dispatch_post(@photo, :to => params[:photo][:to]) unless @photo.pending
current_user.dispatch_post(@photo, :to => params[:photo][:aspect_ids]) unless @photo.pending
respond_to do |format|
format.json{ render(:layout => false , :json => {"success" => true, "data" => @photo}.to_json )}
end

View file

@ -9,6 +9,11 @@ class StatusMessagesController < ApplicationController
respond_to :json, :only => :show
def create
if params[:status_message][:aspect_ids] == "all"
params[:status_message][:aspect_ids] = current_user.aspects.collect{|x| x.id}
end
photos = Photo.all(:id.in => [*params[:photos]], :diaspora_handle => current_user.person.diaspora_handle)
public_flag = params[:status_message][:public]
@ -21,10 +26,10 @@ class StatusMessagesController < ApplicationController
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])
current_user.dispatch_post(@status_message, :to => params[:status_message][:aspect_ids])
for photo in photos
current_user.dispatch_post(photo, :to => params[:status_message][:to])
current_user.dispatch_post(photo, :to => params[:status_message][:aspect_ids])
end
respond_to do |format|

View file

@ -21,8 +21,10 @@ class Post
key :diaspora_handle, String
key :user_refs, Integer, :default => 0
key :pending, Boolean, :default => false
key :aspect_ids, Array, :typecast => 'ObjectId'
many :comments, :class_name => 'Comment', :foreign_key => :post_id, :order => 'created_at ASC'
many :aspects, :in => :aspect_ids, :class_name => 'Aspect'
belongs_to :person, :class_name => 'Person'
timestamps!
@ -38,6 +40,7 @@ class Post
def self.instantiate params
new_post = self.new params.to_hash
new_post.person = params[:person]
new_post.aspect_ids = params[:aspect_ids]
new_post.public = params[:public]
new_post.pending = params[:pending]
new_post.diaspora_handle = new_post.person.diaspora_handle

View file

@ -6,7 +6,7 @@
function createUploader(){
var uploader = new qq.FileUploaderBasic({
element: document.getElementById('file-upload'),
params: {'photo' : {'pending' : 'true', 'to' : "#{aspect_id}"}, 'set_profile_image' : "#{set_profile_image if defined?(set_profile_image)}"},
params: {'photo' : {'pending' : 'true', 'aspect_ids' : "#{aspect_id}"}, 'set_profile_image' : "#{set_profile_image if defined?(set_profile_image)}"},
allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
action: "#{photos_path}",
debug: true,

View file

@ -10,7 +10,7 @@
- if post.public?
=t('the_world')
- else
- for aspect in current_user.aspects_with_post( post.id )
- for aspect in post.aspects
%li= link_to aspect.name, aspect
#person_nav_links

View file

@ -47,7 +47,7 @@
= status.label :message, t('.post_a_message_to', :aspect => (aspect == :all ? t('.all_contacts') : aspect))
= status.text_area :message, :rows => 2, :value => params[:prefill]
= status.hidden_field :to, :value => (aspect == :all ? aspect : aspect.id)
= status.hidden_field :aspect_ids, :value => (aspect == :all ? aspect : aspect.id)
.options_and_submit

View file

@ -2,16 +2,11 @@
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
- unless current_user.aspects.size == current_user.aspects_with_post(post.id).size
.reshare_pane
.reshare_pane
%span.reshare_button
= link_to t('.reshare'), "#"
%ul.reshare_box
- for aspect in current_user.aspects
- unless aspect.posts.include? post
%li.aspect_to_share= link_to aspect, :controller => "aspects", :action => "show", :id => aspect.id, :prefill => post.message
- else
.reshare_pane
%span.reshare_button
= link_to t('.reshare'), "#", :class => "inactive"

View file

@ -17,7 +17,7 @@
- if post.public?
%li= t('the_world')
- else
- for aspect in aspects.select{|a| a.post_ids.include?(post.id)}
- for aspect in post.aspects
%li= link_to aspect.name, aspect
.right

View file

@ -25,7 +25,7 @@ describe StatusMessagesController do
{:status_message =>{
:public =>"true",
:message =>"facebook, is that you?",
:to =>"#{aspect.id}"}}
:aspect_ids =>"#{aspect.id}"}}
}
it "doesn't overwrite person_id" do