diff downloads/models.py @ 1023:a5ebc74dc3f3

Perform image_check on downloads.
author Brian Neal <bgneal@gmail.com>
date Thu, 10 Dec 2015 20:57:50 -0600
parents 3e1905e523be
children 5ba2508939f7
line wrap: on
line diff
--- a/downloads/models.py	Wed Dec 09 21:16:04 2015 -0600
+++ b/downloads/models.py	Thu Dec 10 20:57:50 2015 -0600
@@ -69,6 +69,18 @@
         except OSError:
             return '?'
 
+    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 = kwargs.pop('html', None)
+        if not self.html and self.description:
+            self.html = site_markup(self.description)
+        super(DownloadBase, self).save(*args, **kwargs)
+
 
 class PendingDownload(DownloadBase):
     """This model represents pending downloads created by users. These pending
@@ -81,16 +93,6 @@
     def __unicode__(self):
         return self.title
 
-    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)
-
 
 class Download(DownloadBase):
     """Model to represent a download."""
@@ -110,16 +112,6 @@
     def get_absolute_url(self):
         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)
-
     def vote(self, vote_value):
         """receives a vote_value and updates internal score accordingly"""
         total_score = self.average_score * self.total_votes