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:
parent
2034c0f965
commit
7c0cd30dda
13 changed files with 85 additions and 7 deletions
15
app/controllers/admin/venue_photos_controller.rb
Normal file
15
app/controllers/admin/venue_photos_controller.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
module Admin
|
||||
class VenuePhotosController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource :venue, through: :conference, singleton: true
|
||||
|
||||
def destroy
|
||||
photo = @venue.venue_photos.find(params[:id])
|
||||
if photo.destroy
|
||||
redirect_to edit_admin_conference_venue_path(@conference.short_title), notice: 'Photo deleted'
|
||||
else
|
||||
redirect_to edit_admin_conference_venue_path(@conference.short_title), alert: 'Photo not deleted'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue