mirror of
https://github.com/oonyeje/Pearlception_Website_RoR.git
synced 2025-12-25 11:47:41 +00:00
36 lines
1.1 KiB
Ruby
36 lines
1.1 KiB
Ruby
class DashboardController < ApplicationController
|
|
before_filter :deny_to_visitors
|
|
|
|
def index
|
|
#This is a temporary fix until runs and results models are properly discussed with bobby
|
|
#@results = Result.page(params[:page]).per(5)
|
|
if current_user.admin?
|
|
puts params
|
|
@results = Hash.new
|
|
names = (Company.pluck :company_name) - ["IVA"]
|
|
names.map!{|tenant| tenant.gsub(/'/,'').gsub(/\s/,'')}
|
|
names.each do
|
|
|name|
|
|
|
|
Apartment::Tenant.switch!(name.gsub(/'/,'').gsub(/\s/,''))
|
|
|
|
if params[:company] == name
|
|
@results[name.gsub(/'/,'').gsub(/\s/,'')] = {results: Run.page(params[:page]).per(5), active: true, name: name}
|
|
else
|
|
@results[name.gsub(/'/,'').gsub(/\s/,'')] = {results: Run.page(params[:page]).per(5), active: false}
|
|
end
|
|
end
|
|
#binding.pry
|
|
Apartment::Tenant.switch!
|
|
else
|
|
@results = Run.page(params[:page]).per(5)
|
|
end
|
|
|
|
end
|
|
|
|
def deny_to_visitors
|
|
redirect_to "/signin" unless user_signed_in?
|
|
end
|
|
|
|
end
|