Skip to content
Extraits de code Groupes Projets
Valider b987b47f rédigé par maxwell's avatar maxwell
Parcourir les fichiers

there is a job to process photos and it is called from the controller

parent 516b6201
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -56,6 +56,7 @@ class StatusMessagesController < ApplicationController ...@@ -56,6 +56,7 @@ class StatusMessagesController < ApplicationController
end end
end end
photos.update_all(:pending => false, :public => public_flag) photos.update_all(:pending => false, :public => public_flag)
photos.each{|x| x.queue_post_process}
end end
if request.env['HTTP_REFERER'].include?("people") if request.env['HTTP_REFERER'].include?("people")
......
# 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 ...@@ -85,6 +85,10 @@ class Photo < Post
{:thumb_url => url(:thumb_medium), :id => id, :album_id => nil} {:thumb_url => url(:thumb_medium), :id => id, :album_id => nil}
end end
def queue_processing_job
Resque.enqueue(Job::ProcessPhoto, self.id)
end
def mutable? def mutable?
true true
end end
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
-# 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.
%h5 %h5
= t('aspects.manage.add_a_new_contact') = t('aspects.manage.add_a_new_contact')
= info_text(t('.enter_a_diaspora_username')) = info_text(t('.enter_a_diaspora_username'))
...@@ -22,4 +21,3 @@ ...@@ -22,4 +21,3 @@
%li.error.hidden %li.error.hidden
#message #message
= link_to t('.know_email'), new_user_invitation_path = link_to t('.know_email'), new_user_invitation_path
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
= render 'shared/reshare', :aspects => reshare_aspects, :post => post = 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') = 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 .content
.from .from
......
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
- if photos.size > 1 - if photos.size > 1
- if photos.size >= 8 - if photos.size >= 8
- for photo in photos[1..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 - else
- for photo in photos[1..photos.size] - 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]) = markdownify(post.text, :youtube_maps => post[:youtube_titles])
- else - else
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
= markdownify(@status_message.text, :youtube_maps => @status_message[:youtube_titles]) = markdownify(@status_message.text, :youtube_maps => @status_message[:youtube_titles])
- for photo in @status_message.photos - 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 .info
%span.time %span.time
......
...@@ -1071,7 +1071,7 @@ label ...@@ -1071,7 +1071,7 @@ label
img.thumb_small img.thumb_small
:max-height 50px :max-height 50px
:max-width 50px :max-width 50px
img.thumb_mediumimg img.thumb_medium
:max-height 100px :max-height 100px
:max-width 100px :max-width 100px
img.thumb_large img.thumb_large
...@@ -1079,7 +1079,7 @@ img.thumb_large ...@@ -1079,7 +1079,7 @@ img.thumb_large
:max-width 300px :max-width 300px
img.scaled_full img.scaled_full
:max-height 700px :max-height 700px
:width 700px :max-width 700px
#thumbnails #thumbnails
a a
......
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 ...@@ -155,6 +155,13 @@ describe Photo do
end end
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 context "deletion" do
before do before do
@status_message = @user.build_post(:status_message, :text => "", :to => @aspect.id) @status_message = @user.build_post(:status_message, :text => "", :to => @aspect.id)
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter