Beispiel #1
0
 def __unicode__(self, specify_user=False):
     fmt = "%(quantity)g%(mult)s%(unit)s %(prod_name)s à %(price).2f€"
     unit = self.product.unit
     result = fmt % {
         'mult': '×'if len(unit)>0 and unit[0].isdigit() else ' ',
         'quantity': self.quantity,
         'unit': plural(self.product.unit, self.quantity),
         'prod_name': articulate(self.product.name, self.quantity),
         'price': self.quantity * self.product.price,
         'user_name': self.user.__unicode__()
     }
     if specify_user:
         result += " pour %s %s" % (self.user.first_name, self.user.last_name)
     return result
Beispiel #2
0
 def __unicode__(self, specify_user=False):
     if self.ordered == self.granted:
         fmt = u"%(granted)g%(mult)s%(unit)s %(prod_name)s à %(price).2f€"
     else:
         fmt = u"%(granted)g%(mult)s%(unit)s (au lieu de %(ordered)g) %(prod_name)s à %(price).2f€"
     unit = self.product.unit
     result = fmt % {
         'mult': u'×'if len(unit)>0 and unit[0].isdigit() else u' ',
         'granted': self.granted,
         'ordered': self.ordered,
         'unit': plural(self.product.unit, self.granted),
         'prod_name': articulate(self.product.name, self.granted),
         'price': self.granted * self.product.price,
         'user_name': self.user.__unicode__()
     }
     if specify_user:
         result += " pour %s %s" % (self.user.first_name, self.user.last_name)
     return result
Beispiel #3
0
def plural(singular):
    return francais.plural(singular, 2)