mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Merge branch 'admin_registrations_attended' of github.com:differentreality/osem into differentreality-admin_registrations_attended
Conflicts: app/controllers/admin/registrations_controller.rb app/models/registration.rb
This commit is contained in:
commit
243f33ff91
8 changed files with 217 additions and 90 deletions
|
|
@ -6,7 +6,7 @@ class Admin::RegistrationsController < ApplicationController
|
|||
@pdf_filename = "#{@conference.title}.pdf"
|
||||
@registrations = @conference.registrations.includes(:person).order("registrations.created_at ASC")
|
||||
@attended = @conference.registrations.where("attended = ?", true).count
|
||||
@headers = %w[attended name email attending_social_events attending_with_partner need_access other_needs arrival departure]
|
||||
@headers = %w[name email attending_social_events attending_with_partner need_access other_needs arrival departure attended]
|
||||
end
|
||||
|
||||
def change_field
|
||||
|
|
@ -21,7 +21,7 @@ class Admin::RegistrationsController < ApplicationController
|
|||
redirect_to admin_conference_registrations_path(@conference.short_title, @registration)
|
||||
flash[:notice] = "Updated '#{params[:view_field]}' 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
|
||||
|
|
@ -34,10 +34,12 @@ class Admin::RegistrationsController < ApplicationController
|
|||
begin
|
||||
@person.update_attributes!(params[:registration][:person_attributes])
|
||||
params[:registration].delete :person_attributes
|
||||
@registration.supporter_registration = @conference.supporter_registrations.new(params[:registration][:supporter_registration_attributes])
|
||||
params[:registration].delete :supporter_registration_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}"
|
||||
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")
|
||||
|
|
@ -46,11 +48,70 @@ class Admin::RegistrationsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@user = User.new
|
||||
@person = Person.new
|
||||
@registration = @person.registrations.new
|
||||
@supporter_registration = @conference.supporter_registrations.new
|
||||
@conference = Conference.find_all_by_short_title(params[:conference_id]).first
|
||||
end
|
||||
|
||||
def create
|
||||
@conference = Conference.find_all_by_short_title(params[:conference_id]).first
|
||||
person = Person.where("email LIKE ?", params[:registration][:user][:email]).first
|
||||
|
||||
if !person.nil?
|
||||
reg = @conference.registrations.where("person_id = ?", person.id).first
|
||||
if reg.nil?
|
||||
registration = person.registrations.new
|
||||
else
|
||||
redirect_to admin_conference_registrations_path(@conference.short_title)
|
||||
flash[:notice] = "#{person.email} is already registred!"
|
||||
return
|
||||
end
|
||||
else
|
||||
if params[:registration][:person][:first_name].blank? || params[:registration][:person][:last_name].blank?
|
||||
redirect_to(:back, :alert => "Please fill in your first and last name before registering.")
|
||||
return
|
||||
end
|
||||
user = User.new
|
||||
user.email = params[:registration][:user][:email]
|
||||
user.password = rand(36**6).to_s(36)
|
||||
begin user.save!
|
||||
user.skip_confirmation!
|
||||
person = Person.where("user_id = ?", user.id).first
|
||||
person.update_attributes(params[:registration][:person])
|
||||
begin
|
||||
registration = person.registrations.new
|
||||
if params[:registration][:supporter_registration]
|
||||
registration.supporter_registration = @conference.supporter_registrations.new(:supporter_level_id => params[:registration][:supporter_registration][:supporter_level_id], :code => params[:registration][:supporter_registration][:code], :email => person.email, :name => person.public_name)
|
||||
end
|
||||
rescue Exception => e
|
||||
user.destroy
|
||||
person.destroy
|
||||
redirect_to(:back, :alert => "Did not create registration. #{e.message}")
|
||||
return
|
||||
end
|
||||
rescue Exception => e
|
||||
redirect_to(:back, :alert => "Did not create new user/person. #{e.message}")
|
||||
return
|
||||
end
|
||||
end
|
||||
params[:registration].delete :person
|
||||
params[:registration].delete :user
|
||||
params[:registration].delete :supporter_registration
|
||||
registration.update_attributes(params[:registration])
|
||||
registration.update_attributes(:conference_id => @conference.id, :attended => true)
|
||||
registration.save!
|
||||
redirect_to admin_conference_registrations_path(@conference.short_title)
|
||||
flash[:notice] = "Successfully created new registration for #{person.email}."
|
||||
end
|
||||
|
||||
def delete
|
||||
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}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue