| Total Complexity | 7 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | # Filters added to this controller apply to all controllers in the application. |
||
| 4 | class ApplicationController < ActionController::Base |
||
| 5 | helper :all # include all helpers, all the time |
||
| 6 | helper :layout |
||
| 7 | helper_method :current_participant |
||
| 8 | helper_method :logged_in? |
||
| 9 | protect_from_forgery # See ActionController::RequestForgeryProtection for details |
||
| 10 | |||
| 11 | def current_participant |
||
| 12 | @current_participant ||= (current_participant_session && current_participant_session.participant) |
||
| 13 | end |
||
| 14 | alias_method :current_user, :current_participant |
||
| 15 | |||
| 16 | def current_participant_session |
||
| 17 | return @current_participant_session if defined?(@current_participant_session) |
||
| 18 | @current_participant_session = ParticipantSession.find |
||
| 19 | end |
||
| 20 | |||
| 21 | def logged_in? |
||
| 22 | current_participant_session.present? |
||
| 23 | end |
||
| 24 | |||
| 25 | def verify_session |
||
| 26 | unless logged_in? |
||
| 27 | flash[:notice] = 'You must be logged in to do that. Please log in or create a new account and try again.' |
||
| 28 | redirect_to new_login_path |
||
| 29 | end |
||
| 30 | end |
||
| 31 | |||
| 32 | def event_schedule_cache_key(event) |
||
| 33 | [ |
||
| 34 | event, |
||
| 35 | event.sessions, |
||
| 36 | event.participants, |
||
| 37 | event.timeslots, |
||
| 38 | event.rooms |
||
| 39 | ] |
||
| 40 | end |
||
| 41 | helper_method :event_schedule_cache_key |
||
| 42 | end |
||
| 43 |