Пример #1
0
    def OnCorporationVoteCaseOptionChanged(self, corporationID, voteCaseID,
                                           optionID, change):
        try:
            if corporationID in self.__voteCaseOptionsByCorporation:
                bAdd, bRemove = self.GetAddRemoveFromChange(change)
                if bAdd:
                    header = self.__voteCaseOptionsRD
                    if header is None:
                        self.GetVoteCaseOptions(voteCaseID, corporationID)
                        header = self.__voteCaseOptionsRD
                    if voteCaseID not in self.__voteCaseOptionsByCorporation[
                            corporationID]:
                        self.__voteCaseOptionsByCorporation[corporationID][
                            voteCaseID] = dbutil.CIndexedRowset(
                                header, 'optionID')
                    line = blue.DBRow(header)
                    for columnName in header.Keys():
                        setattr(line, columnName, change[columnName][1])

                    self.__voteCaseOptionsByCorporation[corporationID][
                        voteCaseID][optionID] = line
                elif bRemove:
                    if self.__voteCaseOptionsByCorporation[
                            corporationID].has_key(voteCaseID):
                        if self.__voteCaseOptionsByCorporation[corporationID][
                                voteCaseID].has_key(optionID):
                            del self.__voteCaseOptionsByCorporation[
                                corporationID][voteCaseID][optionID]
                elif self.__voteCaseOptionsByCorporation[
                        corporationID].has_key(voteCaseID):
                    row = self.__voteCaseOptionsByCorporation[corporationID][
                        voteCaseID][optionID]
                    for columnName, oldAndNewValue in change.iteritems():
                        oldValue, newValue = oldAndNewValue
                        setattr(row, columnName, newValue)

        finally:
            uthread.new(
                self.OnCorporationVoteCaseOptionChanged_thread, corporationID,
                voteCaseID, optionID,
                change).context = 'svc.corp.OnCorporationVoteCaseOptionChanged'
Пример #2
0
    def OnSanctionedActionChanged(self, corpID, voteCaseID, change):
        bAdd, bRemove = self.GetAddRemoveFromChange(change)
        if bAdd:
            if change.has_key('inEffect'):
                inEffect = change['inEffect'][1]
                state = inEffect
                if inEffect == 0:
                    if change.has_key('expires'):
                        if change['expires'][1] > blue.os.GetWallclockTime():
                            state = 2
                if corpID not in self.__sanctionedActionsByCorpID[state]:
                    rowset = self.GetCorpRegistry(
                    ).GetSanctionedActionsByCorporation(corpID, state)
                    self.__sanctionedActionsByCorpID[state][
                        corpID] = rowset.Index('voteCaseID')
                    line = []
                    for columnName in rowset.columns:
                        line.append(change[columnName][1])

                    self.__sanctionedActionsByCorpID[state][corpID][
                        voteCaseID] = blue.DBRow(
                            self.__sanctionedActionsByCorpID[state]
                            [corpID].header, line)
                else:
                    line = []
                    for columnName in self.__sanctionedActionsByCorpID[state][
                            corpID].columns:
                        line.append(change[columnName][1])

                    self.__sanctionedActionsByCorpID[state][corpID][
                        voteCaseID] = blue.DBRow(
                            self.__sanctionedActionsByCorpID[state]
                            [corpID].header, line)
        elif bRemove:
            if self.__sanctionedActionsByCorpID[1].has_key(corpID):
                if self.__sanctionedActionsByCorpID[1][corpID].has_key(
                        voteCaseID):
                    del self.__sanctionedActionsByCorpID[1][corpID][voteCaseID]
            elif self.__sanctionedActionsByCorpID[2].has_key(corpID):
                if self.__sanctionedActionsByCorpID[2][corpID].has_key(
                        voteCaseID):
                    del self.__sanctionedActionsByCorpID[2][corpID][voteCaseID]
            elif self.__sanctionedActionsByCorpID[0].has_key(corpID):
                if self.__sanctionedActionsByCorpID[0][corpID].has_key(
                        voteCaseID):
                    del self.__sanctionedActionsByCorpID[0][corpID][voteCaseID]
        elif change.has_key('inEffect'):
            oldRow = None
            oldEffect, newEffect = change['inEffect']
            if oldEffect == 0:
                if self.__sanctionedActionsByCorpID[2].has_key(corpID):
                    if self.__sanctionedActionsByCorpID[2][corpID].has_key(
                            voteCaseID):
                        oldRow = copy.deepcopy(
                            self.__sanctionedActionsByCorpID[2][corpID]
                            [voteCaseID])
                        del self.__sanctionedActionsByCorpID[2][corpID][
                            voteCaseID]
                elif self.__sanctionedActionsByCorpID[0].has_key(corpID):
                    if self.__sanctionedActionsByCorpID[0][corpID].has_key(
                            voteCaseID):
                        oldRow = copy.deepcopy(
                            self.__sanctionedActionsByCorpID[0][corpID]
                            [voteCaseID])
                        del self.__sanctionedActionsByCorpID[0][corpID][
                            voteCaseID]
            else:
                if self.__sanctionedActionsByCorpID[1].has_key(corpID):
                    if self.__sanctionedActionsByCorpID[1][corpID].has_key(
                            voteCaseID):
                        oldRow = copy.deepcopy(
                            self.__sanctionedActionsByCorpID[1][corpID]
                            [voteCaseID])
                        del self.__sanctionedActionsByCorpID[1][corpID][
                            voteCaseID]
                newEffect = 0
            if oldRow is None:
                oldRow = self.GetCorpRegistry(
                ).GetSanctionedActionsByCorporation(
                    corpID, newEffect).Index('voteCaseID')[voteCaseID]
            if corpID not in self.__sanctionedActionsByCorpID[newEffect]:
                self.__sanctionedActionsByCorpID[newEffect][
                    corpID] = dbutil.CIndexedRowset(oldRow.header,
                                                    'voteCaseID')
            self.__sanctionedActionsByCorpID[newEffect][corpID][
                voteCaseID] = oldRow
            row = self.__sanctionedActionsByCorpID[newEffect][corpID][
                voteCaseID]
            for columnName, oldAndNewValue in change.iteritems():
                oldValue, newValue = oldAndNewValue
                setattr(row, columnName, newValue)

        else:
            row = None
            if self.__sanctionedActionsByCorpID[1].has_key(corpID):
                if self.__sanctionedActionsByCorpID[1][corpID].has_key(
                        voteCaseID):
                    row = self.__sanctionedActionsByCorpID[1][corpID][
                        voteCaseID]
            elif self.__sanctionedActionsByCorpID[2].has_key(corpID):
                if self.__sanctionedActionsByCorpID[2][corpID].has_key(
                        voteCaseID):
                    row = self.__sanctionedActionsByCorpID[2][corpID][
                        voteCaseID]
            elif self.__sanctionedActionsByCorpID[0].has_key(corpID):
                if self.__sanctionedActionsByCorpID[0][corpID].has_key(
                        voteCaseID):
                    row = self.__sanctionedActionsByCorpID[0][corpID][
                        voteCaseID]
            if row:
                for columnName, oldAndNewValue in change.iteritems():
                    oldValue, newValue = oldAndNewValue
                    setattr(row, columnName, newValue)

        uthread.new(self.OnSanctionedActionChanged_thread, corpID, voteCaseID,
                    change).context = 'svc.corp.OnSanctionedActionChanged'
