# HG changeset patch # User dellsystem # Date 1351367888 14400 # Node ID b711f0087709bbb5f8e6aa0974c500fb62805053 # Parent cdcbfaa65cfee0f980684815d9d9d3ee00d6dfa3 Use DESCRIPTION file for bundles (SCHEMA CHANGE) * Added two new fields to the Bundle model: * octave_format, which allows users to specify if their bundle has been formatted according to octave packaging standards or not * description_file, which points to a file named DESCRIPTION in the root directory (or the next top-level directory), if the octave_format checkbox is ticked and if one exists * Fixed the uploader field for form by making it a hidden input and preventing hidden inputs from showing up entirely diff -r cdcbfaa65cfe -r b711f0087709 apps/bundle/forms.py --- a/apps/bundle/forms.py Sat Oct 27 15:41:58 2012 -0400 +++ b/apps/bundle/forms.py Sat Oct 27 15:58:08 2012 -0400 @@ -8,6 +8,12 @@ model = Bundle fields = ('uploader', 'name', 'description', 'free_license', 'octave_format') + widgets = { + # Ideally, the uploader field should just not show up at all + # Not really possible if we want to validate the name + # This is the next best option (hidden fields just aren't shown) + 'uploader': forms.HiddenInput, + } file = forms.FileField(help_text=("Upload a plain text file or an \ archive file.")) diff -r cdcbfaa65cfe -r b711f0087709 apps/bundle/models.py --- a/apps/bundle/models.py Sat Oct 27 15:41:58 2012 -0400 +++ b/apps/bundle/models.py Sat Oct 27 15:58:08 2012 -0400 @@ -22,7 +22,12 @@ "Acceptable characters: alphanumeric characters, hyphens, and " + "underscores.")) uploader = models.ForeignKey(User) - description = models.TextField(max_length=32728, blank=True, null=True) + description = models.TextField(blank=True, null=True) + octave_format = models.BooleanField('Is the bundle formatted according' + ' to Octave package manager standards?', default=False) + # If octave_format is true and there is a DESCRIPTION file in the root + description_file = models.ForeignKey('BundleFile', blank=True, null=True, + related_name="described") free_license = models.ForeignKey(FreeLicense, default=1) pub_date = models.DateTimeField('date uploaded', auto_now_add=True) mod_date = models.DateTimeField('date last modified', auto_now=True) diff -r cdcbfaa65cfe -r b711f0087709 apps/bundle/tasks.py --- a/apps/bundle/tasks.py Sat Oct 27 15:41:58 2012 -0400 +++ b/apps/bundle/tasks.py Sat Oct 27 15:58:08 2012 -0400 @@ -26,8 +26,6 @@ dir_contents = [os.path.join(dir_name, f) for f in os.listdir(dir_name)] dirs = filter(os.path.isdir, dir_contents) files = filter(os.path.isfile, dir_contents) - print "Directories: %s" % ", ".join(dirs) - print "Files: %s" % ", ".join(files) for file_path in sorted(dirs) + sorted(files): filename = os.path.basename(file_path) @@ -37,6 +35,7 @@ version=bundle.latest_version) if file_path in files: + is_desc = False bundle_file.is_dir = False bundle_file.file_size = os.path.getsize(file_path) @@ -47,6 +46,16 @@ # Store the contents of the file in the code field bundle_file.save_file_contents(file) + # DESCRIPTION file should be at most 1 level deep + single_parent = (parent_dir is not None or + '/' not in parent_dir) + is_desc = single_parent and filename == 'DESCRIPTION' + + # Check if this is the description file (if no description exists) + if bundle.octave_format and bundle.description == '' and is_desc: + bundle.description_file = bundle_file + bundle.save() + bundle_file.save() else: # It's a directory - call this function on it recursively diff -r cdcbfaa65cfe -r b711f0087709 static/css/agora.less --- a/static/css/agora.less Sat Oct 27 15:41:58 2012 -0400 +++ b/static/css/agora.less Sat Oct 27 15:58:08 2012 -0400 @@ -398,7 +398,7 @@ #bundle-file { padding: 0 20px; - margin-left: 220px; + margin-left: 230px; h2 { padding-top: 0; @@ -420,3 +420,8 @@ .form-field { margin-bottom: 10px; } + +.bundle-description { + white-space: pre-wrap; + .hint; +} diff -r cdcbfaa65cfe -r b711f0087709 templates/bundle/bundle.djhtml --- a/templates/bundle/bundle.djhtml Sat Oct 27 15:41:58 2012 -0400 +++ b/templates/bundle/bundle.djhtml Sat Oct 27 15:58:08 2012 -0400 @@ -74,9 +74,21 @@

Download file (feature not yet available)

{% endif %} {% else %} -

Description: {{ bundle.description|default:"N/A" }}

+

Description

+ {% if bundle.description %} +

{{ bundle.description }}

+ {% else %} + {% if bundle.description_file %} +

{{ bundle.description_file.code|safe }}

+ {% else %} +

N/A

+ {% endif %} + {% endif %} + + {% if bundle.description %}

License: {{ bundle.free_license }}

Latest version number: {{ bundle.latest_version }}

+ {% endif %} {% if previous_versions %}

Versions