From a9207671b8a7db038abdbd263b7d0ed3fe37bc29 Mon Sep 17 00:00:00 2001 From: Matt Barringer Date: Tue, 8 Jan 2013 08:51:34 +0100 Subject: [PATCH] Allow users to confirm their proposal --- app/controllers/proposal_controller.rb | 25 ++++++++++++++++++++++++- app/views/proposal/index.html.haml | 2 +- config/routes.rb | 1 + 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/app/controllers/proposal_controller.rb b/app/controllers/proposal_controller.rb index 62c81f3f..575b6295 100644 --- a/app/controllers/proposal_controller.rb +++ b/app/controllers/proposal_controller.rb @@ -1,9 +1,12 @@ class ProposalController < ApplicationController before_filter :verify_user - before_filter :verify_access, :only => [:edit, :update, :destroy] + before_filter :verify_access, :only => [:edit, :update, :destroy, :confirm] def verify_access @person = current_user.person + if params.has_key? :proposal_id + params[:id] = params[:proposal_id] + end begin if !organizer_or_admin? @event = @person.event.find(params[:id]) @@ -105,4 +108,24 @@ class ProposalController < ApplicationController def show end + + def confirm + if @event.transition_possible? :confirm + begin + @event.confirm! + rescue Exception => e + redirect_to(conference_proposal_index_path(:conference_id => @conference.short_title), :alert => 'Event was NOT confirmed: #{e.message}') + return + end + + if !@conference.user_registered?(current_user) + redirect_to(register_conference_path(@conference.short_title), :notice => "Event was confirmed. Please register to attend the conference.") + return + end + redirect_to(conference_proposal_index_path(:conference_id => @conference.short_title), :notice => 'Event was confirmed.') + else + redirect_to(conference_proposal_index_path(:conference_id => @conference.short_title), :alert => 'Event was NOT confirmed!') + end + end + end diff --git a/app/views/proposal/index.html.haml b/app/views/proposal/index.html.haml index 8d24d82f..c0d7915c 100644 --- a/app/views/proposal/index.html.haml +++ b/app/views/proposal/index.html.haml @@ -27,7 +27,7 @@ %td .pull-right - if event.transition_possible? :confirm - = link_to "Confirm", "#", :class => "btn btn-mini btn-success" + = link_to "Confirm", conference_proposal_confirm_path(@conference.short_title, event), :method => :put, :class => "btn btn-mini btn-success" - if @conference.cfp_open? - if !event.unconfirmed? && !event.confirmed? = link_to "Edit", edit_conference_proposal_path(@conference.short_title, event.id), :class => "btn btn-mini btn-primary" diff --git a/config/routes.rb b/config/routes.rb index 869ee30b..6dc7eeff 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -33,6 +33,7 @@ Osem::Application.routes.draw do resources :conference, :only => [] do resources :proposal do resources :event_attachment, :controller => "EventAttachments" + put "/confirm" => "proposal#confirm" end member do get "/register" => "ConferenceRegistration#register"