Add confirmed sponsors
This commit is contained in:
parent
b770f9bd4d
commit
792a7fed1c
10 changed files with 162 additions and 65 deletions
|
|
@ -57,13 +57,32 @@ module Admin
|
|||
end
|
||||
end
|
||||
|
||||
def add_swags(form, index)
|
||||
render partial: 'swag_fields', locals: { f: form, index: (index + 1), v_type: nil, v_quantity: 0}
|
||||
def add_swags()
|
||||
@sponsor.update_attributes(sponsor_params)
|
||||
redirect_to edit_admin_conference_sponsor_path(@conference.short_title, @sponsor)
|
||||
end
|
||||
|
||||
def confirm
|
||||
@sponsor.confirm!
|
||||
|
||||
if @sponsor.save
|
||||
redirect_to admin_conference_sponsors_path(@conference.short_title),
|
||||
notice: 'Sponsor successfully confirmed!'
|
||||
else
|
||||
flash[:error] = 'Sponsor couldn\' t be confirmed.'
|
||||
end
|
||||
end
|
||||
|
||||
def get_swags; end
|
||||
def cancel
|
||||
@sponsor.cancel!
|
||||
|
||||
if @sponsor.save
|
||||
redirect_to admin_conference_sponsors_path(@conference.short_title),
|
||||
notice: 'Sponsor successfully canceled'
|
||||
else
|
||||
flash[:error] = 'Sponsor couldn\'t be canceled'
|
||||
end
|
||||
end
|
||||
|
||||
def paid
|
||||
@sponsor.paid = !@sponsor.paid
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
class Sponsor < ActiveRecord::Base
|
||||
include ActiveRecord::Transitions
|
||||
|
||||
belongs_to :sponsorship_level
|
||||
belongs_to :conference
|
||||
|
||||
|
|
@ -10,4 +12,25 @@ class Sponsor < ActiveRecord::Base
|
|||
mount_uploader :picture, PictureUploader, mount_on: :logo_file_name
|
||||
|
||||
validates :name, :website_url, :sponsorship_level, presence: true
|
||||
|
||||
scope :confirmed, -> { where(state: 'confirmed') }
|
||||
scope :unconfirmed, -> { where(state: 'uncofirmed') }
|
||||
|
||||
state_machine initial: :uncofirmed do
|
||||
state :uncofirmed
|
||||
state :confirmed
|
||||
|
||||
|
||||
event :confirm do
|
||||
transitions to: :confirmed, from: [:uncofirmed]
|
||||
end
|
||||
|
||||
event :cancel do
|
||||
transitions to: :uncofirmed, from: [:confirmed]
|
||||
end
|
||||
end
|
||||
|
||||
def transition_possible?(transition)
|
||||
self.class.state_machine.events_for(current_state).include?(transition)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
.row
|
||||
.col-md-12
|
||||
.page-header
|
||||
%h1
|
||||
Edit
|
||||
= @sponsor.name
|
||||
= @sponsor.swag_index
|
||||
.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, input_html: { rows: 5, data: { provide: 'markdown-editable' } }
|
||||
= f.input :picture
|
||||
= f.input :website_url
|
||||
= f.input :sponsorship_level, collection: @conference.sponsorship_levels
|
||||
= f.input :address, label: 'Company\'s address'
|
||||
= f.input :vat, label: 'VAT Registration Number'
|
||||
%b Has Swags?
|
||||
= 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' }
|
||||
- @sponsor.swags.each_with_index do |(key, value), index|
|
||||
=render partial: 'swag_fields', locals: {f: f, index: index, v_type: value[:type].to_s, v_quantity: value[:quantity].to_i}
|
||||
|
||||
.row
|
||||
.col-md-8
|
||||
= 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' }
|
||||
|
|
@ -1 +1,33 @@
|
|||
= render 'edit_form'
|
||||
.row
|
||||
.col-md-12
|
||||
.page-header
|
||||
%h1
|
||||
Edit
|
||||
= @sponsor.name
|
||||
= @sponsor.swag_index
|
||||
.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, input_html: { rows: 5, data: { provide: 'markdown-editable' } }
|
||||
= f.input :picture
|
||||
= f.input :website_url
|
||||
= f.input :sponsorship_level, collection: @conference.sponsorship_levels
|
||||
= f.input :address, label: 'Company\'s address'
|
||||
= f.input :vat, label: 'VAT Registration Number'
|
||||
%b Has Swags?
|
||||
= 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' }
|
||||
- @sponsor.swags.each_with_index do |(key, value), index|
|
||||
=render partial: 'swag_fields', locals: {f: f, index: index, v_type: value[:type].to_s, v_quantity: value[:quantity].to_i}
|
||||
=render partial: 'swag_fields', locals: {f: f, index: @sponsor.swag_index, v_type: nil, v_quantity: 0}
|
||||
.row
|
||||
.col-md-8
|
||||
= 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' }
|
||||
|
|
|
|||
|
|
@ -7,14 +7,17 @@
|
|||
.row
|
||||
.col-md-12
|
||||
%div{ role: 'tabpanel' }
|
||||
%ul.nav.nav-tabs{ role: 'tablist' }
|
||||
%li.active{ role: 'presentation'}
|
||||
%a{ 'aria-controls' => 'sponsorship', 'data-toggle' => 'tab', href: '#sponsorship', role: 'tab'} Sponsorship
|
||||
%li{ role: 'Swags'}
|
||||
%a{ 'aria-controls' => 'swags','data-toggle' => 'tab', href: '#swags', role: 'tab'} Swags
|
||||
%ul.nav.nav-tabs
|
||||
%li.active
|
||||
%a{'data-toggle' => 'tab', href: '#sponsorship', role: 'tab'} Sponsorship
|
||||
%li
|
||||
%a{'data-toggle' => 'tab', href: '#swags', role: 'tab'} Swags
|
||||
%li
|
||||
%a{'data-toggle' => 'tab', href: '#uncofirmed', role: 'tab'} Unconfirmed
|
||||
|
||||
.tab-content
|
||||
#sponsorship.tab-pane.active{ role: 'tabpanel' }
|
||||
- if @conference.sponsors.any?
|
||||
#sponsorship.tab-pane.active
|
||||
- if @conference.sponsors.confirmed.any?
|
||||
.row
|
||||
.col-md-12
|
||||
%table.table.table-hover#sponsors
|
||||
|
|
@ -26,7 +29,7 @@
|
|||
%th Level
|
||||
%th Actions
|
||||
%tbody
|
||||
- @conference.sponsors.each do |sponsor|
|
||||
- @conference.sponsors.confirmed.each do |sponsor|
|
||||
%tr
|
||||
%td
|
||||
= image_tag(sponsor.picture.thumb.url, width: '20%')
|
||||
|
|
@ -41,12 +44,18 @@
|
|||
%td
|
||||
.btn-group
|
||||
= link_to 'Edit', edit_admin_conference_sponsor_path(@conference.short_title, sponsor),
|
||||
method: :get, class: 'btn btn-primary'
|
||||
method: :get, class: 'btn btn-mini 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}?" }
|
||||
method: :delete, class: 'btn btn-mini btn-danger', data: { confirm: "Do you really want to delete the sponsor #{sponsor.name}?" }
|
||||
- if sponsor.transition_possible? :confirm
|
||||
= link_to 'Confirm', confirm_admin_conference_sponsor_path(@conference.short_title, sponsor.id),
|
||||
method: :patch, class: 'btn btn-mini btn-success'
|
||||
- if sponsor.transition_possible? :cancel
|
||||
= link_to 'Cancel', cancel_admin_conference_sponsor_path(@conference.short_title, sponsor.id),
|
||||
method: :patch, class: 'btn btn-mini btn-default'
|
||||
|
||||
#swags.tab-pane.active{ role: 'tabpanel' }
|
||||
- if @conference.sponsors.any?
|
||||
#swags.tab-pane
|
||||
- if @conference.sponsors.confirmed.any?
|
||||
.row
|
||||
.col-md-12
|
||||
%table.table.table-hover#sponsors
|
||||
|
|
@ -59,7 +68,7 @@
|
|||
%th Received
|
||||
%th Actions
|
||||
%tbody
|
||||
- @conference.sponsors.each do |sponsor|
|
||||
- @conference.sponsors.confirmed.each do |sponsor|
|
||||
%tr
|
||||
%td
|
||||
= image_tag(sponsor.picture.thumb.url, width: '20%')
|
||||
|
|
@ -69,12 +78,12 @@
|
|||
- if sponsor.has_banner
|
||||
%span.fa.fa-check.text-success
|
||||
- else
|
||||
%span.fa.fa-times
|
||||
%span.fa.fa-times.text-danger
|
||||
%td
|
||||
- if sponsor.has_swag
|
||||
%span.fa.fa-check.text-success
|
||||
- else
|
||||
%span.fa.fa-times
|
||||
%span.fa.fa-times.text-danger
|
||||
%td
|
||||
- if sponsor.has_swag
|
||||
- sponsor.swags.each do |key, value|
|
||||
|
|
@ -91,9 +100,55 @@
|
|||
%td
|
||||
.btn-group
|
||||
= link_to 'Edit', edit_admin_conference_sponsor_path(@conference.short_title, sponsor),
|
||||
method: :get, class: 'btn btn-primary'
|
||||
method: :get, class: 'btn btn-mini 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}?" }
|
||||
method: :delete, class: 'btn btn-mini btn-danger', data: { confirm: "Do you really want to delete the sponsor #{sponsor.name}?" }
|
||||
- if sponsor.transition_possible? :confirm
|
||||
= link_to 'Confirm', confirm_admin_conference_sponsor_path(@conference.short_title, sponsor.id),
|
||||
method: :patch, class: 'btn btn-mini btn-success'
|
||||
- if sponsor.transition_possible? :cancel
|
||||
= link_to 'Cancel', cancel_admin_conference_sponsor_path(@conference.short_title, sponsor.id),
|
||||
method: :patch, class: 'btn btn-mini btn-default'
|
||||
|
||||
.tab-content
|
||||
#unconfirmed.tab-pane
|
||||
- if @conference.sponsors.unconfirmed.any?
|
||||
.row
|
||||
.col-md-12
|
||||
%table.table.table-hover#sponsors
|
||||
%thead
|
||||
%th Logo
|
||||
%th Name
|
||||
%th Description
|
||||
%th URL
|
||||
%th Level
|
||||
%th Actions
|
||||
%tbody
|
||||
- @conference.sponsors.unconfirmed.each do |sponsor|
|
||||
%tr
|
||||
%td
|
||||
= image_tag(sponsor.picture.thumb.url, width: '20%')
|
||||
%td
|
||||
= link_to sponsor.name, admin_conference_sponsor_path(@conference.short_title, sponsor)
|
||||
%td
|
||||
= truncate(sponsor.description)
|
||||
%td
|
||||
= sponsor.website_url
|
||||
%td
|
||||
= sponsor.sponsorship_level.title
|
||||
%td
|
||||
.btn-group
|
||||
= link_to 'Edit', edit_admin_conference_sponsor_path(@conference.short_title, sponsor),
|
||||
method: :get, class: 'btn btn-mini btn-primary'
|
||||
= link_to 'Delete', admin_conference_sponsor_path(@conference.short_title, sponsor),
|
||||
method: :delete, class: 'btn btn-mini btn-danger', data: { confirm: "Do you really want to delete the sponsor #{sponsor.name}?" }
|
||||
- if sponsor.transition_possible? :confirm
|
||||
= link_to 'Confirm', confirm_admin_conference_sponsor_path(@conference.short_title, sponsor.id),
|
||||
method: :patch, class: 'btn btn-mini btn-success'
|
||||
- if sponsor.transition_possible? :cancel
|
||||
= link_to 'Cancel', cancel_admin_conference_sponsor_path(@conference.short_title, sponsor.id),
|
||||
method: :patch, class: 'btn btn-mini btn-default'
|
||||
|
||||
.row
|
||||
.col-md-12
|
||||
= link_to 'Add Sponsor', new_admin_conference_sponsor_path(@conference.short_title), class: 'btn btn-primary pull-right'
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
.col-md-8
|
||||
= semantic_form_for(@sponsor, url: (admin_conference_sponsors_path)) do |f|
|
||||
= f.input :name
|
||||
= f.input :description
|
||||
= f.input :description, input_html: { rows: 7, data: { provide: 'markdown-editable' } }
|
||||
= image_tag f.object.picture.thumb.url if f.object.picture?
|
||||
= f.input :picture
|
||||
= f.input :website_url
|
||||
|
|
@ -43,7 +43,7 @@
|
|||
= link_to @sponsor.website_url, @sponsor.website_url
|
||||
%tr
|
||||
%td.col-md-2
|
||||
%b Has swags?
|
||||
%b Has swag?
|
||||
%td
|
||||
= 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]=",
|
||||
|
|
@ -75,9 +75,6 @@
|
|||
= value[:type]
|
||||
%td
|
||||
= value[:quantity]
|
||||
|
||||
|
||||
|
||||
- if @sponsor.address?
|
||||
%tr
|
||||
%td.col-md-2
|
||||
|
|
|
|||
|
|
@ -117,7 +117,12 @@ Osem::Application.routes.draw do
|
|||
|
||||
resources :resources
|
||||
resources :tickets
|
||||
resources :sponsors
|
||||
resources :sponsors do
|
||||
member do
|
||||
patch :confirm
|
||||
patch :cancel
|
||||
end
|
||||
end
|
||||
resources :lodgings, except: [:show]
|
||||
resources :targets, except: [:show]
|
||||
resources :campaigns, except: [:show]
|
||||
|
|
|
|||
|
|
@ -7,5 +7,7 @@ class AddSwagsToSponsors < ActiveRecord::Migration
|
|||
add_column :sponsors, :vat, :string
|
||||
add_column :sponsors, :has_banner, :boolean, default: false
|
||||
add_column :sponsors, :swags, :text
|
||||
add_column :sponsors, :courrier_info, :text
|
||||
add_column :sponsors, :state, :string
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -468,11 +468,6 @@ ActiveRecord::Schema.define(version: 20170822173332) do
|
|||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "picture"
|
||||
t.boolean "payed", default: false
|
||||
t.boolean "swags_received"
|
||||
t.string "company_address"
|
||||
t.string "vat_registration"
|
||||
t.text "swag_hash"
|
||||
t.boolean "paid", default: false
|
||||
t.boolean "has_swag", default: false
|
||||
t.boolean "swag_received"
|
||||
|
|
@ -480,6 +475,8 @@ ActiveRecord::Schema.define(version: 20170822173332) do
|
|||
t.string "vat"
|
||||
t.boolean "has_banner", default: false
|
||||
t.text "swags"
|
||||
t.text "courrier_info"
|
||||
t.string "state"
|
||||
end
|
||||
|
||||
create_table "sponsorship_levels", force: :cascade do |t|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue