diff --git a/.haml-lint_todo.yml b/.haml-lint_todo.yml index b79ddc17..3fc8440b 100644 --- a/.haml-lint_todo.yml +++ b/.haml-lint_todo.yml @@ -89,8 +89,12 @@ linters: - "app/views/admin/schedules/show.html.haml" - "app/views/admin/splashpages/_form.html.haml" - "app/views/admin/splashpages/show.html.haml" - - "app/views/admin/sponsors/_form.html.haml" + - "app/views/admin/sponsors/_carrier_fields.html.haml" + - "app/views/admin/sponsors/_swag_fields.html.haml" + - "app/views/admin/sponsors/edit.html.haml" - "app/views/admin/sponsors/index.html.haml" + - "app/views/admin/sponsors/new.html.haml" + - "app/views/admin/sponsors/show.html.haml" - "app/views/admin/sponsorship_levels/_form.html.haml" - "app/views/admin/sponsorship_levels/index.html.haml" - "app/views/admin/targets/_form.html.haml" @@ -269,6 +273,7 @@ linters: - "app/views/admin/questions/show.html.haml" - "app/views/admin/roles/show.html.haml" - "app/views/admin/schedules/index.html.haml" + - "app/views/admin/sponsors/index.html.haml" - "app/views/admin/sponsorship_levels/index.html.haml" - "app/views/admin/users/_event_registrations.html.haml" - "app/views/admin/users/show.html.haml" @@ -365,6 +370,7 @@ linters: - "app/views/admin/emails/index.html.haml" - "app/views/admin/events/show.html.haml" - "app/views/admin/reports/index.html.haml" + - "app/views/admin/sponsors/index.html.haml" - "app/views/admin/users/show.html.haml" - "app/views/admin/venues/_form.html.haml" - "app/views/conferences/index.html.haml" diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a91f2ae9..5c3ce628 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -585,6 +585,7 @@ Style/PredicateName: - 'spec/**/*' - 'app/models/comment.rb' - 'app/models/contact.rb' + - 'app/controllers/admin/sponsors_controller.rb' # Offense count: 1 # Cop supports --auto-correct. diff --git a/app/controllers/admin/sponsors_controller.rb b/app/controllers/admin/sponsors_controller.rb index 909c2d7c..4356f8ca 100644 --- a/app/controllers/admin/sponsors_controller.rb +++ b/app/controllers/admin/sponsors_controller.rb @@ -8,7 +8,12 @@ module Admin authorize! :index, Sponsor.new(conference_id: @conference.id) end - def edit; end + def show; end + + def edit + @sponsor.swag_index = @sponsor.swag.length + @sponsor.carrier_index = @sponsor.swag_transportation.length + end def new @sponsor = @conference.sponsors.new @@ -27,8 +32,11 @@ module Admin def update if @sponsor.update_attributes(sponsor_params) - redirect_to admin_conference_sponsors_path( - conference_id: @conference.short_title), + @sponsor.update_attribute(:swag, @sponsor.swag.reject! { |_key, value| value[:type].blank? || value[:quantity].blank? }) + @sponsor.update_attribute(:swag_transportation, @sponsor.swag_transportation.reject! { |_key, value| value[:carrier_name].blank? || value[:tracking_number].blank? }) + + 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 +55,73 @@ module Admin end 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 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 contact + @sponsor.contact! + + if @sponsor.save + redirect_to admin_conference_sponsors_path(@conference.short_title), + notice: 'Sponsor\'s state successfully updated' + else + flash[:error] = 'Sponsor\'s state couldn\'t be updated' + end + 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 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, :carrier_index, :amount, + responsibe: [:responsible_name, :responsible_email], swag: [:type, :quantity], + swag_transportation: [:carrier_name, :tracking_number, :boxes]) end def sponsorship_level_required diff --git a/app/models/sponsor.rb b/app/models/sponsor.rb index df687f20..08678904 100644 --- a/app/models/sponsor.rb +++ b/app/models/sponsor.rb @@ -1,10 +1,45 @@ class Sponsor < ActiveRecord::Base + include ActiveRecord::Transitions + belongs_to :sponsorship_level belongs_to :conference + serialize :swag, Hash + serialize :swag_transportation, Hash + serialize :responsibe, Hash + + attr_accessor :type, :quantity, :swag_index, :carrier_index, + :carrier_name, :tracking_number, :boxes, + :responsible_name, :responsible_email + has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id } mount_uploader :picture, PictureUploader, mount_on: :logo_file_name validates :name, :website_url, :sponsorship_level, presence: true + + scope :confirmed, -> { where(state: 'confirmed') } + scope :contacted, -> { where(state: 'contacted') } + + state_machine initial: :to_contact do + state :to_contact + state :confirmed + state :contacted + + event :confirm do + transitions to: :confirmed, from: [:to_contact, :contacted] + end + + event :cancel do + transitions to: :to_contact, from: [:confirmed, :contacted] + end + + event :contact do + transitions to: :contacted, from: [:to_contact] + end + end + + def transition_possible?(transition) + self.class.state_machine.events_for(current_state).include?(transition) + end end diff --git a/app/views/admin/sponsors/_carrier_fields.html.haml b/app/views/admin/sponsors/_carrier_fields.html.haml new file mode 100644 index 00000000..8ed811dd --- /dev/null +++ b/app/views/admin/sponsors/_carrier_fields.html.haml @@ -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 } diff --git a/app/views/admin/sponsors/_swag_fields.html.haml b/app/views/admin/sponsors/_swag_fields.html.haml new file mode 100644 index 00000000..502d41cc --- /dev/null +++ b/app/views/admin/sponsors/_swag_fields.html.haml @@ -0,0 +1,5 @@ +.row + .col-md-6 + = 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...9999, input_html: { name: "sponsor[swag][#{index}][quantity]", value: quantity_value} diff --git a/app/views/admin/sponsors/edit.html.haml b/app/views/admin/sponsors/edit.html.haml new file mode 100644 index 00000000..4948ba26 --- /dev/null +++ b/app/views/admin/sponsors/edit.html.haml @@ -0,0 +1,55 @@ +.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 :amount, as: :number, label: 'Donation amount' + %b Sponsorship paid? + = check_box_tag @conference.short_title, @sponsor.id, @sponsor.paid, + method: :patch, url: "/admin/conferences/#{@conference.short_title}/sponsors/#{@sponsor.id}?sponsor[paid]=", + class: 'switch-checkbox', data: { size: 'small', + off_color: 'warning', + on_text: 'Yes', + off_text: 'No' } + = f.input :responsible_name, label: 'Responsible\'s name', hint: 'The person with whom you are in contact', input_html: { name: 'sponsor[responsibe][responsible_name]', value: @sponsor.responsibe[:responsible_name] } + = f.input :responsible_name, label: 'Responsible\'s email', input_html: { name: 'sponsor[responsibe][responsible_email]', value: @sponsor.responsibe[:responsible_email] } + = 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: '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, + 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.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} + + %b Swag received? + = 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' } + + - @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 + = 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' } diff --git a/app/views/admin/sponsors/index.html.haml b/app/views/admin/sponsors/index.html.haml index 1c8f1077..c485ff61 100644 --- a/app/views/admin/sponsors/index.html.haml +++ b/app/views/admin/sponsors/index.html.haml @@ -4,36 +4,209 @@ %h1 Sponsors %p.text-muted People supporting your conference -- if @conference.sponsors.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.each do |sponsor| - %tr - %td - = image_tag(sponsor.picture.thumb.url, width: '20%') - %td - = sponsor.name - %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-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}?" } .row .col-md-12 - = link_to 'Add Sponsor', new_admin_conference_sponsor_path(@conference.short_title), class: 'btn btn-primary pull-right' + %div{ role: 'tabpanel' } + %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: '#contacted', role: 'tab' } Contacted + %li + %a{ 'data-toggle' => 'tab', href: '#to_contact', role: 'tab' } To contact + + .tab-content + #sponsorship.tab-pane.active + - if @conference.sponsors.confirmed.any? + .row + .col-md-12 + %table.table.table-hover + %thead + %th Logo + %th Name + %th Donation + %th Payment + %th Level + %th Actions + %tbody + - @conference.sponsors.confirmed.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 + = sponsor.amount + %td + - if sponsor.paid + %span.fa.fa-check.text-success + - else + %span.fa.fa-times.text-danger + %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-warning' + - else + %p No confirmed sponsors yet! + #swags.tab-pane + - if @conference.sponsors.confirmed.any? + .row + .col-md-12 + %table.table.table-hover + %thead + %th Logo + %th Name + %th Banner + %th Swags + %th Swag Items + %th Received + %th Actions + %tbody + - @conference.sponsors.confirmed.each do |sponsor| + %tr + %td + - if sponsor.picture? + = image_tag(sponsor.picture.thumb.url, width: '20%') + %td + = link_to sponsor.name, admin_conference_sponsor_path(@conference.short_title, sponsor) + %td + - if sponsor.has_banner + %span.fa.fa-check.text-success + - else + %span.fa.fa-times.text-danger + %td + - if sponsor.has_swag + %span.fa.fa-check.text-success + - else + %span.fa.fa-times.text-danger + %td + - if sponsor.swag.length > 0 + - sponsor.swag.each do |key, value| + - unless value[:type].blank? + = value[:type] + ( + = value[:quantity] + ) + %br + + %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' } + %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? :contact + = link_to 'Contacted', contact_admin_conference_sponsor_path(@conference.short_title, sponsor.id), + method: :patch, class: 'btn btn-mini btn-default' + - 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-warning' + + - else + %p No confirmed sponsors yet! + #contacted.tab-pane + - if @conference.sponsors.contacted.any? + .row + .col-md-12 + %table.table.table-hover + %thead + %th Logo + %th Name + %th Description + %th URL + %th Level + %th Actions + %tbody + - @conference.sponsors.contacted.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 + = link_to sponsor.website_url, 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-warning' + #to_contact.tab-pane + - if @conference.sponsors.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.each do |sponsor| + - if sponsor.state =='to_contact' + %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 + = link_to sponsor.website_url, 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? :contact + = link_to 'Mark as Contacted', contact_admin_conference_sponsor_path(@conference.short_title, sponsor.id), + method: :patch, class: 'btn btn-mini btn-default' + - 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-warning' + + - else + %p There are no unconfirmed sponsors + .row + .col-md-12 + = link_to 'Add Sponsor', new_admin_conference_sponsor_path(@conference.short_title), class: 'btn btn-primary pull-right' diff --git a/app/views/admin/sponsors/_form.html.haml b/app/views/admin/sponsors/new.html.haml similarity index 63% rename from app/views/admin/sponsors/_form.html.haml rename to app/views/admin/sponsors/new.html.haml index ba24f9f3..a94b1d03 100644 --- a/app/views/admin/sponsors/_form.html.haml +++ b/app/views/admin/sponsors/new.html.haml @@ -2,18 +2,18 @@ .col-md-12 .page-header %h1 - -if @sponsor.new_record? - New + New Sponsor = @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 + = 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 = f.input :sponsorship_level, collection: @conference.sponsorship_levels + %p.text-right = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' } diff --git a/app/views/admin/sponsors/show.html.haml b/app/views/admin/sponsors/show.html.haml new file mode 100644 index 00000000..26ee3c85 --- /dev/null +++ b/app/views/admin/sponsors/show.html.haml @@ -0,0 +1,131 @@ +.row + .col-md-12 + %h2 + - if @sponsor.picture? + = 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 + - if @sponsor.amount? + %td.col-md-2 + %b Donation amount + %td + = @sponsor.amount + %tr + %td.col-md-2 + %b Sponsorship paid? + %td + = check_box_tag @conference.short_title, @sponsor.id, @sponsor.paid, + method: :patch, url: "/admin/conferences/#{@conference.short_title}/sponsors/#{@sponsor.id}?sponsor[paid]=", + class: 'switch-checkbox', data: { size: 'small', + off_color: 'warning', + on_text: 'Yes', + off_text: 'No' } + - unless @sponsor.responsibe[:responsible_name].blank? + %tr + %td.col-md-2 + %b Responsible's name + %td + = @sponsor.responsibe[:responsible_name] + - unless @sponsor.responsibe[:responsible_email].blank? + %tr + %td.col-md-2 + %b Responsible's email + %td + = @sponsor.responsibe[:responsible_email] + - 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 + + + - if @sponsor.address? + %tr + %td.col-md-2 + %b Sponsor's address + %td + = @sponsor.address + - if @sponsor.vat? + %tr + %td.col-md-2 + %b Sponsor's VAT Registration Number + %td + = @sponsor.vat + %tr + %td.col-md-2 + %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]=", + class: 'switch-checkbox', data: { size: 'small', + off_color: 'warning', + on_text: 'Yes', + off_text: 'No' } + + + - if @sponsor.swag.any? + %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 + %b Swags 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.swag_transportation.any? + %tr + %td.col-md-2 + %b Courrier's name + %td.col-md-2 + %b Tracking Number + %td + %b Number of boxes + - @sponsor.swag_transportation.each do |key, value| + %tr + %td.col-md-2 + = value[:carrier_name] + %td + = value[:tracking_number] + %td + = value[:boxes] diff --git a/config/routes.rb b/config/routes.rb index 6e8a66de..f7eb5de7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -117,7 +117,13 @@ Osem::Application.routes.draw do resources :resources resources :tickets - resources :sponsors, except: [:show] + resources :sponsors do + member do + patch :confirm + patch :cancel + patch :contact + end + end resources :lodgings, except: [:show] resources :targets, except: [:show] resources :campaigns, except: [:show] diff --git a/db/migrate/20170822173332_add_swags_to_sponsors.rb b/db/migrate/20170822173332_add_swags_to_sponsors.rb new file mode 100644 index 00000000..adf0c363 --- /dev/null +++ b/db/migrate/20170822173332_add_swags_to_sponsors.rb @@ -0,0 +1,15 @@ +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, :swag_transportation, :text + add_column :sponsors, :state, :string + add_column :sponsors, :responsibe, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 82f5923d..4f6d5f98 100644 --- a/db/schema.rb +++ b/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,17 @@ ActiveRecord::Schema.define(version: 20170816203325) do t.datetime "created_at" 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 "swag_transportation" + t.string "state" + t.text "responsibe" end create_table "sponsorship_levels", force: :cascade do |t| diff --git a/spec/features/sponsor_spec.rb b/spec/features/sponsor_spec.rb index b12ee90d..30cc8bf4 100644 --- a/spec/features/sponsor_spec.rb +++ b/spec/features/sponsor_spec.rb @@ -26,6 +26,7 @@ feature Sponsor do click_button 'Create Sponsor' expect(flash).to eq('Sponsor successfully created.') + click_link 'To contact' within('table#sponsors') do expect(page.has_content?('SUSE')).to be true expect(page.has_content?('The original provider')).to be true