Merge branch 'master' of github.com:diaspora/diaspora
This commit is contained in:
commit
119680d209
9 changed files with 28 additions and 20 deletions
|
|
@ -34,6 +34,11 @@ class PhotosController < ApplicationController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
begin
|
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)
|
params[:photo][:user_file] = file_handler(params)
|
||||||
|
|
||||||
@photo = current_user.build_post(:photo, params[:photo])
|
@photo = current_user.build_post(:photo, params[:photo])
|
||||||
|
|
@ -41,7 +46,7 @@ class PhotosController < ApplicationController
|
||||||
if @photo.save
|
if @photo.save
|
||||||
raise 'MongoMapper failed to catch a failed save' unless @photo.id
|
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|
|
respond_to do |format|
|
||||||
format.json{ render(:layout => false , :json => {"success" => true, "data" => @photo}.to_json )}
|
format.json{ render(:layout => false , :json => {"success" => true, "data" => @photo}.to_json )}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,11 @@ class StatusMessagesController < ApplicationController
|
||||||
respond_to :json, :only => :show
|
respond_to :json, :only => :show
|
||||||
|
|
||||||
def create
|
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)
|
photos = Photo.all(:id.in => [*params[:photos]], :diaspora_handle => current_user.person.diaspora_handle)
|
||||||
|
|
||||||
public_flag = params[:status_message][:public]
|
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
|
raise 'MongoMapper failed to catch a failed save' unless @status_message.id
|
||||||
|
|
||||||
@status_message.photos += photos unless photos.nil?
|
@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
|
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
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,10 @@ class Post
|
||||||
key :diaspora_handle, String
|
key :diaspora_handle, String
|
||||||
key :user_refs, Integer, :default => 0
|
key :user_refs, Integer, :default => 0
|
||||||
key :pending, Boolean, :default => false
|
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 :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'
|
belongs_to :person, :class_name => 'Person'
|
||||||
|
|
||||||
timestamps!
|
timestamps!
|
||||||
|
|
@ -38,6 +40,7 @@ class Post
|
||||||
def self.instantiate params
|
def self.instantiate params
|
||||||
new_post = self.new params.to_hash
|
new_post = self.new params.to_hash
|
||||||
new_post.person = params[:person]
|
new_post.person = params[:person]
|
||||||
|
new_post.aspect_ids = params[:aspect_ids]
|
||||||
new_post.public = params[:public]
|
new_post.public = params[:public]
|
||||||
new_post.pending = params[:pending]
|
new_post.pending = params[:pending]
|
||||||
new_post.diaspora_handle = new_post.person.diaspora_handle
|
new_post.diaspora_handle = new_post.person.diaspora_handle
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
function createUploader(){
|
function createUploader(){
|
||||||
var uploader = new qq.FileUploaderBasic({
|
var uploader = new qq.FileUploaderBasic({
|
||||||
element: document.getElementById('file-upload'),
|
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'],
|
allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
|
||||||
action: "#{photos_path}",
|
action: "#{photos_path}",
|
||||||
debug: true,
|
debug: true,
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
- if post.public?
|
- if post.public?
|
||||||
=t('the_world')
|
=t('the_world')
|
||||||
- else
|
- else
|
||||||
- for aspect in current_user.aspects_with_post( post.id )
|
- for aspect in post.aspects
|
||||||
%li= link_to aspect.name, aspect
|
%li= link_to aspect.name, aspect
|
||||||
|
|
||||||
#person_nav_links
|
#person_nav_links
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
= status.label :message, t('.post_a_message_to', :aspect => (aspect == :all ? t('.all_contacts') : aspect))
|
= 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.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
|
.options_and_submit
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,11 @@
|
||||||
-# licensed under the Affero General Public License version 3 or later. See
|
-# licensed under the Affero General Public License version 3 or later. See
|
||||||
-# the COPYRIGHT file.
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
- unless current_user.aspects.size == current_user.aspects_with_post(post.id).size
|
.reshare_pane
|
||||||
.reshare_pane
|
%span.reshare_button
|
||||||
%span.reshare_button
|
= link_to t('.reshare'), "#"
|
||||||
= link_to t('.reshare'), "#"
|
|
||||||
|
%ul.reshare_box
|
||||||
|
- for aspect in current_user.aspects
|
||||||
|
%li.aspect_to_share= link_to aspect, :controller => "aspects", :action => "show", :id => aspect.id, :prefill => post.message
|
||||||
|
|
||||||
%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"
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
- if post.public?
|
- if post.public?
|
||||||
%li= t('the_world')
|
%li= t('the_world')
|
||||||
- else
|
- else
|
||||||
- for aspect in aspects.select{|a| a.post_ids.include?(post.id)}
|
- for aspect in post.aspects
|
||||||
%li= link_to aspect.name, aspect
|
%li= link_to aspect.name, aspect
|
||||||
|
|
||||||
.right
|
.right
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ describe StatusMessagesController do
|
||||||
{:status_message =>{
|
{:status_message =>{
|
||||||
:public =>"true",
|
:public =>"true",
|
||||||
:message =>"facebook, is that you?",
|
:message =>"facebook, is that you?",
|
||||||
:to =>"#{aspect.id}"}}
|
:aspect_ids =>"#{aspect.id}"}}
|
||||||
}
|
}
|
||||||
|
|
||||||
it "doesn't overwrite person_id" do
|
it "doesn't overwrite person_id" do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue