mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Refactoring Tickets
- Tickets now independent from registration - Implemented money gem #419
This commit is contained in:
parent
5485fe0e7f
commit
5f8a8ac6d9
63 changed files with 1581 additions and 573 deletions
54
app/controllers/admin/tickets_controller.rb
Normal file
54
app/controllers/admin/tickets_controller.rb
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
module Admin
|
||||
class TicketsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource :ticket, through: :conference
|
||||
|
||||
def index
|
||||
authorize! :update, Ticket.new(conference_id: @conference.id)
|
||||
end
|
||||
|
||||
def new
|
||||
@ticket = @conference.tickets.new
|
||||
end
|
||||
|
||||
def create
|
||||
@ticket = @conference.tickets.new(ticket_params)
|
||||
if @ticket.save(ticket_params)
|
||||
redirect_to(admin_conference_tickets_path(conference_id: @conference.short_title),
|
||||
notice: 'Ticket successfully created.')
|
||||
else
|
||||
flash[:alert] = "Creating Ticket failed: #{@ticket.errors.full_messages.join('. ')}."
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def edit; end
|
||||
|
||||
def update
|
||||
if @ticket.update_attributes(ticket_params)
|
||||
redirect_to(admin_conference_tickets_path(conference_id: @conference.short_title),
|
||||
notice: 'Ticket successfully updated.')
|
||||
else
|
||||
flash[:alert] = "Ticket update failed: #{@ticket.errors.full_messages.join('. ')}."
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @ticket.destroy
|
||||
redirect_to(admin_conference_tickets_path(conference_id: @conference.short_title),
|
||||
notice: 'Ticket successfully destroyed.')
|
||||
else
|
||||
redirect_to(admin_conference_tickets_path(conference_id: @conference.short_title),
|
||||
alert: "Ticket was successfully destroyed." \
|
||||
"#{@ticket.errors.full_messages.join('. ')}.")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def ticket_params
|
||||
params[:ticket]
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue