--- a/src/cm/views/create.py Fri Sep 14 09:49:27 2012 +0200
+++ b/src/cm/views/create.py Fri Sep 14 09:50:05 2012 +0200
@@ -61,7 +61,7 @@
return cleaned_data
uploaded_file = self.cleaned_data['file']
- if (uploaded_file.content_type != 'text/xml'):
+ if (uploaded_file.content_type != 'text/xml' and (uploaded_file.content_type != 'application/octet-stream' or cleaned_data.get('mime', 'application/xml') != 'application/xml')):
msg = _("The imported file should be an XML file generated by co-ment when exporting a text and comments.")
self._errors["file"] = ErrorList([msg])
return cleaned_data
@@ -179,6 +179,7 @@
# Replaces attachements keys in content.
for old_key in attachments_keys_map.keys():
form.cleaned_data['content'] = re.sub(old_key, attachments_keys_map[old_key], form.cleaned_data['content'])
+ form.cleaned_data['content'] = re.sub(r'src="/attach/', 'src="' + settings.SITE_URL + '/attach/', form.cleaned_data['content'])
# Creates text.
text = create_text(request.user, form.cleaned_data)
@@ -242,7 +243,7 @@
# Logs on activity.
register_activity(request, "text_imported", text)
display_message(request, _(u'Text "%(text_title)s" has been imported')%{"text_title":text.get_latest_version().title})
- return None, HttpResponseRedirect(reverse('text-view', args=[text.key]))
+ return text, HttpResponseRedirect(reverse('text-view', args=[text.key]))
else:
form = createForm()