From 3181c1c0d8ef62e1735220db762b06417ad67470 Mon Sep 17 00:00:00 2001 From: Matt Barringer Date: Tue, 8 Jan 2013 08:36:21 +0100 Subject: [PATCH] Making the user workflow easier --- app/controllers/proposal_controller.rb | 27 +++++++++---- app/models/event.rb | 18 +++++++++ .../register.html.haml | 5 +++ app/views/layouts/_navigation.html.haml | 20 +++++++++- app/views/proposal/index.html.haml | 38 +++++++++++++------ app/views/proposal/new.html.haml | 4 ++ 6 files changed, 92 insertions(+), 20 deletions(-) diff --git a/app/controllers/proposal_controller.rb b/app/controllers/proposal_controller.rb index b4975bf9..62c81f3f 100644 --- a/app/controllers/proposal_controller.rb +++ b/app/controllers/proposal_controller.rb @@ -1,5 +1,19 @@ class ProposalController < ApplicationController before_filter :verify_user + before_filter :verify_access, :only => [:edit, :update, :destroy] + + def verify_access + @person = current_user.person + begin + if !organizer_or_admin? + @event = @person.event.find(params[:id]) + else + @event = Event.find(params[:id]) + end + rescue Exception => e + redirect_to(conference_proposal_index_path(:conference_id => @conference.short_title), :alert => 'Invalid or uneditable proposal.') + end + end def index @person = current_user.person @@ -7,7 +21,7 @@ class ProposalController < ApplicationController end def destroy - current_user.person.withdraw_proposal(params[:id]) + @person.withdraw_proposal(params[:id]) redirect_to(conference_proposal_index_path(:conference_id => @conference.short_title), :alert => 'Proposal withdrawn.') end @@ -20,26 +34,23 @@ class ProposalController < ApplicationController def edit @url = conference_proposal_path(@conference.short_title, params[:id]) - @person = current_user.person @event_types = @conference.event_types - @event = @person.events.find_by_id(params[:id]) @attachments = @event.event_attachments - if @event.nil? || !@conference.cfp_open? - redirect_to(conference_proposal_index_path(:conference_id => @conference.short_title), :alert => 'Invalid proposal.') + if @event.nil? || !@conference.cfp_open? || @event.unconfirmed? || @event.confirmed? + redirect_to(conference_proposal_index_path(:conference_id => @conference.short_title), :alert => 'Invalid or uneditable proposal.') end end def update - person = current_user.person session[:return_to] ||= request.referer submitter = params[:person] params[:event].delete :people_attributes params[:event].delete :person - if submitter[:public_name] != person.public_name || submitter[:biography] != person.biography - person.update_attributes(submitter) + if submitter[:public_name] != @person.public_name || submitter[:biography] != @person.biography + @person.update_attributes(submitter) end event = Event.find_by_id(params[:id]) diff --git a/app/models/event.rb b/app/models/event.rb index a6df0b56..d3718103 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -76,6 +76,24 @@ class Event < ActiveRecord::Base end + def public_state + public_state = "Submitted" + case self.state + when "withdrawn" + public_state = "Withdrawn" + when "new", "review" + public_state = "Review Pending" + when "accepted", "unconfirmed" + public_state = "Accepted (confirmation pending)" + when "confirmed" + public_state = "Confirmed" + when "rejected" + public_state = "Rejected" + when "cancelled" + public_state = "Cancelled" + end + public_state + end def abstract_word_count if self.abstract.nil? 0 diff --git a/app/views/conference_registration/register.html.haml b/app/views/conference_registration/register.html.haml index 3774998b..abf2cb4b 100644 --- a/app/views/conference_registration/register.html.haml +++ b/app/views/conference_registration/register.html.haml @@ -4,6 +4,11 @@ %h3.pull-left Registration for = @conference.title + - if @person.proposal_count(@conference) > 0 + .row-fluid + .span12 + %i + Please note: Registration is not automatically performed for speakers. If you're scheduled to speak at the conference, you still need to register! .row-fluid .span12 = semantic_form_for(@registration, :url => register_conference_path(@conference.short_title), :html => { :method => :put }) do |f| diff --git a/app/views/layouts/_navigation.html.haml b/app/views/layouts/_navigation.html.haml index 2beda77d..6ab97bcc 100644 --- a/app/views/layouts/_navigation.html.haml +++ b/app/views/layouts/_navigation.html.haml @@ -1,4 +1,22 @@ -= link_to "OSEM", root_path, :class => 'brand' +- if @conference.nil? || @conference.short_title.nil? + = link_to "OSEM", root_path, :class => 'brand' +- else + = link_to @conference.title, root_path, :class => 'brand' +%ul.nav + - if !@conference.nil? && @conference.registration_open? + - if current_page?(register_conference_path(@conference.short_title)) + %li.active + = link_to "Registration", "#" + - else + %li + = link_to "Registration", register_conference_path(@conference.short_title) + - if !@conference.nil? + - if current_page?(conference_proposal_index_path(@conference.short_title)) + %li.active + = link_to "My Proposals", "#" + - else + %li + = link_to "My Proposals", conference_proposal_index_path(@conference.short_title) %ul.nav.pull-right - if user_signed_in? %li diff --git a/app/views/proposal/index.html.haml b/app/views/proposal/index.html.haml index eda9f75b..8d24d82f 100644 --- a/app/views/proposal/index.html.haml +++ b/app/views/proposal/index.html.haml @@ -2,18 +2,34 @@ .row-fluid .span13 %h2.pull-left - My Proposals + = "My Proposals for #{@conference.title}" .pull-right{:style=>"margin-top:20px;"} = link_to "New Proposal", new_conference_proposal_path(@conference.short_title), :class => "btn btn-primary" - - @events.each do |event| + - if @person.proposal_count(@conference) > 0 .row-fluid .span12 - .well - .row-fluid - .span10 - = event.title - .pull-right - - if @conference.cfp_open? - = link_to "Edit", edit_conference_proposal_path(@conference.short_title, event.id), :class => "btn btn-mini btn-primary" - = link_to "Withdraw", conference_proposal_path(@conference.short_title, event.id), :method => :delete, - :confirm => "Are you sure you want to withdraw this proposal?", :class => "btn btn-mini btn-danger" + %table.table.table-bordered.table-striped + %thead + %th + %b Title + %th + %b Status + %th + - @events.each do |event| + %tr + %td + = event.title + %td + = event.public_state + - if event.confirmed? && !@conference.user_registered?(current_user) + %br + = link_to "Register to attend", register_conference_path(@conference.short_title), :style => "font-size:10px;" + %td + .pull-right + - if event.transition_possible? :confirm + = link_to "Confirm", "#", :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" + = link_to "Withdraw", conference_proposal_path(@conference.short_title, event.id), :method => :delete, + :confirm => "Are you sure you want to withdraw this proposal?", :class => "btn btn-mini btn-danger" diff --git a/app/views/proposal/new.html.haml b/app/views/proposal/new.html.haml index f3f8663c..32b5f224 100644 --- a/app/views/proposal/new.html.haml +++ b/app/views/proposal/new.html.haml @@ -1,2 +1,6 @@ .container + .row + .span12 + .center-text + = @conference.call_for_papers.description = render 'proposal_form'