Change fields and views

This commit is contained in:
nasia 2017-08-28 15:24:51 +03:00
parent 30e70cc5d6
commit 819d55366c
11 changed files with 73 additions and 65 deletions

View file

@ -585,7 +585,7 @@ Style/PredicateName:
- 'spec/**/*' - 'spec/**/*'
- 'app/models/comment.rb' - 'app/models/comment.rb'
- 'app/models/contact.rb' - 'app/models/contact.rb'
- 'app/controllers/admin/sponsors_controller' - 'app/controllers/admin/sponsors_controller.rb'
# Offense count: 1 # Offense count: 1
# Cop supports --auto-correct. # Cop supports --auto-correct.

View file

@ -12,12 +12,13 @@ module Admin
def show def show
@sponsor.swag_index = @sponsor.swag.length @sponsor.swag_index = @sponsor.swag.length
@sponsor.courier_index = @sponsor.courier_info.length @sponsor.carrier_index = @sponsor.swag_transportation.length
end end
def edit def edit
@sponsor.swag = @sponsor.swag
@sponsor.swag_index = @sponsor.swag.length @sponsor.swag_index = @sponsor.swag.length
@sponsor.courier_index = @sponsor.courier_info.length @sponsor.carrier_index = @sponsor.swag_transportation.length
end end
def new def new
@ -115,8 +116,8 @@ module Admin
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,
:paid, :has_swag, :swag_received, :address, :vat, :has_banner, :swag_index, :courier_index, :paid, :has_swag, :swag_received, :address, :vat, :has_banner, :swag_index, :carrier_index, :amount,
swags: [:type, :quantity], courier_info: [:courier_name, :tracking_number, :boxes]) swag: [:type, :quantity], swag_transportation: [:carrier_name, :tracking_number, :boxes])
end end
def sponsorship_level_required def sponsorship_level_required

View file

@ -4,11 +4,11 @@ class Sponsor < ActiveRecord::Base
belongs_to :sponsorship_level belongs_to :sponsorship_level
belongs_to :conference belongs_to :conference
serialize :swags, Hash serialize :swag, Hash
serialize :courier_info, Hash serialize :swag_transportation, Hash
attr_accessor :type, :quantity, :swag_index, :courier_index, attr_accessor :type, :quantity, :swag_index, :carrier_index,
:courier_name, :tracking_number, :boxes :carrier_name, :tracking_number, :boxes
has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id } has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id }
@ -23,7 +23,6 @@ class Sponsor < ActiveRecord::Base
state :unconfirmed state :unconfirmed
state :confirmed state :confirmed
event :confirm do event :confirm do
transitions to: :confirmed, from: [:unconfirmed] transitions to: :confirmed, from: [:unconfirmed]
end end

View 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 }

View file

@ -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 }

View file

@ -1,5 +1,5 @@
.row .row
.col-md-6 .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 .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}

View file

@ -8,11 +8,12 @@
.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|
= f.input :name = f.input :name
= f.input :amount, as: :number, label: 'Donation amount'
= f.input :description, input_html: { rows: 5, data: { provide: 'markdown-editable' } } = f.input :description, input_html: { rows: 5, data: { provide: 'markdown-editable' } }
= 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 :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' = f.input :vat, label: 'VAT Registration Number'
%b Has Swags? %b Has Swags?
= check_box_tag @conference.short_title, @sponsor.id, @sponsor.has_swag, = check_box_tag @conference.short_title, @sponsor.id, @sponsor.has_swag,
@ -21,13 +22,13 @@
off_color: 'warning', off_color: 'warning',
on_text: 'Yes', on_text: 'Yes',
off_text: 'No' } 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: 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} =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| - @sponsor.swag_transportation.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: '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: 'courier_fields', locals: {f: f, index: @sponsor.courier_index, name_value: nil, tracking_value: nil, boxes_value: nil} =render partial: 'carrier_fields', locals: {f: f, index: @sponsor.carrier_index, name_value: nil, tracking_value: nil, boxes_value: nil}
.row .row
.col-md-8 .col-md-8

View file

