Add an option not to export charges to ESI
This commit is contained in:
@@ -177,7 +177,7 @@ class CopySelectDialog(wx.Dialog):
|
||||
|
||||
def exportEsi(self, options, callback):
|
||||
fit = getFit(self.mainFrame.getActiveFit())
|
||||
Port.exportESI(fit, callback)
|
||||
Port.exportESI(fit, True, callback)
|
||||
|
||||
def exportXml(self, options, callback):
|
||||
fit = getFit(self.mainFrame.getActiveFit())
|
||||
|
||||
@@ -18,6 +18,7 @@ from service.esiAccess import APIException
|
||||
from service.fit import Fit
|
||||
from service.port import Port
|
||||
from service.port.esi import ESIExportException
|
||||
from service.settings import EsiSettings
|
||||
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
@@ -207,7 +208,7 @@ class ExportToEve(AuxiliaryFrame):
|
||||
def __init__(self, parent):
|
||||
super().__init__(
|
||||
parent, id=wx.ID_ANY, title="Export fit to EVE", pos=wx.DefaultPosition,
|
||||
size=wx.Size(400, 120) if "wxGTK" in wx.PlatformInfo else wx.Size(350, 100), resizeable=True)
|
||||
size=wx.Size(400, 140) if "wxGTK" in wx.PlatformInfo else wx.Size(350, 115), resizeable=True)
|
||||
|
||||
self.mainFrame = parent
|
||||
|
||||
@@ -224,6 +225,11 @@ class ExportToEve(AuxiliaryFrame):
|
||||
|
||||
mainSizer.Add(hSizer, 0, wx.EXPAND, 5)
|
||||
|
||||
self.exportChargesCb = wx.CheckBox(self, wx.ID_ANY, 'Export Charges', wx.DefaultPosition, wx.DefaultSize, 0)
|
||||
self.exportChargesCb.SetValue(EsiSettings.getInstance().get('exportCharges'))
|
||||
self.exportChargesCb.Bind(wx.EVT_CHECKBOX, self.OnChargeExportChange)
|
||||
mainSizer.Add(self.exportChargesCb, 0, 0, 5)
|
||||
|
||||
self.exportBtn.Bind(wx.EVT_BUTTON, self.exportFitting)
|
||||
|
||||
self.statusbar = wx.StatusBar(self)
|
||||
@@ -239,6 +245,10 @@ class ExportToEve(AuxiliaryFrame):
|
||||
|
||||
self.Center(wx.BOTH)
|
||||
|
||||
def OnChargeExportChange(self, event):
|
||||
EsiSettings.getInstance().set('exportCharges', self.exportChargesCb.GetValue())
|
||||
event.Skip()
|
||||
|
||||
def updateCharList(self):
|
||||
sEsi = Esi.getInstance()
|
||||
chars = sEsi.getSsoCharacters()
|
||||
@@ -274,8 +284,9 @@ class ExportToEve(AuxiliaryFrame):
|
||||
sEsi = Esi.getInstance()
|
||||
|
||||
sFit = Fit.getInstance()
|
||||
exportCharges = self.exportChargesCb.GetValue()
|
||||
try:
|
||||
data = sPort.exportESI(sFit.getFit(fitID))
|
||||
data = sPort.exportESI(sFit.getFit(fitID), exportCharges)
|
||||
except ESIExportException as e:
|
||||
msg = str(e)
|
||||
if not msg:
|
||||
|
||||
@@ -56,7 +56,7 @@ INV_FLAG_DRONEBAY = 87
|
||||
INV_FLAG_FIGHTER = 158
|
||||
|
||||
|
||||
def exportESI(ofit, callback):
|
||||
def exportESI(ofit, exportCharges, callback):
|
||||
# A few notes:
|
||||
# max fit name length is 50 characters
|
||||
# Most keys are created simply because they are required, but bogus data is okay
|
||||
@@ -99,7 +99,7 @@ def exportESI(ofit, callback):
|
||||
item['type_id'] = module.item.ID
|
||||
fit['items'].append(item)
|
||||
|
||||
if module.charge:
|
||||
if module.charge and exportCharges:
|
||||
if module.chargeID not in charges:
|
||||
charges[module.chargeID] = 0
|
||||
# `or 1` because some charges (ie scripts) are without qty
|
||||
|
||||
@@ -314,8 +314,8 @@ class Port:
|
||||
return importESI(string)
|
||||
|
||||
@staticmethod
|
||||
def exportESI(fit, callback=None):
|
||||
return exportESI(fit, callback=callback)
|
||||
def exportESI(fit, exportCharges, callback=None):
|
||||
return exportESI(fit, exportCharges, callback=callback)
|
||||
|
||||
# XML-related methods
|
||||
@staticmethod
|
||||
|
||||
@@ -370,7 +370,8 @@ class EsiSettings:
|
||||
"loginMode": 0,
|
||||
"clientID": "",
|
||||
"clientSecret": "",
|
||||
"timeout": 60}
|
||||
"timeout": 60,
|
||||
"exportCharges": True}
|
||||
|
||||
self.settings = SettingsProvider.getInstance().getSettings(
|
||||
"pyfaServiceEsiSettings",
|
||||
|
||||
Reference in New Issue
Block a user