Merge branch 'master' of github.com:diaspora/diaspora_rails
This commit is contained in:
commit
e2c0ae2cee
7 changed files with 60 additions and 0 deletions
|
|
@ -35,4 +35,19 @@ class PhotosController < ApplicationController
|
||||||
@photo = Photo.where(:id => params[:id]).first
|
@photo = Photo.where(:id => params[:id]).first
|
||||||
@album = @photo.album
|
@album = @photo.album
|
||||||
end
|
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
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,11 @@ class Photo < Post
|
||||||
mount_uploader :image, ImageUploader
|
mount_uploader :image, ImageUploader
|
||||||
|
|
||||||
xml_accessor :remote_photo
|
xml_accessor :remote_photo
|
||||||
|
xml_accessor :caption
|
||||||
xml_reader :album_id
|
xml_reader :album_id
|
||||||
|
|
||||||
key :album_id, ObjectId
|
key :album_id, ObjectId
|
||||||
|
key :caption, String
|
||||||
|
|
||||||
|
|
||||||
belongs_to :album, :class_name => 'Album'
|
belongs_to :album, :class_name => 'Album'
|
||||||
|
|
|
||||||
21
app/views/photos/edit.html.haml
Normal file
21
app/views/photos/edit.html.haml
Normal 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
|
||||||
|
|
||||||
|
|
@ -14,6 +14,9 @@
|
||||||
#show_photo
|
#show_photo
|
||||||
= linked_scaled_photo @photo, @album
|
= linked_scaled_photo @photo, @album
|
||||||
|
|
||||||
|
.caption
|
||||||
|
= @photo.caption
|
||||||
|
|
||||||
#next_prev_links
|
#next_prev_links
|
||||||
= link_to_prev @photo, @album
|
= link_to_prev @photo, @album
|
||||||
|
|
|
|
||||||
|
|
|
||||||
|
|
@ -264,6 +264,10 @@ ul.comment_set {
|
||||||
min-height: 200px; }
|
min-height: 200px; }
|
||||||
#show_photo img {
|
#show_photo img {
|
||||||
max-width: 100%; }
|
max-width: 100%; }
|
||||||
|
#show_photo .caption {
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-bottom: 25px;
|
||||||
|
font-size: larger; }
|
||||||
|
|
||||||
#debug_info {
|
#debug_info {
|
||||||
margin-top: 20px; }
|
margin-top: 20px; }
|
||||||
|
|
|
||||||
|
|
@ -319,6 +319,14 @@ ul.comment_set
|
||||||
img
|
img
|
||||||
:max-width 100%
|
:max-width 100%
|
||||||
|
|
||||||
|
.caption
|
||||||
|
:margin
|
||||||
|
:top 10px
|
||||||
|
:bottom 25px
|
||||||
|
:font
|
||||||
|
:size larger
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#debug_info
|
#debug_info
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,13 @@ describe Photo do
|
||||||
Photo.first.album.name.should == 'foo'
|
Photo.first.album.name.should == 'foo'
|
||||||
end
|
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
|
it 'should remove its reference in user profile if it is referred' do
|
||||||
@photo.image.store! File.open(@fixture_name)
|
@photo.image.store! File.open(@fixture_name)
|
||||||
@photo.save
|
@photo.save
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue