diff --git a/app/controllers/admin/sponsors_controller.rb b/app/controllers/admin/sponsors_controller.rb index 909c2d7c..5a639f52 100644 --- a/app/controllers/admin/sponsors_controller.rb +++ b/app/controllers/admin/sponsors_controller.rb @@ -4,11 +4,16 @@ module Admin load_and_authorize_resource :sponsor, through: :conference before_action :sponsorship_level_required, only: [:index, :new] + attr_accessor :type, :quantity + def index authorize! :index, Sponsor.new(conference_id: @conference.id) end - def edit; end + def show; end + + def edit + end def new @sponsor = @conference.sponsors.new @@ -27,8 +32,8 @@ module Admin def update if @sponsor.update_attributes(sponsor_params) - redirect_to admin_conference_sponsors_path( - conference_id: @conference.short_title), + redirect_to admin_conference_sponsor_path( + conference_id: @conference.short_title, id: @sponsor.id), notice: 'Sponsor successfully updated.' else flash.now[:error] = "Update sponsor failed: #{@sponsor.errors.full_messages.join('. ')}." @@ -47,10 +52,15 @@ module Admin end end + def generate_swags_hash(type, quantity) + swags_hash[type.to_s] = quantity.to_i + end + private def sponsor_params - params.require(:sponsor).permit(:name, :description, :website_url, :picture, :picture_cache, :sponsorship_level_id, :conference_id) + params.require(:sponsor).permit(:name, :description, :website_url, :picture, :picture_cache, :sponsorship_level_id, :conference_id, + :payed, :swags, :swags_received, :company_address, :vat_registration, :has_banner) end def sponsorship_level_required diff --git a/app/views/admin/sponsors/_edit_form.html.haml b/app/views/admin/sponsors/_edit_form.html.haml new file mode 100644 index 00000000..000ad4fe --- /dev/null +++ b/app/views/admin/sponsors/_edit_form.html.haml @@ -0,0 +1,20 @@ +.row + .col-md-12 + .page-header + %h1 + Edit + = @sponsor.name +.row + .col-md-8 + = semantic_form_for(@sponsor, url: admin_conference_sponsor_path(@conference.short_title, @sponsor)) do |f| + = f.input :name + = f.input :description + = f.input :picture + = f.input :website_url + = f.input :sponsorship_level, collection: @conference.sponsorship_levels + = f.input :company_address + = f.input :vat_registration + = image_tag f.object.picture.thumb.url if f.object.picture? + = f.input :picture + %p.text-right + = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' } diff --git a/app/views/admin/sponsors/_form.html.haml b/app/views/admin/sponsors/_form.html.haml index ba24f9f3..6221cfa2 100644 --- a/app/views/admin/sponsors/_form.html.haml +++ b/app/views/admin/sponsors/_form.html.haml @@ -8,12 +8,16 @@ = @sponsor.name .row .col-md-8 - = semantic_form_for(@sponsor, url: (@sponsor.new_record? ? admin_conference_sponsors_path : admin_conference_sponsor_path(@conference.short_title, @sponsor))) do |f| + = semantic_form_for(@sponsor, url: (admin_conference_sponsors_path)) do |f| = f.input :name = f.input :description = image_tag f.object.picture.thumb.url if f.object.picture? = f.input :picture = f.input :website_url = f.input :sponsorship_level, collection: @conference.sponsorship_levels + -# = f.input :type + -# = f.input :quantity + -# - generate_swags_hash(type, quantity) + %p.text-right = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' } diff --git a/app/views/admin/sponsors/edit.html.haml b/app/views/admin/sponsors/edit.html.haml new file mode 100644 index 00000000..aeb138a2 --- /dev/null +++ b/app/views/admin/sponsors/edit.html.haml @@ -0,0 +1 @@ += render 'edit_form' diff --git a/app/views/admin/sponsors/index.html.haml b/app/views/admin/sponsors/index.html.haml index 1c8f1077..71223f17 100644 --- a/app/views/admin/sponsors/index.html.haml +++ b/app/views/admin/sponsors/index.html.haml @@ -21,7 +21,7 @@ %td = image_tag(sponsor.picture.thumb.url, width: '20%') %td - = sponsor.name + = link_to sponsor.name, admin_conference_sponsor_path(@conference.short_title, sponsor) %td = truncate(sponsor.description) %td diff --git a/app/views/admin/sponsors/show.html.haml b/app/views/admin/sponsors/show.html.haml new file mode 100644 index 00000000..bb0e5196 --- /dev/null +++ b/app/views/admin/sponsors/show.html.haml @@ -0,0 +1,78 @@ +.row + .col-md-12 + %h2 + = image_tag(@sponsor.picture.thumb.url, size: '20%', alt: '') + = @sponsor.name +.row + .col-md-12 + .btn-group.pull-right + = link_to 'Edit', edit_admin_conference_sponsor_path(@conference.short_title, @sponsor), + method: :get, class: 'btn btn-primary' + = link_to 'Delete', admin_conference_sponsor_path(@conference.short_title, @sponsor), + method: :delete, class: 'btn btn-danger', data: { confirm: "Do you really want to delete the sponsor #{@sponsor.name}?" } + .col-md-12 + %table.table + %tr + %td.col-md-2 + %b Sponsorship payed? + %td + = check_box_tag @conference.short_title, @sponsor.id, @sponsor.swags, + method: :patch, url: payed_admin_conference_sponsor_path(@conference.short_title, @sponsor.id), + class: 'switch-checkbox', data: { size: 'small', + off_color: 'warning', + on_text: 'Yes', + off_text: 'No' } + - if @sponsor.description? + %tr + %td.col-md-2 + %b Description + %td + = markdown(@sponsor.description) + %tr + %td.col-md-2 + %b Sponsorship Level + %td + = @sponsor.sponsorship_level.title + ( + = @sponsor.sponsorship_level.position + ) + %tr + %td.col-md-2 + %b Website url + %td + = link_to @sponsor.website_url, @sponsor.website_url + %tr + %td.col-md-2 + %b Has swags? + %td + = check_box_tag @conference.short_title, @sponsor.id, @sponsor.swags, + method: :patch, url: swags_admin_conference_sponsor_path(@conference.short_title, @sponsor.id), + class: 'switch-checkbox', data: { size: 'small', + off_color: 'warning', + on_text: 'Yes', + off_text: 'No' } + - if @sponsor.company_address + %tr + %td.col-md-2 + %b Company's address + %td + = @sponsor.company_address + + - if @sponsor.vat_registration + %tr + %td.col-md-2 + %b Campany's VAT Registration Number + %td + = @sponsor.vat_registration + + - if @sponsor.swags + %tr + %td.col-md-2 + %b Swags received? + %td + = check_box_tag @conference.short_title, @sponsor.id, @sponsor.swags, + method: :patch, url: swags_received_admin_conference_sponsor_path(@conference.short_title, @sponsor.id), + class: 'switch-checkbox', data: { size: 'small', + off_color: 'warning', + on_text: 'Yes', + off_text: 'No' } diff --git a/config/routes.rb b/config/routes.rb index 0d7e7aec..dfa3d6e8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -117,7 +117,14 @@ Osem::Application.routes.draw do resources :resources resources :tickets - resources :sponsors, except: [:show] + resources :sponsors do + member do + patch :payed + patch :swags + patch :swags_received + patch :has_banner + end + end resources :lodgings, except: [:show] resources :targets, except: [:show] resources :campaigns, except: [:show] diff --git a/db/migrate/20170822173332_add_swags_to_sponsors.rb b/db/migrate/20170822173332_add_swags_to_sponsors.rb new file mode 100644 index 00000000..31ef9a70 --- /dev/null +++ b/db/migrate/20170822173332_add_swags_to_sponsors.rb @@ -0,0 +1,10 @@ +class AddSwagsToSponsors < ActiveRecord::Migration + def change + add_column :sponsors, :payed, :boolean, default: false + add_column :sponsors, :swags, :boolean, default: false + add_column :sponsors, :swags_received, :boolean + add_column :sponsors, :company_address, :string + add_column :sponsors, :vat_registration, :string + add_column :sponsors, :has_banner, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 82f5923d..b1bb4136 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170816203325) do +ActiveRecord::Schema.define(version: 20170822173332) do create_table "ahoy_events", force: :cascade do |t| t.uuid "visit_id", limit: 16 @@ -207,6 +207,9 @@ ActiveRecord::Schema.define(version: 20170816203325) do t.string "cfp_dates_updated_subject" t.text "program_schedule_public_body" t.text "cfp_dates_updated_body" + t.text "booths_acceptance_template" + t.text "booths_rejection_template" + t.string "booths_accetance_subject" t.boolean "send_on_booths_acceptance", default: false t.string "booths_acceptance_subject" t.text "booths_acceptance_body" @@ -325,11 +328,8 @@ ActiveRecord::Schema.define(version: 20170816203325) do t.integer "ticket_purchase_id", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.string "token" end - add_index "physical_tickets", ["token"], name: "index_physical_tickets_on_token", unique: true - create_table "programs", force: :cascade do |t| t.integer "conference_id" t.integer "rating", default: 0 @@ -468,6 +468,12 @@ ActiveRecord::Schema.define(version: 20170816203325) do t.datetime "created_at" t.datetime "updated_at" t.string "picture" + t.boolean "payed", default: false + t.boolean "swags", default: false + t.boolean "swags_received" + t.string "company_address" + t.string "vat_registration" + t.boolean "has_banner", default: false end create_table "sponsorship_levels", force: :cascade do |t|