there is a job to process photos and it is called from the controller
This commit is contained in:
parent
516b620148
commit
b987b47f5f
10 changed files with 42 additions and 8 deletions
|
|
@ -56,6 +56,7 @@ class StatusMessagesController < ApplicationController
|
|||
end
|
||||
end
|
||||
photos.update_all(:pending => false, :public => public_flag)
|
||||
photos.each{|x| x.queue_post_process}
|
||||
end
|
||||
|
||||
if request.env['HTTP_REFERER'].include?("people")
|
||||
|
|
|
|||
13
app/models/jobs/process_photo.rb
Normal file
13
app/models/jobs/process_photo.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
|
||||
module Job
|
||||
class ProcessPhoto < Base
|
||||
@queue = :photos
|
||||
def self.perform_delegate(photo_id)
|
||||
Photo.find(photo_id).image.post_process
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -85,6 +85,10 @@ class Photo < Post
|
|||
{:thumb_url => url(:thumb_medium), :id => id, :album_id => nil}
|
||||
end
|
||||
|
||||
def queue_processing_job
|
||||
Resque.enqueue(Job::ProcessPhoto, self.id)
|
||||
end
|
||||
|
||||
def mutable?
|
||||
true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
|
||||
%h5
|
||||
= t('aspects.manage.add_a_new_contact')
|
||||
= info_text(t('.enter_a_diaspora_username'))
|
||||
|
|
@ -22,4 +21,3 @@
|
|||
%li.error.hidden
|
||||
#message
|
||||
= link_to t('.know_email'), new_user_invitation_path
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
= render 'shared/reshare', :aspects => reshare_aspects, :post => post
|
||||
= link_to image_tag('deletelabel.png'), status_message_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete", :title => t('delete')
|
||||
|
||||
.thumb_small= person_image_link(post.author, :size => :thumb_small)
|
||||
= person_image_link(post.author, :size => :thumb_small)
|
||||
|
||||
.content
|
||||
.from
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@
|
|||
- if photos.size > 1
|
||||
- if photos.size >= 8
|
||||
- for photo in photos[1..8]
|
||||
.thumb_small= link_to (image_tag photo.url(:thumb_small)), photo_path(photo)
|
||||
= link_to (image_tag photo.url(:thumb_small), :class => 'thumb_small'), photo_path(photo)
|
||||
- else
|
||||
- for photo in photos[1..photos.size]
|
||||
.thumb_small= link_to (image_tag photo.url(:thumb_small)), photo_path(photo)
|
||||
= link_to (image_tag photo.url(:thumb_small), :class => 'thumb_small'), photo_path(photo)
|
||||
= markdownify(post.text, :youtube_maps => post[:youtube_titles])
|
||||
|
||||
- else
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
= markdownify(@status_message.text, :youtube_maps => @status_message[:youtube_titles])
|
||||
|
||||
- for photo in @status_message.photos
|
||||
.thumb_small= link_to (image_tag photo.url(:thumb_small)), photo.url(:thumb_medium)
|
||||
= link_to (image_tag photo.url(:thumb_small), :class => 'thumb_small'), photo.url(:thumb_medium)
|
||||
|
||||
.info
|
||||
%span.time
|
||||
|
|
|
|||
|
|
@ -1071,7 +1071,7 @@ label
|
|||
img.thumb_small
|
||||
:max-height 50px
|
||||
:max-width 50px
|
||||
img.thumb_mediumimg
|
||||
img.thumb_medium
|
||||
:max-height 100px
|
||||
:max-width 100px
|
||||
img.thumb_large
|
||||
|
|
@ -1079,7 +1079,7 @@ img.thumb_large
|
|||
:max-width 300px
|
||||
img.scaled_full
|
||||
:max-height 700px
|
||||
:width 700px
|
||||
:max-width 700px
|
||||
|
||||
#thumbnails
|
||||
a
|
||||
|
|
|
|||
11
spec/models/jobs/process_photo_spec.rb
Normal file
11
spec/models/jobs/process_photo_spec.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Job::ProcessPhoto do
|
||||
it 'calls post_process on an image uploader' do
|
||||
photo = mock()
|
||||
photo.should_receive(:image).and_return(photo)
|
||||
photo.should_receive(:post_process)
|
||||
Photo.should_receive(:find).with(1).and_return(photo)
|
||||
Job::ProcessPhoto.perform(1)
|
||||
end
|
||||
end
|
||||
|
|
@ -155,6 +155,13 @@ describe Photo do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#queue_processing_job' do
|
||||
it 'should queue a resque job to process the images' do
|
||||
Resque.should_receive(:enqueue).with(Job::ProcessPhoto, @photo.id)
|
||||
@photo.queue_processing_job
|
||||
end
|
||||
end
|
||||
|
||||
context "deletion" do
|
||||
before do
|
||||
@status_message = @user.build_post(:status_message, :text => "", :to => @aspect.id)
|
||||
|
|
|
|||
Loading…
Reference in a new issue