Пример #3
0
def UnlockBlueprint(invItem, invCacheSvc):
    voteCases = sm.GetService('corp').GetVoteCasesByCorporation(
        session.corpid, 2)
    voteCaseIDByItemToUnlockID = {}
    if voteCases and len(voteCases):
        for voteCase in voteCases.itervalues():
            if voteCase.voteType in [
                    const.voteItemUnlock
            ] and voteCase.endDateTime > blue.os.GetWallclockTime() - const.DAY:
                options = sm.GetService('corp').GetVoteCaseOptions(
                    voteCase.voteCaseID, voteCase.corporationID)
                if len(options):
                    for option in options.itervalues():
                        if option.parameter:
                            voteCaseIDByItemToUnlockID[
                                option.parameter] = voteCase.voteCaseID

    if invItem.itemID in voteCaseIDByItemToUnlockID:
        raise UserError(
            'CustomInfo', {
                'info':
                localization.GetByLabel(
                    'UI/Corporations/Common/UnlockCorpVoteAlreadyExists')
            })
    sanctionedActionsInEffect = sm.GetService(
        'corp').GetSanctionedActionsByCorporation(session.corpid, 1)
    sanctionedActionsByLockedItemID = dbutil.CIndexedRowset(
        sanctionedActionsInEffect.header, 'parameter')
    for sanctionedActionInEffect in sanctionedActionsInEffect.itervalues():
        if sanctionedActionInEffect.voteType in [
                const.voteItemLockdown
        ] and sanctionedActionInEffect.parameter and sanctionedActionInEffect.inEffect:
            sanctionedActionsByLockedItemID[
                sanctionedActionInEffect.parameter] = sanctionedActionInEffect

    if invItem.itemID not in sanctionedActionsByLockedItemID:
        raise UserError(
            'CustomInfo', {
                'info':
                localization.GetByLabel(
                    'UI/Corporations/Common/CannotUnlockNoLockdownSanctionedAction'
                )
            })
    dlg = form.VoteWizardDialog.Open()
    stationID = invCacheSvc.GetStationIDOfItem(invItem)
    blueprints = invCacheSvc.GetInventory(
        const.containerGlobal).ListStationBlueprintItems(
            invItem.locationID, stationID, True)
    description = None
    for blueprint in blueprints:
        if blueprint.itemID != invItem.itemID:
            continue
        description = localization.GetByLabel(
            'UI/Corporations/Votes/ProposeLockdownDescription',
            blueprintLocation=stationID,
            efficiencyLevel=blueprint.materialLevel,
            productivityLevel=blueprint.productivityLevel)
        break

    dlg.voteType = const.voteItemUnlock
    dlg.voteTitle = localization.GetByLabel('UI/Corporations/Votes/UnlockItem',
                                            blueprint=invItem.typeID)
    dlg.voteDescription = description or dlg.voteTitle
    dlg.voteDays = 1
    dlg.itemID = invItem.itemID
    dlg.typeID = invItem.typeID
    dlg.flagInput = invItem.flagID
    dlg.locationID = stationID
    dlg.GoToStep(len(dlg.steps))
    dlg.ShowModal()