Parcourir la source

Use __str__ to display unit and capacity

Better suited thn name to represent the resources in many places.
Jocelyn Delande il y a 9 ans
Parent
commit
5b2986dfe1
3 fichiers modifiés avec 2 ajouts et 3 suppressions
  1. 1 1
      costs/admin.py
  2. 0 1
      costs/models.py
  3. 1 1
      costs/templates/costs/service_detail.html

+ 1 - 1
costs/admin.py

@@ -37,7 +37,7 @@ class DirectDocumentFilter(admin.SimpleListFilter):
 
 
 @admin.register(Cost)
 @admin.register(Cost)
 class CostAdmin(admin.ModelAdmin):
 class CostAdmin(admin.ModelAdmin):
-    list_display = ('name', 'price', 'document')
+    list_display = ('__str__', 'price', 'document')
     list_filter = [DirectDocumentFilter]
     list_filter = [DirectDocumentFilter]
 
 
 
 

+ 0 - 1
costs/models.py

@@ -25,7 +25,6 @@ class Document(models.Model):
         return reverse('detail-document', kwargs={'pk': self.pk})
         return reverse('detail-document', kwargs={'pk': self.pk})
 
 
 
 
-
 class AbstractItem(models.Model):
 class AbstractItem(models.Model):
     name = models.CharField(max_length=130)
     name = models.CharField(max_length=130)
     description = models.TextField(blank=True)
     description = models.TextField(blank=True)

+ 1 - 1
costs/templates/costs/service_detail.html

@@ -15,7 +15,7 @@
   {% for usage in costs_uses %}
   {% for usage in costs_uses %}
   <tr>
   <tr>
     <td>récurent</td>
     <td>récurent</td>
-    <td>{{ usage.resource.name }}</td>
+    <td>{{ usage.resource }}</td>
     <td>{{ usage.unit_cost_share|price }}</td>
     <td>{{ usage.unit_cost_share|price }}</td>
   </tr>
   </tr>
   {% endfor %}
   {% endfor %}