Work around for sso character not being delete from characters after sso deleted, some other minor tweaks

This commit is contained in:
Ryan Holmes
2018-03-15 19:57:58 -04:00
parent b74654a5b3
commit 8153b80d05
8 changed files with 48 additions and 45 deletions

View File

@@ -76,7 +76,7 @@ sd_lock = threading.RLock()
# noinspection PyPep8
from eos.db.gamedata import alphaClones, attribute, category, effect, group, icon, item, marketGroup, metaData, metaGroup, queries, traits, unit
# noinspection PyPep8
from eos.db.saveddata import booster, cargo, character, ssoCharacter, damagePattern, databaseRepair, drone, fighter, fit, implant, implantSet, loadDefaultDatabaseValues, \
from eos.db.saveddata import booster, cargo, character, damagePattern, databaseRepair, drone, fighter, fit, implant, implantSet, loadDefaultDatabaseValues, \
miscData, module, override, price, queries, skill, targetResists, user
# Import queries

View File

@@ -12,7 +12,6 @@ __all__ = [
"miscData",
"targetResists",
"override",
"ssoCharacter",
"implantSet",
"loadDefaultDatabaseValues"
]

View File

@@ -88,7 +88,7 @@ mapper(Character, characters_table,
"_Character__ssoCharacters" : relation(
SsoCharacter,
collection_class=HandledSsoCharacterList,
backref='characters',
backref='characters',
secondary=sso_character_map_table)
}
)

View File

@@ -1,25 +0,0 @@
# ===============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of eos.
#
# eos is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# eos is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with eos. If not, see <http://www.gnu.org/licenses/>.
# ===============================================================================
from sqlalchemy import Table, Column, Integer, String, DateTime, UniqueConstraint, ForeignKey
from sqlalchemy.orm import mapper
import datetime
from eos.db import saveddata_meta
from eos.saveddata.ssocharacter import SsoCharacter

View File

@@ -45,6 +45,7 @@ from gui.utils.clipboard import toClipboard, fromClipboard
import roman
import re
import webbrowser
pyfalog = Logger(__name__)
@@ -723,7 +724,6 @@ class APIView(wx.Panel):
self.charEditor = self.Parent.Parent # first parent is Notebook, second is Character Editor
self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW))
pmainSizer = wx.BoxSizer(wx.VERTICAL)
hintSizer = wx.BoxSizer(wx.HORIZONTAL)
@@ -733,6 +733,13 @@ class APIView(wx.Panel):
"Please select another character or make a new one.", style=wx.ALIGN_CENTER)
self.stDisabledTip.Wrap(-1)
hintSizer.Add(self.stDisabledTip, 0, wx.TOP | wx.BOTTOM, 10)
self.noCharactersTip = wx.StaticText(self, wx.ID_ANY,
"You haven't logging into EVE SSO with any characters yet. Please use the "
"button below to log into EVE.", style=wx.ALIGN_CENTER)
self.noCharactersTip.Wrap(-1)
hintSizer.Add(self.noCharactersTip, 0, wx.TOP | wx.BOTTOM, 10)
self.stDisabledTip.Hide()
hintSizer.AddStretchSpacer()
pmainSizer.Add(hintSizer, 0, wx.EXPAND, 5)
@@ -744,26 +751,27 @@ class APIView(wx.Panel):
self.m_staticCharText = wx.StaticText(self, wx.ID_ANY, "Character:", wx.DefaultPosition, wx.DefaultSize, 0)
self.m_staticCharText.Wrap(-1)
fgSizerInput.Add(self.m_staticCharText, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
fgSizerInput.Add(self.m_staticCharText, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 10)
self.charChoice = wx.Choice(self, wx.ID_ANY, style=0)
fgSizerInput.Add(self.charChoice, 1, wx.ALL | wx.EXPAND, 5)
fgSizerInput.Add(self.charChoice, 1, wx.ALL | wx.EXPAND, 10)
pmainSizer.Add(fgSizerInput, 0, wx.EXPAND, 5)
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
pmainSizer.Add(btnSizer, 0, wx.EXPAND, 5)
self.addButton = wx.Button(self, wx.ID_ANY, "Log In with EVE SSO", wx.DefaultPosition, wx.DefaultSize, 0)
self.addButton.Bind(wx.EVT_BUTTON, self.addCharacter)
pmainSizer.Add(self.addButton, 0, wx.ALL | wx.ALIGN_CENTER, 5)
self.stStatus = wx.StaticText(self, wx.ID_ANY, wx.EmptyString)
pmainSizer.Add(self.stStatus, 0, wx.ALL, 5)
self.charEditor.mainFrame.Bind(GE.EVT_SSO_LOGOUT, self.ssoListChanged)
self.charEditor.mainFrame.Bind(GE.EVT_SSO_LOGIN, self.ssoListChanged)
self.charEditor.entityEditor.Bind(wx.EVT_CHOICE, self.charChanged)
self.charChoice.Bind(wx.EVT_CHOICE, self.ssoCharChanged)
self.SetSizer(pmainSizer)
self.Layout()
self.charChanged(None)
self.ssoListChanged(None)
def ssoCharChanged(self, event):
sChar = Character.getInstance()
@@ -771,10 +779,30 @@ class APIView(wx.Panel):
sChar.setSsoCharacter(activeChar.ID, self.getActiveCharacter())
event.Skip()
def addCharacter(self, event):
sCrest = Esi.getInstance()
uri = sCrest.startServer()
webbrowser.open(uri)
def getActiveCharacter(self):
selection = self.charChoice.GetCurrentSelection()
return self.charChoice.GetClientData(selection) if selection is not -1 else None
def ssoListChanged(self, event):
sEsi = Esi.getInstance()
ssoChars = sEsi.getSsoCharacters()
if len(ssoChars) == 0:
self.charChoice.Hide()
self.m_staticCharText.Hide()
self.noCharactersTip.Show()
else:
self.noCharactersTip.Hide()
self.m_staticCharText.Show()
self.charChoice.Show()
self.charChanged(event)
def charChanged(self, event):
sChar = Character.getInstance()
sEsi = Esi.getInstance()

View File

@@ -115,10 +115,7 @@ class CrestFittings(wx.Frame):
self.statusbar.SetStatusText("Cached for %s" % sTime, 0)
def ssoLogout(self, event):
if event.type == CrestModes.IMPLICIT:
self.Close()
else:
self.updateCharList()
self.updateCharList()
event.Skip() # continue event
def OnClose(self, event):
@@ -307,7 +304,7 @@ class ExportToEve(wx.Frame):
class CrestMgmt(wx.Dialog):
def __init__(self, parent):
wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title="CREST Character Management", pos=wx.DefaultPosition,
wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title="SSO Character Management", pos=wx.DefaultPosition,
size=wx.Size(550, 250), style=wx.DEFAULT_DIALOG_STYLE)
self.mainFrame = parent
mainSizer = wx.BoxSizer(wx.HORIZONTAL)
@@ -316,8 +313,6 @@ class CrestMgmt(wx.Dialog):
self.lcCharacters.InsertColumn(0, heading='Character')
self.lcCharacters.InsertColumn(1, heading='Character ID')
self.lcCharacters.InsertColumn(2, heading='Access Token')
self.lcCharacters.InsertColumn(3, heading='Refresh Token')
self.popCharList()
@@ -355,7 +350,7 @@ class CrestMgmt(wx.Dialog):
for index, char in enumerate(chars):
self.lcCharacters.InsertItem(index, char.characterName)
self.lcCharacters.SetStringItem(index, 1, char.refreshToken)
self.lcCharacters.SetItem(index, 1, str(char.characterID))
self.lcCharacters.SetItemData(index, char.ID)
self.lcCharacters.SetColumnWidth(0, wx.LIST_AUTOSIZE)

View File

@@ -138,7 +138,7 @@ class MainMenuBar(wx.MenuBar):
# CREST Menu
crestMenu = wx.Menu()
self.Append(crestMenu, "&CREST")
self.Append(crestMenu, "EVE &SSO")
crestMenu.Append(self.ssoLoginId, "Manage Characters")
crestMenu.Append(self.eveFittingsId, "Browse EVE Fittings")

View File

@@ -104,6 +104,12 @@ class Esi(object):
def delSsoCharacter(self, id):
char = eos.db.getSsoCharacter(id, config.getClientSecret())
# There is an issue in which the SSO character is not removed from any linked characters - a reference to the
# sso character remains even though the SSO character is deleted which should have deleted the link. This is a
# work around until we can figure out why. Manually delete SSOCharacter from all of it's characters
for x in char.characters:
x._Character__ssoCharacters.remove(char)
eos.db.remove(char)
wx.PostEvent(self.mainFrame, GE.SsoLogout(charID=id))