diff apps/bundle/models.py @ 177:86129d185ddb

Add versioning to bundles Some other bundle-related changes were made, including: * Editing the snippetform CSS and HTML to allow bundle/form.djhtml to be reused for editing * Changing {% block title %} to {% block section %} in the base template for bundles to allow for more flexibility when creating breadcrumbs * Saved common URL patterns in variables in bundle/urls.py * Renamed explore.html to explore.djhtml for consistency You should now be able to upload new versions as well as view the files (or a particular file) for a bundle at a specific version. Coming soon: the ability to add a timestamp and a comment for each new uploaded version (if this feature is desirable).
author dellsystem <ilostwaldo@gmail.com>
date Sat, 20 Oct 2012 23:28:50 -0400
parents c042d26e6936
children b711f0087709
line wrap: on
line diff
--- a/apps/bundle/models.py	Sat Oct 20 19:24:09 2012 -0400
+++ b/apps/bundle/models.py	Sat Oct 20 23:28:50 2012 -0400
@@ -28,6 +28,7 @@
     mod_date = models.DateTimeField('date last modified', auto_now=True)
     done_uploading = models.BooleanField(default=False)
     file_name = models.CharField(max_length=256) # the uploaded file
+    latest_version = models.IntegerField(default=1)
 
     def __unicode__(self):
         return self.name
@@ -37,11 +38,16 @@
         return ('bundle_details', [self.uploader.username, self.name])
 
     def get_temp_path(self):
-        return os.path.join('tmp', 'bundles', '%s' % self.id)
+        """
+        Returns the path to where the file is initially uploaded
+        """
+        return os.path.join('tmp', 'bundles',
+            "%d_%d" % (self.id, self.latest_version))
 
 
 class BundleFile(MPTTModel):
     bundle = models.ForeignKey(Bundle)
+    version = models.IntegerField()
     parent = TreeForeignKey('self', null=True, blank=True,
         related_name='children')
     name = models.CharField(max_length=256)
@@ -86,5 +92,6 @@
         return ('bundlefile_details', [
             self.bundle.uploader.username,
             self.bundle.name,
+            self.version,
             self.get_path()
         ])