Save attachments into FS. Fixes #342

- Legacy-Id: 2482
This commit is contained in:
Emilio A. Sánchez López 2010-08-17 12:00:20 +00:00
parent f581e0fb8e
commit cbde116241
7 changed files with 28 additions and 8 deletions

View file

@ -1,6 +1,7 @@
import datetime
from django import forms
from django.conf import settings
from django.forms.util import ErrorList
from django.template.loader import render_to_string
@ -179,6 +180,9 @@ class LiaisonForm(forms.ModelForm):
detail = instance,
file_extension = extension,
)
attach_file = open('%sfile%s%s' % (settings.LIAISON_ATTACH_PATH, attach.pk, attach.file_extension), 'w')
attach_file.write(attached_file.read())
attach_file.close()
class IncomingLiaisonForm(LiaisonForm):
@ -281,6 +285,7 @@ class EditLiaisonForm(LiaisonForm):
def __init__(self, *args, **kwargs):
super(EditLiaisonForm, self).__init__(*args, **kwargs)
self.edit = True
self.initial.update({'attachments': self.instance.uploads_set.all()})
def set_from_field(self):
self.fields['from_field'].initial = self.instance.from_body

View file

@ -1,3 +1,5 @@
from django.conf import settings
from django.db.models.query import QuerySet
from django.forms.widgets import Select, Widget
from django.utils.safestring import mark_safe
@ -54,9 +56,11 @@ class ShowAttachmentsWidget(Widget):
def render(self, name, value, attrs=None):
html = u'<div id="id_%s">' % name
html += u'<span style="display: none" class="showAttachmentsEmpty">No files attached</span>'
if not value:
html += u'<div class="attachedFiles">No files attached</div>'
html += u'<div class="attachedFiles">'
if value and isinstance(value, QuerySet):
for attach in value:
html += u'<a class="initialAttach" href="%sfile%s%s">%s</a><br />' % (settings.LIAISON_ATTACH_URL, attach.file_id, attach.file_extension, attach.file_title, )
else:
pass
html += u'</div>'
html += u'No files attached'
html += u'</div></div>'
return mark_safe(html)

View file

@ -31,8 +31,6 @@ SERVER_EMAIL = 'Django Server <django-project@' + TOOLS_SERVER + '>'
DEFAULT_FROM_EMAIL = 'IETF Secretariat <ietf-secretariat-reply@' + IETF_DOMAIN + '>'
LIAISON_UNIVERSAL_FROM = 'Liaison Statement Management Tool <lsmt@' + IETF_DOMAIN + '>'
MANAGERS = ADMINS
DATABASE_ENGINE = 'mysql'
@ -176,6 +174,11 @@ else:
IPR_EMAIL_TO = ['ietf-ipr@ietf.org', ]
# Liaison Statement Tool settings
LIAISON_UNIVERSAL_FROM = 'Liaison Statement Management Tool <lsmt@' + IETF_DOMAIN + '>'
LIAISON_ATTACH_PATH = '/a/www/ietf-datatracker/documents/LIAISON/'
LIAISON_ATTACH_URL = '/documents/LIAISON/'
# Put SECRET_KEY in here, or any other sensitive or site-specific
# changes. DO NOT commit settings_local.py to svn.
from settings_local import *

View file

@ -13,7 +13,7 @@
{% if not liaison %}
<ul>
<li>If you wish to submit your liaison statement by e-mail, then please send it to <a href="mailto:statements@ietf.org">statements@ietf.org</a></li>
<li>Fields marked with <span class="requiredField">*</span> are required. For detailed descriptions of the fields see <a href="https://datatracker.ietf.org/liaison/help/fields/">Field help</a></li>
<li>Fields marked with <span class="fieldRequired">*</span> are required. For detailed descriptions of the fields see <a href="https://datatracker.ietf.org/liaison/help/fields/">Field help</a></li>
</ul>
{% endif %}

View file

@ -8,7 +8,7 @@
{% endblock %}
</div>
<div class="baseform">
<div class="baseform{% if form.edit %} baseformedit{% endif %}">
{% if form.errors %}
<div class="formErrors">
Please correct the errors below.

View file

@ -52,6 +52,13 @@
}
#id_title,
.baseformedit #id_from_field,
.baseformedit #id_replyto,
.baseformedit #id_organization,
.baseformedit #id_to_poc,
.baseformedit #id_response_contact,
.baseformedit #id_technical_contact,
.baseformedit #id_cc1,
.baseform textarea {
width: 80%;
}

View file

@ -21,6 +21,7 @@
config.showOn = $('#' + fieldset.find('.showAttachsOn').html());
config.showOnDisplay = config.showOn.find('.attachedFiles');
count = config.showOnDisplay.find('.initialAttach').length;
config.showOnEmpty = config.showOn.find('.showAttachmentsEmpty').html();
config.enabledLabel = fieldset.find('.attachEnabledLabel').html();
};