Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-django-attachments for
openSUSE:Factory checked in at 2023-04-24 22:31:03
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-django-attachments (Old)
and /work/SRC/openSUSE:Factory/.python-django-attachments.new.1533 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-django-attachments"
Mon Apr 24 22:31:03 2023 rev:6 rq:1082315 version:1.11
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-django-attachments/python-django-attachments.changes
2023-04-16 16:07:44.241045943 +0200
+++
/work/SRC/openSUSE:Factory/.python-django-attachments.new.1533/python-django-attachments.changes
2023-04-24 22:31:08.535485320 +0200
@@ -1,0 +2,9 @@
+Sun Apr 23 20:12:06 UTC 2023 - Dirk Müller <[email protected]>
+
+- update to 1.11:
+ * Return form errors as JSON from ``add_attachment()`` view
+ when the ``X-Return-Form-Errors`` request header is present.
+ Response code is 400 - BAD REQUEST because this is a client
+ error.
+
+-------------------------------------------------------------------
Old:
----
django-attachments-1.10.tar.gz
New:
----
django-attachments-1.11.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-django-attachments.spec ++++++
--- /var/tmp/diff_new_pack.viBL4K/_old 2023-04-24 22:31:09.039488316 +0200
+++ /var/tmp/diff_new_pack.viBL4K/_new 2023-04-24 22:31:09.047488363 +0200
@@ -19,7 +19,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python36 1
Name: python-django-attachments
-Version: 1.10
+Version: 1.11
Release: 0
Summary: Attach files to any Django model
License: MIT
++++++ django-attachments-1.10.tar.gz -> django-attachments-1.11.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-attachments-1.10/CHANGELOG.rst
new/django-attachments-1.11/CHANGELOG.rst
--- old/django-attachments-1.10/CHANGELOG.rst 2023-04-14 19:32:18.000000000
+0200
+++ new/django-attachments-1.11/CHANGELOG.rst 2023-04-20 09:53:39.000000000
+0200
@@ -1,8 +1,17 @@
Changelog:
==========
+v1.11 (2023-04-20)
+------------------
+
+- Return form errors as JSON from ``add_attachment()`` view
+ when the ``X-Return-Form-Errors`` request header is present.
+ Response code is 400 - BAD REQUEST because this is a client
+ error.
+
+
v1.10 (2023-04-14)
--------------------
+------------------
- Support custom form validators via ``AppConfig.attachment_validators``
- Remove quotes from "attachment_list" (Aaron C. de Bruyn)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-attachments-1.10/PKG-INFO
new/django-attachments-1.11/PKG-INFO
--- old/django-attachments-1.10/PKG-INFO 2023-04-14 19:32:47.553861900
+0200
+++ new/django-attachments-1.11/PKG-INFO 2023-04-20 09:54:47.045522000
+0200
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: django-attachments
-Version: 1.10
+Version: 1.11
Summary: django-attachments is generic Django application to attach Files
(Attachments) to any model.
Home-page: https://github.com/bartTC/django-attachments
Author: Martin Mahner
@@ -291,8 +291,17 @@
Changelog:
==========
+v1.11 (2023-04-20)
+------------------
+
+- Return form errors as JSON from ``add_attachment()`` view
+ when the ``X-Return-Form-Errors`` request header is present.
+ Response code is 400 - BAD REQUEST because this is a client
+ error.
+
+
v1.10 (2023-04-14)
--------------------
+------------------
- Support custom form validators via ``AppConfig.attachment_validators``
- Remove quotes from "attachment_list" (Aaron C. de Bruyn)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-attachments-1.10/attachments/tests/base.py
new/django-attachments-1.11/attachments/tests/base.py
--- old/django-attachments-1.10/attachments/tests/base.py 2023-04-14
19:03:55.000000000 +0200
+++ new/django-attachments-1.11/attachments/tests/base.py 2023-04-20
09:53:39.000000000 +0200
@@ -43,7 +43,7 @@
self.obj = self.target_model_class.objects.create(title="My first test
item")
- def _upload_testfile(self, file_obj=None, file_content=b"file content"):
+ def _upload_testfile(self, file_obj=None, file_content=b"file content",
**extra):
"""
Uploads a sample file for the given user.
"""
@@ -63,5 +63,6 @@
content_type="image/jpeg",
)
return self.client.post(
- add_url, {"attachment_file": file_obj}, follow=True
+ add_url, {"attachment_file": file_obj}, follow=True,
+ **extra
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-attachments-1.10/attachments/tests/test_views.py
new/django-attachments-1.11/attachments/tests/test_views.py
--- old/django-attachments-1.10/attachments/tests/test_views.py 2023-04-14
19:03:55.000000000 +0200
+++ new/django-attachments-1.11/attachments/tests/test_views.py 2023-04-20
09:53:39.000000000 +0200
@@ -1,6 +1,8 @@
import os
-
+import json
import mock
+
+from http import HTTPStatus
from django.urls import reverse
from ..models import Attachment
@@ -248,4 +250,24 @@
self.assertEqual(Attachment.objects.count(), 0)
self.assertEqual(
Attachment.objects.attachments_for_object(self.obj).count(), 0
+ )
+
+ def test_form_errors_are_returned_as_json(self):
+ self.client.login(**self.cred_jon)
+ response = self._upload_testfile(
+ file_content=b"<xml>this is not allowed</xml>",
+ HTTP_X_RETURN_FORM_ERRORS=True,
+ )
+
+ self.assertEqual(response.status_code, HTTPStatus.BAD_REQUEST)
+ self.assertEqual(response.headers.get("Content-Type"),
"application/json")
+
+ # this should be a dict
+ errors = json.loads(response.content)
+ # note: field errors are a list of string messages
+ self.assertEqual(errors["attachment_file"], ["XML is forbidden"])
+
+ self.assertEqual(Attachment.objects.count(), 0)
+ self.assertEqual(
+ Attachment.objects.attachments_for_object(self.obj).count(), 0
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-attachments-1.10/attachments/views.py
new/django-attachments-1.11/attachments/views.py
--- old/django-attachments-1.10/attachments/views.py 2023-03-11
20:52:08.000000000 +0100
+++ new/django-attachments-1.11/attachments/views.py 2023-04-20
09:53:39.000000000 +0200
@@ -2,11 +2,12 @@
import os
+from http import HTTPStatus
from django.apps import apps
from django.conf import settings
from django.contrib import messages
from django.contrib.auth.decorators import login_required
-from django.http import HttpResponseRedirect
+from django.http import HttpResponseRedirect, JsonResponse
from django.shortcuts import get_object_or_404, render
from django.urls import reverse
from django.utils.translation import gettext
@@ -61,6 +62,9 @@
messages.success(request, gettext("Your attachment was uploaded."))
return HttpResponseRedirect(next_)
+ if request.headers.get("X-Return-Form-Errors", None):
+ return JsonResponse(form.errors, status=HTTPStatus.BAD_REQUEST)
+
template_context = {
"form": form,
"form_url": add_url_for_obj(obj),
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-attachments-1.10/django_attachments.egg-info/PKG-INFO
new/django-attachments-1.11/django_attachments.egg-info/PKG-INFO
--- old/django-attachments-1.10/django_attachments.egg-info/PKG-INFO
2023-04-14 19:32:47.000000000 +0200
+++ new/django-attachments-1.11/django_attachments.egg-info/PKG-INFO
2023-04-20 09:54:46.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: django-attachments
-Version: 1.10
+Version: 1.11
Summary: django-attachments is generic Django application to attach Files
(Attachments) to any model.
Home-page: https://github.com/bartTC/django-attachments
Author: Martin Mahner
@@ -291,8 +291,17 @@
Changelog:
==========
+v1.11 (2023-04-20)
+------------------
+
+- Return form errors as JSON from ``add_attachment()`` view
+ when the ``X-Return-Form-Errors`` request header is present.
+ Response code is 400 - BAD REQUEST because this is a client
+ error.
+
+
v1.10 (2023-04-14)
--------------------
+------------------
- Support custom form validators via ``AppConfig.attachment_validators``
- Remove quotes from "attachment_list" (Aaron C. de Bruyn)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-attachments-1.10/setup.cfg
new/django-attachments-1.11/setup.cfg
--- old/django-attachments-1.10/setup.cfg 2023-04-14 19:32:47.554861800
+0200
+++ new/django-attachments-1.11/setup.cfg 2023-04-20 09:54:47.045522000
+0200
@@ -1,6 +1,6 @@
[metadata]
name = django-attachments
-version = 1.10
+version = 1.11
description = django-attachments is generic Django application to attach Files
(Attachments) to any model.
long_description = file: README.rst, CHANGELOG.rst
author = Martin Mahner