Add #show for sponsors
This commit is contained in:
parent
de1fa448a2
commit
336c1e86bd
9 changed files with 147 additions and 11 deletions
|
|
@ -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
|
||||
|
|
|
|||
20
app/views/admin/sponsors/_edit_form.html.haml
Normal file
20
app/views/admin/sponsors/_edit_form.html.haml
Normal file
|
|
@ -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' }
|
||||
|
|
@ -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' }
|
||||
|
|
|
|||
1
app/views/admin/sponsors/edit.html.haml
Normal file
1
app/views/admin/sponsors/edit.html.haml
Normal file
|
|
@ -0,0 +1 @@
|
|||
= render 'edit_form'
|
||||
|
|
@ -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
|
||||
|
|
|
|||
78
app/views/admin/sponsors/show.html.haml
Normal file
78
app/views/admin/sponsors/show.html.haml
Normal file
|
|
@ -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' }
|
||||
|
|
@ -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]
|
||||
|
|
|
|||
10
db/migrate/20170822173332_add_swags_to_sponsors.rb
Normal file
10
db/migrate/20170822173332_add_swags_to_sponsors.rb
Normal file
|
|
@ -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
|
||||
14
db/schema.rb
14
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|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue