def export_project_yaml_action(modeladmin, request, queryset) -> HttpResponse: """An action that will export projects into a YAML file. """ if len(queryset) == 0: raise ValueError("No project selected") projects = queryset result = export_project_data(projects) response = HttpResponse(yaml.dump(result), content_type='application/yaml') filename = f"catmaid-projects-{'-'.join([str(p.id) for p in projects])}.yaml" response['Content-Disposition'] = f'attachment; filename={filename}' return response
def export_project_yaml_action(modeladmin, requet, queryset): """An action that will export projects into a YAML file. """ if len(queryset) == 0: raise ValueError("No project selected") projects = queryset result = export_project_data(projects) response = HttpResponse(yaml.dump(result), content_type='application/yaml') filename = "catmaid-projects-{}.yaml".format( "-".join([str(p.id) for p in projects])) response['Content-Disposition'] = u'attachment; filename={}'.format(filename) return response
def export_project_json_action(modeladmin, requet, queryset): """An action that will export projects into a JSON file. """ if len(queryset) == 0: raise ValueError("No project selected") projects = queryset result = export_project_data(projects) response = HttpResponse(json.dumps(result), content_type='application/json') filename = "catmaid-projects-{}.json".format("-".join( [str(p.id) for p in projects])) response['Content-Disposition'] = u'attachment; filename={}'.format( filename) return response