(self, sketch)
return send_file(
            file_object, mimetype='zip',
            attachment_filename='timesketch_export.zip')
Returns a ZIP file with the exported content of a sketch.
Returns a ZIP file with the exported content of a sketch.
Returns a ZIP file with the exported content of a sketch .
def _export_sketch(self, sketch):
        """Returns a ZIP file with the exported content of a sketch."""
        file_object = io.BytesIO()
        sketch_is_archived = sketch.get_status.status == 'archived'

        if sketch_is_archived:
            _ = self._unarchive_sketch(sketch)

        story_exporter = story_export_manager.StoryExportManager.get_exporter(
            'html')

        meta = {
            'user': current_user.username,
            'time': datetime.datetime.utcnow().isoformat(),
            'sketch_id': sketch.id,
            'sketch_name': sketch.name,
            'sketch_description': sketch.description,
            'timesketch_version': version.get_version(),
        }

        with zipfile.ZipFile(file_object, mode='w') as zip_file:
            zip_file.writestr('METADATA', data=json.dumps(meta))

            for story in sketch.stories:
                export.export_story(story, sketch, story_exporter, zip_file)

            for aggregation in sketch.aggregations:
                export.export_aggregation(aggregation, sketch, zip_file)

            for view in sketch.views:
                self._export_view(view, sketch, zip_file)

            for group in sketch.aggregationgroups:
                export.export_aggregation_group(group, sketch, zip_file)

            self._export_events_with_comments(sketch, zip_file)
            self._export_starred_events(sketch, zip_file)
            self._export_tagged_events(sketch, zip_file)

            # TODO (kiddi): Add in aggregation group support.

        if sketch_is_archived:
            _ = self._archive_sketch(sketch)

        file_object.seek(0)
        return send_file(
            file_object, mimetype='zip',
            attachment_filename='timesketch_export.zip')
def _export_sketch ( self , sketch ) : file_object = io . BytesIO ( ) sketch_is_archived = sketch . get_status . status == 'archived' if sketch_is_archived : _ = self . _unarchive_sketch ( sketch ) story_exporter = story_export_manager . StoryExportManager . get_exporter ( 'html' ) meta = { 'user' : current_user . username , 'time' : datetime . datetime . utcnow ( ) . isoformat ( ) , 'sketch_id' : sketch . id , 'sketch_name' : sketch . name , 'sketch_description' : sketch . description , 'timesketch_version' : version . get_version ( ) , } with zipfile . ZipFile ( file_object , mode = 'w' ) as zip_file : zip_file . writestr ( 'METADATA' , data = json . dumps ( meta ) ) for story in sketch . stories : export . export_story ( story , sketch , story_exporter , zip_file ) for aggregation in sketch . aggregations : export . export_aggregation ( aggregation , sketch , zip_file ) for view in sketch . views : self . _export_view ( view , sketch , zip_file ) for group in sketch . aggregationgroups : export . export_aggregation_group ( group , sketch , zip_file ) self . _export_events_with_comments ( sketch , zip_file ) self . _export_starred_events ( sketch , zip_file ) self . _export_tagged_events ( sketch , zip_file ) # TODO (kiddi): Add in aggregation group support. if sketch_is_archived : _ = self . _archive_sketch ( sketch ) file_object . seek ( 0 ) return send_file ( file_object , mimetype = 'zip' , attachment_filename = 'timesketch_export.zip' )