Use PictureUploader on Conference

This commit is contained in:
Henne Vogelsang 2016-04-27 15:17:12 +02:00
parent cea9081347
commit 40023044af
8 changed files with 24 additions and 14 deletions

View file

@ -180,7 +180,7 @@ module Admin
params.require(:conference).permit(:title, :short_title, :description, :timezone,
:start_date, :end_date, :rooms_attributes, :tracks_attributes,
:tickets_attributes, :event_types_attributes,
:logo, :questions_attributes,
:picture, :picture_cache, :questions_attributes,
:question_ids, :answers_attributes, :answer_ids, :difficulty_levels_attributes,
:use_difficulty_levels, :use_vpositions, :use_vdays, :vdays_attributes,
:vpositions_attributes, :use_volunteers, :color,

View file

@ -46,12 +46,7 @@ class Conference < ActiveRecord::Base
accepts_nested_attributes_for :targets, allow_destroy: true
accepts_nested_attributes_for :campaigns, allow_destroy: true
has_attached_file :logo,
styles: { thumb: '100x100>', large: '300x300>' }
validates_attachment_content_type :logo,
content_type: [/jpg/, /jpeg/, /png/, /gif/],
size: { in: 0..500.kilobytes }
mount_uploader :picture, PictureUploader, mount_on: :logo_file_name
validates_presence_of :title,
:short_title,

View file

@ -1,5 +1,5 @@
class ConferenceSerializer < ActiveModel::Serializer
attributes :short_title, :title, :description, :start_date, :end_date, :logo,
attributes :short_title, :title, :description, :start_date, :end_date, :picture_url,
:difficulty_levels, :event_types, :rooms, :tracks,
:date_range, :revision

View file

@ -11,9 +11,12 @@
= f.input :short_title, :hint => "A short title, e.g. 'oSC14', to be used in URLs"
= f.input :description, hint: markdown_hint('A description of the conference.'), input_html: { rows: 5, data: { provide: 'markdown-editable' } }
= f.input :color, :hint => "The color will be used eg for the dashboard.", :input_html => {:size => 6, :type => "color"}
- if !@conference.logo.blank?
= image_tag @conference.logo(:thumb)
= f.input :logo, :label => "Conference Logo", :hint => "This will be displayed on the front page."
= f.label 'Conference Logo'
%br
- if @conference.picture?
= image_tag @conference.picture.thumb.url
= f.input :picture, :label => false, :hint => "This will be displayed on the front page."
= f.hidden_field :picture_cache
= f.inputs :name => "Scheduling" do
= f.input :timezone, :as => :time_zone, :hint => "The conference time zone"
= f.input :start_date, :as => :string, :input_html => { :id => "conference-start-datepicker", :readonly => "readonly" }

View file

@ -3,7 +3,7 @@
.well
.row
.col-md-4.text-center
= image_tag(conference.logo(:original), class: 'img-responsive') if conference.logo?
= image_tag(conference.picture_url, class: 'img-responsive') if conference.picture?
.col-md-6
%h3
= conference.title

View file

@ -9,7 +9,7 @@
.col-md-8.col-md-offset-2#header
.row
.col-md-4
= image_tag(@conference.logo(:original), class: 'img-responsive img-center', id: 'splash-logo') if @conference.logo?
= image_tag(@conference.picture_url, class: 'img-responsive img-center', id: 'splash-logo') if @conference.picture?
.col-md-8
%h1
= @conference.title

View file

@ -0,0 +1,8 @@
class AddPictures < ActiveRecord::Migration
def change
add_column :conferences, :picture, :string
add_column :lodgings, :picture, :string
add_column :sponsors, :picture, :string
add_column :venues, :picture, :string
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160427101444) do
ActiveRecord::Schema.define(version: 20160427104236) do
create_table "ahoy_events", force: :cascade do |t|
t.uuid "visit_id", limit: 16
@ -101,6 +101,7 @@ ActiveRecord::Schema.define(version: 20160427101444) do
t.text "events_per_week"
t.text "description"
t.integer "registration_limit", default: 0
t.string "picture"
end
create_table "conferences_questions", id: false, force: :cascade do |t|
@ -246,6 +247,7 @@ ActiveRecord::Schema.define(version: 20160427101444) do
t.datetime "updated_at"
t.string "website_link"
t.integer "conference_id"
t.string "picture"
end
create_table "openids", force: :cascade do |t|
@ -366,6 +368,7 @@ ActiveRecord::Schema.define(version: 20160427101444) do
t.integer "conference_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "picture"
end
create_table "sponsorship_levels", force: :cascade do |t|
@ -498,6 +501,7 @@ ActiveRecord::Schema.define(version: 20160427101444) do
t.string "latitude"
t.string "longitude"
t.integer "conference_id"
t.string "picture"
end
create_table "versions", force: :cascade do |t|