Changeset 181:c66e64ccb02f


Ignore:
Timestamp:
Nov 20, 2009 4:25:14 PM (4 years ago)
Author:
slav0nic <slav0nic0@…>
Branch:
default
Message:

Fix #56: attachments does not work

Location:
djangobb/apps/forum
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • djangobb/apps/forum/forms.py

    r177 r181  
    8181 
    8282 
    83     def save(self, commit=True): 
     83    def save(self): 
    8484        if self.forum: 
    8585            topic = Topic(forum=self.forum, 
     
    9393                    markup='bbcode', 
    9494                    body=self.cleaned_data['body']) 
    95          
     95 
     96        post.save() 
    9697        if forum_settings.ATTACHMENT_SUPPORT: 
    9798            self.save_attachment(post, self.cleaned_data['attachment']) 
    98  
    99         if commit: 
    100             post.save() 
    10199        return post 
     100 
    102101 
    103102    def save_attachment(self, post, memfile): 
  • djangobb/apps/forum/views.py

    r177 r181  
    1313from django.utils import translation 
    1414from django.db.models import Q, F, Sum 
    15  
     15from django.utils.encoding import smart_str 
    1616 
    1717from forum.util import render_to, paged, build_form, paginate, set_language 
     
    791791def show_attachment(request, hash): 
    792792    attachment = get_object_or_404(Attachment, hash=hash) 
    793     file_obj = file(attachment.get_absolute_path()) 
    794     response = HttpResponse(file_obj, content_type=attachment.content_type) 
    795     response['Content-Disposition'] = 'attachment; filename=%s' % attachment.name.encode('utf-8', 'ignore') 
     793    file_data = file(attachment.get_absolute_path()).read() 
     794    response = HttpResponse(file_data, mimetype=attachment.content_type) 
     795    response['Content-Disposition'] = 'attachment; filename=%s' % smart_str(attachment.name) 
    796796    return response 
    797797 
Note: See TracChangeset for help on using the changeset viewer.