diff --git a/tailbone/views/exports.py b/tailbone/views/exports.py index 6c193c51..793810f2 100644 --- a/tailbone/views/exports.py +++ b/tailbone/views/exports.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2018 Lance Edgar +# Copyright © 2010-2019 Lance Edgar # # This file is part of Rattail. # @@ -45,9 +45,6 @@ class ExportMasterView(MasterView): """ creatable = False editable = False - - # TODO: should deprecate `export_has_file` in favor of `downloadable` - export_has_file = False downloadable = False grid_columns = [ @@ -132,16 +129,6 @@ class ExportMasterView(MasterView): else: f.set_readonly('record_count') - # download - # TODO: should probably stop doing this altogether? and just make each - # derived view declare the field renderer? - if self.export_has_file and self.viewing: - # download = forms.renderers.FileFieldRenderer.new( - # self, storage_path=self.rattail_config.export_filedir(self.export_key), - # file_path=self.get_file_path(fs.model), download_url=self.get_download_url) - f.append('download') - f.set_renderer('download', self.render_download) - def objectify(self, form, data=None): obj = super(ExportMasterView, self).objectify(form, data=data) if self.creating: @@ -182,39 +169,3 @@ class ExportMasterView(MasterView): response.headers[b'Content-Length'] = six.binary_type(os.path.getsize(path)) response.headers[b'Content-Disposition'] = b'attachment; filename="{}"'.format(export.filename) return response - - def delete_instance(self, export): - """ - Delete the export file also, if it exists. - """ - if self.export_has_file: - path = self.get_file_path(export) - if os.path.exists(path): - os.remove(path) - os.rmdir(os.path.dirname(path)) - super(ExportMasterView, self).delete_instance(export) - - @classmethod - def defaults(cls, config): - """ - Provide default configuration for a master view. - """ - cls._defaults(config) - cls._export_defaults(config) - - @classmethod - def _export_defaults(cls, config): - route_prefix = cls.get_route_prefix() - url_prefix = cls.get_url_prefix() - permission_prefix = cls.get_permission_prefix() - model_key = cls.get_model_key() - model_title = cls.get_model_title() - - # download export file - # TODO: should deprecate this and just use 'downloadable' instead - if cls.export_has_file: - config.add_route('{}.download'.format(route_prefix), '{}/{{{}}}/download'.format(url_prefix, model_key)) - config.add_view(cls, attr='download', route_name='{}.download'.format(route_prefix), - permission='{}.download'.format(permission_prefix)) - config.add_tailbone_permission(permission_prefix, '{}.download'.format(permission_prefix), - "Download {} data file".format(model_title))