widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #01551
[Merge] lp:~widelands-dev/widelands-website/map-uploader-fixes into lp:widelands-website
Shevonar has proposed merging lp:~widelands-dev/widelands-website/map-uploader-fixes into lp:widelands-website.
Requested reviews:
SirVer (sirver)
Related bugs:
Bug #1092692 in Widelands Website: ""Pentagon" map download file name incorrect"
https://bugs.launchpad.net/widelands-website/+bug/1092692
Bug #1106783 in Widelands Website: "instruction for "where to put map""
https://bugs.launchpad.net/widelands-website/+bug/1106783
Bug #1210606 in Widelands Website: "Map section: upload fails if Widelands internal map name already exists"
https://bugs.launchpad.net/widelands-website/+bug/1210606
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands-website/map-uploader-fixes/+merge/179552
This branch should fix several bugs in the map uploader. I still had no time to set up a test environment so I cannot verify that they are fixed but I really believe in it.
--
https://code.launchpad.net/~widelands-dev/widelands-website/map-uploader-fixes/+merge/179552
Your team Widelands Developers is subscribed to branch lp:widelands-website.
=== modified file 'templates/wlmaps/index.html'
--- templates/wlmaps/index.html 2012-05-08 21:52:15 +0000
+++ templates/wlmaps/index.html 2013-08-09 22:55:54 +0000
@@ -13,6 +13,9 @@
<a href="{% url wlmaps_upload %}" class="posRight invertedColor small">Upload a new map</a>
<h1>Maps</h1>
<div class="blogEntry">
+ <p>
+ The map files have to be placed in the Widelands map directory to be found by the game. Check the <a href="/wiki/Technical%20FAQ/#where_are_my_maps_and_savegames_stored">Technical FAQ</a> to find the map directory.
+ </p>
{% autopaginate maps maps_per_page %}
{% paginate %}
<br />
=== modified file 'templates/wlmaps/upload.html'
--- templates/wlmaps/upload.html 2012-04-24 21:14:22 +0000
+++ templates/wlmaps/upload.html 2013-08-09 22:55:54 +0000
@@ -12,8 +12,14 @@
<br /><br />
<form enctype="multipart/form-data" action="{% url wlmaps_upload %}" method="post">
{{ form.file.label_tag }}: {{ form.file }}<br />
+ {% if form.file.errors %}
+ <span class="errormessage">{{ form.file.errors }}</span><br />
+ {% endif %}
{{ form.uploader_comment.label_tag }}:<br />
{{ form.uploader_comment }}
+ {% if form.uploader_comment.errors %}
+ <span class="errormessage">{{ form.uploader_comment.errors }}</span><br />
+ {% endif %}
{% csrf_token %}<br />
<input type="submit" value="Upload" />
</form>
=== modified file 'wlmaps/views.py'
--- wlmaps/views.py 2013-06-14 19:23:53 +0000
+++ wlmaps/views.py 2013-08-09 22:55:54 +0000
@@ -60,26 +60,16 @@
"""
m = get_object_or_404( models.Map, slug = map_slug )
- file = open(m.file.path,"rb")
+ file = open(m.file.path, "rb")
data = file.read()
-
- # We have to find the correct filename, widelands is quite
- # buggy. The Filename must be the same as the directory
- # packed in the zip.
- file.seek(0)
- zf = zipfile.ZipFile(file)
- probable_filenames = filter( len, [ i.filename.split('/')[0] for i in zf.filelist ])
- if not len(probable_filenames):
- probable_filename = os.path.basename("%s.wmf" % m.name)
- else:
- probable_filename = probable_filenames[0]
+ filename = os.path.basename("%s.wmf" % m.name)
# Remember that this has been downloaded
m.nr_downloads += 1
m.save()
response = HttpResponse( data, mimetype = "application/octet-stream")
- response['Content-Disposition'] = 'attachment; filename="%s"' % probable_filename
+ response['Content-Disposition'] = 'attachment; filename="%s"' % filename
return response
Follow ups