comparison downloads/models.py @ 661:15dbe0ccda95

Prevent exceptions when viewing downloads in the admin when the file doesn't exist on the filesystem. This is usually seen in development but can also happen in production if the file is missing.
author Brian Neal <bgneal@gmail.com>
date Tue, 14 May 2013 21:02:47 -0500
parents ee87ea74d46b
children 3e1905e523be
comparison
equal deleted inserted replaced
660:0dd84cff2477 661:15dbe0ccda95
62 62
63 class Meta: 63 class Meta:
64 abstract = True 64 abstract = True
65 65
66 def size(self): 66 def size(self):
67 return filesizeformat(self.file.size) 67 try:
68 return filesizeformat(self.file.size)
69 except OSError:
70 return '?'
68 71
69 72
70 class PendingDownload(DownloadBase): 73 class PendingDownload(DownloadBase):
71 """This model represents pending downloads created by users. These pending 74 """This model represents pending downloads created by users. These pending
72 downloads must be approved by an admin before they turn into "real" 75 downloads must be approved by an admin before they turn into "real"