mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2024-12-13 02:10:49 +01:00
Merge pull request #190 from tony-zhu/master
Fix the bug of handling attachments when Django DEFAULT_FILE_STORAGE is not default. Should fix #3.
This commit is contained in:
commit
cf63c61d82
@ -11,6 +11,7 @@ from StringIO import StringIO
|
||||
|
||||
from django import forms
|
||||
from django.forms import extras
|
||||
from django.core.files.storage import default_storage
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.translation import ugettext as _
|
||||
@ -305,7 +306,10 @@ class TicketForm(forms.Form):
|
||||
if file.size < getattr(settings, 'MAX_EMAIL_ATTACHMENT_SIZE', 512000):
|
||||
# Only files smaller than 512kb (or as defined in
|
||||
# settings.MAX_EMAIL_ATTACHMENT_SIZE) are sent via email.
|
||||
files.append(a.file.path)
|
||||
try:
|
||||
files.append(a.file.path)
|
||||
except NotImplementedError:
|
||||
pass
|
||||
|
||||
context = safe_template_context(t)
|
||||
context['comment'] = f.comment
|
||||
|
@ -604,8 +604,9 @@ def attachment_path(instance, filename):
|
||||
os.umask(0)
|
||||
path = 'helpdesk/attachments/%s/%s' % (instance.followup.ticket.ticket_for_url, instance.followup.id )
|
||||
att_path = os.path.join(settings.MEDIA_ROOT, path)
|
||||
if not os.path.exists(att_path):
|
||||
os.makedirs(att_path, 0777)
|
||||
if settings.DEFAULT_FILE_STORAGE == "django.core.files.storage.FileSystemStorage":
|
||||
if not os.path.exists(att_path):
|
||||
os.makedirs(att_path, 0777)
|
||||
return os.path.join(path, filename)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user