Example #1
0
    def test_attachment_with_custom_storage(self):
        summernote_config['attachment_storage_class'] = \
            'django.core.files.storage.DefaultStorage'

        from django_summernote.models import _get_attachment_storage
        file_field = get_attachment_model()._meta.get_field('file')
        original_storage = file_field.storage
        file_field.storage = _get_attachment_storage()

        url = reverse('django_summernote-upload_attachment')

        with open(__file__, 'rb') as fp:
            response = self.client.post(url, {'files': [fp]})
            self.assertEqual(response.status_code, 200)

        file_field.storage = original_storage
Example #2
0
    def test_attachment_with_custom_storage(self):
        summernote_config["attachment_storage_class"] = "django.core.files.storage.DefaultStorage"

        from django_summernote.models import Attachment, _get_attachment_storage

        file_field = Attachment._meta.get_field_by_name("file")[0]
        original_storage = file_field.storage
        file_field.storage = _get_attachment_storage()

        url = reverse("django_summernote-upload_attachment")

        with open(__file__, "rb") as fp:
            response = self.client.post(url, {"files": [fp]})
            self.assertEqual(response.status_code, 200)

        file_field.storage = original_storage
Example #3
0
    def test_attachment_with_custom_storage(self):
        summernote_config['attachment_storage_class'] = \
            'django.core.files.storage.DefaultStorage'

        from django_summernote.models import _get_attachment_storage
        file_field = get_attachment_model()._meta.get_field('file')
        original_storage = file_field.storage
        file_field.storage = _get_attachment_storage()

        url = reverse('django_summernote-upload_attachment')

        with open(__file__, 'rb') as fp:
            response = self.client.post(url, {'files': [fp]})
            self.assertEqual(response.status_code, 200)

        file_field.storage = original_storage