app/soc/views/models/base.py
changeset 1399 5b154edd94ac
parent 1398 e6a11f0dba68
child 1400 842958b8a55d
equal deleted inserted replaced
1398:e6a11f0dba68 1399:5b154edd94ac
    59       'a New %(entity_type)s</a> page.')
    59       'a New %(entity_type)s</a> page.')
    60 
    60 
    61   DEF_CREATE_INSTRUCTION_MSG_FMT = ugettext(
    61   DEF_CREATE_INSTRUCTION_MSG_FMT = ugettext(
    62       'Please select a %s for the new %s.')
    62       'Please select a %s for the new %s.')
    63 
    63 
       
    64   DEF_EXPORT_EXTENSION = '.txt'
       
    65 
    64   def __init__(self, params=None):
    66   def __init__(self, params=None):
    65     """
    67     """
    66 
    68 
    67     Args:
    69     Args:
    68       params: This dictionary should be filled with the parameters
    70       params: This dictionary should be filled with the parameters
   221     context['entity_type'] = params['name']
   223     context['entity_type'] = params['name']
   222 
   224 
   223     template = params['export_template']
   225     template = params['export_template']
   224 
   226 
   225     response_args = {'mimetype': params['export_content_type']}
   227     response_args = {'mimetype': params['export_content_type']}
       
   228 
       
   229     export_extension = params.get('export_extension',
       
   230                                   self.DEF_EXPORT_EXTENSION)
   226     response_headers = {
   231     response_headers = {
   227         'Content-Disposition': 'attachment; filename=%s.txt' % entity.link_id,
   232         'Content-Disposition': 'attachment; filename=%s%s' % (
       
   233             entity.link_id, export_extension),
   228         }
   234         }
   229 
   235 
   230     return helper.responses.respond(request, template, context=context,
   236     return helper.responses.respond(request, template, context=context,
   231                                     response_args=response_args,
   237                                     response_args=response_args,
   232                                     response_headers=response_headers)
   238                                     response_headers=response_headers)