diff --git a/app/controllers/admin/events_controller.rb b/app/controllers/admin/events_controller.rb index 622a1034..5fb5e215 100644 --- a/app/controllers/admin/events_controller.rb +++ b/app/controllers/admin/events_controller.rb @@ -1,198 +1,200 @@ -class Admin::EventsController < ApplicationController - before_filter :verify_organizer +module Admin + class EventsController < ApplicationController + before_filter :verify_organizer - # FIXME: The timezome should only be applied on output, otherwise - # you get lost in timezone conversions... - # around_filter :set_timezone_for_this_request + # FIXME: The timezome should only be applied on output, otherwise + # you get lost in timezone conversions... + # around_filter :set_timezone_for_this_request - def set_timezone_for_this_request(&block) - Time.use_zone(@conference.timezone, &block) - end - - def index - @events = @conference.events - @tracks = @conference.tracks - @machine_states = @events.state_machine.states.map - @event_types = @conference.event_types - - @mystates = [] - @mytypes = [] - @eventstats = Hash.new - statelength = 0 - @totallength = 0 - - @machine_states.each do |mystate| - length = 0 - events_mystate= @events.where("state" => mystate.name) - if events_mystate.count > 0 - @mystates << mystate - events_mystate.each do |myevent| - length += myevent.event_type.length - end - @eventstats["#{mystate.name}"] = {"count" => events_mystate.count, "length" => length} - end + def set_timezone_for_this_request(&block) + Time.use_zone(@conference.timezone, &block) end - - @event_types.each do |mytype| - events_mytype = @events.where("event_type_id" => mytype.id) - if events_mytype.count > 0 - @mytypes << mytype - end - end - @mytypes.each do |mytype| - @mystates.each do |mystate| - events_mytype = @events.where("event_type_id" => mytype.id) - events_mytype_mystate= events_mytype.where("state" => mystate.name) - typelength = 0 - if events_mytype_mystate.count > 0 - events_mytype_mystate.each do |myevent| - typelength += myevent.event_type.length - @totallength += myevent.event_type.length + + def index + @events = @conference.events + @tracks = @conference.tracks + @machine_states = @events.state_machine.states.map + @event_types = @conference.event_types + + @mystates = [] + @mytypes = [] + @eventstats = Hash.new + @totallength = 0 + + @machine_states.each do |mystate| + length = 0 + events_mystate = @events.where('state' => mystate.name) + if events_mystate.count > 0 + @mystates << mystate + events_mystate.each do |myevent| + length += myevent.event_type.length end - @eventstats[mytype.title] = {"count" => events_mytype.count, "length" => events_mytype.count * mytype.length} if @eventstats[mytype.title] == nil - tmp = {"#{mystate.name}" => {"type_state_count" => events_mytype_mystate.count, "type_state_length" => typelength}} - @eventstats[mytype.title].merge!(tmp) + @eventstats["#{mystate.name}"] = { 'count' => events_mystate.count, 'length' => length } end end - end - @eventstats["totallength"] = @totallength - respond_to do |format| - format.html - # Explicity call #to_json to avoid the use of EventSerializer - format.json { render :json => Event.where(:state => :confirmed).to_json } - end - end - - def show - @event = @conference.events.find(params[:id]) - @tracks = @conference.tracks - @event_types = @conference.event_types - @comments = @event.root_comments - @comment_count = @event.comment_threads.count - @ratings = @event.votes.includes(:person) - @difficulty_levels = @conference.difficulty_levels - end - - def edit - @event = @conference.events.find(params[:id]) - @event_types = @conference.event_types - @tracks = Track.all - @comments = @event.root_comments - @comment_count = @event.comment_threads.count - @person = @event.submitter - @url = 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) - end - - def update - @event = Event.find(params[:id]) - if params.has_key? :track_id - @event.update_attribute(:track_id, params[:track_id]) - end - if params.has_key? :event_type_id - @event.update_attribute(:event_type_id, params[:event_type_id]) - end - if params.has_key? :difficulty_level_id - @event.update_attribute(:difficulty_level_id, params[:difficulty_level_id]) - end - - if @event.submitter.update_attributes!(params[:person]) && @event.update_attributes!(params[:event]) - flash[:notice] = "Successfully updated #{@event.title}." - else - flash[:notice] = "Update not successful." - end - - redirect_back_or_to(admin_conference_event_path(@conference.short_title, @event)) - end - - def create - end - - def accept - update_state(params[:id], :accept, 'Event accepted!', true) - end - - def confirm - update_state(params[:id], :confirm, 'Event confirmed!') - end - - def cancel - update_state(params[:id], :cancel, 'Event canceled!') - end - - def reject - update_state(params[:id], :reject, 'Event rejected!', true) - end - - def restart - update_state(params[:id], :restart, 'Review started!') - end - - def vote - @event = Event.find(params[:id]) - @ratings = @event.votes.includes(:person) - - if votes = current_user.person.votes.find_by_event_id(params[:id]) - votes.update_attributes(:rating => params[:rating]) - else - @myvote = @event.votes.build - @myvote.person = current_user.person - @myvote.rating = params[:rating] - @myvote.save - end - - respond_to do |format| - format.html { redirect_to admin_conference_event_path(@conference.short_title, @event)} - format.js - end - end - - private - - def update_state(id, transition, notice, mail = false) - event = Event.find(id) - if mail - check_mail_settings(event) - end - if event - begin - if mail - event.send(transition, - send_mail: params[:send_mail]) - else - event.send(transition) + @event_types.each do |mytype| + events_mytype = @events.where('event_type_id' => mytype.id) + if events_mytype.count > 0 + @mytypes << mytype end - event.save - rescue Transitions::InvalidTransition => e - redirect_to( - admin_conference_events_path(conference_id: @conference.short_title), - notice: "Update state failed. #{e.message}") && return end - redirect_to(admin_conference_events_path(conference_id: @conference.short_title), - notice: notice) - else - redirect_to(admin_conference_events_path(conference_id: @conference.short_title), - notice: 'Error! Could not find event!') - end - end + @mytypes.each do |mytype| + @mystates.each do |mystate| + events_mytype = @events.where('event_type_id' => mytype.id) + events_mytype_mystate = events_mytype.where('state' => mystate.name) + typelength = 0 + if events_mytype_mystate.count > 0 + events_mytype_mystate.each do |myevent| + typelength += myevent.event_type.length + @totallength += myevent.event_type.length + end + @eventstats[mytype.title] = { 'count' => events_mytype.count, 'length' => events_mytype.count * mytype.length } if @eventstats[mytype.title] == nil + tmp = { "#{mystate.name}" => { 'type_state_count' => events_mytype_mystate.count, + 'type_state_length' => typelength } } + @eventstats[mytype.title].merge!(tmp) + end + end + end + @eventstats['totallength'] = @totallength - def check_mail_settings(event) - if !params[:send_mail].blank? && event && - event.conference.email_settings.rejected_email_template.nil? && - event.conference.email_settings.accepted_email_template.nil? - redirect_to(admin_conference_events_path(conference_id: @conference.short_title), - notice: 'Update Email Template before Sending Mails') && return + respond_to do |format| + format.html + # Explicity call #to_json to avoid the use of EventSerializer + format.json { render json: Event.where(state: :confirmed).to_json } + end + end + + def show + @event = @conference.events.find(params[:id]) + @tracks = @conference.tracks + @event_types = @conference.event_types + @comments = @event.root_comments + @comment_count = @event.comment_threads.count + @ratings = @event.votes.includes(:user) + @difficulty_levels = @conference.difficulty_levels + end + + def edit + @event = @conference.events.find(params[:id]) + @event_types = @conference.event_types + @tracks = Track.all + @comments = @event.root_comments + @comment_count = @event.comment_threads.count + @user = @event.submitter + @url = 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) + end + + def update + @event = Event.find(params[:id]) + if params.has_key? :track_id + @event.update_attribute(:track_id, params[:track_id]) + end + if params.has_key? :event_type_id + @event.update_attribute(:event_type_id, params[:event_type_id]) + end + if params.has_key? :difficulty_level_id + @event.update_attribute(:difficulty_level_id, params[:difficulty_level_id]) + end + + if @event.submitter.update_attributes!(params[:user]) && @event.update_attributes!(params[:event]) + flash[:notice] = "Successfully updated #{@event.title}." + else + flash[:notice] = 'Update not successful.' + end + + redirect_back_or_to(admin_conference_event_path(@conference.short_title, @event)) + end + + def create + end + + def accept + update_state(params[:id], :accept, 'Event accepted!', true) + end + + def confirm + update_state(params[:id], :confirm, 'Event confirmed!') + end + + def cancel + update_state(params[:id], :cancel, 'Event canceled!') + end + + def reject + update_state(params[:id], :reject, 'Event rejected!', true) + end + + def restart + update_state(params[:id], :restart, 'Review started!') + end + + def vote + @event = Event.find(params[:id]) + @ratings = @event.votes.includes(:user) + + if votes = current_user.votes.find_by_event_id(params[:id]) + votes.update_attributes(rating: params[:rating]) + else + @myvote = @event.votes.build + @myvote.user = current_user + @myvote.rating = params[:rating] + @myvote.save + end + + respond_to do |format| + format.html { redirect_to admin_conference_event_path(@conference.short_title, @event) } + format.js + end + end + + private + + def update_state(id, transition, notice, mail = false) + event = Event.find(id) + if mail + check_mail_settings(event) + end + if event + begin + if mail + event.send(transition, + send_mail: params[:send_mail]) + else + event.send(transition) + end + event.save + rescue Transitions::InvalidTransition => e + redirect_to( + admin_conference_events_path(conference_id: @conference.short_title), + notice: "Update state failed. #{e.message}") && return + end + redirect_to(admin_conference_events_path(conference_id: @conference.short_title), + notice: notice) + else + redirect_to(admin_conference_events_path(conference_id: @conference.short_title), + notice: 'Error! Could not find event!') + end + end + + def check_mail_settings(event) + if !params[:send_mail].blank? && event && + event.conference.email_settings.rejected_email_template.nil? && + event.conference.email_settings.accepted_email_template.nil? + redirect_to(admin_conference_events_path(conference_id: @conference.short_title), + notice: 'Update Email Template before Sending Mails') && return + end end end end diff --git a/app/controllers/admin/people_controller.rb b/app/controllers/admin/people_controller.rb deleted file mode 100644 index 4b25c683..00000000 --- a/app/controllers/admin/people_controller.rb +++ /dev/null @@ -1,46 +0,0 @@ -class Admin::PeopleController < ApplicationController - before_filter :verify_organizer - respond_to :html - - def index - @people = Person.all - mails = [] - @people.each do |p| - if p.registrations.count < 1 and p.confirmed? - mails << p.email - end - end - respond_to do |format| - format.html - format.text { render :text => mails } - end - end - - def new - @person = Person.new - end - - def create - @person = Person.new(params[:person]) - flash[:notice] = 'Person was successfully created.' if @person.save - respond_with @person, :location => admin_people_path - end - - def show - @person = Person.find(params[:id]) - end - - def edit - @person = Person.find(params[:id]) - end - - def update - @person = Person.find(params[:id]) - flash[:notice] = 'Person was successfully updated' if @person.update_attributes(params[:person]) - respond_with @person, :location => admin_people_path - end - - def delete - - end -end diff --git a/app/controllers/admin/registrations_controller.rb b/app/controllers/admin/registrations_controller.rb index 3577ef91..c38b6572 100644 --- a/app/controllers/admin/registrations_controller.rb +++ b/app/controllers/admin/registrations_controller.rb @@ -1,134 +1,128 @@ -class Admin::RegistrationsController < ApplicationController - before_filter :verify_organizer +module Admin + class RegistrationsController < ApplicationController + before_filter :verify_organizer - def index - session[:return_to] ||= request.referer - @pdf_filename = "#{@conference.title}.pdf" - @registrations = @conference.registrations.includes(:person).order("registrations.created_at ASC") - @attended = @conference.registrations.where("attended = ?", true).count - @headers = %w[first_name last_name email irc_nickname other_needs arrival departure attended] - end - - def change_field - @registration = Registration.find(params[:id]) - field = params[:view_field] - if @registration.send(field.to_sym) - @registration.update_attribute(:"#{field}",0) - else - @registration.update_attribute(:"#{field}",1) - end - - redirect_to admin_conference_registrations_path(@conference.short_title) - flash[:notice] = "Updated '#{params[:view_field]}' => #{@registration.attended} for - #{(Person.where("id = ?", @registration.person_id).first).email}" - end - - def edit - @registration = @conference.registrations.where("id = ?", params[:id]).first - @person = Person.where("id = ?", @registration.person_id).first - end - - def update - @registration = @conference.registrations.where("id = ?", params[:id]).first - @person = Person.where("id = ?", @registration.person_id).first - begin - @person.update_attributes!(params[:registration][:person_attributes]) - params[:registration].delete :person_attributes - if params[:registration][:supporter_registration] - @registration.supporter_registration.update_attributes(params[:registration][:supporter_registration_attributes]) - params[:registration].delete :supporter_registration_attributes - end - @registration.update_attributes!(params[:registration]) - flash[:notice] = "Successfully updated registration for #{@person.public_name} #{@person.email}" - redirect_to(admin_conference_registrations_path(@conference.short_title)) - rescue Exception => e - Rails.logger.debug e.backtrace.join("\n") - redirect_to(admin_conference_registrations_path(@conference.short_title), - alert: 'Failed to update registration:' + e.message) - return + def index + session[:return_to] ||= request.referer + @pdf_filename = "#{@conference.title}.pdf" + @registrations = @conference.registrations.includes(:user).order("registrations.created_at ASC") + @attended = @conference.registrations.where("attended = ?", true).count + @headers = %w[name email nickname other_needs arrival departure attended] end - end - def new - @user = User.new - @person = Person.new - @registration = @person.registrations.new - @supporter_registration = @conference.supporter_registrations.new - @conference = Conference.find_by(short_title: params[:conference_id]) - end - - def create - @conference = Conference.find_by(short_title: params[:conference_id]) - email = params[:registration][:person].delete(:user)[:email] - @person = Person.find_by_email email - @registration = nil - @user = nil - - if @person - if @person.registrations.where(conference_id: @conference).empty? - @person.attributes = params[:registration][:person] # Should we really modify person information? - else + def change_field + @registration = Registration.find(params[:id]) + field = params[:view_field] + if @registration.send(field.to_sym) + @registration.update_attribute(:"#{field}",0) + else + @registration.update_attribute(:"#{field}",1) + end + redirect_to admin_conference_registrations_path(@conference.short_title) - flash[:notice] = "#{@person.email} is already registred!" - return - end - else - @person = Person.new params[:registration][:person] + flash[:notice] = "Updated '#{params[:view_field]}' => #{@registration.attended} for + #{(User.where("id = ?", @registration.user_id).first).email}" end - @person.email = email - @user = @person.user - if @user.nil? - @user = @person.build_user - @user.password = rand(36**6).to_s(36) - @user.skip_confirmation! + def edit + @registration = @conference.registrations.where("id = ?", params[:id]).first + @user = User.where("id = ?", @registration.user_id).first end - @user.email = @person.email - @registration = @person.registrations.build - if params[:registration][:supporter_registration] - @supporter_registration = @registration.build_supporter_registration - @supporter_registration.attributes = params[:registration][:supporter_registration] - @supporter_registration.conference_id = @conference.id - else - @supporter_registration = @conference.supporter_registrations.new - end - params[:registration].delete :person - params[:registration].delete :user - params[:registration].delete :supporter_registration - @registration.attributes = params[:registration] - @registration.conference_id = @conference.id - @registration.attended = true - begin - Registration.transaction do - @person.save! - @user.save! - @registration.save! - end - flash[:notice] = "Successfully created new registration for #{@person.email}." - redirect_to admin_conference_registrations_path(@conference.short_title) - rescue ActiveRecord::RecordInvalid - render action: "new" - end - end - - def destroy - if has_role?(current_user, "Admin") - registration = @conference.registrations.where(:id => params[:id]).first - person = Person.where("id = ?", registration.person_id).first - - begin registration.destroy - redirect_to admin_conference_registrations_path - flash[:notice] = "Deleted registration for #{person.public_name} #{person.email}" + def update + @registration = @conference.registrations.where("id = ?", params[:id]).first + @user = User.where("id = ?", @registration.user_id).first + begin + @user.update_attributes!(params[:registration][:user_attributes]) + params[:registration].delete :user_attributes + if params[:registration][:supporter_registration] + @registration.supporter_registration.update_attributes(params[:registration][:supporter_registration_attributes]) + params[:registration].delete :supporter_registration_attributes + end + @registration.update_attributes!(params[:registration]) + flash[:success] = "Successfully updated registration for #{@user.name} #{@user.email}" + redirect_to(admin_conference_registrations_path(@conference.short_title)) rescue Exception => e Rails.logger.debug e.backtrace.join("\n") redirect_to(admin_conference_registrations_path(@conference.short_title), - alert: 'Failed to delete registration:' + e.message) + alert: 'Failed to update registration:' + e.message) return end - else - redirect_to(admin_conference_registrations_path(@conference.short_title), - alert: 'You must be an admin to delete a registration.') end + + def new + @user = User.new + @registration = @user.registrations.new + @supporter_registration = @conference.supporter_registrations.new + end + + def create + @user = User.prepare(user_params['user']) + @registration = Registration.new + + unless @user.save + render action: 'new' + return + end + + if @conference.user_registered? @user # Check if user is already registered to the conference + redirect_to admin_conference_registrations_path(@conference.short_title) + flash[:alert] = "#{@user.email} is already registred!" + return + end + + # Build registration + @registration = @user.registrations.build + @registration.attributes = registration_params + @registration.conference_id = @conference.id + @registration.attended = true + + if params[:registration][:supporter_registration] + @supporter_registration = @registration.build_supporter_registration + @supporter_registration.attributes = supporter_params['supporter_registration'] + @supporter_registration.conference_id = @conference.id + else + # If we render action: 'new' we need the @supporter_registration variable to be set + @supporter_registration = @conference.supporter_registrations.new + end + + if @registration.save + flash[:success] = "Successfully created new registration for #{@user.email}." + redirect_to admin_conference_registrations_path(@conference.short_title) + else + render action: 'new' + end + end + + def destroy + if has_role?(current_user, "Admin") + registration = @conference.registrations.where(:id => params[:id]).first + user = User.where("id = ?", registration.user_id).first + + begin registration.destroy + redirect_to admin_conference_registrations_path + flash[:notice] = "Deleted registration for #{user.name} #{user.email}" + rescue Exception => e + Rails.logger.debug e.backtrace.join("\n") + redirect_to(admin_conference_registrations_path(@conference.short_title), + alert: 'Failed to delete registration:' + e.message) + return + end + else + redirect_to(admin_conference_registrations_path(@conference.short_title), + alert: 'You must be an admin to delete a registration.') + end + end + + protected + def registration_params + params.require(:registration).permit(:attending_with_partner, :using_affiliated_lodging, :handicapped_access_required, :other_special_needs, :attended) + end + def user_params + params.require(:registration).permit(user: [:email, :name, :nickname, :affiliation]) + end + def supporter_params + params.require(:registration).permit(supporter_registration: [:supporter_level_id, :code]) + end end -end \ No newline at end of file +end diff --git a/app/controllers/admin/speakers_controller.rb b/app/controllers/admin/speakers_controller.rb index e80a2f9f..76fd40ce 100644 --- a/app/controllers/admin/speakers_controller.rb +++ b/app/controllers/admin/speakers_controller.rb @@ -1,17 +1,19 @@ -class Admin::SpeakersController < ApplicationController - before_filter :verify_organizer - respond_to :js, :html +module Admin + class SpeakersController < ApplicationController + before_filter :verify_organizer + respond_to :js, :html - def edit - @event = @conference.events.find(params[:event_id]) - @speaker = @event.event_people.where(:event_role => "speaker").first - end + def edit + @event = @conference.events.find(params[:event_id]) + @speaker = @event.event_users.where(event_role: 'speaker').first + end - def update - @event = @conference.events.find(params[:event_id]) - @speaker = @event.event_people.where(:event_role => "speaker").first - @speaker.person_id = params[:speaker][:person_id] - @speaker.save - respond_with @speaker, :location => admin_conference_events_path(@conference.short_title) + def update + @event = @conference.events.find(params[:event_id]) + @speaker = @event.event_users.where(event_role: 'speaker').first + @speaker.user_id = params[:speaker][:user_id] + @speaker.save + respond_with @speaker, location: admin_conference_events_path(@conference.short_title) + end end end diff --git a/app/controllers/admin/stats_controller.rb b/app/controllers/admin/stats_controller.rb index d0820a1d..2c37c34f 100644 --- a/app/controllers/admin/stats_controller.rb +++ b/app/controllers/admin/stats_controller.rb @@ -1,210 +1,211 @@ -class Admin::StatsController < ApplicationController - before_filter :verify_organizer - - def index - @registrations = @conference.registrations.includes(:person).order("registrations.created_at ASC") - @registered = @conference.registrations.count - @attendees = @conference.registrations.where("attended = ?", true).count - @pre_registered = @conference.registrations.where("created_at < ?", @conference.start_date).count - @pre_registered_attended = @conference.registrations.where("created_at < ? AND attended = ?", @conference.start_date, true).count +module Admin + class StatsController < ApplicationController + before_filter :verify_organizer - @registered_with_partner = @conference.registrations.where("attending_with_partner = ?", true).count - @attended_with_partner = @conference.registrations.where("attending_with_partner = ? AND attended = ?", true, true).count + def index + @registrations = @conference.registrations.includes(:user).order('registrations.created_at ASC') + @registered = @conference.registrations.count + @attendees = @conference.registrations.where('attended = ?', true).count + @pre_registered = @conference.registrations.where('created_at < ?', @conference.start_date).count + @pre_registered_attended = @conference.registrations.where('created_at < ? AND attended = ?', @conference.start_date, true).count - @handicapped_access = @conference.registrations.where(handicapped_access_required: true).count - @handicapped_access_attended = @conference.registrations.where(handicapped_access_required: true) - @handicapped_access_attended = @handicapped_access_attended.where(attended: true).count - @suggested_hotel_stay = @conference.registrations.where("using_affiliated_lodging = ?", true).count - - @events = @conference.events -#Events charts - @machine_states = [['confirmed'], ['cancelled'], ['rejected'], ['withdrawn'], ['new', 'review'], ['unconfirmed', 'accepted']] - #Types distribution per state - @type_state = {} - @machine_states.each do |state| - @type_state[state[0]] = var_state_func(@conference.event_types, "event_type", state) - end + @registered_with_partner = @conference.registrations.where('attending_with_partner = ?', true).count + @attended_with_partner = @conference.registrations.where('attending_with_partner = ? AND attended = ?', true, true).count - #Tracks distribution per state - @no_track_all = @events.where(track_id: nil) - @no_track_new = @events.where(track_id: nil).where(state: ['new', 'review']) - @no_track_unconfirmed = @events.where(track_id: nil).where(state: "unconfirmed") - @no_track_confirmed = @events.where(track_id: nil).where(state: "confirmed") - @track_state = {} - @machine_states.each do |state| - @track_state[state[0]] = var_state_func(@conference.tracks, "track", state) - end + @handicapped_access = @conference.registrations.where(handicapped_access_required: true).count + @handicapped_access_attended = @conference.registrations.where(handicapped_access_required: true) + @handicapped_access_attended = @handicapped_access_attended.where(attended: true).count + @suggested_hotel_stay = @conference.registrations.where('using_affiliated_lodging = ?', true).count - #Events_time chart - if @events.count > 0 - start_date = @events.minimum("created_at").strftime("%Y-%m-%d") - end_date = @events.maximum("created_at").strftime("%Y-%m-%d") - if start_date != nil && end_date != nil - @events_time = var_time(start_date, end_date, @events, "created_at") + @events = @conference.events + # Events charts + @machine_states = [['confirmed'], ['cancelled'], ['rejected'], ['withdrawn'], ['new', 'review'], ['unconfirmed', 'accepted']] + # Types distribution per state + @type_state = {} + @machine_states.each do |state| + @type_state[state[0]] = var_state_func(@conference.event_types, 'event_type', state) end - end - - #Code for the table in events - @mystates = [] - @mytypes = [] - @eventstats = {} - statelength = 0 - @totallength = 0 - #Get totals per state - @events.state_machine.states.map.each do |mystate| - length = 0 - events_mystate= @events.where("state" => mystate.name) - if events_mystate.count > 0 - @mystates << mystate - events_mystate.each do |myevent| - length += myevent.event_type.length + + # Tracks distribution per state + @no_track_all = @events.where(track_id: nil) + @no_track_new = @events.where(track_id: nil).where(state: ['new', 'review']) + @no_track_unconfirmed = @events.where(track_id: nil).where(state: 'unconfirmed') + @no_track_confirmed = @events.where(track_id: nil).where(state: 'confirmed') + @track_state = {} + @machine_states.each do |state| + @track_state[state[0]] = var_state_func(@conference.tracks, 'track', state) + end + + # Events_time chart + if @events.count > 0 + start_date = @events.minimum('created_at').strftime('%Y-%m-%d') + end_date = @events.maximum('created_at').strftime('%Y-%m-%d') + if start_date != nil && end_date != nil + @events_time = var_time(start_date, end_date, @events, 'created_at') end - @eventstats["#{mystate.name}"] = {"count" => events_mystate.count, "length" => length} end - end - - @conference.event_types.each do |mytype| - events_mytype = @events.where("event_type_id" => mytype.id) - if events_mytype.count > 0 - @mytypes << mytype - end - end - @mytypes.each do |mytype| - @mystates.each do |mystate| - events_mytype = @events.where("event_type_id" => mytype.id) - events_mytype_mystate= events_mytype.where("state" => mystate.name) - typelength = 0 - if events_mytype_mystate.count > 0 - events_mytype_mystate.each do |myevent| - typelength += myevent.event_type.length - @totallength += myevent.event_type.length + + # Code for the table in events + @mystates = [] + @mytypes = [] + @eventstats = {} + @totallength = 0 + # Get totals per state + @events.state_machine.states.map.each do |mystate| + length = 0 + events_mystate = @events.where('state' => mystate.name) + if events_mystate.count > 0 + @mystates << mystate + events_mystate.each do |myevent| + length += myevent.event_type.length end - @eventstats[mytype.title] = {"count" => events_mytype.count, "length" => events_mytype.count * mytype.length} if @eventstats[mytype.title] == nil - tmp = {"#{mystate.name}" => {"type_state_count" => events_mytype_mystate.count, "type_state_length" => typelength}} - @eventstats[mytype.title].merge!(tmp) + @eventstats["#{mystate.name}"] = { 'count' => events_mystate.count, 'length' => length } end end - end - @eventstats["totallength"] = @totallength -#SPEAKERS stats - @speakers = Person.joins(:events).where("events.conference_id = ? AND events.state LIKE ?", @conference.id, 'confirmed').uniq - @speaker_fields_person = %w[name email affiliation] - @speaker_fields_reg = %w[arrival departure] -#TICKETS stats - @supporter_levels = @conference.supporter_levels - @tickets = @conference.registrations.joins(:supporter_registration => :supporter_level) - @tickets = @tickets.where("supporter_levels.title NOT LIKE ? ", "%Free%") + @conference.event_types.each do |mytype| + events_mytype = @events.where('event_type_id' => mytype.id) + if events_mytype.count > 0 + @mytypes << mytype + end + end + @mytypes.each do |mytype| + @mystates.each do |mystate| + events_mytype = @events.where('event_type_id' => mytype.id) + events_mytype_mystate = events_mytype.where('state' => mystate.name) + typelength = 0 + if events_mytype_mystate.count > 0 + events_mytype_mystate.each do |myevent| + typelength += myevent.event_type.length + @totallength += myevent.event_type.length + end + @eventstats[mytype.title] = { 'count' => events_mytype.count, 'length' => events_mytype.count * mytype.length } if @eventstats[mytype.title] == nil + tmp = { "#{mystate.name}" => { 'type_state_count' => events_mytype_mystate.count, 'type_state_length' => typelength } } + @eventstats[mytype.title].merge!(tmp) + end + end + end + @eventstats['totallength'] = @totallength - @tickets_time = [] + # SPEAKERS stats + @speakers = User.joins(:events).where('events.conference_id = ? AND events.state LIKE ?', @conference.id, 'confirmed').uniq + @speaker_fields_user = %w(name email affiliation) + @speaker_fields_reg = %w(arrival departure) + # TICKETS stats + @supporter_levels = @conference.supporter_levels + @tickets = @conference.registrations.joins(supporter_registration: :supporter_level) + @tickets = @tickets.where('supporter_levels.title NOT LIKE ? ', '%Free%') - if @conference.registration_start_date and @conference.end_date and @registered > 0 and @supporter_levels - start_date = @conference.registration_start_date - end_date = @conference.end_date - levels = []; - @conference.supporter_levels.each do |level| - @tickets_time << {"key" => level.title, "values" => []} - levels << ["#{level.title}"] + @tickets_time = [] + + if @conference.registration_start_date and @conference.end_date and @registered > 0 and @supporter_levels + start_date = @conference.registration_start_date + end_date = @conference.end_date + levels = [] + @conference.supporter_levels.each do |level| + @tickets_time << { 'key' => level.title, 'values' => [] } + levels << ["#{level.title}"] + end + + (start_date..end_date).each do |day| + if @tickets.where('supporter_registrations.created_at LIKE ?', "%#{day}%").where('supporter_levels.title' => levels).count != 0 + @conference.supporter_levels.each do |level| + + day_ticket_count = @tickets.where('supporter_registrations.created_at LIKE ? AND supporter_levels.title LIKE ?', "%#{day}%", "%#{level.title}%").count + + index = @tickets_time.index { |v| v['key'] == "#{level.title}" } + @tickets_time[index]['values'] << { 'label' => "#{day}", 'value' => day_ticket_count } + end + end + end + end + @tickets_distribution = [] + @tickets_time.each do |ticket| + value = ticket['values'].map { |x| x['value'] }.sum + percent = (value.to_f / @tickets.count * 100).round(2) + @tickets_distribution << { 'status' => ticket['key'], 'value' => value, 'percent' => percent } end + # OTHER_INFO chart / To be 'Questions' + @other_info = [ + { 'status' => 'with partner (registered)', 'value' => @registered_with_partner }, + { 'status' => 'with partner (attended)', 'value' => @attended_with_partner }, + { 'status' => 'handicapped (registered)', 'value' => @handicapped_access }, + { 'status' => 'handicapped (attended)', 'value' => @handicapped_access_attended }, + { 'status' => 'stay at suggested hotel', 'value' => @suggested_hotel_stay } + ] + + # REGISTRATIONS, registered_time + if @conference.registration_start_date and @conference.end_date and @registered > 0 + start_date = @conference.registration_start_date + end_date = @conference.end_date + @registered_time = var_time(start_date, end_date, @registrations, 'created_at') + end + + respond_to do |format| + format.html + format.json { render json: @tickets_time.to_json } + end + end + # FUNCTIONS + def var_time(start_date, end_date, var, field) + result = [] (start_date..end_date).each do |day| - if @tickets.where("supporter_registrations.created_at LIKE ?", "%#{day}%").where("supporter_levels.title" => levels).count != 0 - @conference.supporter_levels.each do |level| - - day_ticket_count = @tickets.where("supporter_registrations.created_at LIKE ? AND supporter_levels.title LIKE ?", "%#{day}%", "%#{level.title}%").count - - index = @tickets_time.index {|v| v["key"] == "#{level.title}"} - @tickets_time[index]["values"] << {"label" => "#{day}", "value" => day_ticket_count} - end + day_var_count = var.where("#{field} LIKE ?", "%#{day}%").count + if day_var_count != 0 + result << { 'status' => "#{day}", 'value' => day_var_count } end end - end - @tickets_distribution = [] - @tickets_time.each do |ticket| - value = ticket["values"].map{|x| x["value"]}.sum - percent = (value.to_f / @tickets.count * 100).round(2) - @tickets_distribution << {"status" => ticket["key"], "value" => value, "percent" => percent} + return result end -#OTHER_INFO chart / To be 'Questions' - @other_info = [ - {"status" => "with partner (registered)", "value" => @registered_with_partner}, - {"status" => "with partner (attended)", "value" => @attended_with_partner}, - {"status" => "handicapped (registered)", "value" => @handicapped_access}, - {"status" => "handicapped (attended)", "value" => @handicapped_access_attended}, - {"status" => "stay at suggested hotel", "value" => @suggested_hotel_stay} - ] + def var_state_func(vars, field, mystate) + result = [] -# REGISTRATIONS, registered_time - if @conference.registration_start_date and @conference.end_date and @registered > 0 - start_date = @conference.registration_start_date - end_date = @conference.end_date - @registered_time = var_time(start_date, end_date, @registrations, "created_at") - end - - respond_to do |format| - format.html - format.json { render :json => @tickets_time.to_json } - end - end -#FUNCTIONS - def var_time(start_date, end_date, var, field) - result = [] - (start_date..end_date).each do |day| - day_var_count = var.where("#{field} LIKE ?", "%#{day}%").count - if day_var_count !=0 - result << {"status" => "#{day}", "value" => day_var_count} + for myvar in vars do + # Find events per track and state + value = @conference.events.where("#{field}_id" => myvar.id).where(state: mystate).count + # Find all events in that state + total = @conference.events.where(state: mystate).count + status = "#{myvar.name}" + + if value != 0 + percent = (value.to_f / total * 100).round(2) + result << { 'status' => status, 'value' => value, 'percent' => percent } + else + percent = 0 + end end - end - return result - end - - def var_state_func(vars, field, mystate) - result = [] - - for myvar in vars do - #Find events per track and state - value = @conference.events.where("#{field}_id" => myvar.id).where(state: mystate).count - #Find all events in that state - total = @conference.events.where(state: mystate).count - status = "#{myvar.name}" - - if value != 0 + # Get no of events for which the field is not set (Needed so that the pie shows half piece for 50%) + sum = result.inject(0) { |sum, hash| sum + hash['value'] } + value = total - sum if total and sum + if sum != 0 && value != 0 percent = (value.to_f / total * 100).round(2) - result << {"status" => status, "value" => value, "percent" => percent} - else - percent = 0 + result << { 'status' => "no #{field} set", 'value' => value, 'percent' => percent } end + + return result end - #Get no of events for which the field is not set (Needed so that the pie shows half piece for 50%) - sum = result.inject(0) {|sum, hash| sum + hash["value"]} - value = total - sum if total and sum - if sum !=0 && value !=0 - percent = (value.to_f / total * 100).round(2) - result << {"status" => "no #{field} set", "value" => value, "percent" => percent } + + def speaker_reg(speaker) + speaker.registrations.where('conference_id = ? AND user_id = ?', @conference.id, speaker.id).first end - - return result - end - - def speaker_reg(speaker) - speaker.registrations.where("conference_id = ? AND person_id = ?", @conference.id, speaker.id).first - end - def speaker_diet(reg) - @conference.dietary_choices.find(reg.dietary_choice_id) - end + def speaker_diet(reg) + @conference.dietary_choices.find(reg.dietary_choice_id) + end - def diet_count(diet) - @conference.registrations.where("dietary_choice_id = ?", diet) - end + def diet_count(diet) + @conference.registrations.where('dietary_choice_id = ?', diet) + end - def social_event_count(event) - @conference.registrations.joins(:social_events).where("registrations_social_events.social_event_id = ?", event).count - end + def social_event_count(event) + @conference.registrations.joins(:social_events).where('registrations_social_events.social_event_id = ?', event).count + end - helper_method :speaker_reg - helper_method :speaker_diet - helper_method :diet_count - helper_method :social_event_count -end \ No newline at end of file + helper_method :speaker_reg + helper_method :speaker_diet + helper_method :diet_count + helper_method :social_event_count + end +end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index aa4fc096..b6966822 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -1,29 +1,40 @@ -class Admin::UsersController < ApplicationController - before_filter :verify_admin +module Admin + class UsersController < ApplicationController + before_filter :verify_admin - def index - @users = User.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") + def index + @users = User.all + end + + def show + @user = User.find(params[:id]) + + # Variable @show_attributes holds the attributes that are visible for the 'show' action + # If you want to change the attributes that are shown in the 'show' action of users + # add/remove the attributes in the following string array + @show_attributes = %w(name email affiliation biography registered attended created_at + updated_at sign_in_count current_sign_in_at last_sign_in_at + current_sign_in_ip last_sign_in_ip) + end + + def update + user = User.find(params[:id]) + user.update_attributes!(params[:user]) + redirect_to admin_users_path, notice: "Updated #{user.email}" + end + + def edit + @user = User.find(params[:id]) + end + + def delete + @user = User.find(params[:id]) + end + + def destroy + @user = User.find(params[:id]) + @user.destroy + redirect_to admin_users_path, notice: 'User got deleted' + end end - - def update - user = User.find(params[:id]) - user.update_attributes!(params[:user]) - redirect_to admin_users_path, :notice => "Updated #{user.email}" - end - - def delete - @user = User.find(params[:id]) - end - - def destroy - @user = User.find(params[:id]) - @user.destroy - redirect_to admin_users_path, :notice => "User got deleted" - - end - end diff --git a/app/controllers/api/v1/events_controller.rb b/app/controllers/api/v1/events_controller.rb index 760785c0..1729b333 100644 --- a/app/controllers/api/v1/events_controller.rb +++ b/app/controllers/api/v1/events_controller.rb @@ -2,7 +2,7 @@ class Api::V1::EventsController < Api::BaseController respond_to :json def index - events = Event.includes(:conference, :track, :room, :event_type, {:event_people => :person}) + events = Event.includes(:conference, :track, :room, :event_type, {:event_user => :user}) unless params[:conference_id].blank? events = events.where("conferences.guid" => params[:conference_id]) end diff --git a/app/controllers/api/v1/speakers_controller.rb b/app/controllers/api/v1/speakers_controller.rb index 90ee6f3f..22afff38 100644 --- a/app/controllers/api/v1/speakers_controller.rb +++ b/app/controllers/api/v1/speakers_controller.rb @@ -3,12 +3,12 @@ class Api::V1::SpeakersController < Api::BaseController def index if params[:conference_id].blank? - people = Person.joins(:event_people) + people = User.joins(:event_users) else - people = Person.joins(:event_people => {:event => :conference}) + people = User.joins(:event_users => {:event => :conference}) people = people.where("conferences.guid" => params[:conference_id]) end - people = people.where("event_people.event_role" => "speaker") - render :json => people, :each_serializer => SpeakerSerializer + people = people.where("event_users.event_role" => "speaker") + render :json => users, :each_serializer => SpeakerSerializer end end diff --git a/app/controllers/conference_registration_controller.rb b/app/controllers/conference_registration_controller.rb index a7710b18..b63fe05f 100644 --- a/app/controllers/conference_registration_controller.rb +++ b/app/controllers/conference_registration_controller.rb @@ -5,35 +5,32 @@ class ConferenceRegistrationController < ApplicationController # TODO Figure out how to change the route's id from :id to :conference_id @conference = Conference.find_by(short_title: params[:id]) @workshops = @conference.events.where("require_registration = ? AND state LIKE ?", true, 'confirmed') - @person = current_user.person - if @person.first_name.blank? || @person.last_name.blank? - redirect_to(edit_user_registration_path, :alert => "Please fill in your first and last name before registering.") - return - end - @registration = @person.registrations.where(:conference_id => @conference.id).first + @user = current_user + + @registration = @user.registrations.where(:conference_id => @conference.id).first @registered = true if @registration.nil? @registered = false - @registration = @person.registrations.new(:conference_id => @conference.id) + @registration = @user.registrations.new(:conference_id => @conference.id) end # Check if there's an existing SupporterRegistration for this email and link it when appropriate - @registration.supporter_registration ||= @conference.supporter_registrations.where(:email => @person.email).first + @registration.supporter_registration ||= @conference.supporter_registrations.where(:email => @user.email).first @registration.supporter_registration ||= SupporterRegistration.new(:conference_id => @conference.id) end # TODO this is ugly def update conference = Conference.find_by(short_title: params[:id]) - person = current_user.person - registration = person.registrations.where(:conference_id => conference.id).first + user = current_user + registration = user.registrations.where(:conference_id => conference.id).first update_registration = true # First verify that the supporter code is legit if !params[:registration][:supporter_registration_attributes].nil? && !params[:registration][:supporter_registration_attributes][:code].empty? regs = conference.supporter_registrations.where(:code => params[:registration][:supporter_registration_attributes][:code]) if regs.count != 0 - if regs.where(:email => person.email).count == 0 + if regs.where(:email => user.email).count == 0 redirect_to(register_conference_path(:id => conference.short_title), :alert => "This code is already in use. Please contact #{conference.contact_email} for assistance.") return end @@ -42,16 +39,16 @@ class ConferenceRegistrationController < ApplicationController begin if registration.nil? update_registration = false - person.update_attributes(registration_params[:person_attributes]) - params[:registration].delete :person_attributes + user.update_attributes(registration_params[:user_attributes]) + params[:registration].delete :user_attributes supporter_reg = params[:registration][:supporter_registration_attributes] params[:registration].delete :supporter_registration_attributes - registration = person.registrations.new(registration_params) + registration = user.registrations.new(registration_params) if conference.use_supporter_levels? && !supporter_reg.nil? if !supporter_reg[:id].blank? # This means that their supporter registration was entered ahead of time, probably by an admin registration.supporter_registration = SupporterRegistration.find(supporter_reg[:id]) - if registration.supporter_registration.email != person.email + if registration.supporter_registration.email != user.email raise "Invalid code" end else @@ -78,7 +75,7 @@ class ConferenceRegistrationController < ApplicationController # Track ahoy event ahoy.track 'Registered', title: 'New registration' if conference.email_settings.send_on_registration? - Mailbot.registration_mail(conference, current_user.person).deliver + Mailbot.registration_mail(conference, current_user).deliver end end redirect_to(register_conference_path(:id => conference.short_title), :notice => redirect_message) @@ -86,8 +83,8 @@ class ConferenceRegistrationController < ApplicationController def unregister conference = Conference.find_by(short_title: params[:id]) - person = current_user.person - registration = person.registrations.where(:conference_id => conference.id).first + user = current_user + registration = user.registrations.where(:conference_id => conference.id).first registration.destroy redirect_to :root end @@ -106,9 +103,8 @@ class ConferenceRegistrationController < ApplicationController vchoice_ids: [], qanswer_ids: [], qanswers_attributes: [], - person_attributes: [ - :id, :public_name, :mobile, :tshirt, :languages, - :volunteer_experience], + user_attributes: [ + :id, :name], supporter_registration_attributes: [ :id, :supporter_level_id, :code ]) diff --git a/app/controllers/event_attachments_controller.rb b/app/controllers/event_attachments_controller.rb index ac52bdb4..d7b4fa90 100644 --- a/app/controllers/event_attachments_controller.rb +++ b/app/controllers/event_attachments_controller.rb @@ -25,7 +25,7 @@ class EventAttachmentsController < ApplicationController return end - if organizer_or_admin? || current_user.person == upload.event.submitter + if organizer_or_admin? || current_user == upload.event.submitter send_file upload.attachment.path else raise ActionController::RoutingError.new('Not Found') @@ -52,7 +52,7 @@ class EventAttachmentsController < ApplicationController if !organizer_or_admin? begin - event = current_user.person.events.find(params[:proposal_id]) + event = current_user.events.find(params[:proposal_id]) rescue Exception => e # They certainly aren't allowed to attach a file to someone else's proposal raise ActionController::RoutingError.new('Invalid proposal') @@ -81,7 +81,7 @@ class EventAttachmentsController < ApplicationController end def update - @proposal = current_user.person.events.find(params[:proposal_id]) + @proposal = current_user.events.find(params[:proposal_id]) @upload = @proposal.event_attachments.find(params[:proposal_id]) respond_to do |format| @@ -98,7 +98,7 @@ class EventAttachmentsController < ApplicationController def destroy @proposal = Event.find(params[:proposal_id]) - if organizer_or_admin? || current_user.person == @proposal.submitter + if organizer_or_admin? || current_user == @proposal.submitter @upload = @proposal.event_attachments.find(params[:id]) end diff --git a/app/controllers/proposal_controller.rb b/app/controllers/proposal_controller.rb index 095952f0..1016bad7 100644 --- a/app/controllers/proposal_controller.rb +++ b/app/controllers/proposal_controller.rb @@ -1,11 +1,11 @@ class ProposalController < ApplicationController - before_filter :verify_user, :except => [:show] + before_filter :verify_user, except: [:show] before_filter :setup before_filter :verify_access, only: [:edit, :update, :destroy, :confirm, :restart] def setup - @person = current_user.person if current_user - #FIXME: @conference also comes from verify_user, but we need setup also in show + @user = current_user if current_user + # FIXME: @conference also comes from verify_user, but we need setup also in show # which can be accessed anonymusly @conference = Conference.find_by(short_title: params[:conference_id]) @url = conference_proposal_index_path(@conference.short_title) @@ -19,22 +19,23 @@ class ProposalController < ApplicationController begin if !organizer_or_admin? - @event = @person.events.find(params[:id]) + @event = @user.events.find(params[:id]) else @event = Event.find(params[:id]) end rescue Exception => e Rails.logger.debug("Proposal failure in verify_access: #{e.message}") - redirect_to(conference_proposal_index_path(:conference_id => @conference.short_title), :alert => 'Invalid or uneditable proposal.') + redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), + alert: 'Invalid or uneditable proposal.') end end def index - @events = @person.proposals @conference + @events = @user.proposals @conference end def destroy - proposal = @person.events.find_by_id(params[:id]) + proposal = @user.events.find_by_id(params[:id]) if proposal proposal.withdraw proposal.save @@ -56,92 +57,99 @@ class ProposalController < ApplicationController @attachments = @event.event_attachments if @event.nil? - redirect_to(conference_proposal_index_path(:conference_id => @conference.short_title), :alert => 'Invalid or uneditable proposal.') + redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), + alert: 'Invalid or uneditable proposal.') end end def update session[:return_to] ||= request.referer - submitter = params[:person] + submitter = params[:user] - params[:event].delete :people_attributes - params[:event].delete :person + params[:event].delete :users_attributes + params[:event].delete :user - if submitter[:public_name].blank? - redirect_to edit_conference_proposal_path(@conference.short_title, @event), :alert => "Your public name cannot be blank" + if submitter[:name].blank? + redirect_to edit_conference_proposal_path(@conference.short_title, @event), + alert: 'Your name cannot be blank' return end if submitter[:biography].blank? - redirect_to edit_conference_proposal_path(@conference.short_title, @event), :alert => "Your biography cannot be blank" + redirect_to edit_conference_proposal_path(@conference.short_title, @event), + alert: 'Your biography cannot be blank' return end - if submitter[:public_name] != @person.public_name || submitter[:biography] != @person.biography - @person.update_attributes(submitter) + if submitter[:name] != @user.name || submitter[:biography] != @user.biography + @user.update_attributes(submitter) end event = Event.find_by_id(params[:id]) begin event.update_attributes!(params[:event]) - redirect_to(conference_proposal_index_path(:conference_id => @conference.short_title), :notice => "'#{event.title}' was successfully updated.") + redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), + notice: "'#{event.title}' was successfully updated.") rescue Exception => e - redirect_to edit_conference_proposal_path(@conference.short_title, @event), :alert => e.message + redirect_to edit_conference_proposal_path(@conference.short_title, @event), alert: e.message end end def create - person = current_user.person + user = current_user session[:return_to] ||= request.referer event_params = params[:event] - submitter = params[:person] - params[:event].delete :person + submitter = params[:user] + params[:event].delete :user @event = Event.new(event_params) @event.conference = @conference - if submitter[:public_name].blank? - flash[:error] = "Your public name cannot be blank." - render :action => "new" + if submitter[:name].blank? + flash[:error] = 'Your public name cannot be blank.' + render action: 'new' return end if submitter[:biography].blank? - flash[:error] = "Your biography cannot be blank." - render :action => "new" + flash[:error] = 'Your biography cannot be blank.' + render action: 'new' return end # 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) + if submitter[:name] != user.name || submitter[:biography] != user.biography + user.update_attributes(submitter) end - @event.event_people.new(:person => person, - :event_role => "submitter") - @event.event_people.new(:person => person, - :event_role => "speaker") + @event.event_users.new(user: user, + event_role: 'submitter') + @event.event_users.new(user: user, + 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 + @user = current_user flash[:error] = "Could not submit proposal: #{e.message}" - render :action => 'new' + render action: 'new' return end - registration = person.registrations.where(:conference_id => @conference.id).first + registration = user.registrations.where(conference_id: @conference.id).first ahoy.track 'Event submission', title: 'New submission' 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!') + 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.') + redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), + notice: 'Event was successfully submitted.') end end @@ -155,17 +163,21 @@ class ProposalController < ApplicationController begin @event.confirm! rescue InvalidTransition => e - redirect_to(conference_proposal_index_path(:conference_id => @conference.short_title), :alert => "Event was NOT confirmed: #{e.message}") + 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.") + 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.') + 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!') + redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), + alert: 'Event was NOT confirmed!') end end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index b6137bac..06a4e967 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -36,15 +36,15 @@ class RegistrationsController < Devise::RegistrationsController if successfully_updated if email_changed - if !@user.person.nil? - @user.person.update_attribute("email", params[:user][:email]) + if !@user.nil? + @user.update_attribute('email', params[:user][:email]) end set_flash_message :notice, :update_needs_confirmation else set_flash_message :notice, :updated end # Sign in the user bypassing validation in case his password changed - sign_in @user, :bypass => true + sign_in @user, bypass: true redirect_to after_update_path_for(@user) else flash[:alert] = 'Updating account failed. ' \ @@ -66,11 +66,11 @@ class RegistrationsController < Devise::RegistrationsController def configure_permitted_parameters devise_parameter_sanitizer.for(:account_update) do |u| u. - permit(:email, :password, :password_confirmation, :current_password, - person_attributes: [:id, :email, :first_name, :last_name, - :public_name, :biography, :company, :avatar, - :irc_nickname, :mobile, :tshirt, :languages, - :volunteer_experience]) + permit(:email, :password, :password_confirmation, :current_password, :name, :biography) + end + devise_parameter_sanitizer.for(:sign_up) do |u| + u. + permit(:email, :password, :password_confirmation, :name) end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 58fdf091..6849105d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -159,7 +159,7 @@ module ApplicationHelper result = "" result += "
" - details += "#{self.sign_in_count}
" - details += "Current Sign-in
" - details += "#{self.current_sign_in_at}
" - details += "Last Sign-in
" - details += "#{self.last_sign_in_at}
" - details += "Current Sign-in IP
" - details += "#{self.current_sign_in_ip}
" - details += "Last Sign-in IP
" - details += "#{self.last_sign_in_ip}
" - details += "Created at
" - details += "#{self.created_at}
" + def self.prepare(params) + email = params['email'] + user = User.where(email: email).first_or_initialize + + # If there is a new user, add the necessary attributes + if user.new_record? + user.password = Devise.friendly_token[0,20] + user.skip_confirmation! + user.attributes = params + end + + user + end + + def registered + registrations = self.registrations + if registrations.count == 0 + 'None' + else + registrations.map { |r| r.conference.title }.join ', ' + end + end + + def attended + registrations_attended = self.registrations.where(attended: true) + if registrations_attended.count == 0 + 'None' + else + registrations_attended.map { |r| r.conference.title }.join ', ' + end end def confirmed? !confirmed_at.nil? end - private - def create_person - # TODO Search people for existing email address, add to their account - build_person(email: email) if person.nil? - true + def attending_conference? conference + Registration.where(:conference_id => conference.id, + :user_id => self.id).count end + + def proposals conference + events.where('conference_id = ? AND event_users.event_role=?', conference.id, 'submitter') + end + + def proposal_count conference + proposals(conference).count + end + + def biography_word_count + if self.biography.nil? + 0 + else + self.biography.split.size + end + end + private + def biography_limit + if !self.biography.nil? && self.biography.split.size > 150 + errors.add(:abstract, "cannot have more than 150 words") + end + end end diff --git a/app/models/vote.rb b/app/models/vote.rb index 051561ae..c879efcd 100644 --- a/app/models/vote.rb +++ b/app/models/vote.rb @@ -1,10 +1,8 @@ class Vote < ActiveRecord::Base attr_accessible :rating - - belongs_to :person + + belongs_to :user belongs_to :event - - delegate :first_name, :to => :person - delegate :last_name, :to => :person - delegate :public_name, :to => :person -end \ No newline at end of file + + delegate :name, :to => :user +end diff --git a/app/serializers/event_serializer.rb b/app/serializers/event_serializer.rb index 0eb417d0..b4ca5880 100644 --- a/app/serializers/event_serializer.rb +++ b/app/serializers/event_serializer.rb @@ -10,8 +10,8 @@ class EventSerializer < ActiveModel::Serializer end def speaker_ids - speakers = object.event_people.select {|i| i.event_role == "speaker" } - speakers.map {|i| i.person.guid} + speakers = object.event_users.select {|i| i.event_role == "speaker" } + speakers.map {|i| i.user.id} end def type diff --git a/app/serializers/speaker_serializer.rb b/app/serializers/speaker_serializer.rb index e3e98656..b3aa7471 100644 --- a/app/serializers/speaker_serializer.rb +++ b/app/serializers/speaker_serializer.rb @@ -1,14 +1,10 @@ class SpeakerSerializer < ActiveModel::Serializer include ActionView::Helpers::TextHelper - attributes :guid, :name, :full_name, :company, :biography + attributes :guid, :name, :affiliation, :biography def name - object.public_name - end - - def full_name - [object.first_name, object.last_name].join(" ") + object.name end def biography diff --git a/app/views/admin/conference/_recent_registrations.html.haml b/app/views/admin/conference/_recent_registrations.html.haml index 8211c33f..2a6b449d 100644 --- a/app/views/admin/conference/_recent_registrations.html.haml +++ b/app/views/admin/conference/_recent_registrations.html.haml @@ -11,9 +11,9 @@ %tbody %tr %td #{index + 1} - %td #{registration.public_name} + %td #{registration.name} %td #{registration.conference.title} %td #{registration.created_at.strftime('%m/%d/%Y')} - else %h5.text-warning.text-center - No registrations! \ No newline at end of file + No registrations! diff --git a/app/views/admin/conference/_recent_submissions.html.haml b/app/views/admin/conference/_recent_submissions.html.haml index ac522c5b..24e26fff 100644 --- a/app/views/admin/conference/_recent_submissions.html.haml +++ b/app/views/admin/conference/_recent_submissions.html.haml @@ -12,11 +12,11 @@ %tbody %tr %td #{index + 1} - %td #{event.submitter} + %td #{event.submitter.name} %td #{event.title} %td #{event.conference.title} %td .span{'class'=>label_for(event.state)} #{event.state.humanize} - else %h5.text-warning.text-center - No submissions! \ No newline at end of file + No submissions! diff --git a/app/views/admin/conference/_recent_users.html.haml b/app/views/admin/conference/_recent_users.html.haml index d750f309..e65b6fed 100644 --- a/app/views/admin/conference/_recent_users.html.haml +++ b/app/views/admin/conference/_recent_users.html.haml @@ -20,4 +20,4 @@ %span.label.label-danger Unconfirmed - else %h5.text-warning.text-center - No sign ups! \ No newline at end of file + No sign ups! diff --git a/app/views/admin/conference/_top_submitter.html.haml b/app/views/admin/conference/_top_submitter.html.haml index 6a072f72..36bf2302 100644 --- a/app/views/admin/conference/_top_submitter.html.haml +++ b/app/views/admin/conference/_top_submitter.html.haml @@ -6,10 +6,10 @@ - @top_submitter.each do |key, value| .row.top-submitter .col-md-2 - = image_tag(key.gravatar_url(size: '25'), title: "Yo #{key.public_name}!", :alt => '', 'class'=>'img-circle img-responsive text-center') + = image_tag(key.gravatar_url(size: '25'), title: "Yo #{key.name}!", :alt => '', 'class'=>'img-circle img-responsive text-center') .col-md-10 %h4 - #{key} + #{key.name} %div %small #{pluralize(value, 'submission')} diff --git a/app/views/admin/events/_person_fields.html.haml b/app/views/admin/events/_person_fields.html.haml deleted file mode 100644 index 4999c2ab..00000000 --- a/app/views/admin/events/_person_fields.html.haml +++ /dev/null @@ -1,6 +0,0 @@ -.nested-fields - = f.inputs do - = f.input :email - = f.input :public_name - = remove_association_link :person, f - diff --git a/app/views/admin/events/_proposal.html.haml b/app/views/admin/events/_proposal.html.haml index 83b1391f..77b24a52 100644 --- a/app/views/admin/events/_proposal.html.haml +++ b/app/views/admin/events/_proposal.html.haml @@ -81,7 +81,7 @@ %td %b Submitter %td - = link_to @event.submitter.public_name, admin_person_path(@event.submitter) + = link_to @event.submitter.name, admin_user_path(@event.submitter) ( = link_to @event.submitter.email, "mailto: #{@event.submitter.email}" ) diff --git a/app/views/admin/events/_user_fields.html.haml b/app/views/admin/events/_user_fields.html.haml new file mode 100644 index 00000000..7b555c9f --- /dev/null +++ b/app/views/admin/events/_user_fields.html.haml @@ -0,0 +1,6 @@ +.nested-fields + = f.inputs do + = f.input :email + = f.input :name + = remove_association_link :user, f + diff --git a/app/views/admin/events/_voting.html.haml b/app/views/admin/events/_voting.html.haml index b7af6aaf..2b6d431b 100644 --- a/app/views/admin/events/_voting.html.haml +++ b/app/views/admin/events/_voting.html.haml @@ -3,7 +3,7 @@ %td{:style => "width:15%"} %b Rating %td - - if @event.average_rating.to_f > 0 + - if @event.average_rating.to_f > 0 #{@event.average_rating}/#{@conference.call_for_papers.rating} - else Rating: 0/#{@conference.call_for_papers.rating} @@ -15,20 +15,20 @@ - else = label_tag "label_rating", "", :class => "avgrating" %tr - %td + %td %b Voters %td = @event.voters.length - if @event.voters.length > 0 ( - = @ratings.map {|x| "#{x.first_name} #{x.last_name}"}.join ', ' + = @ratings.map {|x| "#{x.name}"}.join ', ' ) %tr - %td + %td %b Your vote %td - @conference.call_for_papers.rating.times do |counter| - - voted = @event.voted?(@event, current_user.person) + - voted = @event.voted?(@event, current_user) - if voted && voted.rating == counter+1 = link_to "", vote_admin_conference_event_path(@conference.short_title, @event, :rating => counter+1), :remote => true, :id =>"label#{counter+1}", :class => "myrating", :voted => true - else @@ -37,20 +37,20 @@ - if @ratings.length > 0 - @ratings.each do |rate| - - unless rate.person_id == current_user.person.id + - unless rate.user_id == current_user.id %tr %td = rate.first_name = rate.last_name %td - @conference.call_for_papers.rating.times do |counter| - - voted = @event.voted?(@event, rate.person) + - voted = @event.voted?(@event, rate.user) - if voted && voted.rating == counter+1 = label_tag "label#{counter+1}", "", :class => "othersrating", :voted => true = javascript_tag "$('label[voted=true]').prevAll().andSelf().addClass('bright');" - else = label_tag "label#{counter+1}", "", :class => "othersrating" -:javascript +:javascript $(function () { var checkedId = $("a[voted='true']").attr('id'); $('a[id=' + checkedId + ']').prevAll().andSelf().addClass('bright'); @@ -68,4 +68,4 @@ $(".myrating").click(function() { $(this).siblings().removeClass("bright"); $(this).prevAll().andSelf().addClass("bright"); - }); \ No newline at end of file + }); diff --git a/app/views/admin/events/index.html.haml b/app/views/admin/events/index.html.haml index 4c6ed113..a9737289 100644 --- a/app/views/admin/events/index.html.haml +++ b/app/views/admin/events/index.html.haml @@ -58,14 +58,14 @@ - bgcolor="" %td{:style=>"background-color: #{bgcolor}"} - if !event.submitter.nil? - =link_to event.submitter.public_name, admin_person_path(event.submitter) + =link_to event.submitter.name, admin_user_path(event.submitter) - if event.submitter.registrations.count < 1 (Unregistered!) - else Unknown submitter %td - if speaker = event.speakers.first - = link_to speaker.public_name, admin_person_path(speaker) + = link_to speaker.name, admin_user_path(speaker) - else Unknown speaker - l = link_to "Change", edit_admin_conference_event_speaker_path(@conference.short_title, event), :remote => true diff --git a/app/views/admin/events/show.html.haml b/app/views/admin/events/show.html.haml index a33a650f..5508f2be 100644 --- a/app/views/admin/events/show.html.haml +++ b/app/views/admin/events/show.html.haml @@ -24,7 +24,7 @@ %tr %td - if !version.whodunnit.nil? - = Person.find_person_by_user_id(version.whodunnit).public_name + = User.find(version.whodunnit).name - else No user (probably via the console) %td diff --git a/app/views/admin/people/_form.html.haml b/app/views/admin/people/_form.html.haml deleted file mode 100644 index a4c5d045..00000000 --- a/app/views/admin/people/_form.html.haml +++ /dev/null @@ -1,10 +0,0 @@ -= semantic_form_for [:admin, @person] do |f| - = f.inputs "Basic Information" do - = f.input :first_name, :as => :string - = f.input :last_name, :as => :string - = f.input :public_name, :as => :string - = f.input :email - = f.input :company, :as => :string - = f.input :biography, :input_html => {:rows => 10} - = f.actions do - = f.action :submit, :button_html => {:class => "btn primary"} diff --git a/app/views/admin/people/index.html.haml b/app/views/admin/people/index.html.haml deleted file mode 100644 index c53a468a..00000000 --- a/app/views/admin/people/index.html.haml +++ /dev/null @@ -1,43 +0,0 @@ -.row - .col-md-12 - .page-header - %h1 - People - - if @people - = "(#{@people.length})" - = link_to "New person", new_admin_person_path, :class => "btn btn-success pull-right" - -.row - .col-md-12 - .well - %table.table.table-striped.table-bordered.table-hover#people - %thead - %th - %b Email - %th - %b Last Name - %th - %b First Name - %th - %b Public Name - %th - %b # of Conference Registrations - %th - %th - - @people.each do |person| - %tr - %td= person.email - %td= person.last_name - %td= person.first_name - %td= person.public_name - %td= person.registrations.count - %td= link_to "Edit", edit_admin_person_path(person) - %td= link_to "View", admin_person_path(person) - -:javascript - $(document).ready(function() { - $('#people').dataTable( { - "bPaginate": false, - "bLengthChange": false - } ); - } ); diff --git a/app/views/admin/people/show.html.haml b/app/views/admin/people/show.html.haml deleted file mode 100644 index c996aec3..00000000 --- a/app/views/admin/people/show.html.haml +++ /dev/null @@ -1,49 +0,0 @@ -%table.table - %tr - %td - %b First Name - %td - = @person.first_name - %tr - %td - %b Last Name - %td - = @person.last_name - %tr - %td - %b Public Name - %td - = @person.public_name - %tr - %td - %b Company - %td - = @person.company - %tr - %td - %b Email - %td - = @person.email - %tr - %td - %b Created At - %td - = @person.created_at - %tr - %td - %b Updated At - %td - = @person.updated_at - %tr - %td - %b Biography - %td - = @person.biography - %tr - %td - %b Registered to attend - %td - - if @person.registrations.count == 0 - None - - else - = @person.registrations.map { |r| r.conference.title }.join ',' \ No newline at end of file diff --git a/app/views/admin/registrations/edit.html.haml b/app/views/admin/registrations/edit.html.haml index 8d1b6518..1b481721 100644 --- a/app/views/admin/registrations/edit.html.haml +++ b/app/views/admin/registrations/edit.html.haml @@ -1,19 +1,15 @@ .row .col-md-12 %h3 - Edit registration of #{@person.public_name} (#{@person.email}) for #{@conference.title} + Edit registration of #{@user.name} (#{@user.email}) for #{@conference.title} %br .row .col-md-12 = semantic_form_for(@registration, :url => admin_conference_registration_path(@conference.short_title, @registration)) do |f| = f.inputs "Personal Information" do - = f.fields_for :person do |p| - = p.input :first_name, :as => :string - = p.input :last_name, :as => :string - = p.label :Nickname, :as => :string - = p.text_field :irc_nickname, :as => :string - = p.label :Affiliation - = p.text_field :company, :placeholder => "Company/User Group/nothing", :as => :string + = f.fields_for :user do |u| + = u.input :nickname, :as => :string + = u.input :affiliation, :placeholder => "Company/User Group/nothing", :as => :string = f.inputs "Registration Information" do - if @conference.use_supporter_levels? and @conference.supporter_levels.length > 0 = f.semantic_fields_for :supporter_registration do |reg| diff --git a/app/views/admin/registrations/index.html.haml b/app/views/admin/registrations/index.html.haml index 815c83ee..78aa4db7 100644 --- a/app/views/admin/registrations/index.html.haml +++ b/app/views/admin/registrations/index.html.haml @@ -29,7 +29,7 @@ - @headers.each do |field| %td - if field == "name" - #{registration.last_name} #{registration.first_name} (#{registration.irc_nickname}) #{registration.company} + #{registration.name} #{registration.nickname} #{registration.affiliation} - if registration.supporter_level && registration.supporter_level.title != 'Free' %p{:style => "color:red"} = registration.supporter_level.title @@ -52,7 +52,7 @@ = link_to "Edit", edit_admin_conference_registration_path(@conference.short_title, :id => registration), :method => :get, :class => "btn btn-primary" %td - = link_to "Delete", admin_conference_registration_path(@conference.short_title, registration), :method => :delete, :class => "btn btn-danger", data: {confirm: "Really delete registration for #{registration.public_name} #{registration.email}?"} + = link_to "Delete", admin_conference_registration_path(@conference.short_title, registration), :method => :delete, :class => "btn btn-danger", data: {confirm: "Really delete registration for #{registration.name} #{registration.email}?"} %tr{:id => "row#{counter}", :style=>"display:none;"} %td{:colspan=>13} = render :partial => "questions", :locals => {:registration => registration} diff --git a/app/views/admin/registrations/index.pdf.prawn b/app/views/admin/registrations/index.pdf.prawn index 39c57e0f..a75c062c 100644 --- a/app/views/admin/registrations/index.pdf.prawn +++ b/app/views/admin/registrations/index.pdf.prawn @@ -1,9 +1,7 @@ prawn_document(:force_download=>true, :filename => @pdf_filename) do |pdf| table_array = [] header_array = [" ", - "Last Name", - "First Name", - "Public Name", + "Name", "Email", "Attending Social Events", "Attending With Partner", @@ -13,9 +11,7 @@ prawn_document(:force_download=>true, :filename => @pdf_filename) do |pdf| @registrations.each do |registration| row = [] row << "" - row << registration.last_name - row << registration.first_name - row << registration.public_name + row << registration.name row << registration.email if registration.attending_social_events row << "X" diff --git a/app/views/admin/registrations/index.xlsx.axlsx b/app/views/admin/registrations/index.xlsx.axlsx index 9e4b7117..96e5e489 100644 --- a/app/views/admin/registrations/index.xlsx.axlsx +++ b/app/views/admin/registrations/index.xlsx.axlsx @@ -8,9 +8,9 @@ wb.add_worksheet(:name => "registrations") do |sheet| @registrations.each do |reg| row = [] row << reg.attended - row << "#{reg.last_name} #{reg.first_name} (#{reg.public_name})" - row << reg.irc_nickname - row << reg.company + row << reg.name + row << reg.nickname + row << reg.affiliation row << reg.email row << reg.attending_social_events row << reg.attending_with_partner @@ -21,5 +21,5 @@ wb.add_worksheet(:name => "registrations") do |sheet| sheet.add_row row end sheet.column_info[8].width = [sheet.column_info[8].width, 30].min -end +end diff --git a/app/views/admin/registrations/new.html.haml b/app/views/admin/registrations/new.html.haml index 8d0676d0..58bc3747 100644 --- a/app/views/admin/registrations/new.html.haml +++ b/app/views/admin/registrations/new.html.haml @@ -7,16 +7,11 @@ = semantic_form_for(@registration, :url => admin_conference_registrations_path(@conference.short_title)) do |f| = f.inputs "Your details" do - = f.fields_for @person do |p| - = p.fields_for @user do |u| - = u.input :email, :as => :string, :hint => "Please enter a valid email address. You will need it to log in to OSEM later." - = p.input :first_name, :as => :string - = p.input :last_name, :as => :string - = p.input :public_name, :as => :string - = p.label :Nickname - = p.text_field :irc_nickname, :as => :string - = p.label :Affiliation - = p.text_field :company, :placeholder => "Company/User Group/nothing", :as => :string + = f.fields_for @user do |u| + = u.input :email, :as => :string, :hint => "Please enter a valid email address. You will need it to log in to OSEM later." + = u.input :name, as: :string + = u.input :nickname, :as => :string + = u.input :affiliation, :placeholder => "Company/User Group/nothing", :as => :string = f.inputs "Registration Information" do - if @conference.use_supporter_levels? and @conference.supporter_levels.length > 0 diff --git a/app/views/admin/speakers/_form.html.haml b/app/views/admin/speakers/_form.html.haml index 56c3b738..aad39894 100644 --- a/app/views/admin/speakers/_form.html.haml +++ b/app/views/admin/speakers/_form.html.haml @@ -4,7 +4,7 @@ Assign speaker = semantic_form_for @speaker, :as => :speaker, :url => admin_conference_event_speaker_path(@conference.short_title, @event), :method => :put do |f| .form-inputs.form-horizontal.modal-body - = f.collection_select(:person_id, Person.order(:public_name), :id, :public_name) + = f.collection_select(:user_id, User.order(:name), :id, :name) .modal-footer = link_to "Close", "#", :data => {:dismiss => "modal"}, :class => 'btn' diff --git a/app/views/admin/stats/_speakers.html.haml b/app/views/admin/stats/_speakers.html.haml index 3b29a980..1525126c 100644 --- a/app/views/admin/stats/_speakers.html.haml +++ b/app/views/admin/stats/_speakers.html.haml @@ -5,22 +5,16 @@ %thead %th ID - - (@speaker_fields_person + @speaker_fields_reg).each do |field| + - (@speaker_fields_user + @speaker_fields_reg).each do |field| %th = field.capitalize - @speakers.each do |speaker| %tr %td = count +=1 - - @speaker_fields_person.each do |field| + - @speaker_fields_user.each do |field| %td - - if field == 'name' - = speaker.first_name - = speaker.last_name - %br - (#{speaker.public_name}) - - else - = speaker.send(field.to_sym) + = speaker.send(field.to_sym) - @speaker_fields_reg.each do |field| %td - reg = speaker_reg(speaker) diff --git a/app/views/admin/users/_form.html.haml b/app/views/admin/users/_form.html.haml new file mode 100644 index 00000000..ddd33cf8 --- /dev/null +++ b/app/views/admin/users/_form.html.haml @@ -0,0 +1,8 @@ += semantic_form_for [:admin, @user] do |f| + = f.inputs "Basic Information" do + = f.input :name, :as => :string + = f.input :email + = f.input :affiliation, :as => :string + = f.input :biography, :input_html => {:rows => 10} + = f.actions do + = f.action :submit, :button_html => {:class => "btn btn-primary"} diff --git a/app/views/admin/users/index.html.haml b/app/views/admin/users/index.html.haml index 03edd401..d66a475d 100644 --- a/app/views/admin/users/index.html.haml +++ b/app/views/admin/users/index.html.haml @@ -4,6 +4,8 @@ Users - if @users = "(#{@users.length})" + + = link_to "New User", new_admin_user_path, :class => "btn btn-success pull-right" .well %table.table.table-striped.table-bordered.table-hover#users %thead @@ -14,18 +16,15 @@ %th %b Email %th - %b Last Name + %b Name %th - %b First Name - %th - %b Public Name + %b # of Conference Registrations %th %b Roles %th %th %th - @users.each do |user| - - person = Person.find_person_by_user_id(user.id) %tr %td = user.id @@ -37,13 +36,9 @@ %td = user.email %td - = user.last_name + = user.name %td - = user.first_name - %td - = user.public_name - %td - = user.roles.map { |role| role.name }.join ',' + = user.registrations.count %td .modal.fade{:id => "user-role-selection-#{user.id}", "role" => "dialog", "aria-hidden" => "true"} .modal-dialog @@ -60,22 +55,21 @@ %button{:class=> "btn btn-danger", "data-dismiss"=> "modal", "aria-hidden"=>"true"} Cancel - else - = "Give #{user.public_name} (#{user.email}) the following roles:" + = "Give #{user.name} (#{user.email}) the following roles:" = semantic_form_for(user, :url => admin_user_path(user), :method => :put) do |f| = f.input :roles, :label => false %button{:class=> "btn btn-danger", "data-dismiss"=> "modal", "aria-hidden"=>"true"} Cancel = f.action :submit, :as => :button, :button_html => {:value => "Save", :class => "btn btn-primary"} - =link_to "Modify Roles", "#", "data-toggle" => "modal", "data-target" => "#user-role-selection-#{user.id}",id: "user-modify-role-#{user.id}" + =link_to "#{user.roles.map { |role| role.name }.join ', '}", "#", "data-toggle" => "modal", "data-target" => "#user-role-selection-#{user.id}",id: "user-modify-role-#{user.id}" %td - =link_to "Details", "javascript: void(0)", :class => "user-details-popover", "data-trigger" => "click", "data-placement" => "bottom", - "data-html" => "true", - "data-content" => user.popup_details, - "data-original-title" => "" + = link_to "Edit", edit_admin_user_path(user) + %td + = link_to "View", admin_user_path(user) %td - if current_user.id == user.id or user.role_ids.include? 3 - =link_to 'Delete',admin_user_path(user), :method => :delete , :data => {:confirm => 'Are you sure ?'}, :disabled => true,:class => "btn btn-primary disabled btn-danger",:role => "button" - - else + =link_to 'Delete',admin_user_path(user), :method => :delete , :data => {:confirm => 'Are you sure ?'}, :disabled => true,:class => "btn btn-primary disabled btn-danger",:role => "button" + - else =link_to 'Delete',admin_user_path(user), :method=> :delete , :data=> {:confirm => 'Are you sure ?'},:class => "btn btn-primary btn-danger" diff --git a/app/views/admin/users/show.html.haml b/app/views/admin/users/show.html.haml new file mode 100644 index 00000000..c41a6b3b --- /dev/null +++ b/app/views/admin/users/show.html.haml @@ -0,0 +1,7 @@ +%table.table + - @show_attributes.each do |attr| + %tr + %td + %b + = attr.capitalize.gsub('_', ' ') + %td= @user.send(attr) diff --git a/app/views/conference_registration/_registration.html.haml b/app/views/conference_registration/_registration.html.haml index 3d63a3cb..34cafd35 100644 --- a/app/views/conference_registration/_registration.html.haml +++ b/app/views/conference_registration/_registration.html.haml @@ -3,7 +3,7 @@ %h3 Registration for = @conference.title -- if @person.proposal_count(@conference) > 0 +- if @user.proposal_count(@conference) > 0 .row .col-md-12 %i @@ -14,8 +14,8 @@ %br Your public name (required) %br - = f.fields_for :person do |p| - = p.text_field :public_name, :for => :person + = f.fields_for :user do |p| + = p.input :name - if @conference.questions = render :partial => "questions", :locals => {:f => f} diff --git a/app/views/conference_registration/_volunteer.html.haml b/app/views/conference_registration/_volunteer.html.haml index 0057c886..bdcde7b7 100644 --- a/app/views/conference_registration/_volunteer.html.haml +++ b/app/views/conference_registration/_volunteer.html.haml @@ -1,8 +1,8 @@ .row .col-md-12 = f.input :volunteer, :label => "Click here if you want to become a volunteer at #{@conference.short_title}", :input_html => {:maxlength => 15, :size => 40} - = f.fields_for :person do |p| - = render :partial => 'devise/registrations/volunteerperson', :locals => {:p => p} + = f.fields_for :user do |u| + = render :partial => 'devise/registrations/volunteeruser', :locals => {:u => u} %br - if @conference.vpositions.count > 0 diff --git a/app/views/devise/registrations/_volunteerperson.html.haml b/app/views/devise/registrations/_volunteerperson.html.haml deleted file mode 100644 index bf363099..00000000 --- a/app/views/devise/registrations/_volunteerperson.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -=p.input :mobile, :label => "Mobile No (Include country code)", :input_html => {:placeholder => "Eg. +336812345679"}, :hint => "Only visible to org team & volunteer coordinator" - -=p.input :tshirt, :label => "Tshirt Size", :collection => [["Choose", nil],["XS","XS"],["S","S"],["M", "M"], ["L", "L"], ["XL", "XL"], ["XXL", "XXL"], ["XXXL", "XXXL"], ["Girl-S","Girl-s"], ["Girl-M","Girl-M"], ["Girl-L","Girl-L"], ["Girl-XL","Girl-XL"]] - -=p.input :languages, :label => "Which languages do you speak", :hint => "Start from the one you speak best and use 2 letter symbolization, eg. EN, GR, DE" - -= p.input :volunteer_experience, :label => "Do you have any past experience?", :input_html => {:rows => 3, :class => "span6"} \ No newline at end of file diff --git a/app/views/devise/registrations/_volunteeruser.html.haml b/app/views/devise/registrations/_volunteeruser.html.haml new file mode 100644 index 00000000..a120c233 --- /dev/null +++ b/app/views/devise/registrations/_volunteeruser.html.haml @@ -0,0 +1,7 @@ += u.input :mobile, :label => "Mobile No (Include country code)", :input_html => {:placeholder => "Eg. +336812345679"}, :hint => "Only visible to org team & volunteer coordinator" + += u.input :tshirt, :label => "Tshirt Size", :collection => [["Choose", nil],["XS","XS"],["S","S"],["M", "M"], ["L", "L"], ["XL", "XL"], ["XXL", "XXL"], ["XXXL", "XXXL"], ["Girl-S","Girl-s"], ["Girl-M","Girl-M"], ["Girl-L","Girl-L"], ["Girl-XL","Girl-XL"]] + += u.input :languages, :label => "Which languages do you speak", :hint => "Start from the one you speak best and use 2 letter symbolization, eg. EN, GR, DE" + += u.input :volunteer_experience, :label => "Do you have any past experience?", :input_html => {:rows => 3, :class => "span6"} \ No newline at end of file diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml index 36992da5..fcfe0e05 100644 --- a/app/views/devise/registrations/edit.html.haml +++ b/app/views/devise/registrations/edit.html.haml @@ -2,19 +2,17 @@ .col-md-12 = semantic_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| = f.inputs :name => "Profile" do - = f.fields_for :person do |p| - = p.input :first_name, :as => :string - = p.input :last_name, :as => :string - = p.input :public_name, :as => :string - = p.input :irc_nickname, :label => "IRC nick:", :as => :string - = p.input :company, :label => "Affiliation", :as => :string, :hint => "This could be a company, a user group, or nothing at all." - = p.input :biography, :input_html => {:rows => 5, "onkeyup" => "word_count(this, 'biography-count', 150)"}, :for => :person + = f.fields_for :user do |u| + = u.input :name, :as => :string + = u.input :nickname, :as => :string + = u.input :affiliation, :as => :string, :hint => "This could be a company, a user group, or nothing at all." + = u.input :biography, :input_html => {:rows => 5, "onkeyup" => "word_count(this, 'biography-count', 150)"} You have used - %span#biography-count #{current_user.person.biography_word_count} + %span#biography-count #{current_user.biography_word_count} words. Biographies are limited to 150 words. %br %br - = render :partial => 'devise/registrations/volunteerperson', :locals => {:p => p} + = render :partial => 'devise/registrations/volunteeruser', :locals => {:u => u} = f.inputs :name => 'OpenID' do %h4 Currently using the following openIDs: diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index 576b34d9..c68c958c 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -5,6 +5,7 @@ .well = semantic_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| = f.input :email + = f.input :name, required: true = f.input :password = f.input :password_confirmation = f.action :submit, as: :button, label: 'Sign Up', button_html: {class: 'btn btn-primary'} diff --git a/app/views/home/_conference_details.html.haml b/app/views/home/_conference_details.html.haml index 25320002..19378be5 100644 --- a/app/views/home/_conference_details.html.haml +++ b/app/views/home/_conference_details.html.haml @@ -29,7 +29,7 @@ - else = link_to "Register", register_conference_path(conference.short_title), :class =>"btn btn-success" = link_to "Schedule", conference_schedule_path(conference.short_title), :class =>"btn btn-default" if conference.call_for_papers and conference.call_for_papers.schedule_public - - if !current_user.nil? && current_user.person.proposal_count(conference) > 0 + - if !current_user.nil? && current_user.proposal_count(conference) > 0 = link_to "View My Proposals", conference_proposal_index_path(conference.short_title), :class =>"btn btn-default" - elsif conference.cfp_open? - = link_to "Submit Proposal", conference_proposal_index_path(conference.short_title), :class =>"btn btn-default" + = link_to "Submit Proposal", conference_proposal_index_path(conference.short_title), :class =>"btn btn-default" \ No newline at end of file diff --git a/app/views/layouts/_admin_sidebar_index.html.haml b/app/views/layouts/_admin_sidebar_index.html.haml index a8c3807b..a5f4191c 100644 --- a/app/views/layouts/_admin_sidebar_index.html.haml +++ b/app/views/layouts/_admin_sidebar_index.html.haml @@ -24,7 +24,3 @@ = link_to(admin_users_path) do %span.glyphicon.glyphicon-user Users - %li - = link_to(admin_people_path) do - %span.glyphicon.glyphicon-star-empty - People diff --git a/app/views/layouts/_navigation.html.haml b/app/views/layouts/_navigation.html.haml index 6521dbec..ca2df504 100644 --- a/app/views/layouts/_navigation.html.haml +++ b/app/views/layouts/_navigation.html.haml @@ -16,11 +16,11 @@ %ul.nav.navbar-nav.navbar-right %li.dropdown %a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#", id: "current-user-detail"} - - if not current_user.person.public_name.empty? - #{current_user.person.public_name} + - if not current_user.name.empty? + #{current_user.name} -else #{current_user.email} - = image_tag(current_user.person.gravatar_url(size: '18'), title: "Yo #{current_user.person.public_name}!", :alt => '') + = image_tag(current_user.gravatar_url(size: '18'), title: "Yo #{current_user.name}!", :alt => '') %b.caret %ul.dropdown-menu = render 'layouts/user_menu' diff --git a/app/views/proposal/_proposal_form.html.haml b/app/views/proposal/_proposal_form.html.haml index 769f4bac..593c0669 100644 --- a/app/views/proposal/_proposal_form.html.haml +++ b/app/views/proposal/_proposal_form.html.haml @@ -42,12 +42,12 @@ %section#information = f.inputs :name => "Your Information" do - = semantic_fields_for @person do |p| - = p.input :public_name, :as => :string, :required => true - = p.input :company, :as => :string, :label => "Affiliation", :hint => "This could be a company, a user group, or nothing at all." - = p.input :biography, :required => true, :input_html => {:rows => 5, :class => 'span11', "onkeyup" => "word_count(this, 'biography-count', 150)"} + = semantic_fields_for @user do |u| + = u.input :name, :as => :string, :required => true + = u.input :affiliation, :as => :string, :hint => "This could be a company, a user group, or nothing at all." + = u.input :biography, :required => true, :input_html => {:rows => 5, :class => 'span11', "onkeyup" => "word_count(this, 'biography-count', 150)"} You have used - %span#biography-count #{@person.biography_word_count} + %span#biography-count #{@user.biography_word_count} words. Biographies are limited to 150 words. %br %br diff --git a/app/views/proposal/index.html.haml b/app/views/proposal/index.html.haml index fff86416..c93456d3 100644 --- a/app/views/proposal/index.html.haml +++ b/app/views/proposal/index.html.haml @@ -4,7 +4,7 @@ = "My Proposals for #{@conference.title}" - if @conference.cfp_open? || organizer_or_admin? = link_to "New Proposal", new_conference_proposal_path(@conference.short_title), :class => "btn btn-primary pull-right" -- if @person.proposal_count(@conference) > 0 +- if @user.proposal_count(@conference) > 0 .row .col-md-12 %table.table.table-bordered.table-striped diff --git a/app/views/proposal/show.html.haml b/app/views/proposal/show.html.haml index 9f974ede..1478b3ae 100644 --- a/app/views/proposal/show.html.haml +++ b/app/views/proposal/show.html.haml @@ -57,15 +57,15 @@ .col-md-8 %h3 by - = @speaker.public_name + = @speaker.name ( = @speaker.email ) - - if @speaker.company? + - if @speaker.affiliation? %br %span.muted from - = @speaker.company + = @speaker.affiliation -if @speaker.biography? = simple_format(@speaker.biography) .col-md-4 diff --git a/app/views/schedule/index.html.erb b/app/views/schedule/index.html.erb index 88f6cb55..98aea947 100644 --- a/app/views/schedule/index.html.erb +++ b/app/views/schedule/index.html.erb @@ -49,8 +49,8 @@ data-href="<%= url_for(conference_proposal_path(@conference.short_title, event[0].id)) %>"> <%- if speaker = event[0].speakers.first %> <%= image_tag speaker.gravatar_url, :class => "img-circle pull-right", - :alt => speaker.public_name, - :title => speaker.public_name, + :alt => speaker.name, + :title => speaker.name, :style => "padding:8px;" %> <%- end %>
@@ -65,7 +65,7 @@ - <%= "#{speaker.first_name} #{speaker.last_name}" %> + <%= "#{speaker.name}" %> <% if event[0].track%> diff --git a/app/views/shared/_conference_registration.html.haml b/app/views/shared/_conference_registration.html.haml deleted file mode 100644 index 8975058e..00000000 --- a/app/views/shared/_conference_registration.html.haml +++ /dev/null @@ -1,54 +0,0 @@ -= f.inputs :name => "Your Details" do - %br - Your public name (required) - %br - = f.fields_for :person do |p| - = p.text_field :public_name, :for => :person - - if @conference.use_supporter_levels? and @conference.supporter_levels.length > 0 - = f.semantic_fields_for :supporter_registration do |reg| - = reg.input :supporter_level, :as => :select, :collection => @conference.supporter_levels - = reg.input :code, :label => "Confirmation or registration code (if applicable)" - %span#supporter-link.help-block - - = f.input :attending_with_partner, :label => false - = f.input :using_affiliated_lodging, :label => false - = f.input :handicapped_access_required, :label => false - = f.input :other_special_needs, :label => "Any other special needs?", :input_html => {:rows => 2, :class => "span6"} -= f.inputs "Travel Info" do - = f.input :arrival, :as => :string, :input_html => {:value => (f.object.arrival.to_formatted_s(:db_without_seconds) unless f.object.arrival.nil?), :id => "registration-arrival-datepicker", :readonly => "readonly" } - = f.input :departure, :as => :string, :input_html => {:value => (f.object.departure.to_formatted_s(:db_without_seconds) unless f.object.departure.nil?), :id => "registration-departure-datepicker", :readonly => "readonly" } -- if @conference.social_events.count > 0 - = f.inputs "Are you planning to attend any of the parties?" do - %br Yes, I'll be attending... - %br - = f.input :social_events, :as => :check_boxes, :label => false, :collection => @conference.social_events - -:javascript - $("#registration_supporter_registration_attributes_supporter_level_id").change(function () { - var str = ""; - #{generate_supporter_level_js @conference} - $("#supporter-link").html(str); - }) - .trigger('change'); - - $("#registration-arrival-datepicker").datetimepicker({ - dateFormat: "yy-mm-dd", - timeFormat: "HH:mm", - showSecond: false, - numberOfMonths: 1, - defaultDate: '#{@conference.start_date.yesterday.strftime('%Y-%m-%d')}', - onSelect: function(selected) { - $("#registration-departure-datepicker").datepicker("option","minDate", selected) - } - }); - - $("#registration-departure-datepicker").datetimepicker({ - dateFormat: "yy-mm-dd", - timeFormat: "HH:mm", - showSecond: false, - numberOfMonths: 1, - defaultDate: '#{@conference.end_date.tomorrow.strftime('%Y-%m-%d')}', - onSelect: function(selected) { - $("#registration-arrival-datepicker").datepicker("option","maxDate", selected) - } - }); diff --git a/db/migrate/20140609172219_add_person_attributes_to_user.rb b/db/migrate/20140609172219_add_person_attributes_to_user.rb new file mode 100644 index 00000000..24ddf144 --- /dev/null +++ b/db/migrate/20140609172219_add_person_attributes_to_user.rb @@ -0,0 +1,13 @@ +class AddPersonAttributesToUser < ActiveRecord::Migration + def change + add_column :users, :name, :string + add_column :users, :email_public, :boolean + add_column :users, :biography, :string + add_column :users, :nickname, :string + add_column :users, :affiliation, :string + add_column :users, :avatar_file_name, :string + add_column :users, :avatar_content_type, :string + add_column :users, :avatar_file_size, :integer + add_column :users, :avatar_updated_at, :datetime + end +end diff --git a/db/migrate/20140610163947_create_event_users.rb b/db/migrate/20140610163947_create_event_users.rb new file mode 100644 index 00000000..91043d20 --- /dev/null +++ b/db/migrate/20140610163947_create_event_users.rb @@ -0,0 +1,35 @@ +class CreateEventUsers < ActiveRecord::Migration + class TempPerson < ActiveRecord::Base + self.table_name = 'people' + end + + class TempEventPerson < ActiveRecord::Base + self.table_name = 'event_people' + end + + class TempEventUser < ActiveRecord::Base + self.table_name = 'event_users' + end + + def change + create_table :event_users do |t| + t.references :user + t.references :event + t.string :event_role, null: false, default: 'participant' + t.string :comment + + t.timestamps + end + + TempEventPerson.all.each do |ep| + record = TempEventUser.new + record.event_id = ep.event_id + person = TempPerson.where(id: ep.person_id).first + record.user_id = person.user_id + record.event_role = ep.event_role + record.comment = ep.comment + record.save! + end + + end +end diff --git a/db/migrate/20140610165551_migrate_data_person_to_user.rb b/db/migrate/20140610165551_migrate_data_person_to_user.rb new file mode 100644 index 00000000..e68aa6f9 --- /dev/null +++ b/db/migrate/20140610165551_migrate_data_person_to_user.rb @@ -0,0 +1,28 @@ +class MigrateDataPersonToUser < ActiveRecord::Migration + class TempPerson < ActiveRecord::Base + self.table_name = 'people' + end + + class TempUser < ActiveRecord::Base + self.table_name = 'users' + end + + def change + TempPerson.all.each do |p| + user = TempUser.find(p.user_id) + if p.public_name.empty? + user.name = p.email + else + user.name = p.public_name + end + user.biography = p.biography + user.nickname = p.irc_nickname + user.affiliation = p.company + user.avatar_file_name = p.avatar_file_name + user.avatar_content_type = p.avatar_content_type + user.avatar_file_size = p.avatar_file_size + user.avatar_updated_at = p.avatar_updated_at + user.save! + end + end +end diff --git a/db/migrate/20140610173021_change_person_id_to_user_id_in_registrations.rb b/db/migrate/20140610173021_change_person_id_to_user_id_in_registrations.rb new file mode 100644 index 00000000..ac54e435 --- /dev/null +++ b/db/migrate/20140610173021_change_person_id_to_user_id_in_registrations.rb @@ -0,0 +1,26 @@ +class ChangePersonIdToUserIdInRegistrations < ActiveRecord::Migration + class TempPerson < ActiveRecord::Base + self.table_name = 'people' + end + + class TempRegistration < ActiveRecord::Base + self.table_name = 'registrations' + end + + def change + add_column :registrations, :user_id, :integer + + TempPerson.all.each do |t| + registrations = TempRegistration.where(person_id: t.id) + + unless registrations.empty? + registrations.each do |r| + r.user_id = t.user_id + r.save! + end + end + end + + remove_column :registrations, :person_id + end +end diff --git a/db/migrate/20140611123926_change_person_id_to_user_id_in_votes.rb b/db/migrate/20140611123926_change_person_id_to_user_id_in_votes.rb new file mode 100644 index 00000000..973f0001 --- /dev/null +++ b/db/migrate/20140611123926_change_person_id_to_user_id_in_votes.rb @@ -0,0 +1,26 @@ +class ChangePersonIdToUserIdInVotes < ActiveRecord::Migration + class TempPerson < ActiveRecord::Base + self.table_name = 'people' + end + + class TempVote < ActiveRecord::Base + self.table_name = 'votes' + end + + def change + add_column :votes, :user_id, :integer + + TempPerson.all.each do |t| + votes = TempVote.where(person_id: t.id) + + unless votes.empty? + votes.each do |v| + v.user_id = t.user_id + v.save! + end + end + end + + remove_column :votes, :person_id + end +end diff --git a/db/migrate/20140623150541_drop_person_and_event_person_tables.rb b/db/migrate/20140623150541_drop_person_and_event_person_tables.rb new file mode 100644 index 00000000..d83ae15b --- /dev/null +++ b/db/migrate/20140623150541_drop_person_and_event_person_tables.rb @@ -0,0 +1,6 @@ +class DropPersonAndEventPersonTables < ActiveRecord::Migration + def change + drop_table :people + drop_table :event_people + end +end diff --git a/db/schema.rb b/db/schema.rb index a9294f6d..b52e553c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140625114813) do +ActiveRecord::Schema.define(version: 20140626123837) do create_table "ahoy_events", force: true do |t| t.uuid "visit_id" @@ -21,7 +21,7 @@ ActiveRecord::Schema.define(version: 20140625114813) do t.datetime "time" end - #add_index "ahoy_events", ["id"], name: "sqlite_autoindex_ahoy_events_1", unique: true +# add_index "ahoy_events", ["id"], name: "sqlite_autoindex_ahoy_events_1", unique: true add_index "ahoy_events", ["time"], name: "index_ahoy_events_on_time" add_index "ahoy_events", ["user_id"], name: "index_ahoy_events_on_user_id" add_index "ahoy_events", ["visit_id"], name: "index_ahoy_events_on_visit_id" @@ -178,16 +178,6 @@ ActiveRecord::Schema.define(version: 20140625114813) do t.datetime "updated_at" end - create_table "event_people", force: true do |t| - t.integer "proposal_id" - t.integer "person_id" - t.integer "event_id" - t.string "event_role", default: "participant", null: false - t.string "comment" - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "event_types", force: true do |t| t.integer "conference_id" t.string "title", null: false @@ -197,6 +187,15 @@ ActiveRecord::Schema.define(version: 20140625114813) do t.string "color" end + create_table "event_users", force: true do |t| + t.integer "user_id" + t.integer "event_id" + t.string "event_role", default: "participant", null: false + t.string "comment" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "events", force: true do |t| t.string "guid", null: false t.integer "conference_id" @@ -254,29 +253,6 @@ ActiveRecord::Schema.define(version: 20140625114813) do t.datetime "updated_at" end - create_table "people", force: true do |t| - t.string "guid", null: false - t.string "first_name", default: "" - t.string "last_name", default: "" - t.string "public_name", default: "" - t.string "company", default: "" - t.string "email", null: false - t.boolean "email_public" - t.string "avatar_file_name" - t.string "avatar_content_type" - t.integer "avatar_file_size" - t.datetime "avatar_updated_at" - t.text "biography" - t.integer "user_id" - t.datetime "created_at" - t.datetime "updated_at" - t.string "irc_nickname" - t.text "volunteer_experience" - t.string "tshirt" - t.string "mobile" - t.string "languages" - end - create_table "photos", force: true do |t| t.text "description" t.string "picture_file_name" @@ -314,7 +290,6 @@ ActiveRecord::Schema.define(version: 20140625114813) do end create_table "registrations", force: true do |t| - t.integer "person_id" t.integer "conference_id" t.boolean "attending_social_events", default: true t.boolean "attending_with_partner", default: false @@ -330,6 +305,7 @@ ActiveRecord::Schema.define(version: 20140625114813) do t.boolean "attended", default: false t.boolean "volunteer" t.integer "week" + t.integer "user_id" end create_table "registrations_social_events", id: false, force: true do |t| @@ -445,6 +421,15 @@ ActiveRecord::Schema.define(version: 20140625114813) do t.string "unconfirmed_email" t.datetime "created_at" t.datetime "updated_at" + t.string "name" + t.boolean "email_public" + t.text "biography" + t.string "nickname" + t.string "affiliation" + t.string "avatar_file_name" + t.string "avatar_content_type" + t.integer "avatar_file_size" + t.datetime "avatar_updated_at" end add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true @@ -517,15 +502,15 @@ ActiveRecord::Schema.define(version: 20140625114813) do t.datetime "started_at" end - #add_index "visits", ["id"], name: "sqlite_autoindex_visits_1", unique: true +# add_index "visits", ["id"], name: "sqlite_autoindex_visits_1", unique: true add_index "visits", ["user_id"], name: "index_visits_on_user_id" create_table "votes", force: true do |t| - t.integer "person_id" t.integer "event_id" t.integer "rating" t.datetime "created_at" t.datetime "updated_at" + t.integer "user_id" end create_table "vpositions", force: true do |t| diff --git a/spec/factories/event_people.rb b/spec/factories/event_users.rb similarity index 65% rename from spec/factories/event_people.rb rename to spec/factories/event_users.rb index a2dd9cb6..78bcd10d 100644 --- a/spec/factories/event_people.rb +++ b/spec/factories/event_users.rb @@ -1,10 +1,10 @@ # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do - factory :event_person do - person + factory :event_user do + user - Hash[EventPerson::ROLES].values.each do |role| + Hash[EventUser::ROLES].values.each do |role| factory role do event_role role end diff --git a/spec/factories/events.rb b/spec/factories/events.rb index 0d7d5cf0..d6d80a1f 100644 --- a/spec/factories/events.rb +++ b/spec/factories/events.rb @@ -33,7 +33,7 @@ FactoryGirl.define do libero quis porta ultricies. Fusce pulvinar accumsan lobortis. EOS after(:build) do |event| - event.event_people << build(:submitter, event: event) + event.event_users << build(:submitter, event: event) end end end diff --git a/spec/factories/people.rb b/spec/factories/people.rb deleted file mode 100644 index f1b589fc..00000000 --- a/spec/factories/people.rb +++ /dev/null @@ -1,18 +0,0 @@ -# Read about factories at https://github.com/thoughtbot/factory_girl - -FactoryGirl.define do - factory :person do - first_name 'Pat' - last_name 'Jones' - email 'pjones@nowhere.net' - biography <<-EOS - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus enim - nunc, venenatis non sapien convallis, dictum suscipit purus. Vestibulum - sed tincidunt tortor. Fusce viverra nisi nisi, quis congue dui faucibus - nec. Sed sodales suscipit nulla, accumsan porttitor augue ultrices vel. - Quisque cursus facilisis consequat. Etiam volutpat ligula turpis, at - gravida. - EOS - end - -end diff --git a/spec/factories/registration.rb b/spec/factories/registration.rb index 6d72df9b..fb79cb4d 100644 --- a/spec/factories/registration.rb +++ b/spec/factories/registration.rb @@ -2,7 +2,7 @@ FactoryGirl.define do factory :registration do - person + user conference end end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 9b2d1e8c..01c175e7 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -2,9 +2,18 @@ FactoryGirl.define do factory :user do sequence(:email) { |n| "example#{n}@example.com" } + sequence(:name) { |n| "name#{n}" } password 'changeme' password_confirmation 'changeme' confirmed_at Time.now + biography <<-EOS + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus enim + nunc, venenatis non sapien convallis, dictum suscipit purus. Vestibulum + sed tincidunt tortor. Fusce viverra nisi nisi, quis congue dui faucibus + nec. Sed sodales suscipit nulla, accumsan porttitor augue ultrices vel. + Quisque cursus facilisis consequat. Etiam volutpat ligula turpis, at + gravida. + EOS factory :participant do after(:create) { |user| user.role_ids = create(:participant_role).id } diff --git a/spec/features/proposal_spec.rb b/spec/features/proposal_spec.rb index ebd30f86..591015f7 100644 --- a/spec/features/proposal_spec.rb +++ b/spec/features/proposal_spec.rb @@ -36,20 +36,11 @@ feature Event do select('YouTube', from: 'event[media_type]') fill_in 'event_media_id', with: '123456' - fill_in 'person_biography', with: 'Lorem ipsum biography' - fill_in 'person_public_name', with: 'Example User' + fill_in 'user_biography', with: 'Lorem ipsum biography' + fill_in 'user_name', with: 'Example User' click_button 'Submit Session' - expect(current_path).to eq(edit_user_registration_path) - - fill_in 'user_person_attributes_first_name', with: 'Example' - fill_in 'user_person_attributes_last_name', with: 'User' - fill_in 'user_person_attributes_biography', with: 'Lorem ipsum biography' - - click_button 'Update' - - expect(flash). - to eq('You updated your account successfully.') + expect(current_path).to eq(register_conference_path(conference.short_title)) expect(Event.count).to eq(expected_count) diff --git a/spec/models/conference_spec.rb b/spec/models/conference_spec.rb index 52ba893d..a039e1d5 100644 --- a/spec/models/conference_spec.rb +++ b/spec/models/conference_spec.rb @@ -27,8 +27,8 @@ describe Conference do e3 = create(:event, conference: subject) e4 = create(:event, conference: subject) - e3.event_people = [create(:event_person, person: e2.submitter, event_role: 'submitter')] - e4.event_people = [create(:event_person, person: e2.submitter, event_role: 'submitter')] + e3.event_users = [create(:event_user, user: e2.submitter, event_role: 'submitter')] + e4.event_users = [create(:event_user, user: e2.submitter, event_role: 'submitter')] expect(subject.get_top_submitter.values).to eq([3, 1]) expect(subject.get_top_submitter.keys).to eq([e2.submitter, e1.submitter]) diff --git a/spec/support/omniauth_macros.rb b/spec/support/omniauth_macros.rb index 88b605fe..64196bc2 100644 --- a/spec/support/omniauth_macros.rb +++ b/spec/support/omniauth_macros.rb @@ -13,6 +13,7 @@ module OmniauthMacros provider: 'google', uid: 'google-test-uid-1', info: { + name: 'new user name', email: 'test-1@gmail.com' }, credentials: { @@ -28,6 +29,7 @@ module OmniauthMacros provider: 'google', uid: 'facebook-test-uid-1', info: { + name: 'new user fb name', email: 'test-1@gmail.com' }, credentials: { @@ -45,6 +47,7 @@ module OmniauthMacros provider: 'google', uid: 'google-test-uid-participant-1', info: { + name: 'existing user participant name', email: 'test-participant-1@google.com' }, credentials: { @@ -62,6 +65,7 @@ module OmniauthMacros provider: 'google', uid: 'google-test-uid-admin-1', info: { + name: 'existing user admin name', email: 'test-admin-1@google.com' }, credentials: {