Merge 7c0cd30dda into ed083be58b
This commit is contained in:
commit
8d548eab62
13 changed files with 85 additions and 7 deletions
3
Gemfile
3
Gemfile
|
|
@ -127,6 +127,9 @@ gem 'bootstrap-switch-rails', '~> 3.0.0'
|
||||||
|
|
||||||
gem 'ruby-oembed'
|
gem 'ruby-oembed'
|
||||||
|
|
||||||
|
# for zoom in images
|
||||||
|
gem 'fancybox2-rails'
|
||||||
|
|
||||||
# Use guard and spring for testing in development
|
# Use guard and spring for testing in development
|
||||||
group :development do
|
group :development do
|
||||||
# rspec Guard rules
|
# rspec Guard rules
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,8 @@ GEM
|
||||||
factory_girl_rails (4.6.0)
|
factory_girl_rails (4.6.0)
|
||||||
factory_girl (~> 4.5.0)
|
factory_girl (~> 4.5.0)
|
||||||
railties (>= 3.0.0)
|
railties (>= 3.0.0)
|
||||||
|
fancybox2-rails (0.2.8)
|
||||||
|
railties (>= 3.1.0, < 5.0)
|
||||||
faraday (0.9.0)
|
faraday (0.9.0)
|
||||||
multipart-post (>= 1.2, < 3)
|
multipart-post (>= 1.2, < 3)
|
||||||
ffi (1.9.3)
|
ffi (1.9.3)
|
||||||
|
|
@ -491,6 +493,7 @@ DEPENDENCIES
|
||||||
devise
|
devise
|
||||||
devise_ichain_authenticatable
|
devise_ichain_authenticatable
|
||||||
factory_girl_rails
|
factory_girl_rails
|
||||||
|
fancybox2-rails
|
||||||
font-awesome-rails
|
font-awesome-rails
|
||||||
formtastic (~> 2.3.0.rc3)
|
formtastic (~> 2.3.0.rc3)
|
||||||
formtastic-bootstrap
|
formtastic-bootstrap
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,14 @@
|
||||||
//= require osem-switch
|
//= require osem-switch
|
||||||
//= require osem-bootstrap
|
//= require osem-bootstrap
|
||||||
//= require osem-commercials
|
//= require osem-commercials
|
||||||
|
//= require fancybox
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('a[disabled=disabled]').click(function(event){
|
$('a[disabled=disabled]').click(function(event){
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
$("a.fancybox").fancybox();
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,5 @@
|
||||||
*= require bootstrap-datetimepicker
|
*= require bootstrap-datetimepicker
|
||||||
*= require leaflet
|
*= require leaflet
|
||||||
*= require bootstrap3-switch
|
*= require bootstrap3-switch
|
||||||
|
*= require fancybox
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,6 @@
|
||||||
|
|
||||||
#venue {
|
#venue {
|
||||||
padding-top: 0px;
|
padding-top: 0px;
|
||||||
padding-bottom: 0px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#lodging {
|
#lodging {
|
||||||
|
|
|
||||||
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)
|
@venue = @conference.build_venue(venue_params)
|
||||||
|
|
||||||
if @venue.save
|
if @venue.save
|
||||||
|
if params[:venue_photos]
|
||||||
|
create_additional_photos(@venue, params[:venue_photos])
|
||||||
|
end
|
||||||
redirect_to admin_conference_venue_path,
|
redirect_to admin_conference_venue_path,
|
||||||
notice: 'Venue was successfully created.'
|
notice: 'Venue was successfully created.'
|
||||||
else
|
else
|
||||||
|
|
@ -24,6 +27,9 @@ module Admin
|
||||||
|
|
||||||
def update
|
def update
|
||||||
if @venue.update_attributes(venue_params)
|
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),
|
redirect_to(admin_conference_venue_path(conference_id: @conference.short_title),
|
||||||
notice: 'Venue was successfully updated.')
|
notice: 'Venue was successfully updated.')
|
||||||
else
|
else
|
||||||
|
|
@ -46,5 +52,11 @@ module Admin
|
||||||
def venue_params
|
def venue_params
|
||||||
params.require(:venue).permit(:name, :street, :postalcode, :city, :country, :longitude, :latitude, :description, :website, :photo, :lodgings_attributes, :conference_id)
|
params.require(:venue).permit(:name, :street, :postalcode, :city, :country, :longitude, :latitude, :description, :website, :photo, :lodgings_attributes, :conference_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_additional_photos(venue, photos)
|
||||||
|
photos.each { |photo|
|
||||||
|
venue.venue_photos.create(photo: photo )
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
class Venue < ActiveRecord::Base
|
class Venue < ActiveRecord::Base
|
||||||
belongs_to :conference
|
belongs_to :conference
|
||||||
has_many :rooms, dependent: :destroy
|
has_many :rooms, dependent: :destroy
|
||||||
|
has_many :venue_photos, dependent: :destroy
|
||||||
before_create :generate_guid
|
before_create :generate_guid
|
||||||
|
|
||||||
validates :name, :street, :city, :country, presence: true
|
validates :name, :street, :city, :country, presence: true
|
||||||
|
|
|
||||||
9
app/models/venue_photo.rb
Normal file
9
app/models/venue_photo.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
class VenuePhoto < ActiveRecord::Base
|
||||||
|
belongs_to :venue
|
||||||
|
|
||||||
|
has_attached_file :photo,
|
||||||
|
styles: { thumb: '100x100>', large: '300x300>' }
|
||||||
|
validates_attachment_content_type :photo,
|
||||||
|
content_type: [/jpg/, /jpeg/, /png/, /gif/],
|
||||||
|
size: { in: 0..500.kilobytes }
|
||||||
|
end
|
||||||
|
|
@ -11,4 +11,15 @@
|
||||||
- unless @venue.photo.blank?
|
- unless @venue.photo.blank?
|
||||||
= image_tag @venue.photo(:thumb)
|
= image_tag @venue.photo(:thumb)
|
||||||
= f.input :photo
|
= f.input :photo
|
||||||
|
%label
|
||||||
|
Additional photos
|
||||||
|
- @venue.venue_photos.in_groups_of(4, false).each do |photo_group|
|
||||||
|
.row
|
||||||
|
- photo_group.each do |photo|
|
||||||
|
.col-md-3
|
||||||
|
= image_tag photo.photo(:thumb)
|
||||||
|
= link_to "Delete", admin_conference_venue_photo_path(@conference.short_title, photo), method: :delete, class: 'btn btn-default', data: { confirm: 'really delete this photo ?' }
|
||||||
|
%br
|
||||||
|
= file_field_tag "venue_photos[]", type: :file, multiple: true
|
||||||
|
%br
|
||||||
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
|
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
|
||||||
|
|
|
||||||
|
|
@ -60,3 +60,8 @@
|
||||||
- if @conference.venue.website
|
- if @conference.venue.website
|
||||||
%br
|
%br
|
||||||
=link_to @conference.venue.website, @conference.venue.website
|
=link_to @conference.venue.website, @conference.venue.website
|
||||||
|
- @conference.venue.venue_photos.in_groups_of(4, false).each do |photo_group|
|
||||||
|
.row
|
||||||
|
- photo_group.each do |photo|
|
||||||
|
.col-md-3
|
||||||
|
= link_to image_tag(photo.photo(:thumb), class: 'img-rounded'), photo.photo(:large), class: 'fancybox'
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ Osem::Application.routes.draw do
|
||||||
resource :splashpage
|
resource :splashpage
|
||||||
resource :venue do
|
resource :venue do
|
||||||
resources :rooms, except: [:show]
|
resources :rooms, except: [:show]
|
||||||
|
resources :venue_photos, only: [:destroy], as: :photos
|
||||||
end
|
end
|
||||||
resource :registration_period
|
resource :registration_period
|
||||||
resource :program do
|
resource :program do
|
||||||
|
|
|
||||||
13
db/migrate/20160212231923_create_venue_photos.rb
Normal file
13
db/migrate/20160212231923_create_venue_photos.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
class CreateVenuePhotos < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :venue_photos do |t|
|
||||||
|
t.integer :venue_id
|
||||||
|
t.string :photo_file_name
|
||||||
|
t.string :photo_content_type
|
||||||
|
t.integer :photo_file_size
|
||||||
|
t.datetime :photo_updated_at
|
||||||
|
|
||||||
|
t.timestamps null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue