changes
This commit is contained in:
parent
336c1e86bd
commit
a0e1760ef1
8 changed files with 79 additions and 48 deletions
|
|
@ -4,7 +4,7 @@ module Admin
|
||||||
load_and_authorize_resource :sponsor, through: :conference
|
load_and_authorize_resource :sponsor, through: :conference
|
||||||
before_action :sponsorship_level_required, only: [:index, :new]
|
before_action :sponsorship_level_required, only: [:index, :new]
|
||||||
|
|
||||||
attr_accessor :type, :quantity
|
helper_method :generate_swags_hash
|
||||||
|
|
||||||
def index
|
def index
|
||||||
authorize! :index, Sponsor.new(conference_id: @conference.id)
|
authorize! :index, Sponsor.new(conference_id: @conference.id)
|
||||||
|
|
@ -53,14 +53,44 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_swags_hash(type, quantity)
|
def generate_swags_hash(type, quantity)
|
||||||
|
swags_hash = Hash.new
|
||||||
swags_hash[type.to_s] = quantity.to_i
|
swags_hash[type.to_s] = quantity.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_swag_hash; end
|
||||||
|
|
||||||
|
def paid
|
||||||
|
@sponsor.paid = !@sponsor.paid
|
||||||
|
if @sponsor.save
|
||||||
|
flash[:notice] = "Sponsor successfully updated."
|
||||||
|
else
|
||||||
|
flash[:error] = "Sponsor failed to be updated."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def has_swag
|
||||||
|
@sponsor.has_swag = !@sponsor.has_swag
|
||||||
|
if @sponsor.save
|
||||||
|
flash[:notice] = "Sponsor successfully updated."
|
||||||
|
else
|
||||||
|
flash[:error] = "Sponsor failed to be updated."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def swag_received
|
||||||
|
@sponsor.swag_received = !@sponsor.swag_received
|
||||||
|
if @sponsor.save
|
||||||
|
flash[:notice] = "Sponsor successfully updated."
|
||||||
|
else
|
||||||
|
flash[:error] = "Sponsor failed to be updated."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def sponsor_params
|
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)
|
:paid, :has_swag, :swag_received, :address, :vat, :has_banner, :type, :quantity)
|
||||||
end
|
end
|
||||||
|
|
||||||
def sponsorship_level_required
|
def sponsorship_level_required
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ class Sponsor < ActiveRecord::Base
|
||||||
belongs_to :sponsorship_level
|
belongs_to :sponsorship_level
|
||||||
belongs_to :conference
|
belongs_to :conference
|
||||||
|
|
||||||
|
attr_accessor :type, :quantity
|
||||||
|
|
||||||
has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id }
|
has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id }
|
||||||
|
|
||||||
mount_uploader :picture, PictureUploader, mount_on: :logo_file_name
|
mount_uploader :picture, PictureUploader, mount_on: :logo_file_name
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
.col-md-12
|
.col-md-12
|
||||||
.page-header
|
.page-header
|
||||||
%h1
|
%h1
|
||||||
Edit
|
Edit
|
||||||
= @sponsor.name
|
= @sponsor.name
|
||||||
.row
|
.row
|
||||||
.col-md-8
|
.col-md-8
|
||||||
= semantic_form_for(@sponsor, url: admin_conference_sponsor_path(@conference.short_title, @sponsor)) do |f|
|
= semantic_form_for(@sponsor, url: admin_conference_sponsor_path(@conference.short_title, @sponsor)) do |f|
|
||||||
|
|
@ -12,8 +12,17 @@
|
||||||
= f.input :picture
|
= f.input :picture
|
||||||
= f.input :website_url
|
= f.input :website_url
|
||||||
= f.input :sponsorship_level, collection: @conference.sponsorship_levels
|
= f.input :sponsorship_level, collection: @conference.sponsorship_levels
|
||||||
= f.input :company_address
|
= f.input :address, label: 'Company\'s address'
|
||||||
= f.input :vat_registration
|
= f.input :vat, label: 'VAT Registration Number'
|
||||||
|
= check_box_tag @conference.short_title, @sponsor.id, @sponsor.has_swag,
|
||||||
|
method: :patch, url: "/admin/conferences/#{@conference.short_title}/sponsors/#{@sponsor.id}?sponsor[has_swag]=",
|
||||||
|
class: 'switch-checkbox', data: { size: 'small',
|
||||||
|
off_color: 'warning',
|
||||||
|
on_text: 'Yes',
|
||||||
|
off_text: 'No' }
|
||||||
|
= f.input :type, label: 'Swags type'
|
||||||
|
= f.input :quantity, label: 'Swags quantity', as: :number, in: 0..9999
|
||||||
|
- generate_swags_hash(@type, @quantity)
|
||||||
= image_tag f.object.picture.thumb.url if f.object.picture?
|
= image_tag f.object.picture.thumb.url if f.object.picture?
|
||||||
= f.input :picture
|
= f.input :picture
|
||||||
%p.text-right
|
%p.text-right
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,6 @@
|
||||||
= f.input :picture
|
= f.input :picture
|
||||||
= f.input :website_url
|
= f.input :website_url
|
||||||
= f.input :sponsorship_level, collection: @conference.sponsorship_levels
|
= f.input :sponsorship_level, collection: @conference.sponsorship_levels
|
||||||
-# = f.input :type
|
|
||||||
-# = f.input :quantity
|
|
||||||
-# - generate_swags_hash(type, quantity)
|
|
||||||
|
|
||||||
%p.text-right
|
%p.text-right
|
||||||
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
|
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,10 @@
|
||||||
%table.table
|
%table.table
|
||||||
%tr
|
%tr
|
||||||
%td.col-md-2
|
%td.col-md-2
|
||||||
%b Sponsorship payed?
|
%b Sponsorship paid?
|
||||||
%td
|
%td
|
||||||
= check_box_tag @conference.short_title, @sponsor.id, @sponsor.swags,
|
= check_box_tag @conference.short_title, @sponsor.id, @sponsor.paid,
|
||||||
method: :patch, url: payed_admin_conference_sponsor_path(@conference.short_title, @sponsor.id),
|
method: :patch, url: "/admin/conferences/#{@conference.short_title}/sponsors/#{@sponsor.id}?sponsor[paid]=",
|
||||||
class: 'switch-checkbox', data: { size: 'small',
|
class: 'switch-checkbox', data: { size: 'small',
|
||||||
off_color: 'warning',
|
off_color: 'warning',
|
||||||
on_text: 'Yes',
|
on_text: 'Yes',
|
||||||
|
|
@ -45,34 +45,34 @@
|
||||||
%td.col-md-2
|
%td.col-md-2
|
||||||
%b Has swags?
|
%b Has swags?
|
||||||
%td
|
%td
|
||||||
= check_box_tag @conference.short_title, @sponsor.id, @sponsor.swags,
|
= check_box_tag @conference.short_title, @sponsor.id, @sponsor.has_swag,
|
||||||
method: :patch, url: swags_admin_conference_sponsor_path(@conference.short_title, @sponsor.id),
|
method: :patch, url: "/admin/conferences/#{@conference.short_title}/sponsors/#{@sponsor.id}?sponsor[has_swag]=",
|
||||||
class: 'switch-checkbox', data: { size: 'small',
|
class: 'switch-checkbox', data: { size: 'small',
|
||||||
off_color: 'warning',
|
off_color: 'warning',
|
||||||
on_text: 'Yes',
|
on_text: 'Yes',
|
||||||
off_text: 'No' }
|
off_text: 'No' }
|
||||||
- if @sponsor.company_address
|
|
||||||
%tr
|
|
||||||
%td.col-md-2
|
|
||||||
%b Company's address
|
|
||||||
%td
|
|
||||||
= @sponsor.company_address
|
|
||||||
|
|
||||||
- if @sponsor.vat_registration
|
- if @sponsor.has_swag
|
||||||
%tr
|
|
||||||
%td.col-md-2
|
|
||||||
%b Campany's VAT Registration Number
|
|
||||||
%td
|
|
||||||
= @sponsor.vat_registration
|
|
||||||
|
|
||||||
- if @sponsor.swags
|
|
||||||
%tr
|
%tr
|
||||||
%td.col-md-2
|
%td.col-md-2
|
||||||
%b Swags received?
|
%b Swags received?
|
||||||
%td
|
%td
|
||||||
= check_box_tag @conference.short_title, @sponsor.id, @sponsor.swags,
|
= check_box_tag @conference.short_title, @sponsor.id, @sponsor.swag_received,
|
||||||
method: :patch, url: swags_received_admin_conference_sponsor_path(@conference.short_title, @sponsor.id),
|
method: :patch, url: "/admin/conferences/#{@conference.short_title}/sponsors/#{@sponsor.id}?sponsor[swag_received]=",
|
||||||
class: 'switch-checkbox', data: { size: 'small',
|
class: 'switch-checkbox', data: { size: 'small',
|
||||||
off_color: 'warning',
|
off_color: 'warning',
|
||||||
on_text: 'Yes',
|
on_text: 'Yes',
|
||||||
off_text: 'No' }
|
off_text: 'No' }
|
||||||
|
|
||||||
|
- if @sponsor.address?
|
||||||
|
%tr
|
||||||
|
%td.col-md-2
|
||||||
|
%b Company's address
|
||||||
|
%td
|
||||||
|
= @sponsor.address
|
||||||
|
- if @sponsor.vat?
|
||||||
|
%tr
|
||||||
|
%td.col-md-2
|
||||||
|
%b Campany's VAT Registration Number
|
||||||
|
%td
|
||||||
|
= @sponsor.vat
|
||||||
|
|
|
||||||
|
|
@ -117,14 +117,7 @@ Osem::Application.routes.draw do
|
||||||
|
|
||||||
resources :resources
|
resources :resources
|
||||||
resources :tickets
|
resources :tickets
|
||||||
resources :sponsors do
|
resources :sponsors
|
||||||
member do
|
|
||||||
patch :payed
|
|
||||||
patch :swags
|
|
||||||
patch :swags_received
|
|
||||||
patch :has_banner
|
|
||||||
end
|
|
||||||
end
|
|
||||||
resources :lodgings, except: [:show]
|
resources :lodgings, except: [:show]
|
||||||
resources :targets, except: [:show]
|
resources :targets, except: [:show]
|
||||||
resources :campaigns, except: [:show]
|
resources :campaigns, except: [:show]
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
class AddSwagsToSponsors < ActiveRecord::Migration
|
class AddSwagsToSponsors < ActiveRecord::Migration
|
||||||
def change
|
def change
|
||||||
add_column :sponsors, :payed, :boolean, default: false
|
add_column :sponsors, :paid, :boolean, default: false
|
||||||
add_column :sponsors, :swags, :boolean, default: false
|
add_column :sponsors, :has_swag, :boolean, default: false
|
||||||
add_column :sponsors, :swags_received, :boolean
|
add_column :sponsors, :swag_received, :boolean
|
||||||
add_column :sponsors, :company_address, :string
|
add_column :sponsors, :address, :string
|
||||||
add_column :sponsors, :vat_registration, :string
|
add_column :sponsors, :vat, :string
|
||||||
add_column :sponsors, :has_banner, :boolean, default: false
|
add_column :sponsors, :has_banner, :boolean, default: false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
10
db/schema.rb
10
db/schema.rb
|
|
@ -468,11 +468,11 @@ ActiveRecord::Schema.define(version: 20170822173332) do
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.string "picture"
|
t.string "picture"
|
||||||
t.boolean "payed", default: false
|
t.boolean "paid", default: false
|
||||||
t.boolean "swags", default: false
|
t.boolean "has_swag", default: false
|
||||||
t.boolean "swags_received"
|
t.boolean "swag_received"
|
||||||
t.string "company_address"
|
t.string "address"
|
||||||
t.string "vat_registration"
|
t.string "vat"
|
||||||
t.boolean "has_banner", default: false
|
t.boolean "has_banner", default: false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue