Merge pull request #1084 from arun1595/define-singular-resource

Modify conference registration to a singular resource
This commit is contained in:
Stella Rouzi 2016-07-11 13:40:56 +03:00 committed by GitHub
commit eb312f139e
17 changed files with 37 additions and 37 deletions

View file

@ -10,7 +10,7 @@ class ConferenceRegistrationsController < ApplicationController
# Redirect to registration edit when user is already registered # Redirect to registration edit when user is already registered
if @conference.user_registered?(current_user) if @conference.user_registered?(current_user)
redirect_to edit_conference_conference_registrations_path(@conference.short_title) redirect_to edit_conference_conference_registration_path(@conference.short_title)
return return
# ichain does not allow us to create users during registration # ichain does not allow us to create users during registration
elsif (ENV['OSEM_ICHAIN_ENABLED'] == 'true') && !current_user elsif (ENV['OSEM_ICHAIN_ENABLED'] == 'true') && !current_user
@ -20,7 +20,7 @@ class ConferenceRegistrationsController < ApplicationController
# avoid openid sign_in to redirect to register/new when the sign_in user had already a registration # avoid openid sign_in to redirect to register/new when the sign_in user had already a registration
if current_user && @conference.user_registered?(current_user) if current_user && @conference.user_registered?(current_user)
redirect_to edit_conference_conference_registrations_path(@conference.short_title) redirect_to edit_conference_conference_registration_path(@conference.short_title)
end end
# @user variable needs to be set so that _sign_up_form_embedded works properly # @user variable needs to be set so that _sign_up_form_embedded works properly
@ -60,7 +60,7 @@ class ConferenceRegistrationsController < ApplicationController
redirect_to conference_tickets_path(@conference.short_title), redirect_to conference_tickets_path(@conference.short_title),
notice: 'You are now registered and will be receiving E-Mail notifications.' notice: 'You are now registered and will be receiving E-Mail notifications.'
else else
redirect_to conference_conference_registrations_path(@conference.short_title), redirect_to conference_conference_registration_path(@conference.short_title),
notice: 'You are now registered and will be receiving E-Mail notifications.' notice: 'You are now registered and will be receiving E-Mail notifications.'
end end
else else
@ -72,7 +72,7 @@ class ConferenceRegistrationsController < ApplicationController
def update def update
if @registration.update_attributes(registration_params) if @registration.update_attributes(registration_params)
redirect_to conference_conference_registrations_path(@conference.short_title), redirect_to conference_conference_registration_path(@conference.short_title),
notice: 'Registration was successfully updated.' notice: 'Registration was successfully updated.'
else else
flash[:error] = "Could not update your registration for #{@conference.title}: "\ flash[:error] = "Could not update your registration for #{@conference.title}: "\
@ -86,7 +86,7 @@ class ConferenceRegistrationsController < ApplicationController
redirect_to root_path, redirect_to root_path,
notice: "You are not registered for #{@conference.title} anymore!" notice: "You are not registered for #{@conference.title} anymore!"
else else
redirect_to conference_conference_registrations_path(@conference.short_title), redirect_to conference_conference_registration_path(@conference.short_title),
error: "Could not delete your registration for #{@conference.title}: "\ error: "Could not delete your registration for #{@conference.title}: "\
"#{@registration.errors.full_messages.join('. ')}." "#{@registration.errors.full_messages.join('. ')}."
end end
@ -97,7 +97,7 @@ class ConferenceRegistrationsController < ApplicationController
def set_registration def set_registration
@registration = Registration.find_by(conference: @conference, user: current_user) @registration = Registration.find_by(conference: @conference, user: current_user)
if !@registration if !@registration
redirect_to new_conference_conference_registrations_path(@conference.short_title), redirect_to new_conference_conference_registration_path(@conference.short_title),
error: "Can't find a registration for #{@conference.title} for you. Please register." error: "Can't find a registration for #{@conference.title} for you. Please register."
end end
end end

View file

@ -109,7 +109,7 @@ class ProposalController < ApplicationController
redirect_to conference_program_proposal_index_path(@conference.short_title), redirect_to conference_program_proposal_index_path(@conference.short_title),
notice: 'The proposal was confirmed.' notice: 'The proposal was confirmed.'
else else
redirect_to new_conference_conference_registrations_path(conference_id: @conference.short_title), redirect_to new_conference_conference_registration_path(conference_id: @conference.short_title),
alert: 'The proposal was confirmed. Please register to attend the conference.' alert: 'The proposal was confirmed. Please register to attend the conference.'
end end
else else

View file

@ -7,13 +7,13 @@ class TicketPurchasesController < ApplicationController
message = TicketPurchase.purchase(@conference, current_user, params[:tickets][0]) message = TicketPurchase.purchase(@conference, current_user, params[:tickets][0])
if message.blank? if message.blank?
if current_user.ticket_purchases.any? if current_user.ticket_purchases.any?
redirect_to conference_conference_registrations_path(@conference.short_title), redirect_to conference_conference_registration_path(@conference.short_title),
notice: "Thank you for supporting #{@conference.title} by purchasing a ticket." notice: "Thank you for supporting #{@conference.title} by purchasing a ticket."
else else
redirect_to conference_conference_registrations_path(@conference.short_title) redirect_to conference_conference_registration_path(@conference.short_title)
end end
else else
redirect_to conference_conference_registrations_path(@conference.short_title), redirect_to conference_conference_registration_path(@conference.short_title),
error: "Oops, something went wrong with your purchase! #{message}" error: "Oops, something went wrong with your purchase! #{message}"
end end
end end
@ -21,10 +21,10 @@ class TicketPurchasesController < ApplicationController
def destroy def destroy
@ticket_purchases = current_user.ticket_purchases.find(params[:id]) @ticket_purchases = current_user.ticket_purchases.find(params[:id])
if @ticket_purchases.destroy if @ticket_purchases.destroy
redirect_to conference_conference_registrations_path(@conference.short_title), redirect_to conference_conference_registration_path(@conference.short_title),
notice: 'Ticket successfully deleted.' notice: 'Ticket successfully deleted.'
else else
redirect_to conference_conference_registrations_path(@conference.short_title), redirect_to conference_conference_registration_path(@conference.short_title),
error: 'An error prohibited deleting your purchase! '\ error: 'An error prohibited deleting your purchase! '\
"#{@ticket_purchases.errors.full_messages.join('. ')}." "#{@ticket_purchases.errors.full_messages.join('. ')}."
end end

View file

@ -8,7 +8,7 @@ class EmailSettings < ActiveRecord::Base
'conference' => conference.title, 'conference' => conference.title,
'conference_start_date' => conference.start_date, 'conference_start_date' => conference.start_date,
'conference_end_date' => conference.end_date, 'conference_end_date' => conference.end_date,
'registrationlink' => Rails.application.routes.url_helpers.conference_conference_registrations_url( 'registrationlink' => Rails.application.routes.url_helpers.conference_conference_registration_url(
conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')), conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')),
'conference_splash_link' => Rails.application.routes.url_helpers.conference_url( 'conference_splash_link' => Rails.application.routes.url_helpers.conference_url(
conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')), conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')),

View file

@ -25,9 +25,9 @@
= link_to "Schedule", schedule_conference_path(conference.short_title), :class =>"btn btn-default" = link_to "Schedule", schedule_conference_path(conference.short_title), :class =>"btn btn-default"
- if conference.registration_open? - if conference.registration_open?
- if conference.user_registered?(current_user) - if conference.user_registered?(current_user)
= link_to "My Registration", conference_conference_registrations_path(conference.short_title), :class =>"btn btn-default" = link_to "My Registration", conference_conference_registration_path(conference.short_title), :class =>"btn btn-default"
- else - else
= link_to "Register", new_conference_conference_registrations_path(conference.short_title), class: "btn btn-default", disabled: conference.registration_limit_exceeded? = link_to "Register", new_conference_conference_registration_path(conference.short_title), class: "btn btn-default", disabled: conference.registration_limit_exceeded?
- if conference.registration_limit_exceeded? - if conference.registration_limit_exceeded?
Sorry, no places left Sorry, no places left
- if !current_user.nil? && current_user.proposal_count(conference) > 0 - if !current_user.nil? && current_user.proposal_count(conference) > 0

View file

@ -26,5 +26,5 @@
The registration period ends on The registration period ends on
= @conference.registration_period.end_date.strftime('%A, %B %-d. %Y') = @conference.registration_period.end_date.strftime('%A, %B %-d. %Y')
%p.cta-button %p.cta-button
= link_to(new_conference_conference_registrations_path(@conference.short_title), class: 'btn btn-lg btn-success') do = link_to(new_conference_conference_registration_path(@conference.short_title), class: 'btn btn-lg btn-success') do
Register Now Register Now

View file

@ -18,7 +18,7 @@
Already have an account? Already have an account?
.tab-content .tab-content
.tab-pane.active{role: 'tabpanel', id: 'signup'} .tab-pane.active{role: 'tabpanel', id: 'signup'}
= semantic_form_for(@registration, url: conference_conference_registrations_path(@conference.short_title)) do |f| = semantic_form_for(@registration, url: conference_conference_registration_path(@conference.short_title)) do |f|
= render partial: 'devise/shared/sign_up_form_embedded' = render partial: 'devise/shared/sign_up_form_embedded'
= render partial: 'registration_info', locals: { f: f } = render partial: 'registration_info', locals: { f: f }

View file

@ -117,11 +117,11 @@
.col-md-12 .col-md-12
-if @registration -if @registration
.btn-group-vertical.pull-right .btn-group-vertical.pull-right
= link_to 'Edit your Registration', edit_conference_conference_registrations_path(@conference.short_title), class: 'btn btn-success', disabled: @conference.end_date < Date.today = link_to 'Edit your Registration', edit_conference_conference_registration_path(@conference.short_title), class: 'btn btn-success', disabled: @conference.end_date < Date.today
= link_to 'Unregister', conference_conference_registrations_path(@conference.short_title), = link_to 'Unregister', conference_conference_registration_path(@conference.short_title),
method: :delete, class: 'btn btn-danger btn-xs', confirm: 'Are you sure you want to unregister?', disabled: @conference.end_date < Date.today method: :delete, class: 'btn btn-danger btn-xs', confirm: 'Are you sure you want to unregister?', disabled: @conference.end_date < Date.today
- else - else
= link_to 'Register', new_conference_conference_registrations_path(@conference.short_title), class: 'btn btn-success btn-lg pull-right' = link_to 'Register', new_conference_conference_registration_path(@conference.short_title), class: 'btn btn-success btn-lg pull-right'
.row .row
.col-md-12 .col-md-12

View file

@ -3,9 +3,9 @@
%li{'class'=>class_for_todo(progress_status['registered'])} %li{'class'=>class_for_todo(progress_status['registered'])}
%span{'class'=>icon_for_todo(progress_status['registered'])} %span{'class'=>icon_for_todo(progress_status['registered'])}
- if progress_status['registered'] - if progress_status['registered']
= link_to 'Register to the conference', edit_conference_conference_registrations_path(event.program.conference.short_title) = link_to 'Register to the conference', edit_conference_conference_registration_path(event.program.conference.short_title)
- else - else
= link_to 'Register to the conference', new_conference_conference_registrations_path(event.program.conference.short_title) = link_to 'Register to the conference', new_conference_conference_registration_path(event.program.conference.short_title)
%li{'class'=>class_for_todo(progress_status['biography'])} %li{'class'=>class_for_todo(progress_status['biography'])}
%span{'class'=>icon_for_todo(progress_status['biography'])} %span{'class'=>icon_for_todo(progress_status['biography'])}
= link_to 'Fill out your biography', edit_user_path(event.submitter) = link_to 'Fill out your biography', edit_user_path(event.submitter)

View file

@ -83,4 +83,4 @@
.col-md-12 .col-md-12
%dt Requires Registration: %dt Requires Registration:
%dd %dd
= link_to "Yes (#{registered_text(@event)})", new_conference_conference_registrations_path(@conference.short_title), class: 'btn btn-xs btn-danger', disabled: !@event.registration_possible? = link_to "Yes (#{registered_text(@event)})", new_conference_conference_registration_path(@conference.short_title), class: 'btn btn-xs btn-danger', disabled: !@event.registration_possible?

View file

@ -37,10 +37,10 @@
= button_tag(type: 'submit', class: 'btn btn-success btn-lg') do = button_tag(type: 'submit', class: 'btn btn-success btn-lg') do
Support Support
%i.fa.fa-shopping-cart %i.fa.fa-shopping-cart
= link_to 'Continue without a Ticket!', conference_conference_registrations_path(@conference.short_title), = link_to 'Continue without a Ticket!', conference_conference_registration_path(@conference.short_title),
class: 'btn btn-danger btn-sm' class: 'btn btn-danger btn-sm'
.row .row
.col-md-13 .col-md-13
%p.text-muted.text-center %p.text-muted.text-center
%small %small
* Buying a ticket is not mandatory. Checkout will be at the conference registration. * Buying a ticket is not mandatory. Checkout will be at the conference registration.

View file

@ -108,7 +108,7 @@ Osem::Application.routes.draw do
end end
# TODO: change conference_registrations to singular resource # TODO: change conference_registrations to singular resource
resource :conference_registrations, path: 'register' resource :conference_registration, path: 'register'
resources :tickets, only: [:index] resources :tickets, only: [:index]
resources :ticket_purchases, only: [:create, :destroy] resources :ticket_purchases, only: [:create, :destroy]
resource :subscriptions, only: [:create, :destroy] resource :subscriptions, only: [:create, :destroy]

View file

@ -89,7 +89,7 @@ describe ConferenceRegistrationsController, type: :controller do
end end
it 'redirects to registration show path' do it 'redirects to registration show path' do
expect(response).to redirect_to conference_conference_registrations_path(conference.short_title) expect(response).to redirect_to conference_conference_registration_path(conference.short_title)
end end
it 'shows success message in flash notice' do it 'shows success message in flash notice' do
@ -156,7 +156,7 @@ describe ConferenceRegistrationsController, type: :controller do
end end
it 'redirects to registration show path' do it 'redirects to registration show path' do
expect(response).to redirect_to conference_conference_registrations_path(conference.short_title) expect(response).to redirect_to conference_conference_registration_path(conference.short_title)
end end
it 'shows error in flash message' do it 'shows error in flash message' do

View file

@ -468,7 +468,7 @@ describe ProposalController do
end end
it 'redirects to new registration path' do it 'redirects to new registration path' do
expect(response).to redirect_to new_conference_conference_registrations_path conference.short_title expect(response).to redirect_to new_conference_conference_registration_path conference.short_title
end end
it 'shows flash alert asking user to register' do it 'shows flash alert asking user to register' do

View file

