Add venue_photos model and venue_photos admin controller in order to add more images to Venues and allow to delete it.

Show the additional photos in splash. Added fancybox gem for zoom when click on the additional photo.

fix #777
This commit is contained in:
David Sedeño 2016-02-13 17:12:03 +01:00
parent 2034c0f965
commit 7c0cd30dda
13 changed files with 85 additions and 7 deletions

View file

@ -15,6 +15,9 @@ module Admin
@venue = @conference.build_venue(venue_params)
if @venue.save
if params[:venue_photos]
create_additional_photos(@venue, params[:venue_photos])
end
redirect_to admin_conference_venue_path,
notice: 'Venue was successfully created.'
else
@ -24,6 +27,9 @@ module Admin
def update
if @venue.update_attributes(venue_params)
if params[:venue_photos]
create_additional_photos(@venue, params[:venue_photos])
end
redirect_to(admin_conference_venue_path(conference_id: @conference.short_title),
notice: 'Venue was successfully updated.')
else
@ -46,5 +52,11 @@ module Admin
def venue_params
params.require(:venue).permit(:name, :street, :postalcode, :city, :country, :longitude, :latitude, :description, :website, :photo, :lodgings_attributes, :conference_id)
end
def create_additional_photos(venue, photos)
photos.each { |photo|
venue.venue_photos.create(photo: photo )
}
end
end
end