X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/617e60be3c7d2e0f17639f3487a721d4efdc02c0..54d34ece196890ca3688f8c1c0807e4e93710790:/forum/views/writers.py diff --git a/forum/views/writers.py b/forum/views/writers.py index 7dc2e33..125318b 100644 --- a/forum/views/writers.py +++ b/forum/views/writers.py @@ -4,7 +4,6 @@ import time, datetime, random import logging from django.core.files.storage import FileSystemStorage from django.shortcuts import render_to_response, get_object_or_404 -from django.contrib.auth.decorators import login_required from django.http import HttpResponseRedirect, HttpResponse, Http404 from django.template import RequestContext from django.utils.html import * @@ -37,13 +36,16 @@ def upload(request):#ajax upload file to a question or answer raise UploadPermissionNotAuthorized() # check file type - file_name_suffix = os.path.splitext(f.name)[1].lower() + try: + file_name_suffix = os.path.splitext(f.name)[1].lower() + except KeyError: + raise FileTypeNotAllow() if not file_name_suffix in ('.jpg', '.jpeg', '.gif', '.png', '.bmp', '.tiff', '.ico'): raise FileTypeNotAllow() storage = FileSystemStorage(str(settings.UPFILES_FOLDER), str(settings.UPFILES_ALIAS)) - new_file_name = storage.save(f.name, f) + new_file_name = storage.save("_".join(f.name.split()), f) # check file size # byte size = storage.size(new_file_name) @@ -105,10 +107,9 @@ def ask(request): return render_to_response('ask.html', { 'form' : form, - 'email_validation_faq_url':reverse('faq') + '#validate', + 'tab' : 'ask' }, context_instance=RequestContext(request)) -@login_required def edit_question(request, id): question = get_object_or_404(Question, id=id) if question.nis.deleted and not request.user.can_view_deleted_post(question): @@ -172,7 +173,6 @@ def _edit_question(request, question): #'tags' : _get_tags_cache_json() }, context_instance=RequestContext(request)) -@login_required def edit_answer(request, id): answer = get_object_or_404(Answer, id=id) if answer.deleted and not request.user.can_view_deleted_post(answer):