Merge branch 'master' into patch-1

This commit is contained in:
Stella Rouzi 2017-08-09 11:37:09 +03:00 committed by GitHub
commit dfdb6f3a25
26 changed files with 471 additions and 133 deletions

View file

@ -11,7 +11,6 @@ linters:
# Offense count: 945 # Offense count: 945
LineLength: LineLength:
exclude: exclude:
- "app/views/admin/booths/_form.html.haml"
- "app/views/admin/booths/index.html.haml" - "app/views/admin/booths/index.html.haml"
- "app/views/admin/booths/show.html.haml" - "app/views/admin/booths/show.html.haml"
- "app/views/admin/campaigns/_form.html.haml" - "app/views/admin/campaigns/_form.html.haml"
@ -109,6 +108,9 @@ linters:
- "app/views/admin/versions/_object_desc_and_link.html.haml" - "app/views/admin/versions/_object_desc_and_link.html.haml"
- "app/views/admin/versions/index.html.haml" - "app/views/admin/versions/index.html.haml"
- "app/views/admin/volunteers/index.html.haml" - "app/views/admin/volunteers/index.html.haml"
- "app/views/booths/_form.html.haml"
- "app/views/booths/index.html.haml"
- "app/views/booths/show.html.haml"
- "app/views/commercials/edit.html.haml" - "app/views/commercials/edit.html.haml"
- "app/views/commercials/new.html.haml" - "app/views/commercials/new.html.haml"
- "app/views/conference_registrations/_form.html.haml" - "app/views/conference_registrations/_form.html.haml"
@ -369,6 +371,7 @@ linters:
- "app/views/admin/tracks/show.html.haml" - "app/views/admin/tracks/show.html.haml"
- "app/views/admin/venues/show.html.haml" - "app/views/admin/venues/show.html.haml"
- "app/views/admin/versions/index.html.haml" - "app/views/admin/versions/index.html.haml"
- "app/views/booths/index.html.haml"
- "app/views/conference_registrations/_form.html.haml" - "app/views/conference_registrations/_form.html.haml"
- "app/views/conference_registrations/_ticket.html.haml" - "app/views/conference_registrations/_ticket.html.haml"
- "app/views/conference_registrations/show.html.haml" - "app/views/conference_registrations/show.html.haml"
@ -397,6 +400,7 @@ linters:
- "app/views/admin/schedules/_day_tab.html.haml" - "app/views/admin/schedules/_day_tab.html.haml"
- "app/views/admin/schedules/_event.html.haml" - "app/views/admin/schedules/_event.html.haml"
- "app/views/admin/versions/_object_desc_and_link.html.haml" - "app/views/admin/versions/_object_desc_and_link.html.haml"
- "app/views/booths/index.html.haml"
- "app/views/schedules/_carousel.html.haml" - "app/views/schedules/_carousel.html.haml"
# Offense count: 29 # Offense count: 29

View file

@ -333,6 +333,8 @@ Metrics/MethodLength:
# Configuration parameters: CountComments. # Configuration parameters: CountComments.
Metrics/ModuleLength: Metrics/ModuleLength:
Max: 159 Max: 159
Exclude:
- 'app/helpers/format_helper.rb'
# Offense count: 15 # Offense count: 15
Metrics/PerceivedComplexity: Metrics/PerceivedComplexity:

View file

@ -57,7 +57,7 @@ gem 'unobtrusive_flash', '>=3'
gem 'transitions', :require => %w( transitions active_record/transitions ) gem 'transitions', :require => %w( transitions active_record/transitions )
# for comments # for comments
gem 'awesome_nested_set', '~> 3.0.0.rc.5' gem 'awesome_nested_set', '~> 3.1.3'
gem 'acts_as_commentable_with_threading' gem 'acts_as_commentable_with_threading'
# as templating language # as templating language

View file

@ -69,11 +69,10 @@ GEM
uuidtools uuidtools
arel (6.0.4) arel (6.0.4)
ast (2.3.0) ast (2.3.0)
autoprefixer-rails (5.1.9) autoprefixer-rails (7.1.1)
execjs execjs
json awesome_nested_set (3.1.3)
awesome_nested_set (3.0.0.rc.5) activerecord (>= 4.0.0, < 5.2)
activerecord (>= 4.0.0, < 5)
aws_cf_signer (0.1.3) aws_cf_signer (0.1.3)
axlsx_rails (0.2.0) axlsx_rails (0.2.0)
axlsx (>= 2.0.1) axlsx (>= 2.0.1)
@ -117,13 +116,14 @@ GEM
rest-client rest-client
cocoon (1.2.6) cocoon (1.2.6)
coderay (1.1.1) coderay (1.1.1)
coffee-rails (4.1.1) coffee-rails (4.2.2)
coffee-script (>= 2.2.0) coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x) railties (>= 4.0.0)
coffee-script (2.4.1) coffee-script (2.4.1)
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.10.0) coffee-script-source (1.12.2)
concurrent-ruby (1.0.5)
countable-rails (0.0.1) countable-rails (0.0.1)
railties (>= 3.1) railties (>= 3.1)
countries (1.2.5) countries (1.2.5)
@ -145,10 +145,10 @@ GEM
dante (0.2.0) dante (0.2.0)
database_cleaner (1.3.0) database_cleaner (1.3.0)
debug_inspector (0.0.2) debug_inspector (0.0.2)
delayed_job (4.1.1) delayed_job (4.1.3)
activesupport (>= 3.0, < 5.0) activesupport (>= 3.0, < 5.2)
delayed_job_active_record (4.1.0) delayed_job_active_record (4.1.2)
activerecord (>= 3.0, < 5) activerecord (>= 3.0, < 5.2)
delayed_job (>= 3.0, < 5) delayed_job (>= 3.0, < 5)
devise (4.2.0) devise (4.2.0)
bcrypt (~> 3.0) bcrypt (~> 3.0)
@ -162,10 +162,10 @@ GEM
docile (1.1.5) docile (1.1.5)
domain_name (0.5.20160310) domain_name (0.5.20160310)
unf (>= 0.0.5, < 1.0.0) unf (>= 0.0.5, < 1.0.0)
dotenv (2.1.1) dotenv (2.2.1)
dotenv-rails (2.1.1) dotenv-rails (2.2.1)
dotenv (= 2.1.1) dotenv (= 2.2.1)
railties (>= 4.0, < 5.1) railties (>= 3.2, < 5.2)
erubis (2.7.0) erubis (2.7.0)
execjs (2.6.0) execjs (2.6.0)
factory_girl (4.5.0) factory_girl (4.5.0)
@ -180,8 +180,8 @@ GEM
fastimage (2.0.0) fastimage (2.0.0)
addressable (~> 2) addressable (~> 2)
ffi (1.9.18) ffi (1.9.18)
font-awesome-rails (4.1.0.0) font-awesome-rails (4.7.0.2)
railties (>= 3.2, < 5.0) railties (>= 3.2, < 5.2)
formatador (0.2.5) formatador (0.2.5)
formtastic (3.1.3) formtastic (3.1.3)
actionpack (>= 3.2.13) actionpack (>= 3.2.13)
@ -219,8 +219,7 @@ GEM
rubocop (>= 0.47.0) rubocop (>= 0.47.0)
sysexits (~> 1.1) sysexits (~> 1.1)
hashdiff (0.3.4) hashdiff (0.3.4)
hashie (2.1.1) hashie (3.5.5)
hike (1.2.3)
hoptoad_notifier (2.4.11) hoptoad_notifier (2.4.11)
activesupport activesupport
builder builder
@ -235,8 +234,9 @@ GEM
jquery-datatables-rails (2.2.3) jquery-datatables-rails (2.2.3)
jquery-rails jquery-rails
sass-rails sass-rails
jquery-rails (3.1.4) jquery-rails (4.3.1)
railties (>= 3.0, < 5.0) rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0) thor (>= 0.14, < 2.0)
jquery-ui-rails (4.2.1) jquery-ui-rails (4.2.1)
railties (>= 3.2.16) railties (>= 3.2.16)
@ -295,15 +295,15 @@ GEM
notiffany (0.1.1) notiffany (0.1.1)
nenv (~> 0.1) nenv (~> 0.1)
shellany (~> 0.0) shellany (~> 0.0)
oauth2 (0.9.4) oauth2 (1.3.1)
faraday (>= 0.8, < 0.10) faraday (>= 0.8, < 0.12)
jwt (~> 1.0) jwt (~> 1.0)
multi_json (~> 1.3) multi_json (~> 1.3)
multi_xml (~> 0.5) multi_xml (~> 0.5)
rack (~> 1.2) rack (>= 1.2, < 3)
omniauth (1.2.1) omniauth (1.6.1)
hashie (>= 1.2, < 3) hashie (>= 3.4.6, < 3.6.0)
rack (~> 1.0) rack (>= 1.6.2, < 3)
omniauth-facebook (1.6.0) omniauth-facebook (1.6.0)
omniauth-oauth2 (~> 1.1) omniauth-oauth2 (~> 1.1)
omniauth-github (1.1.2) omniauth-github (1.1.2)
@ -312,10 +312,8 @@ GEM
omniauth-google-oauth2 (0.2.4) omniauth-google-oauth2 (0.2.4)
omniauth (~> 1.0) omniauth (~> 1.0)
omniauth-oauth2 (~> 1.1) omniauth-oauth2 (~> 1.1)
omniauth-oauth2 (1.1.2) omniauth-oauth2 (1.4.0)
faraday (>= 0.8, < 0.10) oauth2 (~> 1.0)
multi_json (~> 1.3)
oauth2 (~> 0.9.3)
omniauth (~> 1.2) omniauth (~> 1.2)
omniauth-openid (1.0.1) omniauth-openid (1.0.1)
omniauth (~> 1.0) omniauth (~> 1.0)
@ -425,8 +423,9 @@ GEM
redcarpet (3.2.3) redcarpet (3.2.3)
referer-parser (0.2.1) referer-parser (0.2.1)
request_store (1.1.0) request_store (1.1.0)
responders (2.1.1) responders (2.4.0)
railties (>= 4.2.0, < 5.1) actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3)
rest-client (1.8.0) rest-client (1.8.0)
http-cookie (>= 1.0.2, < 2.0) http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0) mime-types (>= 1.16, < 3.0)
@ -473,11 +472,12 @@ GEM
rubyzip (1.2.1) rubyzip (1.2.1)
safe_yaml (1.0.4) safe_yaml (1.0.4)
sass (3.2.19) sass (3.2.19)
sass-rails (4.0.4) sass-rails (5.0.6)
railties (>= 4.0.0, < 5.0) railties (>= 4.0.0, < 6)
sass (~> 3.2.2) sass (~> 3.1)
sprockets (~> 2.8, < 2.12) sprockets (>= 2.8, < 4.0)
sprockets-rails (~> 2.0) sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
selectize-rails (0.12.4) selectize-rails (0.12.4)
shellany (0.0.1) shellany (0.0.1)
shoulda-matchers (2.8.0) shoulda-matchers (2.8.0)
@ -494,11 +494,9 @@ GEM
spring (1.6.3) spring (1.6.3)
spring-commands-rspec (1.0.4) spring-commands-rspec (1.0.4)
spring (>= 0.9.1) spring (>= 0.9.1)
sprockets (2.11.3) sprockets (3.7.1)
hike (~> 1.2) concurrent-ruby (~> 1.0)
multi_json (~> 1.0) rack (> 1, < 3)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.3.3) sprockets-rails (2.3.3)
actionpack (>= 3.0) actionpack (>= 3.0)
activesupport (>= 3.0) activesupport (>= 3.0)
@ -566,7 +564,7 @@ DEPENDENCIES
acts_as_list acts_as_list
ahoy_matey ahoy_matey
autoprefixer-rails autoprefixer-rails
awesome_nested_set (~> 3.0.0.rc.5) awesome_nested_set (~> 3.1.3)
axlsx! axlsx!
axlsx_rails axlsx_rails
bootstrap-sass (~> 3.3.4.1) bootstrap-sass (~> 3.3.4.1)

View file

@ -29,7 +29,7 @@
} }
} }
.dropdown-menu { .dropdown-menu {
padding: 17px 17px 0px 17px; padding: 17px;
min-width: 225px; min-width: 225px;
} }
} }

View file

@ -7,9 +7,13 @@ module Admin
def show; end def show; end
def new; end def new
@url = admin_conference_booths_path(@conference.short_title)
end
def create def create
@url = admin_conference_booths_path(@conference.short_title)
@booth = @conference.booths.new(booth_params) @booth = @conference.booths.new(booth_params)
@booth.submitter = current_user @booth.submitter = current_user
@ -23,9 +27,13 @@ module Admin
end end
end end
def edit; end def edit
@url = admin_conference_booth_path(@conference.short_title, @booth.id)
end
def update def update
@url = admin_conference_booth_path(@conference.short_title, @booth.id)
@booth.update_attributes(booth_params) @booth.update_attributes(booth_params)
if @booth.save if @booth.save
@ -38,16 +46,6 @@ module Admin
end end
end end
def destroy
if @booth.destroy
redirect_to admin_conference_booths_path,
notice: 'Booth successfully destroyed.'
else
redirect_to admin_conference_booths_path,
error: "Booth couldn't be deleted. #{@booth.errors.full_messages.join('. ')}."
end
end
def accept def accept
update_state(:accept, 'Booth accepted!') update_state(:accept, 'Booth accepted!')
end end

View file

@ -0,0 +1,97 @@
class BoothsController < ApplicationController
before_action :authenticate_user!
load_resource :conference, find_by: :short_title
load_and_authorize_resource through: :conference
skip_authorize_resource only: [:withdraw, :confirm, :restart]
def index
@booths = current_user.booths.where(conference_id: @conference.id).uniq
end
def show; end
def new
@url = conference_booths_path(@conference.short_title)
end
def create
@url = conference_booths_path(@conference.short_title)
@booth.submitter = current_user
if @booth.save
redirect_to conference_booths_path,
notice: 'Booth successfully created.'
else
flash[:error] = "Creating booth failed. #{@booth.errors.full_messages.to_sentence}."
render :new
end
end
def edit
@url = conference_booth_path(@conference.short_title, @booth.id)
end
def update
@url = conference_booth_path(@conference.short_title, @booth.id)
@booth.update_attributes(booth_params)
if @booth.save
redirect_to conference_booths_path,
notice: 'Booth successfully updated!'
else
flash[:error] = "Booth could not be updated. #{@booth.errors.full_messages.to_sentence}."
end
end
def destroy; end
def withdraw
authorize! :update, @booth
@url = conference_booth_path(@conference.short_title, @booth.id)
@booth.withdraw!
if @booth.save
redirect_to conference_booths_path,
notice: 'Booth successfully withdrawn'
else
flash[:error] = "Booth could not be withdrawn. #{@booth.errors.full_messages.to_sentence}."
end
end
def confirm
authorize! :update, @booth
@url = conference_booth_path(@conference.short_title, @booth.id)
@booth.confirm!
if @booth.save
redirect_to conference_booths_path,
notice: 'Booth successfully confirmed'
else
flash[:error] = "Booth could not be confirmed. #{@booth.errors.full_messages.to_sentence}."
end
end
def restart
authorize! :update, @booth
@url = conference_booth_path(@conference.short_title, @booth.id)
@booth.restart!
if @booth.save
redirect_to conference_booths_path,
notice: 'Booth successfully re-submitted'
else
flash[:error] = "Booth could not be re-submitted. #{@booth.errors.full_messages.to_sentence}."
end
end
private
def booth_params
params.require(:booth).permit(:title, :description, :reasoning, :state, :picture, :conference_id,
:created_at, :updated_at, :submitter_relationship, :website_url, responsible_ids: [])
end
end

View file

@ -15,6 +15,19 @@ module FormatHelper
end end
end end
def booth_status_icon(booth)
case booth.state
when 'new', 'to_reject', 'to_accept'
'fa-eye'
when 'accepted'
'fa-check text-muted'
when 'confirmed'
'fa-check text-success'
when 'rejected', 'withdrawn', 'canceled'
'fa-ban'
end
end
def event_progress_color(progress) def event_progress_color(progress)
progress = progress.to_i progress = progress.to_i
if progress == 100 if progress == 100

View file

@ -15,7 +15,7 @@ class Mailbot < ActionMailer::Base
PhysicalTicket.last(ticket_purchase.quantity).each do |physical_ticket| PhysicalTicket.last(ticket_purchase.quantity).each do |physical_ticket|
pdf = TicketPdf.new(@conference, @user, physical_ticket, @conference.ticket_layout.to_sym, "ticket_for_#{@conference.short_title}_#{physical_ticket.id}") pdf = TicketPdf.new(@conference, @user, physical_ticket, @conference.ticket_layout.to_sym, "ticket_for_#{@conference.short_title}_#{physical_ticket.id}")
attachments["ticket_for_#{@conference.short_title}_#{physical_ticket.id}"] = pdf.render attachments["ticket_for_#{@conference.short_title}_#{physical_ticket.id}.pdf"] = pdf.render
end end
mail(to: @user.email, mail(to: @user.email,

View file

@ -75,6 +75,12 @@ class Ability
can [:new, :create], Payment, user_id: user.id can [:new, :create], Payment, user_id: user.id
can [:index, :show], PhysicalTicket, user: user can [:index, :show], PhysicalTicket, user: user
can [:new, :create], Booth
can [:edit, :update, :index, :show], Booth do |booth|
booth.users.include?(user)
end
can [:create, :destroy], Subscription, user_id: user.id can [:create, :destroy], Subscription, user_id: user.id
can [:new, :create], Event do |event| can [:new, :create], Event do |event|

View file

@ -35,12 +35,16 @@ class Booth < ActiveRecord::Base
state :to_reject state :to_reject
state :rejected state :rejected
state :canceled state :canceled
state :confirmed
event :restart do event :restart do
transitions to: :new, from: [:withdrawn, :to_accept, :to_reject, :canceled] transitions to: :new, from: [:withdrawn, :rejected, :canceled]
end end
event :withdraw do event :withdraw do
transitions to: :withdrawn, from: [:new, :to_accept, :accepted, :to_reject, :rejected] transitions to: :withdrawn, from: [:new, :to_accept, :accepted, :to_reject, :rejected, :confirmed]
end
event :confirm do
transitions to: :confirmed, from: [:accepted]
end end
event :to_accept do event :to_accept do
transitions to: :to_accept, from: [:new, :to_reject] transitions to: :to_accept, from: [:new, :to_reject]
@ -55,7 +59,7 @@ class Booth < ActiveRecord::Base
transitions to: :rejected, from: [:new, :to_reject] transitions to: :rejected, from: [:new, :to_reject]
end end
event :cancel do event :cancel do
transitions to: :canceled, from: [:accepted, :rejected, :to_accept, :to_reject] transitions to: :canceled, from: [:accepted, :rejected, :to_accept, :to_reject, :confirmed]
end end
end end

View file

@ -1,33 +0,0 @@
.row
.col-md-12
.page-header
%title Request a Booth
.row
.col-md-8
= semantic_form_for(@booth, url: @booth.new_record? ? admin_conference_booths_path(@conference.short_title) : admin_conference_booth_path(@conference.short_title, @booth.id), html: { multipart: true }) do |f|
= f.input :title, as: :string, autofocus: true, required: true
= f.input :description, input_html: { rows: 5, data: { provide: 'markdown-editable' } }, required: true,
hint: 'This field becomes public upon request acceptance'
= f.input :reasoning, input_html: { rows: 5, data: { provide: 'markdown-editable' } }, required: true,
label: 'How it fits the conference'
= f.input :submitter_relationship, input_html: { rows: 5, data: { provide: 'markdown-editable' } }, required: true,
label: 'Submitter\'s relation',
hint: 'e.g. employee, comunity manager, etc'
= f.input :website_url
= responsibles_selector_input f
= image_tag f.object.picture.thumb.url if f.object.picture?
= f.input :picture
%p.text-right
- if @booth.new_record?
= f.submit 'Create Booth Request', class: 'btn btn-success'
- else
= f.submit 'Update Booth Request', class: 'btn btn-success'
:javascript
$(document).ready(function() {
$('#booth_responsible_ids').selectize({
plugins: ['remove_button'],
minItems: 2
} )
});

View file

@ -2,4 +2,4 @@
Editing Editing
= @booth.title = @booth.title
= render 'form' = render 'booths/form'

View file

@ -41,8 +41,9 @@
= link_to booth.submitter.name, admin_user_path(booth.submitter) if booth.submitter = link_to booth.submitter.name, admin_user_path(booth.submitter) if booth.submitter
%td %td
.responsibles .responsibles
- booth.responsibles.each do |responsible| - booth.responsibles.each_with_index do |responsible, i|
= link_to responsible.name, admin_user_path(responsible) = link_to responsible.name, admin_user_path(responsible)
= ", " unless i == booth.responsibles.length - 1
%td %td
.btn-group .btn-group
%button{ type: 'button', class: 'btn btn-link dropdown-toggle', 'data-toggle' => 'dropdown' } %button{ type: 'button', class: 'btn btn-link dropdown-toggle', 'data-toggle' => 'dropdown' }
@ -51,9 +52,5 @@
%ul.dropdown-menu{ role: 'menu' } %ul.dropdown-menu{ role: 'menu' }
= render 'change_state_dropdown', booth: booth = render 'change_state_dropdown', booth: booth
%td %td
.btn-group{ role: "group" } = link_to 'Edit', edit_admin_conference_booth_path(@conference.short_title, booth.id),
= link_to 'Edit', edit_admin_conference_booth_path(@conference.short_title, booth.id), class: 'btn btn-primary'
class: 'btn btn-primary'
= link_to 'Delete', admin_conference_booth_path(@conference.short_title, booth.id),
method: :delete, class: 'btn btn-danger',
data: {confirm: "Do you really want to delete this booth request?"}

View file

@ -1,3 +1,3 @@
%h1 New booth %h1 New booth
= render 'form' = render 'booths/form'

View file

@ -39,12 +39,13 @@
%td.col-md-2 %td.col-md-2
%b Responsibles %b Responsibles
%td %td
- @booth.responsibles.each do |responsibles| - @booth.responsibles.each_with_index do |responsibles, i|
.responsibles .responsibles
= link_to responsibles.name, admin_user_path(responsibles) = link_to responsibles.name, admin_user_path(responsibles)
( (
= responsibles.email = responsibles.email
) )
= " , " unless i == @booth.responsibles.length - 1
%tr %tr
%td.col-md-2 %td.col-md-2
%b Submitted on %b Submitted on

View file

@ -0,0 +1,30 @@
.container
.row
.col-md-8
= semantic_form_for(@booth, url: @url, html: { multipart: true }) do |f|
= f.input :title, as: :string, autofocus: true, required: true
= f.input :description, input_html: { rows: 5, data: { provide: 'markdown-editable' } }, required: true,
hint: 'This field becomes public upon request acceptance'
= f.input :reasoning, input_html: { rows: 5, data: { provide: 'markdown-editable' } }, required: true,
label: 'How it fits the conference'
= f.input :submitter_relationship, input_html: { rows: 5, data: { provide: 'markdown-editable' } }, required: true,
label: 'Submitter\'s relation',
hint: 'e.g. employee, comunity manager, etc'
= f.input :website_url
= responsibles_selector_input f
= image_tag f.object.picture.thumb.url if f.object.picture?
= f.input :picture
%p.text-right
- if @booth.new_record?
= f.submit 'Create Booth Request', class: 'btn btn-success'
- else
= f.submit 'Update Booth Request', class: 'btn btn-success'
:javascript
$(document).ready(function() {
$('#booth_responsible_ids').selectize({
plugins: ['remove_button'],
minItems: 2
} )
});

View file

@ -0,0 +1,6 @@
.container
%h1
Editing
= @booth.title
= render 'form'

View file

@ -0,0 +1,51 @@
.container
.row
.col-md-12.page-header
%h1
Your booth requests for
= @conference.title
.row
.col-md-12
.margin-booth-table
%table.table.table-striped.table-hover
%thead
%th
%b State
%th
%b Logo
%th
%b Title
%th
%b Actions
- @booths.each do |booth|
%tr
%td{ style: "padding:20px 8px 20px 8px;" }
- if (booth.state == 'to_accept' || booth.state == 'to_reject')
- show_state = 'new'
- else
- show_state = booth.state
%span{ title: show_state, class: "fa #{booth_status_icon(booth)}" }
%td
- if booth.logo_link
= image_tag(booth.picture.thumb.url, width: '20%')
%td
= link_to booth.title, conference_booth_path(@conference.short_title, booth)
%td
-if can? :edit, booth
= link_to 'Edit', edit_conference_booth_path(@conference.short_title, booth.id),
class: 'btn btn-default'
- if booth.transition_possible? :withdraw
= link_to 'Withdraw',
withdraw_conference_booth_path(@conference.short_title, booth),
method: :patch, class: 'btn btn-mini btn-warning', id: "withdraw_booth_#{booth.id}",
data: { confirm: 'Are you sure you really want to withdraw this request?' }
- if booth.transition_possible? :confirm
= link_to 'Confirm',
confirm_conference_booth_path(@conference.short_title, booth),
method: :patch, class: 'btn btn-mini btn-success', id: "confirm_booth_#{booth.id}"
- if booth.transition_possible? :restart
= link_to 'Re-submit',
restart_conference_booth_path(@conference.short_title, booth),
method: :patch, class: 'btn btn-mini btn-success', id: "restart_booth_#{booth.id}"
.pull-right
= link_to 'Add Booth', new_conference_booth_path(@conference.short_title), class: 'button btn btn-primary'

View file

@ -0,0 +1,4 @@
.container
%h1 Request a booth
= render 'form'

View file

@ -0,0 +1,60 @@
.container
.row
.col-md-12
%h3
- if @booth.logo_link
= image_tag(@booth.picture.thumb.url, size: '20%', alt: '')
= @booth.title
.btn-group.pull-right
= link_to 'Edit', edit_admin_conference_booth_path(@conference.short_title, @booth), class: 'btn btn-mini btn-primary'
.row
.col-md-12
%table.table
%tr
%td.col-md-2
%b Description
%td
= markdown(@booth.description)
%tr
%td.col-md-2
%b Reasoning
%td
= markdown(@booth.reasoning)
%tr
%td.col-md-2
%b Website
%td
- if @booth.website_url.present?
= link_to @booth.website_url, @booth.website_url
%tr
%td.col-md-2
%b Submitter
%td
= link_to @booth.submitter.name, user_path(@booth.submitter)
%tr
%td.col-md-2
%b Submitter's relationship
%td
= @booth.submitter_relationship
%tr
%td.col-md-2
%b Responsibles
%td
- @booth.responsibles.each_with_index do |responsibles, i|
.responsibles
= link_to responsibles.name, user_path(responsibles)
(
= responsibles.email
)
= ", " unless i == @booth.responsibles.length - 1
%tr
%td.col-md-2
%b Submitted on
%td
= @booth.created_at
%tr
%td.col-md-2
%b Last updated on
%td
= @booth.updated_at

View file

@ -41,7 +41,6 @@ Osem::Application.routes.draw do
member do member do
patch :accept patch :accept
patch :restart patch :restart
patch :withdrawn
patch :to_accept patch :to_accept
patch :reject patch :reject
patch :reset patch :reset
@ -131,6 +130,13 @@ Osem::Application.routes.draw do
end end
resources :organizations, only: [:index] resources :organizations, only: [:index]
resources :conferences, only: [:index, :show] do resources :conferences, only: [:index, :show] do
resources :booths do
member do
patch :withdraw
patch :confirm
patch :restart
end
end
resource :program, only: [] do resource :program, only: [] do
resources :proposals, except: :destroy do resources :proposals, except: :destroy do
get 'commercials/render_commercial' => 'commercials#render_commercial' get 'commercials/render_commercial' => 'commercials#render_commercial'

View file

@ -126,23 +126,5 @@ describe Admin::BoothsController do
end end
end end
end end
describe 'DELETE #destroy' do
context 'deletes successfully' do
before { delete :destroy, id: booth.id, conference_id: conference.short_title }
it 'booth deleted' do
expect(Booth.count).to eq(0)
end
it 'redirects to admin booth index path' do
expect(response).to redirect_to(admin_conference_booths_path)
end
it 'show success message' do
expect(flash[:notice]).to match('Booth successfully destroyed.')
end
end
end
end end
end end

View file

@ -0,0 +1,110 @@
require 'spec_helper'
describe BoothsController do
let(:user) { create(:user) }
let(:conference) { create(:conference) }
let(:booth) { create(:booth, title: 'Title', conference: conference) }
context 'user is signed in with submitter role' do
before :each do
sign_in booth.submitter
end
describe 'GET index' do
before { get :index, conference_id: conference.short_title }
it 'assigns attributes for booths' do
expect(assigns(:booths)).to eq([booth])
end
it 'renders index template' do
expect(response).to render_template('index')
end
end
describe 'GET #new' do
before { get :new, conference_id: conference.short_title }
it 'assigns attributes for booths' do
expect(assigns(:booth)).to be_a_new(Booth)
end
it 'renders new template' do
expect(response).to render_template('new')
end
end
describe 'POST #create' do
context 'successfully created' do
before { post :create, booth: attributes_for(:booth), conference_id: conference.short_title }
it 'creates a new booth' do
expect(Booth.count).to_not eq(0)
end
it 'redirects to booth index' do
expect(response).to redirect_to(conference_booths_path)
end
it 'has responsibles' do
expect(booth.responsibles.count).to_not eq(0)
end
it 'shows success message' do
expect(flash[:notice]).to match('Booth successfully created.')
end
end
context 'create action fails' do
before { post :create, booth: attributes_for(:booth, title: ''), conference_id: conference.short_title }
it 'does not create any record' do
expected = expect do
post :create, booth: attributes_for(:booth, title: ''), conference_id: conference.short_title
end
expected.to_not change(Booth, :count)
end
it 'redirects to new' do
expect(response).to render_template('new')
end
it 'shows flash message' do
expect(flash[:error]).to eq("Creating booth failed. Title can't be blank.")
end
end
end
describe 'GET #edit' do
before { get :edit, id: booth.id, conference_id: conference.short_title }
it 'renders edit template' do
expect(response).to render_template('edit')
end
it 'assigns booth variable' do
expect(assigns(:booth)).to eq booth
end
end
describe 'PATCH #update' do
context 'updates suchessfully' do
before { patch :update, id: booth.id, booth: attributes_for(:booth, title: 'different'), conference_id: conference.short_title }
it 'redirects to booth index path' do
expect(response).to redirect_to conference_booths_path
end
it 'shows success message' do
expect(flash[:notice]).to match 'Booth successfully updated!'
end
it 'updates booth' do
booth.reload
expect(booth.title).to eq('different')
end
end
end
end
end

View file

@ -8,6 +8,7 @@ FactoryGirl.define do
conference conference
submitter { create(:user) }
responsible_ids { [create(:user).id] } responsible_ids { [create(:user).id] }
end end
end end

View file

@ -33,16 +33,17 @@ describe 'Booth' do
end end
end end
states = [:new, :withdrawn, :to_accept, :accepted, :to_reject, :rejected, :canceled] states = [:new, :withdrawn, :to_accept, :accepted, :to_reject, :rejected, :canceled, :confirmed]
transitions = [:restart, :withdraw, :accept, :reject, :to_accept, :to_reject, :cancel] transitions = [:restart, :withdraw, :accept, :reject, :to_accept, :to_reject, :cancel]
states_transitions = { new: { restart: false, withdraw: true, accept: true, to_accept: true, to_reject: true, reject: true, cancel: false }, states_transitions = { new: { restart: false, withdraw: true, accept: true, to_accept: true, to_reject: true, reject: true, cancel: false, confirm: false },
withdrawn: { restart: true, withdraw: false, accept: false, to_accept: false, to_reject: false, reject: false, cancel: false }, withdrawn: { restart: true, withdraw: false, accept: false, to_accept: false, to_reject: false, reject: false, cancel: false, confirm: false },
to_accept: { restart: true, withdraw: true, accept: true, to_accept: false, to_reject: true, reject: false, cancel: true }, to_accept: { restart: false, withdraw: true, accept: true, to_accept: false, to_reject: true, reject: false, cancel: true, confirm: false },
to_reject: { restart: true, withdraw: true, accept: false, to_accept: true, to_reject: false, reject: true, cancel: true }, to_reject: { restart: false, withdraw: true, accept: false, to_accept: true, to_reject: false, reject: true, cancel: true, confirm: false },
accepted: { restart: false, withdraw: true, accept: false, to_accept: false, to_reject: false, reject: false, cancel: true }, accepted: { restart: false, withdraw: true, accept: false, to_accept: false, to_reject: false, reject: false, cancel: true, confirm: true },
rejected: { restart: false, withdraw: true, accept: false, to_accept: false, to_reject: false, reject: false, cancel: true }, rejected: { restart: true, withdraw: true, accept: false, to_accept: false, to_reject: false, reject: false, cancel: true, confirm: false },
canceled: { restart: true, withdraw: false, accept: false, to_accept: false, to_reject: false, reject: false, cancel: false } } canceled: { restart: true, withdraw: false, accept: false, to_accept: false, to_reject: false, reject: false, cancel: false, confirm: false },
confirmed: { restart: false, withdraw: true, accept: false, to_accept: false, to_reject: false, reject: false, cancel: true, confirm: false } }
states.each do |state| states.each do |state|
transitions.each do |transition| transitions.each do |transition|