@ -24,6 +24,7 @@
%thead %thead
%th Logo %th Logo
%th Name %th Name
%th Donation
%th Payment %th Payment
%th Level %th Level
%th Actions %th Actions
@ -34,6 +35,8 @@
= image_tag(sponsor.picture.thumb.url, width: '20%') = image_tag(sponsor.picture.thumb.url, width: '20%')
%td %td
= link_to sponsor.name, admin_conference_sponsor_path(@conference.short_title, sponsor) = link_to sponsor.name, admin_conference_sponsor_path(@conference.short_title, sponsor)
%td
= sponsor.amount
%td %td
- if sponsor.payed - if sponsor.payed
%span.fa.fa-check.text-success %span.fa.fa-check.text-success
@ -88,17 +91,20 @@
%span.fa.fa-times.text-danger %span.fa.fa-times.text-danger
%td %td
- if sponsor.has_swag - if sponsor.has_swag
- sponsor.swags.each do |key, value| - sponsor.swag.each do |key, value|
= value[:type] = value[:type]
( (
= value[:quantity] = value[:quantity]
) )
%br %br
%td %td
- if sponsor.swag_received = check_box_tag @conference.short_title, sponsor.id, sponsor.swag_received,
%span.fa.fa-check.text-success method: :patch, url: "/admin/conferences/#{@conference.short_title}/sponsors/#{sponsor.id}?sponsor[swag_received]=",
- else class: 'switch-checkbox', data: { size: 'small',
%span.fa.fa-times.text-danger off_color: 'warning',
on_text: 'Yes',
off_text: 'No' }
%td %td
.btn-group .btn-group
= link_to 'Edit', edit_admin_conference_sponsor_path(@conference.short_title, sponsor), = link_to 'Edit', edit_admin_conference_sponsor_path(@conference.short_title, sponsor),
@ -135,7 +141,7 @@
%td %td
= truncate(sponsor.description) = truncate(sponsor.description)
%td %td
= sponsor.website_url = link_to sponsor.website_url, sponsor.website_url
%td %td
= sponsor.sponsorship_level.title = sponsor.sponsorship_level.title
%td %td

View file

@ -13,6 +13,12 @@
method: :delete, class: 'btn btn-danger', data: { confirm: "Do you really want to delete the sponsor #{@sponsor.name}?" } method: :delete, class: 'btn btn-danger', data: { confirm: "Do you really want to delete the sponsor #{@sponsor.name}?" }
.col-md-12 .col-md-12
%table.table %table.table
%tr
- if @sponsor.amount?
%td.col-md-2
%b Donation amount
%td
= @sponsor.amount
%tr %tr
%td.col-md-2 %td.col-md-2
%b Sponsorship paid? %b Sponsorship paid?
@ -47,13 +53,13 @@
- if @sponsor.address? - if @sponsor.address?
%tr %tr
%td.col-md-2 %td.col-md-2
%b Company's address %b Sponsor's address
%td %td
= @sponsor.address = @sponsor.address
- if @sponsor.vat? - if @sponsor.vat?
%tr %tr
%td.col-md-2 %td.col-md-2
%b Campany's VAT Registration Number %b Sponsor's VAT Registration Number
%td %td
= @sponsor.vat = @sponsor.vat
%tr %tr
@ -67,6 +73,20 @@
on_text: 'Yes', on_text: 'Yes',
off_text: 'No' } 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 - if @sponsor.has_swag
%tr %tr
%td.col-md-2 %td.col-md-2
@ -78,32 +98,10 @@
off_color: 'warning', off_color: 'warning',
on_text: 'Yes', on_text: 'Yes',
off_text: 'No' } 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 .row
.col-md-12 .col-md-12
%table.table %table.table
- if @sponsor.courier_index > 0 - if @sponsor.carrier_index > 0
%tr %tr
%td.col-md-2 %td.col-md-2
%b Courrier's name %b Courrier's name
@ -111,10 +109,10 @@
%b Tracking Number %b Tracking Number
%td %td
%b Number of boxes %b Number of boxes
- @sponsor.courier_info.each do |key, value| - @sponsor.swag_transportation.each do |key, value|
%tr %tr
%td.col-md-2 %td.col-md-2
= value[:courier_name] = value[:carrier_name]
%td %td
= value[:tracking_number] = value[:tracking_number]
%td %td

