User/Person models merge
This commit is contained in:
parent
66b84e3660
commit
23bf55b66c
80 changed files with 1064 additions and 1221 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
end
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
helper_method :speaker_reg
|
||||
helper_method :speaker_diet
|
||||
helper_method :diet_count
|
||||
helper_method :social_event_count
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue