Exemple #1
0
 def __setAccountsAttrs(self, isPremiumAccount, premiumExpiryTime = 0):
     if isPremiumAccount:
         if not premiumExpiryTime > 0:
             raise AssertionError
             deltaInSeconds = float(time_utils.getTimeDeltaFromNow(time_utils.makeLocalServerTime(premiumExpiryTime)))
             if deltaInSeconds > time_utils.ONE_DAY:
                 timeLeft = math.ceil(deltaInSeconds / time_utils.ONE_DAY)
                 timeMetric = i18n.makeString('#menu:header/account/premium/days')
             else:
                 timeLeft = math.ceil(deltaInSeconds / time_utils.ONE_HOUR)
                 timeMetric = i18n.makeString('#menu:header/account/premium/hours')
             premiumBtnLbl = makeHtmlString('html_templates:lobby/header', 'premium-account-label', {'timeMetric': timeMetric,
              'timeLeft': timeLeft})
             canUpdatePremium = deltaInSeconds < time_utils.ONE_YEAR
             buyPremiumLabel = ''
             if canUpdatePremium:
                 buyPremiumLabel = i18n.makeString('#menu:headerButtons/doLabel/premium')
         else:
             canUpdatePremium = True
             premiumBtnLbl = makeHtmlString('html_templates:lobby/header', 'base-account-label')
             buyPremiumLabel = i18n.makeString('#menu:common/premiumBuy')
         hasPersonalDiscount = len(g_itemsCache.items.shop.personalPremiumPacketsDiscounts) > 0
         tooltip = canUpdatePremium or formatters.getLimitExceededPremiumTooltip()
     elif isPremiumAccount:
         tooltip = TOOLTIPS.HEADER_PREMIUM_EXTEND
     else:
         tooltip = TOOLTIPS.HEADER_PREMIUM_BUY
     self.as_setPremiumParamsS(premiumBtnLbl, buyPremiumLabel, hasPersonalDiscount, tooltip, TOOLTIP_TYPES.COMPLEX)
 def _getPremiumTooltipText(self, isPremiumAccount, canUpdatePremium):
     if not canUpdatePremium:
         return formatters.getLimitExceededPremiumTooltip()
     elif isPremiumAccount:
         return TOOLTIPS.HEADER_PREMIUM_EXTEND
     else:
         return TOOLTIPS.HEADER_PREMIUM_BUY
Exemple #3
0
 def __updateData(self):
     canUpdatePremium = self.__canUpdatePremium()
     premiumPackets, self._actualPremiumCost, selectedPacketID = self.__getPremiumPackets(
         canUpdatePremium)
     cantUpgradeTooltip = '' if canUpdatePremium else formatters.getLimitExceededPremiumTooltip(
     )
     self.__setRates(self.__getHeaderText(canUpdatePremium),
                     cantUpgradeTooltip, premiumPackets, selectedPacketID)
     self.as_setButtonsS(self.__getBtnData(cantUpgradeTooltip),
                         TEXT_ALIGN.RIGHT, BTN_WIDTH)
 def __setAccountsAttrs(self, isPremiumAccount, premiumExpiryTime=0):
     if isPremiumAccount:
         if not premiumExpiryTime > 0:
             raise AssertionError
             deltaInSeconds = float(
                 time_utils.getTimeDeltaFromNow(
                     time_utils.makeLocalServerTime(premiumExpiryTime)))
             if deltaInSeconds > time_utils.ONE_DAY:
                 timeLeft = math.ceil(deltaInSeconds / time_utils.ONE_DAY)
                 timeMetric = i18n.makeString(
                     '#menu:header/account/premium/days')
             else:
                 timeLeft = math.ceil(deltaInSeconds / time_utils.ONE_HOUR)
                 timeMetric = i18n.makeString(
                     '#menu:header/account/premium/hours')
             premiumBtnLbl = makeHtmlString('html_templates:lobby/header',
                                            'premium-account-label', {
                                                'timeMetric': timeMetric,
                                                'timeLeft': timeLeft
                                            })
             canUpdatePremium = deltaInSeconds < time_utils.ONE_YEAR
             buyPremiumLabel = ''
             if canUpdatePremium:
                 buyPremiumLabel = i18n.makeString(
                     '#menu:headerButtons/doLabel/premium')
         else:
             canUpdatePremium = True
             premiumBtnLbl = makeHtmlString('html_templates:lobby/header',
                                            'base-account-label')
             buyPremiumLabel = i18n.makeString('#menu:common/premiumBuy')
         hasPersonalDiscount = len(
             g_itemsCache.items.shop.personalPremiumPacketsDiscounts) > 0
         tooltip = canUpdatePremium or formatters.getLimitExceededPremiumTooltip(
         )
     elif isPremiumAccount:
         tooltip = TOOLTIPS.HEADER_PREMIUM_EXTEND
     else:
         tooltip = TOOLTIPS.HEADER_PREMIUM_BUY
     self.as_setPremiumParamsS(premiumBtnLbl, buyPremiumLabel,
                               hasPersonalDiscount, tooltip,
                               TOOLTIP_TYPES.COMPLEX)
 def __updateData(self):
     canUpdatePremium = self.__canUpdatePremium()
     premiumPackets, self._actualPremiumCost, selectedPacketID = self.__getPremiumPackets(canUpdatePremium)
     cantUpgradeTooltip = '' if canUpdatePremium else formatters.getLimitExceededPremiumTooltip()
     self.__setRates(self.__getHeaderText(canUpdatePremium), cantUpgradeTooltip, premiumPackets, selectedPacketID)
     self.as_setButtonsS(self.__getBtnData(cantUpgradeTooltip), TEXT_ALIGN.RIGHT, BTN_WIDTH)