Merge lp:~widelands-dev/widelands-website/map-uploader-fixes into lp:widelands-website

Proposed by Shevonar
Status: Merged
Merged at revision: 364
Proposed branch: lp:~widelands-dev/widelands-website/map-uploader-fixes
Merge into: lp:widelands-website
Diff against target: 65 lines (+12/-13)
3 files modified
templates/wlmaps/index.html (+3/-0)
templates/wlmaps/upload.html (+6/-0)
wlmaps/views.py (+3/-13)
To merge this branch: bzr merge lp:~widelands-dev/widelands-website/map-uploader-fixes
Reviewer Review Type Date Requested Status
SirVer Approve
Review via email: mp+179552@code.launchpad.net

Description of the change

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.

To post a comment you must log in.
Revision history for this message
SirVer (sirver) wrote :

lgtm. merged and deployed - now go to sleep - cheese, it is in the middle of the night for you guys :).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'templates/wlmaps/index.html'
2--- templates/wlmaps/index.html 2012-05-08 21:52:15 +0000
3+++ templates/wlmaps/index.html 2013-08-09 22:57:24 +0000
4@@ -13,6 +13,9 @@
5 <a href="{% url wlmaps_upload %}" class="posRight invertedColor small">Upload a new map</a>
6 <h1>Maps</h1>
7 <div class="blogEntry">
8+ <p>
9+ 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.
10+ </p>
11 {% autopaginate maps maps_per_page %}
12 {% paginate %}
13 <br />
14
15=== modified file 'templates/wlmaps/upload.html'
16--- templates/wlmaps/upload.html 2012-04-24 21:14:22 +0000
17+++ templates/wlmaps/upload.html 2013-08-09 22:57:24 +0000
18@@ -12,8 +12,14 @@
19 <br /><br />
20 <form enctype="multipart/form-data" action="{% url wlmaps_upload %}" method="post">
21 {{ form.file.label_tag }}: {{ form.file }}<br />
22+ {% if form.file.errors %}
23+ <span class="errormessage">{{ form.file.errors }}</span><br />
24+ {% endif %}
25 {{ form.uploader_comment.label_tag }}:<br />
26 {{ form.uploader_comment }}
27+ {% if form.uploader_comment.errors %}
28+ <span class="errormessage">{{ form.uploader_comment.errors }}</span><br />
29+ {% endif %}
30 {% csrf_token %}<br />
31 <input type="submit" value="Upload" />
32 </form>
33
34=== modified file 'wlmaps/views.py'
35--- wlmaps/views.py 2013-06-14 19:23:53 +0000
36+++ wlmaps/views.py 2013-08-09 22:57:24 +0000
37@@ -60,26 +60,16 @@
38 """
39 m = get_object_or_404( models.Map, slug = map_slug )
40
41- file = open(m.file.path,"rb")
42+ file = open(m.file.path, "rb")
43 data = file.read()
44-
45- # We have to find the correct filename, widelands is quite
46- # buggy. The Filename must be the same as the directory
47- # packed in the zip.
48- file.seek(0)
49- zf = zipfile.ZipFile(file)
50- probable_filenames = filter( len, [ i.filename.split('/')[0] for i in zf.filelist ])
51- if not len(probable_filenames):
52- probable_filename = os.path.basename("%s.wmf" % m.name)
53- else:
54- probable_filename = probable_filenames[0]
55+ filename = os.path.basename("%s.wmf" % m.name)
56
57 # Remember that this has been downloaded
58 m.nr_downloads += 1
59 m.save()
60
61 response = HttpResponse( data, mimetype = "application/octet-stream")
62- response['Content-Disposition'] = 'attachment; filename="%s"' % probable_filename
63+ response['Content-Disposition'] = 'attachment; filename="%s"' % filename
64
65 return response
66

Subscribers

People subscribed via source and target branches