Mercurial > agora-palash
comparison 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 |
comparison
equal
deleted
inserted
replaced
176:c042d26e6936 | 177:86129d185ddb |
---|---|
26 free_license = models.ForeignKey(FreeLicense, default=1) | 26 free_license = models.ForeignKey(FreeLicense, default=1) |
27 pub_date = models.DateTimeField('date uploaded', auto_now_add=True) | 27 pub_date = models.DateTimeField('date uploaded', auto_now_add=True) |
28 mod_date = models.DateTimeField('date last modified', auto_now=True) | 28 mod_date = models.DateTimeField('date last modified', auto_now=True) |
29 done_uploading = models.BooleanField(default=False) | 29 done_uploading = models.BooleanField(default=False) |
30 file_name = models.CharField(max_length=256) # the uploaded file | 30 file_name = models.CharField(max_length=256) # the uploaded file |
31 latest_version = models.IntegerField(default=1) | |
31 | 32 |
32 def __unicode__(self): | 33 def __unicode__(self): |
33 return self.name | 34 return self.name |
34 | 35 |
35 @models.permalink | 36 @models.permalink |
36 def get_absolute_url(self): | 37 def get_absolute_url(self): |
37 return ('bundle_details', [self.uploader.username, self.name]) | 38 return ('bundle_details', [self.uploader.username, self.name]) |
38 | 39 |
39 def get_temp_path(self): | 40 def get_temp_path(self): |
40 return os.path.join('tmp', 'bundles', '%s' % self.id) | 41 """ |
42 Returns the path to where the file is initially uploaded | |
43 """ | |
44 return os.path.join('tmp', 'bundles', | |
45 "%d_%d" % (self.id, self.latest_version)) | |
41 | 46 |
42 | 47 |
43 class BundleFile(MPTTModel): | 48 class BundleFile(MPTTModel): |
44 bundle = models.ForeignKey(Bundle) | 49 bundle = models.ForeignKey(Bundle) |
50 version = models.IntegerField() | |
45 parent = TreeForeignKey('self', null=True, blank=True, | 51 parent = TreeForeignKey('self', null=True, blank=True, |
46 related_name='children') | 52 related_name='children') |
47 name = models.CharField(max_length=256) | 53 name = models.CharField(max_length=256) |
48 is_dir = models.BooleanField() | 54 is_dir = models.BooleanField() |
49 code = models.TextField(null=True, blank=True) | 55 code = models.TextField(null=True, blank=True) |
84 @models.permalink | 90 @models.permalink |
85 def get_absolute_url(self): | 91 def get_absolute_url(self): |
86 return ('bundlefile_details', [ | 92 return ('bundlefile_details', [ |
87 self.bundle.uploader.username, | 93 self.bundle.uploader.username, |
88 self.bundle.name, | 94 self.bundle.name, |
95 self.version, | |
89 self.get_path() | 96 self.get_path() |
90 ]) | 97 ]) |