Change fields and views
This commit is contained in:
parent
30e70cc5d6
commit
819d55366c
11 changed files with 73 additions and 65 deletions
|
|
@ -585,7 +585,7 @@ Style/PredicateName:
|
|||
- 'spec/**/*'
|
||||
- 'app/models/comment.rb'
|
||||
- 'app/models/contact.rb'
|
||||
- 'app/controllers/admin/sponsors_controller'
|
||||
- 'app/controllers/admin/sponsors_controller.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
|
|
|
|||
|
|
@ -12,12 +12,13 @@ module Admin
|
|||
|
||||
def show
|
||||
@sponsor.swag_index = @sponsor.swag.length
|
||||
@sponsor.courier_index = @sponsor.courier_info.length
|
||||
@sponsor.carrier_index = @sponsor.swag_transportation.length
|
||||
end
|
||||
|
||||
def edit
|
||||
@sponsor.swag = @sponsor.swag
|
||||
@sponsor.swag_index = @sponsor.swag.length
|
||||
@sponsor.courier_index = @sponsor.courier_info.length
|
||||
@sponsor.carrier_index = @sponsor.swag_transportation.length
|
||||
end
|
||||
|
||||
def new
|
||||
|
|
@ -115,8 +116,8 @@ module Admin
|
|||
|
||||
def sponsor_params
|
||||
params.require(:sponsor).permit(:name, :description, :website_url, :picture, :picture_cache, :sponsorship_level_id, :conference_id,
|
||||
:paid, :has_swag, :swag_received, :address, :vat, :has_banner, :swag_index, :courier_index,
|
||||
swags: [:type, :quantity], courier_info: [:courier_name, :tracking_number, :boxes])
|
||||
:paid, :has_swag, :swag_received, :address, :vat, :has_banner, :swag_index, :carrier_index, :amount,
|
||||
swag: [:type, :quantity], swag_transportation: [:carrier_name, :tracking_number, :boxes])
|
||||
end
|
||||
|
||||
def sponsorship_level_required
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ class Sponsor < ActiveRecord::Base
|
|||
belongs_to :sponsorship_level
|
||||
belongs_to :conference
|
||||
|
||||
serialize :swags, Hash
|
||||
serialize :courier_info, Hash
|
||||
serialize :swag, Hash
|
||||
serialize :swag_transportation, Hash
|
||||
|
||||
attr_accessor :type, :quantity, :swag_index, :courier_index,
|
||||
:courier_name, :tracking_number, :boxes
|
||||
attr_accessor :type, :quantity, :swag_index, :carrier_index,
|
||||
:carrier_name, :tracking_number, :boxes
|
||||
|
||||
has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id }
|
||||
|
||||
|
|
@ -23,7 +23,6 @@ class Sponsor < ActiveRecord::Base
|
|||
state :unconfirmed
|
||||
state :confirmed
|
||||
|
||||
|
||||
event :confirm do
|
||||
transitions to: :confirmed, from: [:unconfirmed]
|
||||
end
|
||||
|
|
|
|||
7
app/views/admin/sponsors/_carrier_fields.html.haml
Normal file
7
app/views/admin/sponsors/_carrier_fields.html.haml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
.row
|
||||
.col-md-4
|
||||
= f.input :courrier_name, label: 'carrier\'s name', input_html: { name: "sponsor[swag_transportation][#{index}][carrier_name]", value: name_value }
|
||||
.col-md-4
|
||||
= f.input :tracking_number, input_html: { name: "sponsor[swag_transportation][#{index}][tracking_number]", value: tracking_value}
|
||||
.col-md-4
|
||||
= f.input :boxes, as: :number, in: 0...999, label: 'Number of boxes', input_html: { name: "sponsor[swag_transportation][#{index}][boxes]", value: boxes_value }
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
.row
|
||||
.col-md-4
|
||||
= f.input :courrier_name, label: 'Courier\'s name', input_html: { name: "sponsor[courier_info][#{index}][courier_name]", value: name_value }
|
||||
.col-md-4
|
||||
= f.input :tracking_number, input_html: { name: "sponsor[courier_info][#{index}][tracking_number]", value: tracking_value}
|
||||
.col-md-4
|
||||
= f.input :boxes, as: :number, in: 0...999, label: 'Number of boxes', input_html: { name: "sponsor[courier_info][#{index}][boxes]", value: boxes_value }
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
.row
|
||||
.col-md-6
|
||||
= f.input :type, label: 'Swag\'s type', input_html: { name: "sponsor[swags][#{index}][type]", value: type_value }
|
||||
= f.input :type, label: 'Swag\'s type', input_html: { name: "sponsor[swag][#{index}][type]", value: type_value }
|
||||
.col-md-6
|
||||
= f.input :quantity, as: :number, in: 0...999, input_html: { name: "sponsor[swags][#{index}][quantity]", value: quantity_value}
|
||||
= f.input :quantity, as: :number, in: 0...9999, input_html: { name: "sponsor[swag][#{index}][quantity]", value: quantity_value}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,12 @@
|
|||
.col-md-8
|
||||
= semantic_form_for(@sponsor, url: admin_conference_sponsor_path(@conference.short_title, @sponsor)) do |f|
|
||||
= f.input :name
|
||||
= f.input :amount, as: :number, label: 'Donation amount'
|
||||
= 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 :address, label: 'Sponsor\'s address', hint: 'Please include the legal company name, along with the address, as you want it to be shown on the invoice'
|
||||
= f.input :vat, label: 'VAT Registration Number'
|
||||
%b Has Swags?
|
||||
= check_box_tag @conference.short_title, @sponsor.id, @sponsor.has_swag,
|
||||
|
|
@ -21,13 +22,13 @@
|
|||
off_color: 'warning',
|
||||
on_text: 'Yes',
|
||||
off_text: 'No' }
|
||||
- @sponsor.swags.each_with_index do |(key, value), index|
|
||||
- @sponsor.swag.each_with_index do |(key, value), index|
|
||||
=render partial: 'swag_fields', locals: {f: f, index: index, type_value: value[:type].to_s, quantity_value: value[:quantity].to_i}
|
||||
=render partial: 'swag_fields', locals: {f: f, index: @sponsor.swag_index, type_value: nil, quantity_value: nil}
|
||||
|
||||
- @sponsor.courier_info.each_with_index do |(key, value), index|
|
||||
=render partial: 'courier_fields', locals: {f: f, index: index, name_value: value[:courier_name].to_s, tracking_value: value[:tracking_number].to_s, boxes_value: value[:boxes]}
|
||||
=render partial: 'courier_fields', locals: {f: f, index: @sponsor.courier_index, name_value: nil, tracking_value: nil, boxes_value: nil}
|
||||
- @sponsor.swag_transportation.each_with_index do |(key, value), index|
|
||||
=render partial: 'carrier_fields', locals: {f: f, index: index, name_value: value[:carrier_name].to_s, tracking_value: value[:tracking_number].to_s, boxes_value: value[:boxes]}
|
||||
=render partial: 'carrier_fields', locals: {f: f, index: @sponsor.carrier_index, name_value: nil, tracking_value: nil, boxes_value: nil}
|
||||
|
||||
.row
|
||||
.col-md-8
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
%thead
|
||||
%th Logo
|
||||
%th Name
|
||||
%th Donation
|
||||
%th Payment
|
||||
%th Level
|
||||
%th Actions
|
||||
|
|
@ -34,6 +35,8 @@
|
|||
= image_tag(sponsor.picture.thumb.url, width: '20%')
|
||||
%td
|
||||
= link_to sponsor.name, admin_conference_sponsor_path(@conference.short_title, sponsor)
|
||||
%td
|
||||
= sponsor.amount
|
||||
%td
|
||||
- if sponsor.payed
|
||||
%span.fa.fa-check.text-success
|
||||
|
|
@ -88,17 +91,20 @@
|
|||
%span.fa.fa-times.text-danger
|
||||
%td
|
||||
- if sponsor.has_swag
|
||||
- sponsor.swags.each do |key, value|
|
||||
- sponsor.swag.each do |key, value|
|
||||
= value[:type]
|
||||
(
|
||||
= value[:quantity]
|
||||
)
|
||||
%br
|
||||
|
||||
%td
|
||||
- if sponsor.swag_received
|
||||
%span.fa.fa-check.text-success
|
||||
- else
|
||||
%span.fa.fa-times.text-danger
|
||||
= check_box_tag @conference.short_title, sponsor.id, sponsor.swag_received,
|
||||
method: :patch, url: "/admin/conferences/#{@conference.short_title}/sponsors/#{sponsor.id}?sponsor[swag_received]=",
|
||||
class: 'switch-checkbox', data: { size: 'small',
|
||||
off_color: 'warning',
|
||||
on_text: 'Yes',
|
||||
off_text: 'No' }
|
||||
%td
|
||||
.btn-group
|
||||
= link_to 'Edit', edit_admin_conference_sponsor_path(@conference.short_title, sponsor),
|
||||
|
|
@ -135,7 +141,7 @@
|
|||
%td
|
||||
= truncate(sponsor.description)
|
||||
%td
|
||||
= sponsor.website_url
|
||||
= link_to sponsor.website_url, sponsor.website_url
|
||||
%td
|
||||
= sponsor.sponsorship_level.title
|
||||
%td
|
||||
|
|
|
|||
|
|
@ -13,6 +13,12 @@
|
|||
method: :delete, class: 'btn btn-danger', data: { confirm: "Do you really want to delete the sponsor #{@sponsor.name}?" }
|
||||
.col-md-12
|
||||
%table.table
|
||||
%tr
|
||||
- if @sponsor.amount?
|
||||
%td.col-md-2
|
||||
%b Donation amount
|
||||
%td
|
||||
= @sponsor.amount
|
||||
%tr
|
||||
%td.col-md-2
|
||||
%b Sponsorship paid?
|
||||
|
|
@ -47,13 +53,13 @@
|
|||
- if @sponsor.address?
|
||||
%tr
|
||||
%td.col-md-2
|
||||
%b Company's address
|
||||
%b Sponsor's address
|
||||
%td
|
||||
= @sponsor.address
|
||||
- if @sponsor.vat?
|
||||
%tr
|
||||
%td.col-md-2
|
||||
%b Campany's VAT Registration Number
|
||||
%b Sponsor's VAT Registration Number
|
||||
%td
|
||||
= @sponsor.vat
|
||||
%tr
|
||||
|
|
@ -67,6 +73,20 @@
|
|||
on_text: 'Yes',
|
||||
off_text: 'No' }
|
||||
|
||||
|
||||
- if @sponsor.has_swag
|
||||
%tr
|
||||
%td.col-md-2
|
||||
%b Swag's Type
|
||||
%td
|
||||
%b Quantity
|
||||
- @sponsor.swag.each do |key, value|
|
||||
%tr
|
||||
%td.col-md-2
|
||||
= value[:type]
|
||||
%td
|
||||
= value[:quantity]
|
||||
|
||||
- if @sponsor.has_swag
|
||||
%tr
|
||||
%td.col-md-2
|
||||
|
|
@ -78,32 +98,10 @@
|
|||
off_color: 'warning',
|
||||
on_text: 'Yes',
|
||||
off_text: 'No' }
|
||||
- if @sponsor.swag_index > 0
|
||||
%tr
|
||||
%td.col-md-2
|
||||
%b Swag's Type
|
||||
%td
|
||||
%b Quantity
|
||||
- @sponsor.swags.each do |key, value|
|
||||
%tr
|
||||
%td.col-md-2
|
||||
= value[:type]
|
||||
%td
|
||||
= value[:quantity]
|
||||
%tr
|
||||
%td.col-md-2
|
||||
%b Swag Received?
|
||||
%td
|
||||
= check_box_tag @conference.short_title, @sponsor.id, @sponsor.swag_received,
|
||||
method: :patch, url: "/admin/conferences/#{@conference.short_title}/sponsors/#{@sponsor.id}?sponsor[swag_received]=",
|
||||
class: 'switch-checkbox', data: { size: 'small',
|
||||
off_color: 'warning',
|
||||
on_text: 'Yes',
|
||||
off_text: 'No' }
|
||||
.row
|
||||
.col-md-12
|
||||
%table.table
|
||||
- if @sponsor.courier_index > 0
|
||||
- if @sponsor.carrier_index > 0
|
||||
%tr
|
||||
%td.col-md-2
|
||||
%b Courrier's name
|
||||
|
|
@ -111,10 +109,10 @@
|
|||
%b Tracking Number
|
||||
%td
|
||||
%b Number of boxes
|
||||
- @sponsor.courier_info.each do |key, value|
|
||||
- @sponsor.swag_transportation.each do |key, value|
|
||||
%tr
|
||||
%td.col-md-2
|
||||
= value[:courier_name]
|
||||
= value[:carrier_name]
|
||||
%td
|
||||
= value[:tracking_number]
|
||||
%td
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
class AddSwagsToSponsors < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :sponsors, :paid, :boolean, default: false
|
||||
add_column :sponsors, :amount, :float
|
||||
add_column :sponsors, :has_swag, :boolean, default: false
|
||||
add_column :sponsors, :swag_received, :boolean
|
||||
add_column :sponsors, :address, :string
|
||||
add_column :sponsors, :vat, :string
|
||||
add_column :sponsors, :has_banner, :boolean, default: false
|
||||
add_column :sponsors, :swag, :text
|
||||
add_column :sponsors, :courier_info, :text
|
||||
add_column :sponsors, :swag_transportation, :text
|
||||
add_column :sponsors, :state, :string
|
||||
end
|
||||
end
|
||||
|
|
|
|||
16
db/schema.rb
16
db/schema.rb
|
|
@ -48,11 +48,11 @@ ActiveRecord::Schema.define(version: 20170822173332) do
|
|||
t.text "reasoning"
|
||||
t.string "state"
|
||||
t.string "logo_link"
|
||||
t.string "website_url"
|
||||
t.text "submitter_relationship"
|
||||
t.integer "conference_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "website_url"
|
||||
t.text "submitter_relationship"
|
||||
end
|
||||
|
||||
create_table "campaigns", force: :cascade do |t|
|
||||
|
|
@ -127,8 +127,8 @@ ActiveRecord::Schema.define(version: 20170822173332) do
|
|||
t.integer "end_hour", default: 20
|
||||
t.integer "organization_id"
|
||||
t.integer "ticket_layout", default: 0
|
||||
t.integer "booth_limit", default: 0
|
||||
t.string "custom_domain"
|
||||
t.integer "booth_limit", default: 0
|
||||
end
|
||||
|
||||
add_index "conferences", ["organization_id"], name: "index_conferences_on_organization_id"
|
||||
|
|
@ -207,6 +207,9 @@ ActiveRecord::Schema.define(version: 20170822173332) 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: 20170822173332) 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
|
||||
|
|
@ -469,13 +469,14 @@ ActiveRecord::Schema.define(version: 20170822173332) do
|
|||
t.datetime "updated_at"
|
||||
t.string "picture"
|
||||
t.boolean "paid", default: false
|
||||
t.float "amount"
|
||||
t.boolean "has_swag", default: false
|
||||
t.boolean "swag_received"
|
||||
t.string "address"
|
||||
t.string "vat"
|
||||
t.boolean "has_banner", default: false
|
||||
t.text "swag"
|
||||
t.text "courier_info"
|
||||
t.text "swag_transportation"
|
||||
t.string "state"
|
||||
end
|
||||
|
||||
|
|
@ -586,6 +587,7 @@ ActiveRecord::Schema.define(version: 20170822173332) do
|
|||
t.boolean "is_admin", default: false
|
||||
t.string "username"
|
||||
t.boolean "is_disabled", default: false
|
||||
t.string "token"
|
||||
end
|
||||
|
||||
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue