comparison apps/bundle/models.py @ 209:4033ebe1867f

Add ability to download files This makes use of a new model (BundleVersion) to keep track of the locations on disk of the original uploads for each version. This will require some manual processing to get it working for existing bundles, since the information needed isn't being stored at the moment.
author dellsystem <ilostwaldo@gmail.com>
date Sun, 17 Feb 2013 14:57:39 -0500
parents 1eb652aa501a
children
comparison
equal deleted inserted replaced
188:1eb652aa501a 209:4033ebe1867f
51 """ 51 """
52 return os.path.join('tmp', 'bundles', 52 return os.path.join('tmp', 'bundles',
53 "%d_%d" % (self.id, self.latest_version)) 53 "%d_%d" % (self.id, self.latest_version))
54 54
55 55
56 class BundleVersion(models.Model):
57 class Meta:
58 unique_together = ('bundle', 'version')
59 """
60 Needed to allow users to download the originally-uploaded files
61 """
62 bundle = models.ForeignKey(Bundle)
63 version = models.IntegerField()
64 file_name = models.CharField(max_length=256)
65
66 def __unicode__(self):
67 return self.file_name
68
69
56 class BundleFile(MPTTModel): 70 class BundleFile(MPTTModel):
57 bundle = models.ForeignKey(Bundle) 71 bundle = models.ForeignKey(Bundle)
58 version = models.IntegerField() 72 version = models.IntegerField()
59 parent = TreeForeignKey('self', null=True, blank=True, 73 parent = TreeForeignKey('self', null=True, blank=True,
60 related_name='children') 74 related_name='children')