diff options
-rw-r--r-- | app/ebay/admin.py | 2 | ||||
-rw-r--r-- | app/ebay/models.py | 11 |
2 files changed, 9 insertions, 4 deletions
diff --git a/app/ebay/admin.py b/app/ebay/admin.py index 80d3a84..93bf87f 100644 --- a/app/ebay/admin.py +++ b/app/ebay/admin.py @@ -10,6 +10,6 @@ class ItemAdmin(admin.ModelAdmin): @admin.register(TrackedItem) class TrackedItemAdmin(admin.ModelAdmin): - list_display = ('title', 'date_ending', 'get_latest_price', 'amount_desired' ) + list_display = ('title', 'admin_link', 'date_ending', 'get_latest_price', 'amount_desired' ) list_filter = ('amount_desired',) diff --git a/app/ebay/models.py b/app/ebay/models.py index f361b7a..fd5d0a3 100644 --- a/app/ebay/models.py +++ b/app/ebay/models.py @@ -37,16 +37,21 @@ class TrackedItem(models.Model): ordering = ('date_ending', 'amount_desired') get_latest_by = 'date_ending' - def save(self, **kwargs): - super(TrackedItem, self).save() - @property def get_latest_price(self): return self.price_set.latest().price + def admin_link(self): + return force_text('<a href="%s">View Auction page</a>' % (self.url)) + admin_link.allow_tags = True + admin_link.short_description = 'Link' + def __str__(self): return self.title + def save(self, **kwargs): + super(TrackedItem, self).save() + class Price(models.Model): date = models.DateTimeField(blank=True) |