From c3330a846f9b09fa5ac09dd74e546046f7193e56 Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Wed, 22 Apr 2015 15:35:46 +0200 Subject: [PATCH 1/3] Always show the Update button for registrations --- app/views/conference_registrations/_form.html.haml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/views/conference_registrations/_form.html.haml b/app/views/conference_registrations/_form.html.haml index ef619583..073eae1d 100644 --- a/app/views/conference_registrations/_form.html.haml +++ b/app/views/conference_registrations/_form.html.haml @@ -30,11 +30,13 @@ = f.inputs 'Your Travel Info' do = f.input :arrival, as: :string, label: 'Your arrival time', 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, label: 'Your departure time', input_html: { value: (f.object.departure.to_formatted_s(:db_without_seconds) unless f.object.departure.nil?), id: 'registration-departure-datepicker', readonly: 'readonly' } - %p.pull-right - - if @conference.user_registered?(current_user) - = f.action :submit, button_html: { value: 'Update Registration', class: 'btn btn-primary' } - - else - = f.action :submit, button_html: { value: 'Register', class: 'btn btn-primary', id: 'register' } + .row + .col-md-12 + %p.pull-right + - if @conference.user_registered?(current_user) + = f.action :submit, button_html: { value: 'Update Registration', class: 'btn btn-primary' } + - else + =f.action :submit, button_html: { value: 'Register', class: 'btn btn-primary', id: 'register' } .tab-pane{role: 'tabpanel', id: 'signin'} - if !CONFIG['authentication']['ichain']['enabled'] = form_tag(new_user_session_path, class: 'form-horizontal') do From 4ed8a72967fc3ad51168819b39003fae09b38328 Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Wed, 22 Apr 2015 16:31:44 +0200 Subject: [PATCH 2/3] Widen the sign-in menu a bit --- app/views/layouts/_navigation.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/_navigation.html.haml b/app/views/layouts/_navigation.html.haml index 0e908e95..ff0a5698 100644 --- a/app/views/layouts/_navigation.html.haml +++ b/app/views/layouts/_navigation.html.haml @@ -41,7 +41,7 @@ %span.fa.fa-user Sign In %span.caret - .dropdown-menu{:style => "padding: 17px;"} + .dropdown-menu{:style => "padding: 17px; min-width: 225px;"} - if CONFIG['authentication']['ichain']['enabled'] = form_tag User.ichain_login_url do = text_field_tag 'username', nil, id: 'user_ichain_email_dd', placeholder: 'Username' From 132fe6f98ce6762312805699c88bce9a88833a70 Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Thu, 23 Apr 2015 11:50:22 +0200 Subject: [PATCH 3/3] Disable registration/event submission without sign in with ichain --- app/controllers/application_controller.rb | 4 +++- app/models/ability.rb | 13 +++++++------ config/environments/development.rb | 8 ++++++++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fca129ac..df6bedff 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -44,7 +44,9 @@ class ApplicationController < ActionController::Base rescue_from CanCan::AccessDenied do |exception| Rails.logger.debug "Access denied on #{exception.action} #{exception.subject.inspect}" - redirect_to root_path, alert: exception.message + message = exception.message + message << ' Maybe you need to sign in?' if !current_user + redirect_to root_path, alert: message end rescue_from IChainRecordNotFound do diff --git a/app/models/ability.rb b/app/models/ability.rb index 4a1abe99..0f89057e 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -49,12 +49,13 @@ class Ability # can view Commercials of confirmed Events can :show, Commercial, commercialable_type: 'Event', commercialable_id: Event.where(state: 'confirmed').pluck(:id) can :show, User - can [:show, :create], Registration do |registration| - registration.new_record? - end - - can [:show, :create], Event do |event| - event.new_record? + unless CONFIG['authentication']['ichain']['enabled'] + can [:show, :create], Registration do |registration| + registration.new_record? + end + can [:show, :create], Event do |event| + event.new_record? + end end end diff --git a/config/environments/development.rb b/config/environments/development.rb index c66c56f0..8167887f 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -85,4 +85,12 @@ Osem::Application.configure do } ) + + config.after_initialize do + Devise.setup do |devise_config| + # Enable ichain test mode + devise_config.ichain_test_mode = true + end + end + end