commit
e8b9c26778
19 changed files with 606 additions and 44 deletions
|
|
@ -27,9 +27,15 @@ class Admin::ConferenceController < ApplicationController
|
|||
|
||||
def update
|
||||
@conference = Conference.find_by(short_title: params[:id])
|
||||
@conference.update_attributes(params[:conference])
|
||||
flash[:notice] = "Updated Conference"
|
||||
redirect_to(admin_conference_path(:id => @conference.short_title), :notice => 'Conference was successfully updated.')
|
||||
short_title = @conference.short_title
|
||||
if @conference.update_attributes(params[:conference])
|
||||
redirect_to(admin_conference_path(id: @conference.short_title),
|
||||
notice: 'Conference was successfully updated.')
|
||||
else
|
||||
errors = @conference.errors.full_messages.join('! ')
|
||||
redirect_to(admin_conference_path(id: short_title),
|
||||
flash: { error: "Conference update failed. #{errors}" })
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
@ -37,7 +43,7 @@ class Admin::ConferenceController < ApplicationController
|
|||
@conference = Conference.find_by(short_title: params[:id])
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render :json => @conference.to_json }
|
||||
format.json { render json: @conference.to_json }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def after_sign_in_path_for(resource)
|
||||
if not session[:return_to].start_with?(user_registration_path)
|
||||
if session[:return_to] &&
|
||||
!session[:return_to].start_with?(user_registration_path)
|
||||
logger.debug "Returning to #{session[:return_to]}"
|
||||
session[:return_to]
|
||||
else
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@ class User < ActiveRecord::Base
|
|||
accepts_nested_attributes_for :person
|
||||
accepts_nested_attributes_for :roles
|
||||
|
||||
before_save :setup_role
|
||||
before_create :setup_role
|
||||
before_create :create_person
|
||||
|
||||
delegate :last_name, :first_name, :public_name, to: :person
|
||||
|
||||
def role?(role)
|
||||
Rails.logger.debug("Checking role in user")
|
||||
return !!self.roles.find_by_name(role.to_s.camelize)
|
||||
!!roles.find_by_name(role.to_s.downcase.camelize)
|
||||
end
|
||||
|
||||
def get_roles
|
||||
|
|
@ -29,13 +29,8 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def setup_role
|
||||
if self.id == 1
|
||||
self.role_ids = [3]
|
||||
end
|
||||
|
||||
if self.role_ids.empty?
|
||||
self.role_ids = [1]
|
||||
end
|
||||
roles << Role.find_by(name: 'Admin') if User.count == 0
|
||||
roles << Role.find_by(name: 'Participant') if roles.empty?
|
||||
end
|
||||
|
||||
def popup_details
|
||||
|
|
@ -54,9 +49,9 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
private
|
||||
def create_person
|
||||
# TODO Search people for existing email address, add to their account
|
||||
build_person(:email => self.email) if person.nil?
|
||||
true
|
||||
end
|
||||
def create_person
|
||||
# TODO Search people for existing email address, add to their account
|
||||
build_person(email: email) if person.nil?
|
||||
true
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@
|
|||
%span.caret
|
||||
.dropdown-menu{:style => "padding: 17px;"}
|
||||
= form_tag user_session_path do
|
||||
= text_field_tag 'user[email]'
|
||||
= password_field_tag 'user[password]'
|
||||
= text_field_tag 'user[email]', nil, id: 'user_email_dd'
|
||||
= password_field_tag 'user[password]', nil, id: 'user_password_dd'
|
||||
%label.checkbox
|
||||
= check_box_tag 'user[remember_me]'
|
||||
Remember me
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue