First checkin

This commit is contained in:
Matt Barringer 2013-01-07 09:04:09 +01:00
parent f207e2c8b7
commit 90b30db9e8
260 changed files with 37349 additions and 0 deletions

View file

@ -0,0 +1,28 @@
class Admin::CallforpapersController < ApplicationController
before_filter :verify_organizer
layout "admin"
def show
@cfp = @conference.call_for_papers
if @cfp.nil?
@cfp = CallForPapers.new
end
end
def update
@cfp = @conference.call_for_papers
@cfp.update_attributes(params[:call_for_papers])
redirect_to(admin_conference_cfp_info_path(:id => @conference.short_title), :notice => 'Call for Papers was successfully updated.')
end
def create
@cfp = CallForPapers.new(params[:call_for_papers])
@conference.call_for_papers = @cfp
if @cfp.save
redirect_to(admin_conference_cfp_info_path(:id => @conference.short_title), :notice => 'Call for Papers was successfully updated.')
else
redirect_to(admin_conference_cfp_info_path(:id => @conference.short_title), :error => 'Call for Papers failed.')
end
end
end

View file

@ -0,0 +1,36 @@
class Admin::ConferenceController < ApplicationController
before_filter :verify_organizer
layout "admin"
def index
@conferences = Conference.all
if @conferences.count == 0
redirect_to new_admin_conference_path
return
end
end
def new
@conference = Conference.new
end
def create
@conference = Conference.new(params[:conference])
if @conference.save
redirect_to(admin_conference_path(:id => @conference.short_title), :notice => 'Conference was successfully created.')
else
render :action => "new"
end
end
def update
@conference = Conference.find_all_by_short_title(params[:id]).first
@conference.update_attributes(params[:conference])
flash[:notice] = "Updated Conference"
redirect_to(admin_conference_path(:id => @conference.short_title), :notice => 'Conference was successfully updated.')
end
def show
@conference = Conference.find_all_by_short_title(params[:id]).first
end
end

View file

@ -0,0 +1,41 @@
class Admin::EventsController < ApplicationController
before_filter :verify_organizer
layout "admin"
def index
@events = @conference.events
end
def show
@event = @conference.events.find(params[:id])
@comments = @event.root_comments
@comment_count = @event.comment_threads.count
end
def edit
@event_types = @conference.event_types
@event = Event.find_by_id(params[:id])
@person = @event.submitter
@url = edit_admin_conference_event_path(@conference.short_title, @event)
end
def comment
event = @conference.events.find_by_id(params[:id])
comment = Comment.build_from(event, current_user.id, params[:comment])
comment.save!
if !params[:parent].nil?
comment.move_to_child_of(params[:parent])
end
redirect_to admin_conference_event_path(:conference_id => @conference.short_title, :id => params[:id])
end
def create
end
def update_state
event = Event.find(params[:id])
event.send(:"#{params[:transition]}!", :send_mail => params[:send_mail])
redirect_to(admin_conference_events_path(:conference_id => @conference.short_title), :notice => "Updated state")
end
end

View file

@ -0,0 +1,17 @@
class Admin::EventtypeController < ApplicationController
before_filter :verify_organizer
layout "admin"
def show
render :event_type_list
end
def update
begin
@conference.update_attributes!(params[:conference])
redirect_to(admin_conference_eventtype_list_path(:conference_id => @conference.short_title), :notice => 'Event types were successfully updated.')
rescue Exception => e
redirect_to(admin_conference_eventtype_list_path(:conference_id => @conference.short_title), :alert => 'Event types update failed: #{e.message}')
end
end
end

View file

@ -0,0 +1,24 @@
class Admin::PeopleController < ApplicationController
before_filter :verify_organizer
layout "admin"
def index
@people = Person.all
end
def create
end
def show
@person = Person.find(params[:id])
end
def update
end
def delete
end
end

View file

@ -0,0 +1,16 @@
class Admin::RegistrationsController < ApplicationController
before_filter :verify_organizer
layout "admin"
def show
session[:return_to] ||= request.referer
@pdf_filename = "#{@conference.title}.pdf"
@registrations = @conference.registrations.all(:joins => :person,
:order => "people.last_name ASC",
:select => "registrations.*,
people.last_name AS last_name,
people.first_name AS first_name,
people.public_name AS public_name,
people.email AS email")
end
end

View file

@ -0,0 +1,18 @@
class Admin::RoomsController < ApplicationController
before_filter :verify_organizer
layout "admin"
def show
render :rooms_list
end
def update
if @conference.update_attributes(params[:conference])
redirect_to(admin_conference_rooms_list_path(:conference_id => @conference.short_title), :notice => 'Rooms were successfully updated.')
else
redirect_to(admin_conference_rooms_list_path(:conference_id => @conference.short_title), :notice => 'Room update failed.')
end
end
end

View file

@ -0,0 +1,18 @@
class Admin::TracksController < ApplicationController
before_filter :verify_organizer
layout "admin"
def show
render :tracks_list
end
def update
if @conference.update_attributes(params[:conference])
redirect_to(admin_conference_tracks_list_path(:conference_id => @conference.short_title), :notice => 'Tracks were successfully updated.')
else
redirect_to(admin_conference_tracks_list_path(:conference_id => @conference.short_title), :notice => 'Tracks update failed.')
end
end
end

View file

@ -0,0 +1,20 @@
class Admin::UsersController < ApplicationController
before_filter :verify_admin
layout "admin"
def index
@users = User.all(:joins => :person,
:order => "people.last_name ASC",
:select => "users.*,
people.last_name AS last_name,
people.first_name AS first_name,
people.public_name AS public_name,
people.email AS email")
end
def update
user = User.find(params[:id])
user.update_attributes!(params[:user])
redirect_to admin_users_path, :notice => "Updated #{user.email}"
end
end

View file

@ -0,0 +1,24 @@
class Admin::VenueController < ApplicationController
before_filter :verify_organizer
layout "admin"
def index
end
def update
@venue = @conference.venue
venue_params = params[:venue]
@venue.name = venue_params[:name]
@venue.address= venue_params[:address]
@venue.website = venue_params[:website]
@venue.description = venue_params[:description]
@venue.save
redirect_to(admin_conference_venue_info_path(:conference_id => @conference.short_title), :notice => 'Venue was successfully updated.')
end
def show
@venue = @conference.venue
render :venue_info
end
end

View file

@ -0,0 +1,42 @@
class ApplicationController < ActionController::Base
include ApplicationHelper
protect_from_forgery
def verify_user
:authenticate_user!
if (current_user.nil?)
redirect_to '/accounts/sign_in'
return
end
@conference = Conference.find_all_by_short_title(params[:conference_id]).first
end
def organizer_or_admin?
has_role?(current_user, 'admin') || has_role?(current_user, 'organizer')
end
def verify_organizer
verify_user
## Todo simplify this
redirect_to '/' unless has_role?(current_user, 'admin') || has_role?(current_user, 'organizer')
end
def verify_admin
verify_user
redirect_to '/' unless has_role?(current_user, 'admin')
end
def current_ability
@current_ability ||= AdminAbility.new(current_user)
end
rescue_from CanCan::AccessDenied do |exception|
Rails.logger.debug("Access denied!")
redirect_to '/', :alert => exception.message
end
end

View file

@ -0,0 +1,51 @@
class ConferenceRegistrationController < ApplicationController
before_filter :verify_user
def register
# TODO Figure out how to change the route's id from :id to :conference_id
@conference = Conference.find_all_by_short_title(params[:id]).first
@person = current_user.person
@registration = @person.registrations.where(:conference_id => @conference.id).first
@registered = true
if @registration.nil?
@registered = false
@registration = @person.registrations.new(:conference_id => @conference.id)
end
end
def update
conference = Conference.find_all_by_short_title(params[:id]).first
person = current_user.person
registration = person.registrations.where(:conference_id => conference.id).first
update_registration = true
begin
if registration.nil?
update_registration = false
person.update_attributes(params[:registration][:person_attributes])
params[:registration].delete :person_attributes
registration = person.registrations.new(params[:registration])
registration.conference_id = conference.id
registration.save!
else
registration.update_attributes!(params[:registration])
end
rescue Exception => e
redirect_to(register_conference_path(:id => conference.short_title), :alert => 'Registration failed:' + e.message)
return
end
redirect_message = "You are now registered."
if update_registration
redirect_message = "Registration updated."
end
redirect_to(register_conference_path(:id => conference.short_title), :notice => redirect_message)
end
def unregister
conference = Conference.find_all_by_short_title(params[:id]).first
person = current_user.person
registration = person.registrations.where(:conference_id => conference.id).first
registration.destroy
redirect_to :root
end
end

View file

@ -0,0 +1,97 @@
class EventAttachmentsController < ApplicationController
before_filter :verify_user
skip_before_filter :verify_user, :only => [:show]
def index
@proposal = current_user.person.events.find(params[:proposal_id])
@uploads = @proposal.event_attachments
respond_to do |format|
format.html # index.html.erb
format.json { render json: @uploads.map{|upload| upload.to_jq_upload } }
end
end
def show
upload = EventAttachment.find(params[:id])
if upload.public?
send_file upload.attachment.path
return
end
if current_user.nil?
verify_user
return
end
if organizer_or_admin? || current_user.person == upload.event.submitter
send_file upload.attachment.path
else
raise ActionController::RoutingError.new('Not Found')
end
end
def new
@upload = EventAttachment.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @upload }
end
end
def edit
@upload = EventAttachment.find(params[:id])
end
def create
params[:event_attachment][:title] = params[:title][0]
params[:event_attachment][:public] = false
params[:event_attachment][:event_id] = params[:proposal_id]
if params.has_key?(:public)
params[:event_attachment][:public] = true
end
@upload = EventAttachment.new(params[:event_attachment])
respond_to do |format|
if @upload.save
format.html {
render :json => [@upload.to_jq_upload].to_json,
:content_type => 'text/html',
:layout => false
}
format.json { render json: [@upload.to_jq_upload].to_json, status: :created,
location: conference_proposal_event_attachment_path(@upload.event.conference.short_title, @upload.event, @upload) }
else
format.html { render action: "new" }
format.json { render json: @upload.errors, status: :unprocessable_entity }
end
end
end
def update
@upload = EventAttachment.find(params[:proposal_id])
respond_to do |format|
if @upload.update_attributes(params[:upload])
format.html { redirect_to @upload, notice: 'Upload was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @upload.errors, status: :unprocessable_entity }
end
end
end
def destroy
@proposal = current_user.person.events.find(params[:proposal_id])
@upload = @proposal.event_attachments.find(params[:id])
@upload.destroy
respond_to do |format|
format.html { redirect_to uploads_url }
format.json { head :no_content }
end
end
end

View file

@ -0,0 +1,7 @@
class HomeController < ApplicationController
def index
@today = Date.current
@conferences = Conference.where("start_date >= ?", @today)
end
end

View file

@ -0,0 +1,97 @@
class ProposalController < ApplicationController
before_filter :verify_user
def index
@person = current_user.person
@events = @person.proposals @conference
end
def destroy
current_user.person.withdraw_proposal(params[:id])
redirect_to(conference_proposal_index_path(:conference_id => @conference.short_title), :alert => 'Proposal withdrawn.')
end
def new
@url = conference_proposal_index_path(@conference.short_title)
@event = Event.new
@event_types = @conference.event_types
@person = current_user.person
end
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?
redirect_to(conference_proposal_index_path(:conference_id => @conference.short_title), :alert => 'Invalid 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)
end
event = Event.find_by_id(params[:id])
if event.update_attributes!(params[:event])
redirect_to(conference_proposal_index_path(:conference_id => @conference.short_title), :notice => "'#{event.title}' was successfully updated.")
else
redirect_to session[:return_to], :alert => "'#{event.title}' was NOT updated!"
end
end
def create
person = current_user.person
session[:return_to] ||= request.referer
event_params = params[:event]
submitter = params[:person]
params[:event].delete :person
# First, update the submitter's info, if they've changed anything
if submitter[:public_name] != person.public_name || submitter[:biography] != person.biography
person.update_attributes(submitter)
end
@event = Event.new(event_params)
@event.conference = @conference
@event.event_people.new(:person => person,
:event_role => "submitter")
@event.event_people.new(:person => person,
:event_role => "speaker")
begin
@event.save!
rescue Exception => e
@url = conference_proposal_index_path(@conference.short_title)
@event_types = @conference.event_types
@person = current_user.person
flash[:error] = "Could not submit proposal: #{e.message}"
render :action => 'new'
return
end
registration = person.registrations.where(:conference_id => @conference.id).first
if registration.nil?
redirect_to(register_conference_path(@conference.short_title), :notice => 'Event was successfully submitted. You probably want to register for the conference now!')
else
redirect_to(conference_proposal_index_path(:conference_id => @conference.short_title), :notice => 'Event was successfully submitted.')
end
end
def show
end
end

View file

@ -0,0 +1,52 @@
class RegistrationsController < Devise::RegistrationsController
def update
@user = User.find(current_user.id)
email_changed = false
if !params[:user][:email].nil?
if @user.email != params[:user][:email]
email_changed = true
else
params[:user].delete :email
end
end
password_changed = false
if !params[:user][:password].nil?
if !params[:user][:password].empty?
password_changed = true
else
params[:user].delete :password
params[:user].delete :password_confirmation
params[:user].delete :current_password
end
end
successfully_updated = if email_changed or password_changed
@user.update_with_password(params[:user])
else
@user.update_without_password(params[:user])
end
if successfully_updated
set_flash_message :notice, :updated
# Sign in the user bypassing validation in case his password changed
sign_in @user, :bypass => true
redirect_to after_update_path_for(@user)
else
render "edit"
end
end
protected
def after_update_path_for(resource)
edit_user_registration_path(resource)
end
def after_sign_up_path_for(resource)
edit_user_registration_path(resource)
end
end