comparison apps/bundle/tasks.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 a05e547449de
children 76abe6d681ea
comparison
equal deleted inserted replaced
176:c042d26e6936 177:86129d185ddb
28 28
29 for file_path in sorted(dirs) + sorted(files): 29 for file_path in sorted(dirs) + sorted(files):
30 filename = os.path.basename(file_path) 30 filename = os.path.basename(file_path)
31 full_path = file_path[len(bundle.get_temp_path()) + 1:] 31 full_path = file_path[len(bundle.get_temp_path()) + 1:]
32 bundle_file = BundleFile(bundle=bundle, name=filename, 32 bundle_file = BundleFile(bundle=bundle, name=filename,
33 parent=parent_dir, full_path=full_path) 33 parent=parent_dir, full_path=full_path,
34 version=bundle.latest_version)
34 35
35 if file_path in files: 36 if file_path in files:
36 bundle_file.is_dir = False 37 bundle_file.is_dir = False
37 bundle_file.file_size = os.path.getsize(file_path) 38 bundle_file.file_size = os.path.getsize(file_path)
38 39
77 print "Archive exception" 78 print "Archive exception"
78 pass 79 pass
79 elif mime_type.startswith('text/'): 80 elif mime_type.startswith('text/'):
80 # Should be a plain text file - create a CodeFile for it 81 # Should be a plain text file - create a CodeFile for it
81 bundle_file = BundleFile(bundle=bundle, name=bundle.file_name, 82 bundle_file = BundleFile(bundle=bundle, name=bundle.file_name,
82 full_path=bundle.file_name, file_size=os.path.getsize(file)) 83 full_path=bundle.file_name, file_size=os.path.getsize(file),
84 version=bundle.latest_version)
83 bundle_file.save_file_contents(open(file, 'rt'), 85 bundle_file.save_file_contents(open(file, 'rt'),
84 original_filename=bundle.file_name) 86 original_filename=bundle.file_name)
85 87
86 print "Done uploading!" 88 print "Done uploading!"
87 bundle.done_uploading = True 89 bundle.done_uploading = True