diff gpp/downloads/models.py @ 277:d424b8bae71d

Fixing #128 and #129. Add elsewhere weblinks to search content. Add support for haystack's get_update_field() method.
author Brian Neal <bgneal@gmail.com>
date Sat, 02 Oct 2010 23:24:39 +0000
parents 27bee3ac85e6
children 639cfdf59167
line wrap: on
line diff
--- a/gpp/downloads/models.py	Thu Sep 30 00:06:04 2010 +0000
+++ b/gpp/downloads/models.py	Sat Oct 02 23:24:39 2010 +0000
@@ -56,8 +56,9 @@
     html = models.TextField(blank=True)
     file = models.FileField(upload_to=download_path)
     user = models.ForeignKey(User)
-    date_added = models.DateTimeField()
+    date_added = models.DateTimeField(db_index=True)
     ip_address = models.IPAddressField('IP Address')
+    update_date = models.DateTimeField(db_index=True, blank=True)
 
     class Meta:
         abstract = True
@@ -80,6 +81,10 @@
     def save(self, *args, **kwargs):
         if not self.pk:
             self.date_added = datetime.datetime.now()
+            self.update_date = self.date_added
+        else:
+            self.update_date = datetime.datetime.now()
+
         self.html = site_markup(self.description)
         super(PendingDownload, self).save(*args, **kwargs)
 
@@ -103,6 +108,12 @@
         return ('downloads-details', [str(self.id)])
 
     def save(self, *args, **kwargs):
+        if not self.pk:
+            self.date_added = datetime.datetime.now()
+            self.update_date = self.date_added
+        else:
+            self.update_date = datetime.datetime.now()
+
         self.html = site_markup(self.description)
         super(Download, self).save(*args, **kwargs)