photos do not require an album. uploading files on a user's photos#index page will post to all aspects.
This commit is contained in:
parent
2b4e3e3a41
commit
a7df1bca68
13 changed files with 46 additions and 41 deletions
|
|
@ -16,10 +16,12 @@ class PhotosController < ApplicationController
|
|||
|
||||
@photos = current_user.visible_posts(:_type => "Photo", :person_id => @person.id)
|
||||
@albums = current_user.visible_posts(:_type => "Album", :person_id => @person.id)
|
||||
|
||||
@aspect = :photos
|
||||
end
|
||||
|
||||
def create
|
||||
album = current_user.find_visible_post_by_id( params[:album_id] )
|
||||
album = current_user.find_visible_post_by_id( params[:photo][:album_id] )
|
||||
|
||||
begin
|
||||
|
||||
|
|
@ -45,9 +47,9 @@ class PhotosController < ApplicationController
|
|||
|
||||
##############
|
||||
|
||||
params[:user_file] = file
|
||||
params[:photo][:user_file] = file
|
||||
|
||||
@photo = current_user.post(:photo, params)
|
||||
@photo = current_user.post(:photo, params[:photo])
|
||||
|
||||
respond_to do |format|
|
||||
format.json{render(:layout => false , :json => {"success" => true, "data" => @photo}.to_json )}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
class PhotoAlbumValidator < ActiveModel::Validator
|
||||
def validate(document)
|
||||
unless document.album.person_id == document.person_id
|
||||
document.errors[:base] << "You can't post photos to that album"
|
||||
unless document.album.nil? || document.album.person_id == document.person_id
|
||||
document.errors[:base] << "You post photos to that album"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -27,7 +27,6 @@ class Photo < Post
|
|||
|
||||
timestamps!
|
||||
|
||||
validates_presence_of :album
|
||||
validates_with PhotoAlbumValidator
|
||||
|
||||
before_destroy :ensure_user_picture
|
||||
|
|
|
|||
|
|
@ -144,8 +144,7 @@ class User
|
|||
|
||||
######## Posting ########
|
||||
def post(class_name, options = {})
|
||||
if class_name == :photo
|
||||
raise ArgumentError.new("No album_id given") unless options[:album_id]
|
||||
if class_name == :photo && !options[:album_id].to_s.empty?
|
||||
aspect_ids = aspects_with_post(options[:album_id])
|
||||
aspect_ids.map! { |aspect| aspect.id }
|
||||
else
|
||||
|
|
|
|||
|
|
@ -4,15 +4,15 @@
|
|||
|
||||
.album{:id => post.id, :class => ("mine" if current_user.owns?(post))}
|
||||
%div.name
|
||||
= link_to post.name, object_path(post, :aspect => @aspect)
|
||||
= link_to post.name, album_path(post)
|
||||
|
||||
%div.time
|
||||
by
|
||||
= link_to ((current_user.person == post.person)? t('.you') : post.person.real_name), person_path(post.person)
|
||||
%br
|
||||
= link_to(how_long_ago(post), object_path(post, :aspect => @aspect))
|
||||
= link_to(how_long_ago(post), album_path(post))
|
||||
|
||||
%div.image_cycle
|
||||
- for photo in post.photos[0..3]
|
||||
= link_to (image_tag photo.url(:thumb_large)), album_path(post, :aspect => @aspect)
|
||||
= link_to (image_tag photo.url(:thumb_large)), album_path(post)
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
="#{t('.updated')} #{how_long_ago(@album)}"
|
||||
|
||||
-if current_user.owns? @album
|
||||
=render 'photos/new_photo'
|
||||
= render 'photos/new_photo', :album_id => @album.id, :aspect_id => nil
|
||||
= link_to t('.edit_album'), edit_album_path(@album), :class => 'button'
|
||||
|
||||
.album_id{:id => @album.id, :style => "display:hidden;"}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
function createUploader(){
|
||||
var uploader = new qq.FileUploader({
|
||||
element: document.getElementById('file-upload'),
|
||||
params: {'album_id' : "#{@album.id}"},
|
||||
params: {'photo' : { 'album_id' : "#{album_id}", 'to' : "#{aspect_id}"}},
|
||||
allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
|
||||
action: "#{photos_path}"
|
||||
});
|
||||
|
|
|
|||
|
|
@ -22,8 +22,11 @@
|
|||
.right
|
||||
= link_to t('.delete'), photo_path(post), :confirm => t('.are_you_sure'), :method => :delete, :remote => true, :class => "delete"
|
||||
|
||||
=t('.posted_a_new_photo_to')
|
||||
= link_to post.album.name, object_path(post.album)
|
||||
- if !post.album_id.nil?
|
||||
=t('.posted_a_new_photo_to')
|
||||
= link_to post.album.name, object_path(post.album)
|
||||
- else
|
||||
posted a photo
|
||||
|
||||
%br
|
||||
%br
|
||||
|
|
|
|||
|
|
@ -10,16 +10,20 @@
|
|||
});
|
||||
|
||||
|
||||
= render 'shared/author_info', :person => @person
|
||||
.span-24.last{:style=>"position:relative;"}
|
||||
= render 'shared/author_info', :person => @person
|
||||
|
||||
%ul#breadcrumb
|
||||
%li= link_to "#{@person.profile.first_name}'s Photos", person_photos_path(@person)
|
||||
.right
|
||||
= link_to "+ Add photos", '#add_photo_pane', :class => "add_photo_button button"
|
||||
|
||||
%ul#breadcrumb
|
||||
%li= link_to "#{@person.profile.first_name}'s Photos", person_photos_path(@person)
|
||||
|
||||
.span-24.last
|
||||
#thumbnails
|
||||
- for photo in @photos
|
||||
.image_thumb
|
||||
= link_to (image_tag photo.url(:thumb_medium)), object_path(photo)
|
||||
= link_to (image_tag photo.url(:thumb_medium)), photo_path(photo)
|
||||
|
||||
.span-24.last
|
||||
%h3
|
||||
|
|
@ -32,3 +36,8 @@
|
|||
%h3
|
||||
Albums
|
||||
|
||||
|
||||
.span-24.last
|
||||
#add_photo_pane
|
||||
= render "photos/new_photo", :album_id => nil, :aspect_id => :all
|
||||
|
||||
|
|
|
|||
|
|
@ -9,15 +9,17 @@
|
|||
= render 'shared/author_info', :person => @photo.person, :post => @photo
|
||||
|
||||
%ul#breadcrumb
|
||||
%li= link_to "#{@album.person.profile.first_name}'s Photos", person_photos_path(@photo.person)
|
||||
%li= link_to @album.name, album_path(@album)
|
||||
%li= link_to "#{@photo.person.profile.first_name}'s Photos", person_photos_path(@photo.person)
|
||||
- if !@photo.album_id.nil?
|
||||
%li= link_to @album.name, album_path(@album)
|
||||
%li= @photo.caption
|
||||
|
||||
= link_to "<< #{t('.prev')}", url_to_prev(@photo, @album), :rel => 'prefetch', :id => "prev_photo"
|
||||
|
|
||||
= link_to "#{t('.full_size')}", @photo.url
|
||||
|
|
||||
= link_to "#{t('.next')} >>", url_to_next(@photo, @album), :rel => 'prefetch', :id => "next_photo"
|
||||
- if @photo.album
|
||||
= link_to "<< #{t('.prev')}", url_to_prev(@photo, @album), :rel => 'prefetch', :id => "prev_photo"
|
||||
|
|
||||
= link_to "#{t('.full_size')}", @photo.url
|
||||
|
|
||||
= link_to "#{t('.next')} >>", url_to_next(@photo, @album), :rel => 'prefetch', :id => "next_photo"
|
||||
|
||||
.span-14.append-1.last
|
||||
%div{:data=>{:guid=>@photo.id}}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ $(document).ready(function(){
|
|||
$(".add_aspect_button").fancybox({ 'titleShow' : false , 'hideOnOverlayClick' : false });
|
||||
$(".add_request_button").fancybox({ 'titleShow': false , 'hideOnOverlayClick' : false });
|
||||
$(".invite_user_button").fancybox({ 'titleShow': false , 'hideOnOverlayClick' : false });
|
||||
$(".add_request_button").fancybox({ 'titleShow': false , 'hideOnOverlayClick' : false });
|
||||
$(".add_photo_button").fancybox({ 'titleShow': false , 'hideOnOverlayClick' : false });
|
||||
$(".remove_person_button").fancybox({ 'titleShow': false , 'hideOnOverlayClick' : false });
|
||||
$(".question_mark").fancybox({ 'titleShow': false , 'hideOnOverlayClick' : false });
|
||||
|
||||
|
|
|
|||
|
|
@ -208,6 +208,10 @@ header
|
|||
.avatar
|
||||
:border-radius 5px
|
||||
|
||||
img
|
||||
:-webkit-box-shadow 0 1px 2px #666
|
||||
:border-radius 5px
|
||||
|
||||
|
||||
.from
|
||||
:font
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
.button, .button_set
|
||||
:font
|
||||
:family "Lucida Grande", sans-serif
|
||||
:style normal
|
||||
:weight bold
|
||||
|
||||
:display inline
|
||||
|
||||
|
|
@ -37,8 +37,6 @@
|
|||
:-webkit-box-shadow 0 1px 1px #eee
|
||||
:-moz-box-shadow 0 1px 1px #eee
|
||||
|
||||
:font-weight normal
|
||||
|
||||
:color #666
|
||||
|
||||
&:hover
|
||||
|
|
|
|||
|
|
@ -52,17 +52,6 @@ describe Photo do
|
|||
binary.should == fixture_binary
|
||||
end
|
||||
|
||||
it 'must have an album' do
|
||||
photo = Photo.new()
|
||||
photo.person = @user.person
|
||||
photo.image = File.open(@fixture_name)
|
||||
photo.save
|
||||
photo.valid?.should be false
|
||||
photo.album = @album
|
||||
photo.save
|
||||
photo.reload.album.name.should == 'foo'
|
||||
end
|
||||
|
||||
it 'should have a caption' do
|
||||
@photo.image.store! File.open(@fixture_name)
|
||||
@photo.caption = "cool story, bro"
|
||||
|
|
|
|||
Loading…
Reference in a new issue