diff --git a/netbox/extras/migrations/0059_attachment_export_templates.py b/netbox/extras/migrations/0059_attachment_export_templates.py new file mode 100644 index 000000000..2598aefa8 --- /dev/null +++ b/netbox/extras/migrations/0059_attachment_export_templates.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2b1 on 2021-03-30 20:16 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('extras', '0058_journalentry'), + ] + + operations = [ + migrations.AddField( + model_name='exporttemplate', + name='as_attachment', + field=models.BooleanField(default=True), + ), + ] diff --git a/netbox/extras/models/models.py b/netbox/extras/models/models.py index d54eac0db..8b9c4cc60 100644 --- a/netbox/extras/models/models.py +++ b/netbox/extras/models/models.py @@ -251,6 +251,10 @@ class ExportTemplate(BigIDModel): blank=True, help_text='Extension to append to the rendered filename' ) + as_attachment = models.BooleanField( + default=True, + help_text="Present file as attachment" + ) objects = RestrictedQuerySet.as_manager() @@ -298,7 +302,9 @@ class ExportTemplate(BigIDModel): queryset.model._meta.verbose_name_plural, '.{}'.format(self.file_extension) if self.file_extension else '' ) - response['Content-Disposition'] = 'attachment; filename="{}"'.format(filename) + + if self.as_attachment: + response['Content-Disposition'] = 'attachment; filename="{}"'.format(filename) return response