From 8e6e708813e133f76c852c94049142eb2a4ac9ae Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Tue, 10 Jun 2014 17:47:46 +0530 Subject: [PATCH] Adds admin components for conference photos --- app/models/conference.rb | 5 +++-- app/views/admin/conference/_photo_fields.html.erb | 10 ++++++++++ app/views/admin/conference/edit.html.haml | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 app/views/admin/conference/_photo_fields.html.erb diff --git a/app/models/conference.rb b/app/models/conference.rb index 0858cf7b..4816cf50 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -19,8 +19,8 @@ class Conference < ActiveRecord::Base :lodging_description, :include_registrations_in_splash, :include_sponsors_in_splash, :include_tracks_in_splash, :include_tickets_in_splash, :include_social_media_in_splash, - :include_program_in_splash, :make_conference_public - + :include_program_in_splash, :make_conference_public, + :photos_attributes has_paper_trail @@ -60,6 +60,7 @@ class Conference < ActiveRecord::Base accepts_nested_attributes_for :questions, :allow_destroy => true accepts_nested_attributes_for :vdays, :allow_destroy => true accepts_nested_attributes_for :vpositions, :allow_destroy => true + accepts_nested_attributes_for :photos, allow_destroy: true has_attached_file :logo, :styles => {:thumb => "100x100>", :large => "300x300>" } diff --git a/app/views/admin/conference/_photo_fields.html.erb b/app/views/admin/conference/_photo_fields.html.erb new file mode 100644 index 00000000..29a1f16b --- /dev/null +++ b/app/views/admin/conference/_photo_fields.html.erb @@ -0,0 +1,10 @@ +
+ <%= f.inputs do %> + <%= image_tag(f.object.picture(:thumb)) unless f.object.picture.blank? %> + <%= f.input :picture, hint: 'This photo will appear in the gallery of the splash + so please give photos of banner sizes' %> + <%= f.input :description, :input_html => {:rows => 2 }, hint: 'This description will appear + at the bottom of each photo' %> + <%= remove_association_link :photo, f %> + <% end %> +
diff --git a/app/views/admin/conference/edit.html.haml b/app/views/admin/conference/edit.html.haml index 330ccbe6..6acdc847 100644 --- a/app/views/admin/conference/edit.html.haml +++ b/app/views/admin/conference/edit.html.haml @@ -25,6 +25,8 @@ = f.input :sponsor_email, hint: 'This will appear in the sponsor segment of the splash for the sponsors to contact to the organizers' = f.input :lodging_description, hint: 'This will appear in the lodging segment of the splash' + = dynamic_association :photos, "Photos", f + = f.inputs :name => 'Social Media' do - if !@conference.logo.blank? = image_tag @conference.logo(:thumb)