add to_contact and contacted tabs
This commit is contained in:
parent
9d2d1c0e5a
commit
7cd1635317
6 changed files with 78 additions and 19 deletions
|
|
@ -90,7 +90,7 @@ linters:
|
|||
- "app/views/admin/splashpages/_form.html.haml"
|
||||
- "app/views/admin/splashpages/show.html.haml"
|
||||
- "app/views/admin/sponsors/_carrier_fields.html.haml"
|
||||
- "pp/views/admin/sponsors/_swag_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"
|
||||
|
|
@ -273,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"
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ module Admin
|
|||
load_and_authorize_resource :sponsor, through: :conference
|
||||
before_action :sponsorship_level_required, only: [:index, :new]
|
||||
|
||||
helper_method :add_swags
|
||||
|
||||
def index
|
||||
authorize! :index, Sponsor.new(conference_id: @conference.id)
|
||||
end
|
||||
|
|
@ -58,11 +56,6 @@ module Admin
|
|||
end
|
||||
end
|
||||
|
||||
def add_swags
|
||||
@sponsor.update_attributes(sponsor_params)
|
||||
redirect_to edit_admin_conference_sponsor_path(@conference.short_title, @sponsor)
|
||||
end
|
||||
|
||||
def confirm
|
||||
@sponsor.confirm!
|
||||
|
||||
|
|
@ -85,6 +78,17 @@ module Admin
|
|||
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
|
||||
|
|
|
|||
|
|
@ -17,18 +17,24 @@ class Sponsor < ActiveRecord::Base
|
|||
validates :name, :website_url, :sponsorship_level, presence: true
|
||||
|
||||
scope :confirmed, -> { where(state: 'confirmed') }
|
||||
scope :unconfirmed, -> { where(state: 'unconfirmed') }
|
||||
scope :contacted, -> { where(state: 'contacted') }
|
||||
scope :to_contact, -> { where(state: 'to_contact') }
|
||||
|
||||
state_machine initial: :unconfirmed do
|
||||
state :unconfirmed
|
||||
state_machine initial: :to_contact do
|
||||
state :to_contact
|
||||
state :confirmed
|
||||
state :contacted
|
||||
|
||||
event :confirm do
|
||||
transitions to: :confirmed, from: [:unconfirmed]
|
||||
transitions to: :confirmed, from: [:to_contact, :contacted]
|
||||
end
|
||||
|
||||
event :cancel do
|
||||
transitions to: :unconfirmed, from: [:confirmed]
|
||||
transitions to: :to_contact, from: [:confirmed, :contacted]
|
||||
end
|
||||
|
||||
event :contact do
|
||||
transitions to: :contacted, from: [:to_contact]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@
|
|||
%li
|
||||
%a{ 'data-toggle' => 'tab', href: '#swags', role: 'tab' } Swags
|
||||
%li
|
||||
%a{'data-toggle' => 'tab', href: '#unconfirmed', role: 'tab' } Unconfirmed
|
||||
%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
|
||||
|
|
@ -114,16 +116,20 @@
|
|||
- 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!
|
||||
#unconfirmed.tab-pane
|
||||
- if @conference.sponsors.unconfirmed.any?
|
||||
#contacted.tab-pane
|
||||
- if @conference.sponsors.contacted.any?
|
||||
.row
|
||||
.col-md-12
|
||||
%table.table.table-hover#sponsors
|
||||
%table.table.table-hover
|
||||
%thead
|
||||
%th Logo
|
||||
%th Name
|
||||
|
|
@ -132,7 +138,7 @@
|
|||
%th Level
|
||||
%th Actions
|
||||
%tbody
|
||||
- @conference.sponsors.unconfirmed.each do |sponsor|
|
||||
- @conference.sponsors.contacted.each do |sponsor|
|
||||
%tr
|
||||
%td
|
||||
= image_tag(sponsor.picture.thumb.url, width: '20%')
|
||||
|
|
@ -156,6 +162,47 @@
|
|||
- 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.to_contact.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.to_contact.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? :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 There are no unconfirmed sponsors
|
||||
.row
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ Osem::Application.routes.draw do
|
|||
member do
|
||||
patch :confirm
|
||||
patch :cancel
|
||||
patch :contact
|
||||
end
|
||||
end
|
||||
resources :lodgings, except: [:show]
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ feature Sponsor do
|
|||
click_button 'Create Sponsor'
|
||||
|
||||
expect(flash).to eq('Sponsor successfully created.')
|
||||
click_link 'Unconfirmed'
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue