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

This commit is contained in:
Raphael 2010-08-04 16:01:37 -07:00
commit e2c0ae2cee
7 changed files with 60 additions and 0 deletions

View file

@ -35,4 +35,19 @@ class PhotosController < ApplicationController
@photo = Photo.where(:id => params[:id]).first
@album = @photo.album
end
def edit
@photo= Photo.first(:id => params[:id])
@album = @photo.album
end
def update
@photo= Photo.first(:id => params[:id])
if @photo.update_attributes(params[:photo])
flash[:notice] = "Successfully updated photo."
redirect_to @photo
else
render :action => 'edit'
end
end
end

View file

@ -4,9 +4,11 @@ class Photo < Post
mount_uploader :image, ImageUploader
xml_accessor :remote_photo
xml_accessor :caption
xml_reader :album_id
key :album_id, ObjectId
key :caption, String
belongs_to :album, :class_name => 'Album'

View file

@ -0,0 +1,21 @@
%h1.big_text
.back
= link_to "⇧ #{@album.name}", album_path(@album)
= "Editing #{@photo.image}"
%div{:id => @photo.id}
#show_photo
= linked_scaled_photo @photo, @album
= form_for @photo do |p|
= p.text_field :caption, :value => @photo.caption
= p.submit
#content_bottom
.back
= link_to "⇧ #{@album.name}", album_path(@album)
-if mine? @album
.button.right
= link_to 'Delete Photo', @photo, :confirm => 'Are you sure?', :method => :delete

View file

@ -14,6 +14,9 @@
#show_photo
= linked_scaled_photo @photo, @album
.caption
= @photo.caption
#next_prev_links
= link_to_prev @photo, @album
|

View file

@ -264,6 +264,10 @@ ul.comment_set {
min-height: 200px; }
#show_photo img {
max-width: 100%; }
#show_photo .caption {
margin-top: 10px;
margin-bottom: 25px;
font-size: larger; }
#debug_info {
margin-top: 20px; }

View file

@ -319,6 +319,14 @@ ul.comment_set
img
:max-width 100%
.caption
:margin
:top 10px
:bottom 25px
:font
:size larger
#debug_info

View file

@ -36,6 +36,13 @@ describe Photo do
Photo.first.album.name.should == 'foo'
end
it 'should have a caption' do
@photo.image.store! File.open(@fixture_name)
@photo.caption = "cool story, bro"
@photo.save
Photo.first.caption.should == "cool story, bro"
end
it 'should remove its reference in user profile if it is referred' do
@photo.image.store! File.open(@fixture_name)
@photo.save