Parcourir la source

Add various french labels for admin.

Jocelyn Delande il y a 9 ans
Parent
commit
3ddd18dfbd
2 fichiers modifiés avec 39 ajouts et 10 suppressions
  1. 2 0
      costs/admin.py
  2. 37 10
      costs/models.py

+ 2 - 0
costs/admin.py

@@ -29,6 +29,8 @@ class ServiceInline(admin.TabularInline):
         'monthly_unit_cost', 'new_subscriber_cost')
     show_change_link = True
     extra = 0
+    verbose_name = 'Service proposé'
+    verbose_name_plural = 'Services proposés'
 
     def monthly_unit_cost(self, obj):
         return '{:.2f}€'.format(obj.get_prices()['unit_recurring_price'])

+ 37 - 10
costs/models.py

@@ -14,8 +14,10 @@ class Document(models.Model):
     TYPE_FACT = 'fact'
     TYPE_PLAN = 'plan'
 
-    name = models.CharField(max_length=130)
-    comment = models.TextField(blank=True, help_text="Texte brut ou markdown")
+    name = models.CharField('Nom', max_length=130)
+    comment = models.TextField(
+        'commentaire',
+        blank=True, help_text="Texte brut ou markdown")
     comment_html = models.TextField(blank=True, editable=False)
     date = models.DateField(default=datetime.datetime.now)
     type = models.CharField(max_length=10, choices=(
@@ -78,8 +80,8 @@ class Document(models.Model):
 
 
 class AbstractItem(models.Model):
-    name = models.CharField(max_length=130)
-    description = models.TextField(blank=True)
+    name = models.CharField('Nom', max_length=130)
+    description = models.TextField('description', blank=True)
     description_html = models.TextField(blank=True)
     document = models.ForeignKey(Document)
 
@@ -103,6 +105,7 @@ class AbstractResource(AbstractItem):
     UNIT_SERVICE = 'services'
 
     capacity_unit = models.CharField(
+        'unité',
         max_length=10,
         choices=(
             (UNIT_AMP, 'A'),
@@ -113,8 +116,12 @@ class AbstractResource(AbstractItem):
             (UNIT_SERVICE, 'abonnement'),
         ),
         blank=True,
+        help_text="unité de capacité (si applicable)",
     )
-    total_capacity = models.FloatField(default=1)
+    total_capacity = models.FloatField(
+        'Capacité totale',
+        default=1,
+        help_text="Laisser à 1 si non divisible")
 
     class Meta:
         abstract = True
@@ -156,7 +163,7 @@ class AbstractResource(AbstractItem):
 class Cost(AbstractResource):
     """ A monthtly cost we have to pay
     """
-    price = models.FloatField(help_text="Coût mensuel")
+    price = models.FloatField("Coût mensuel")
 
     def get_use_class(self):
         return CostUse
@@ -168,8 +175,9 @@ class Cost(AbstractResource):
 class Good(AbstractResource):
     """ A good, which replacement is provisioned
     """
-    price = models.FloatField()
+    price = models.FloatField("Prix d'achat")
     provisioning_duration = models.DurationField(
+        "Durée d'amortissement",
         choices=settings.PROVISIONING_DURATIONS)
 
     def get_use_class(self):
@@ -189,6 +197,9 @@ class AbstractUse(models.Model):
     class Meta:
         abstract = True
 
+    def __str__(self):
+        return str(self.resource)
+
     def clean(self):
         if hasattr(self, 'resource'):
             usage = self.resource.used(except_by=self.service) + self.share
@@ -238,6 +249,10 @@ class AbstractUse(models.Model):
 class CostUse(AbstractUse):
     resource = models.ForeignKey(Cost)
 
+    class Meta:
+        verbose_name = 'Coût associé'
+        verbose_name_plural = 'Coûts associés'
+
     def cost_share(self):
         return (
             self.real_share() / self.resource.total_capacity
@@ -255,6 +270,10 @@ class CostUse(AbstractUse):
 class GoodUse(AbstractUse):
     resource = models.ForeignKey(Good)
 
+    class Meta:
+        verbose_name = 'Bien utilisé'
+        verbose_name_plural = 'Biens utilisés'
+
     def monthly_provision_share(self):
         return (
             self.real_share()
@@ -278,13 +297,17 @@ class Service(AbstractResource):
     costs = models.ManyToManyField(
         Cost,
         through=CostUse,
-        related_name='using_services')
+        related_name='using_services',
+        verbose_name='coûts associés')
     goods = models.ManyToManyField(
         Good,
         through=GoodUse,
-        related_name='using_services')
+        related_name='using_services',
+        verbose_name='biens utilisés')
 
-    subscriptions_count = models.PositiveIntegerField(default=0)
+    subscriptions_count = models.PositiveIntegerField(
+        "Nombre d'abonnements",
+        default=0)
     reusable = models.BooleanField(
         default=False,
         help_text="Peut-être utilisé par d'autres services")
@@ -346,6 +369,10 @@ def validate_reusable_service(v):
 
 
 class ServiceUse(AbstractUse):
+    class Meta:
+        verbose_name = 'service utilisé'
+        verbose_name_plural = 'services utilisés'
+
     resource = models.ForeignKey(
         Service, related_name='dependent_services',
         limit_choices_to={'reusable': True},