View file

@ -1,13 +1,14 @@
class AddSwagsToSponsors < ActiveRecord::Migration class AddSwagsToSponsors < ActiveRecord::Migration
def change def change
add_column :sponsors, :paid, :boolean, default: false add_column :sponsors, :paid, :boolean, default: false
add_column :sponsors, :amount, :float
add_column :sponsors, :has_swag, :boolean, default: false add_column :sponsors, :has_swag, :boolean, default: false
add_column :sponsors, :swag_received, :boolean add_column :sponsors, :swag_received, :boolean
add_column :sponsors, :address, :string add_column :sponsors, :address, :string
add_column :sponsors, :vat, :string add_column :sponsors, :vat, :string
add_column :sponsors, :has_banner, :boolean, default: false add_column :sponsors, :has_banner, :boolean, default: false
add_column :sponsors, :swag, :text add_column :sponsors, :swag, :text
add_column :sponsors, :courier_info, :text add_column :sponsors, :swag_transportation, :text
add_column :sponsors, :state, :string add_column :sponsors, :state, :string
end end
end end

View file

@ -48,11 +48,11 @@ ActiveRecord::Schema.define(version: 20170822173332) do
t.text "reasoning" t.text "reasoning"
t.string "state" t.string "state"
t.string "logo_link" t.string "logo_link"
t.string "website_url"
t.text "submitter_relationship"
t.integer "conference_id" t.integer "conference_id"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.string "website_url"
t.text "submitter_relationship"
end end
create_table "campaigns", force: :cascade do |t| 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 "end_hour", default: 20
t.integer "organization_id" t.integer "organization_id"
t.integer "ticket_layout", default: 0 t.integer "ticket_layout", default: 0
t.integer "booth_limit", default: 0
t.string "custom_domain" t.string "custom_domain"
t.integer "booth_limit", default: 0
end end
add_index "conferences", ["organization_id"], name: "index_conferences_on_organization_id" 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.string "cfp_dates_updated_subject"
t.text "program_schedule_public_body" t.text "program_schedule_public_body"
t.text "cfp_dates_updated_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.boolean "send_on_booths_acceptance", default: false
t.string "booths_acceptance_subject" t.string "booths_acceptance_subject"
t.text "booths_acceptance_body" t.text "booths_acceptance_body"
@ -325,11 +328,8 @@ ActiveRecord::Schema.define(version: 20170822173332) do
t.integer "ticket_purchase_id", null: false t.integer "ticket_purchase_id", null: false
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.string "token"
end end
add_index "physical_tickets", ["token"], name: "index_physical_tickets_on_token", unique: true
create_table "programs", force: :cascade do |t| create_table "programs", force: :cascade do |t|
t.integer "conference_id" t.integer "conference_id"
t.integer "rating", default: 0 t.integer "rating", default: 0
@ -469,13 +469,14 @@ ActiveRecord::Schema.define(version: 20170822173332) do
t.datetime "updated_at" t.datetime "updated_at"
t.string "picture" t.string "picture"
t.boolean "paid", default: false t.boolean "paid", default: false
t.float "amount"
t.boolean "has_swag", default: false t.boolean "has_swag", default: false
t.boolean "swag_received" t.boolean "swag_received"
t.string "address" t.string "address"
t.string "vat" t.string "vat"
t.boolean "has_banner", default: false t.boolean "has_banner", default: false
t.text "swag" t.text "swag"
t.text "courier_info" t.text "swag_transportation"
t.string "state" t.string "state"
end end
@ -586,6 +587,7 @@ ActiveRecord::Schema.define(version: 20170822173332) do
t.boolean "is_admin", default: false t.boolean "is_admin", default: false
t.string "username" t.string "username"
t.boolean "is_disabled", default: false t.boolean "is_disabled", default: false
t.string "token"
end end
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true