Skip to content
Browse files

Nicer admin for models Member and Invoice

  • Loading branch information...
1 parent 953418c commit c37f28a8cc28d0e5a4853291fe20cf88a275077f @anttihirvonen committed Sep 22, 2012
View
5 dotmembership/apps/billing/admin.py
@@ -5,6 +5,9 @@
class InvoiceAdmin(reversion.VersionAdmin):
- readonly_fields = ("reference_number",)
+ readonly_fields = ("reference_number", "for_year")
+ list_display = ("member", "status", "reference_number")
+ list_filter = ("status",)
+ actions = None
admin.site.register(Invoice, InvoiceAdmin)
View
9 dotmembership/apps/members/admin.py
@@ -5,6 +5,13 @@
class MemberAdmin(reversion.VersionAdmin):
- pass
+ list_display = ("full_name", "email", "last_payment_year", "last_payment_status")
+
+ def last_payment_year(self, member):
+ return member.invoices.latest("for_year").for_year
+
+ def last_payment_status(self, member):
+ return member.invoices.latest("for_year").status
+
admin.site.register(Member, MemberAdmin)
View
7 dotmembership/apps/members/models.py
@@ -61,6 +61,13 @@ def edit_link(self):
"""
return reverse("members-edit_member", args=[self.timestamped_id])
+ @property
+ def full_name(self):
+ return u"{0} {1}".format(self.first_name, self.last_name)
+
+ def last_invoice(self):
+ return self.invoices.latest()
+
def send_data_and_edit_link(self):
subject = _(u"Jäsentietosi sekä muokkauslinkki")
fields = self.PUBLIC_FIELDS

0 comments on commit c37f28a

Please sign in to comment.
Something went wrong with that request. Please try again.