mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
new registration
This commit is contained in:
parent
84d30e13f0
commit
4532ad8c0a
6 changed files with 127 additions and 69 deletions
|
|
@ -53,11 +53,58 @@ class Admin::RegistrationsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@registration = Registration.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
|
||||
|
||||
if params[:registration][:people][:first_name].blank? || params[:registration][:people][: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 = params[:registration][:user][:password]
|
||||
begin
|
||||
user.save!
|
||||
user.skip_confirmation!
|
||||
person = Person.where("user_id = ?", user.id).first
|
||||
person.update_attributes(params[:registration][:people])
|
||||
begin
|
||||
params[:registration].delete :people
|
||||
params[:registration].delete :user
|
||||
|
||||
registration = person.registrations.new
|
||||
registration.supporter_registration = @conference.supporter_registrations.new(:supporter_level_id => params[:registration][:supporter_registrations][:supporter_level], :code => params[:registration][:supporter_registrations][:code], :email => person.email, :name => person.public_name)
|
||||
params[:registration].delete :supporter_registrations
|
||||
|
||||
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}."
|
||||
# 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
|
||||
|
||||
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}"
|
||||
|
|
|
|||
|
|
@ -15,50 +15,5 @@ class Admin::UsersController < ApplicationController
|
|||
user = User.find(params[:id])
|
||||
user.update_attributes!(params[:user])
|
||||
redirect_to admin_users_path, :notice => "Updated #{user.email}"
|
||||
end
|
||||
|
||||
def new
|
||||
@user = User.new
|
||||
@person = Person.where("user_id =?", @user.id)
|
||||
@conferences = Conference.where("end_date >= ?", Time.now)
|
||||
@conference = Conference.find_all_by_short_title(params[:format]).first
|
||||
end
|
||||
|
||||
def create
|
||||
@conference = Conference.find_all_by_short_title(params[:id]).first
|
||||
|
||||
if params[:user][:people][:first_name].blank? || params[:user][:people][:last_name].blank?
|
||||
redirect_to(:back, :alert => "Please fill in your first and last name before registering.")
|
||||
return
|
||||
end
|
||||
|
||||
params[:user][:conferences].shift
|
||||
if !params[:user][:conferences].empty?
|
||||
user = User.new
|
||||
user.email = params[:user][:email]
|
||||
user.password = params[:user][:password]
|
||||
begin
|
||||
user.save!
|
||||
user.skip_confirmation!
|
||||
person = Person.where("user_id = ?", user.id).first
|
||||
person.update_attributes(params[:user][:people])
|
||||
begin
|
||||
params[:user][:conferences].each do |r|
|
||||
registration = person.registrations.new(:conference_id => r, :attended => 't')
|
||||
registration.save!
|
||||
end
|
||||
redirect_to admin_conference_registrations_path(@conference.short_title)
|
||||
flash[:notice] = "Successfully created new registration for #{person.email}."
|
||||
rescue Exception => e
|
||||
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
|
||||
else
|
||||
redirect_to(:back, :alert => "Please select at least one conference to register.")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue