<commit_before>class AdminController < ActionController::Base
	include AdminHelper
  	helper_method :current_user

  	rescue_from SecurityError, with: :not_signed_in
	def index
		#Gets last 50 entries
		@log_entries = LogEntry.last(30)
		@is_locked = locked?
	end

	def lock
		index
	end

	def locked?
		check_lock_state
		@is_locked
	end

	def lock
		#Call to active_booking to get @group, can this be done less ugly?
		active_booking
		if @user.in_group?(@group.to_s) || @user.admin?
			#If the params of url are valid
			if params[:lock_type].eql?("locked") || params[:lock_type].eql?("unlocked")
				#Create new lockstate using params
				lock_state = LockState.new
				lock_state.state = params[:lock_type]
				if @group 
					lock_state.group = @group
					lock_state.expiration_date = @exp_date
					@lock_type = params[:lock_type] + " until: " + @exp_date.to_s
				else
					lock_state.group = "digit"
					lock_state.expiration_date = DateTime.now + 1.hour
					@lock_type = params[:lock_type] + " until: " + (DateTime.now + 1.hour).to_s

				end
				lock_state.user = current_user.cid
				lock_state.save
				#To print later
			else
				@lock_type = "INVALID STATE"
			end  
		end
	end
	
    def allow_iframe
      response.headers['X-Frame-Options'] = 'ALLOW-FROM https://chalmers.it'
    end

    def not_signed_in
      render text: 'Logga in på: <a href="https://account.chalmers.it" target="_top">https://account.chalmers.it</a>'
    end
end<commit_msg>fixed a bug where the owner of the current booking couldnt reach /admin<commit_after>class AdminController < ActionController::Base
	include AdminHelper
  	helper_method :current_user
  	before_action :active_booking
  	rescue_from SecurityError, with: :not_signed_in
	def index
		#Gets last 50 entries
		@log_entries = LogEntry.last(30)
		@is_locked = locked?
	end

	def lock
		index
	end

	def locked?
		check_lock_state
		@is_locked
	end

	def lock
		if @user.in_group?(@group.to_s) || @user.admin?
			#If the params of url are valid
			if params[:lock_type].eql?("locked") || params[:lock_type].eql?("unlocked")
				#Create new lockstate using params
				lock_state = LockState.new
				lock_state.state = params[:lock_type]
				if @group 
					lock_state.group = @group
					lock_state.expiration_date = @exp_date
					@lock_type = params[:lock_type] + " until: " + @exp_date.to_s
				else
					lock_state.group = "digit"
					lock_state.expiration_date = DateTime.now + 1.hour
					@lock_type = params[:lock_type] + " until: " + (DateTime.now + 1.hour).to_s

				end
				lock_state.user = current_user.cid
				lock_state.save
				#To print later
			else
				@lock_type = "INVALID STATE"
			end  
		end
	end
	
    def allow_iframe
      response.headers['X-Frame-Options'] = 'ALLOW-FROM https://chalmers.it'
    end

    def not_signed_in
      render text: 'Logga in på: <a href="https://account.chalmers.it" target="_top">https://account.chalmers.it</a>'
    end
end
{'fraction_non_alphanumeric': 0.10748299319727891, 'fraction_numerical': 0.004081632653061225, 'mean_word_length': 3.3313696612665686, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1193466', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1008, 'n_words': 242}