~mvo/software-center/fix-chroot-lp1040311

« back to all changes in this revision

Viewing changes to softwarecenter/db/application.py

  • Committer: Gary Lasker
  • Date: 2012-08-18 05:35:12 UTC
  • mfrom: (3105.1.3 display-price-property)
  • Revision ID: gary.lasker@canonical.com-20120818053512-47yl3g4d32ozlx3k
* lp:~mvo/software-center/display-price-property:
  - changes to displayed price and currency properties, for
    use by Unity

Show diffs side-by-side

added added

removed removed

Lines of Context:
531
531
                          u"current software sources.")) % utf8(self.pkgname)
532
532
                    return PkgStates.NOT_FOUND
533
533
            else:
534
 
                if self.price:
 
534
                if self.raw_price:
535
535
                    return PkgStates.NEEDS_PURCHASE
536
536
                if (self.purchase_date and
537
537
                    self._doc.get_value(XapianValues.ARCHIVE_DEB_LINE)):
568
568
 
569
569
    @property
570
570
    def currency(self):
571
 
        if self.price:
 
571
        """ Get the currency for the price """
 
572
        if self.raw_price:
572
573
            # this is hardcoded to US dollar for now, but if the server
573
574
            # ever changes that we are prepared
574
575
            return "US$"
575
576
 
576
577
    @property
 
578
    def raw_price(self):
 
579
        """ The raw price, useful for e.g. sort-by """
 
580
        if self._doc:
 
581
            return self._doc.get_value(XapianValues.PRICE)
 
582
 
 
583
    @property
577
584
    def price(self):
578
 
        if self._doc:
579
 
            return self._doc.get_value(XapianValues.PRICE)
 
585
        """ The price and the currency ready to display to the user """
 
586
        raw_price = self.raw_price
 
587
        currency = self.currency
 
588
        if raw_price and currency:
 
589
            # FIXME:  need to determine the currency dynamically once we can
 
590
            #         get that info from the software-center-agent/payments
 
591
            #         service.
 
592
            # NOTE:  the currency string for this label is purposely not
 
593
            #        translatable when hardcoded, since it (currently)
 
594
            #        won't vary based on locale and as such we don't want
 
595
            #        it translated
 
596
            # FIXME: if we support different currencies eventually we need
 
597
            #        to format them here differently too, e.g. 
 
598
            #        "US$ 1" but "1EUR"
 
599
            return "%s %s" % (currency, raw_price)
580
600
 
581
601
    @property
582
602
    def supported_distros(self):