Make it easier to support other extensions per-Model (such as .csv, etc.).
Patch by: Todd Larsen
Review by: to-be-reviewed
--- a/app/soc/views/models/base.py Thu Feb 19 20:24:17 2009 +0000
+++ b/app/soc/views/models/base.py Thu Feb 19 20:30:47 2009 +0000
@@ -61,6 +61,8 @@
DEF_CREATE_INSTRUCTION_MSG_FMT = ugettext(
'Please select a %s for the new %s.')
+ DEF_EXPORT_EXTENSION = '.txt'
+
def __init__(self, params=None):
"""
@@ -223,8 +225,12 @@
template = params['export_template']
response_args = {'mimetype': params['export_content_type']}
+
+ export_extension = params.get('export_extension',
+ self.DEF_EXPORT_EXTENSION)
response_headers = {
- 'Content-Disposition': 'attachment; filename=%s.txt' % entity.link_id,
+ 'Content-Disposition': 'attachment; filename=%s%s' % (
+ entity.link_id, export_extension),
}
return helper.responses.respond(request, template, context=context,
--- a/app/soc/views/models/document.py Thu Feb 19 20:24:17 2009 +0000
+++ b/app/soc/views/models/document.py Thu Feb 19 20:30:47 2009 +0000
@@ -75,6 +75,7 @@
new_params['name'] = "Document"
new_params['export_content_type'] = 'text/text'
+ new_params['export_extension'] = '.html'
new_params['no_create_raw'] = True
new_params['no_create_with_scope'] = True