def __getDiscountBannerStr(self, root, rootNode): htmlStr = '' nodeState = rootNode.getState() if NODE_STATE.canTradeIn( nodeState ) and self.__tradeIn.tradeOffSelectedApplicableForLevel(root.level): return htmlStr if NODE_STATE.isRestoreAvailable(nodeState): restoreDueDate = getDueDateOrTimeStr( rootNode.getRestoreFinishTime()) if restoreDueDate: return _BANNER_GETTERS[States.RESTORE](restoreDueDate) if not root.isUnlocked and not root.isCollectible: unlockDiscount = self._itemsCache.items.blueprints.getBlueprintDiscount( root.intCD, root.level) if unlockDiscount > 0: return _BANNER_GETTERS[States.UNLOCKED](unlockDiscount) if root.isRented: discount = rootNode.getActionDiscount() if discount != 0: return _BANNER_GETTERS[States.RENT](discount) if not NODE_STATE.inInventory(nodeState) and NODE_STATE.isActionVehicle( nodeState) or NODE_STATE.isCollectibleActionVehicle(nodeState): discount, isPersonalDiscount = rootNode.getActionDetails() if discount != 0: actionDueDate = '' if isPersonalDiscount else getDueDateOrTimeStr( rootNode.getActionFinishTime(), isShortDateFormat=True) return _BANNER_GETTERS[States.ACTION](discount, actionDueDate) return htmlStr
def _getRootData(self): root = self.vehicle rootNode = self._data.getRootNode() nodeState = rootNode.getState() bpfProps = rootNode.getBpfProps() isNext2Unlock = NODE_STATE.isNext2Unlock(nodeState) isPremium = NODE_STATE.isCollectibleActionVehicle( nodeState) or NODE_STATE.isPremium(nodeState) comparisonState, comparisonTooltip = resolveStateTooltip( self._cmpBasket, root, enabledTooltip='', fullTooltip=TOOLTIPS.RESEARCHPAGE_VEHICLE_BUTTON_COMPARE_DISABLED) tankTier = int2roman(root.level) tankHasNationGroup = (root.isInInventory or root.isRented) and root.hasNationGroup isNationChangeAvailable = root.isNationChangeAvailable isShownNationChangeTooltip = tankHasNationGroup and not isNationChangeAvailable result = { 'vehicleTitle': { 'intCD': self._data.getRootCD(), 'tankTierStr': text_styles.grandTitle(tankTier), 'tankNameStr': text_styles.grandTitle(root.userName), 'tankTierStrSmall': text_styles.promoTitle(tankTier), 'tankNameStrSmall': text_styles.promoTitle(root.userName), 'typeIconPath': getTypeBigIconPath(root.type, root.isElite), 'isElite': root.isElite, 'statusStr': self.__getRootStatusStr(root), 'roleText': getRoleTextWithIcon(root.role, root.roleLabel) }, 'vehicleButton': { 'shopIconPath': RES_SHOP.getVehicleIcon(STORE_CONSTANTS.ICON_SIZE_MEDIUM, root.name.split(':')[1]), 'compareBtnVisible': not self.__bootcamp.isInBootcamp(), 'compareBtnEnabled': comparisonState, 'compareBtnLabel': backport.text( R.strings.menu.research.labels.button.addToCompare()), 'compareBtnTooltip': comparisonTooltip, 'previewBtnEnabled': root.isPreviewAllowed(), 'previewBtnLabel': backport.text( R.strings.menu.research.labels.button.vehiclePreview()), 'isPremium': isPremium, 'vehicleId': self._data.getRootCD(), 'vehicleState': nodeState, 'isInInventory': NODE_STATE.inInventory(nodeState), 'previewAlias': VIEW_ALIAS.LOBBY_RESEARCH, 'cmHandlerType': CONTEXT_MENU_HANDLER_TYPE.RESEARCH_VEHICLE }, 'isInteractive': self.__getIsInteractive(root, rootNode), 'buttonLabel': self.__getMainButtonLabel(root, rootNode), 'blueprintLabel': self.__getResearchPageBlueprintLabel(rootNode), 'blueprintProgress': rootNode.getBlueprintProgress(), 'blueprintCanConvert': bpfProps.canConvert if bpfProps is not None else False, 'bpbGlowEnabled': isNext2Unlock, 'itemPrices': rootNode.getItemPrices(), 'discountStr': self.__getDiscountBannerStr(root, rootNode), 'rentBtnLabel': self.__getRentButtonLabel(rootNode), 'changeNationBtnVisibility': tankHasNationGroup, 'isTankNationChangeAvailable': isNationChangeAvailable, 'nationChangeIsNew': not AccountSettings.getSettings(NATION_CHANGE_VIEWED), 'nationChangeTooltip': self.__getNationChangeTooltip(root) if isShownNationChangeTooltip else '' } return result