public
Description: Django-beancounter is a simple app I built to track my income and expenses.
Homepage: http://github.com/lincolnloop/django-beancounter
Clone URL: git://github.com/lincolnloop/django-beancounter.git
tweak admin display and ordering
lincolnloop (author)
Mon Jan 05 17:41:43 -0800 2009
commit  7d59c1280550ae4d5177498daf5ef7dea2985f19
tree    297b5c9064f5898e187c46646cf8ad05d0af30ec
parent  13e5e7513eaea5b34ef9a14ffb97a40efd443c38
...
29
30
31
 
 
 
32
33
34
 
35
36
37
...
29
30
31
32
33
34
35
36
 
37
38
39
40
0
@@ -29,9 +29,12 @@ class EmployeeAdmin(admin.ModelAdmin):
0
 class ProjectInvoiceInline(admin.TabularInline):
0
     model = ProjectInvoice
0
 
0
+class ProjectTimeInline(admin.TabularInline):
0
+    model = ProjectTime
0
+
0
 class ProjectAdmin(admin.ModelAdmin):
0
     list_display = ('name', 'total_invoiced', 'total_cost', 'profit')
0
-    inlines = [ProjectInvoiceInline,]
0
+    inlines = [ProjectInvoiceInline, ProjectTimeInline]
0
     
0
 class ProjectTimeAdmin(admin.ModelAdmin):
0
     list_display = ('employee', 'start_date', 'project', 'hours', 'cost', 'cost_converted')
...
115
116
117
 
 
 
118
119
120
...
129
130
131
132
 
 
 
133
134
135
...
163
164
165
 
 
 
166
167
168
...
115
116
117
118
119
120
121
122
123
...
132
133
134
 
135
136
137
138
139
140
...
168
169
170
171
172
173
174
175
176
0
@@ -115,6 +115,9 @@ class Project(models.Model):
0
     name = models.CharField(max_length=100)
0
     active = models.BooleanField(default=True)
0
 
0
+    class Meta:
0
+        ordering = ['-active', 'name']
0
+
0
     def __unicode__(self):
0
         return self.name
0
         
0
@@ -129,7 +132,9 @@ class Project(models.Model):
0
         #TODO aggregate support
0
         total = decimal.Decimal("0.00")
0
         for time in self.projecttime_set.all():
0
-            total += time.cost_converted
0
+           #this test should be in the filter above 
0
+           if time.cost_converted:
0
+                total += time.cost_converted
0
         return total
0
     
0
     def profit(self):
0
@@ -163,6 +168,9 @@ class ProjectTime(models.Model):
0
     cost = models.DecimalField(max_digits=9, decimal_places=2, blank=True, null=True, help_text="Leave blank to automatically calculate")
0
     cost_converted = models.DecimalField(max_digits=9, decimal_places=2, blank=True, null=True, help_text="Cost converted to local currency")
0
 
0
+    class Meta:
0
+        ordering = ['-start_date', 'project']
0
+
0
     def __unicode__(self):
0
         return "%s on %s (%s-%s)" % (self.employee, self.project, self.start_date, self.end_date)
0
     

Comments