@ -19,10 +19,10 @@ feature Registration do
scenario 'updates conference registration', feature: true, js: true do scenario 'updates conference registration', feature: true, js: true do
visit root_path visit root_path
click_link 'My Registration' click_link 'My Registration'
expect(current_path).to eq(conference_conference_registrations_path(conference.short_title)) expect(current_path).to eq(conference_conference_registration_path(conference.short_title))
click_link 'Edit your Registration' click_link 'Edit your Registration'
expect(current_path).to eq(edit_conference_conference_registrations_path(conference.short_title)) expect(current_path).to eq(edit_conference_conference_registration_path(conference.short_title))
click_button 'Update Registration' click_button 'Update Registration'
expect(conference.user_registered?(participant)).to be(true) expect(conference.user_registered?(participant)).to be(true)
@ -31,7 +31,7 @@ feature Registration do
scenario 'unregisters for a conference', feature: true, js: true do scenario 'unregisters for a conference', feature: true, js: true do
visit root_path visit root_path
click_link 'My Registration' click_link 'My Registration'
expect(current_path).to eq(conference_conference_registrations_path(conference.short_title)) expect(current_path).to eq(conference_conference_registration_path(conference.short_title))
click_link 'Unregister' click_link 'Unregister'
expect(conference.user_registered?(participant)).to be(false) expect(conference.user_registered?(participant)).to be(false)
@ -43,7 +43,7 @@ feature Registration do
visit root_path visit root_path
click_link 'Register' click_link 'Register'
expect(current_path).to eq(new_conference_conference_registrations_path(conference.short_title)) expect(current_path).to eq(new_conference_conference_registration_path(conference.short_title))
click_button 'Register' click_button 'Register'
expect(conference.user_registered?(participant)).to be(true) expect(conference.user_registered?(participant)).to be(true)

View file

@ -133,7 +133,7 @@ feature Event do
click_link "confirm_proposal_#{@event.id}" click_link "confirm_proposal_#{@event.id}"
expect(flash). expect(flash).
to eq('The proposal was confirmed. Please register to attend the conference.') to eq('The proposal was confirmed. Please register to attend the conference.')
expect(current_path).to eq(new_conference_conference_registrations_path(conference.short_title)) expect(current_path).to eq(new_conference_conference_registration_path(conference.short_title))
@event.reload @event.reload
expect(@event.state).to eq('confirmed') expect(@event.state).to eq('confirmed')
end end

View file

@ -20,7 +20,7 @@ feature Registration do
visit root_path visit root_path
click_link 'Register' click_link 'Register'
expect(current_path).to eq(new_conference_conference_registrations_path(conference.short_title)) expect(current_path).to eq(new_conference_conference_registration_path(conference.short_title))
click_button 'Register' click_button 'Register'
fill_in "tickets__#{ticket.id}", with: '2' fill_in "tickets__#{ticket.id}", with: '2'
@ -30,7 +30,7 @@ feature Registration do
purchase = TicketPurchase.where(user_id: participant.id, ticket_id: ticket.id).first purchase = TicketPurchase.where(user_id: participant.id, ticket_id: ticket.id).first
expect(purchase.quantity).to eq(2) expect(purchase.quantity).to eq(2)
expect(current_path).to eq(conference_conference_registrations_path(conference.short_title)) expect(current_path).to eq(conference_conference_registration_path(conference.short_title))
expect(flash). expect(flash).
to eq("Thank you for supporting #{conference.title} by purchasing a ticket.") to eq("Thank you for supporting #{conference.title} by purchasing a ticket.")
expect(page.has_content?("2 #{ticket.title} Tickets for 10")).to be true expect(page.has_content?("2 #{ticket.title} Tickets for 10")).to be true
@ -40,7 +40,7 @@ feature Registration do
create(:registration, conference: conference, user: participant) create(:registration, conference: conference, user: participant)
create(:ticket_purchase, conference: conference, user: participant, ticket: ticket, quantity: 4) create(:ticket_purchase, conference: conference, user: participant, ticket: ticket, quantity: 4)
visit conference_conference_registrations_path(conference.short_title) visit conference_conference_registration_path(conference.short_title)
expect(page.has_content?("4 #{ticket.title} Tickets for 10")).to be true expect(page.has_content?("4 #{ticket.title} Tickets for 10")).to be true
click_link "ticket-#{ticket.id}-delete" click_link "ticket-#{ticket.id}-delete"