From d6c85897854336adbddef393f6a3644918f8c2d0 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Tue, 17 Mar 2015 00:06:58 -0500 Subject: [PATCH] Add corp tickers to header. --- app/helpers/application_helper.rb | 1 + app/models/user.rb | 10 +++++++--- app/views/shared/_header.html.erb | 2 +- lib/calefaction/eve.rb | 28 ++++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 lib/calefaction/eve.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 60c967b..cea8c28 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,3 +1,4 @@ +require 'calefaction/eve' require 'calefaction/version' module ApplicationHelper diff --git a/app/models/user.rb b/app/models/user.rb index 7db5d34..aa05e5e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -17,13 +17,17 @@ class User < ActiveRecord::Base member_of? AdminSetting.get(:corp_id).to_i end - def member_of?(corp_id) + def member_of?(corp) + corp_id == corp + end + + def corp_id ensure_api_user @api.scope = 'char' begin - @api.CharacterSheet(names: name).corporationID.to_i == corp_id + @api.CharacterSheet(names: name).corporationID.to_i rescue EAAL::EAALError - false + 0 end end diff --git a/app/views/shared/_header.html.erb b/app/views/shared/_header.html.erb index 2be0a09..4648a7b 100644 --- a/app/views/shared/_header.html.erb +++ b/app/views/shared/_header.html.erb @@ -8,7 +8,7 @@