Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-django-eremaea2 for openSUSE:Factory checked in at 2021-12-26 15:30:39 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-django-eremaea2 (Old) and /work/SRC/openSUSE:Factory/.python-django-eremaea2.new.2520 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-django-eremaea2" Sun Dec 26 15:30:39 2021 rev:3 rq:942626 version:2.0.17 Changes: -------- --- /work/SRC/openSUSE:Factory/python-django-eremaea2/python-django-eremaea2.changes 2020-12-02 13:58:20.389808627 +0100 +++ /work/SRC/openSUSE:Factory/.python-django-eremaea2.new.2520/python-django-eremaea2.changes 2021-12-26 15:30:40.855368154 +0100 @@ -1,0 +2,11 @@ +Sun Dec 26 12:48:57 UTC 2021 - Matwey Kornilov <matwey.korni...@gmail.com> + +- Version 2.0.17 + - Fix Django4 build + +------------------------------------------------------------------- +Sun Dec 26 07:10:00 UTC 2021 - John Vandenberg <jay...@gmail.com> + +- Use django-codemod to make test suite Django 4 compatible + +------------------------------------------------------------------- Old: ---- django-eremaea2-2.0.16.tar.gz New: ---- django-eremaea2-2.0.17.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-django-eremaea2.spec ++++++ --- /var/tmp/diff_new_pack.voQVkc/_old 2021-12-26 15:30:41.331368377 +0100 +++ /var/tmp/diff_new_pack.voQVkc/_new 2021-12-26 15:30:41.335368379 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-django-eremaea2 # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -20,7 +20,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-django-eremaea2 -Version: 2.0.16 +Version: 2.0.17 Release: 0 Summary: A simple Django application to store and show webcam snapshots License: BSD-2-Clause @@ -34,6 +34,8 @@ BuildRequires: %{python_module django-dj-inmemorystorage} BuildRequires: %{python_module djangorestframework >= 3.7.0} BuildRequires: %{python_module mock} +# python-magic is actual pypi name +BuildRequires: %{python_module python-magic} BuildRequires: %{python_module requests-mock} BuildRequires: %{python_module requests-toolbelt} BuildRequires: %{python_module requests} @@ -47,6 +49,7 @@ Requires: python-Django >= 1.10 Requires: python-cmdln Requires: python-djangorestframework >= 3.7.0 +Requires: python-magic Requires: python-requests Requires: python-requests-toolbelt Requires: python-six ++++++ django-eremaea2-2.0.16.tar.gz -> django-eremaea2-2.0.17.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-eremaea2-2.0.16/PKG-INFO new/django-eremaea2-2.0.17/PKG-INFO --- old/django-eremaea2-2.0.16/PKG-INFO 2020-12-01 04:36:37.000000000 +0100 +++ new/django-eremaea2-2.0.17/PKG-INFO 2021-12-26 13:45:36.355461600 +0100 @@ -1,86 +1,11 @@ Metadata-Version: 2.1 Name: django-eremaea2 -Version: 2.0.16 +Version: 2.0.17 Summary: A simple Django application to store and show webcam snapshots Home-page: https://github.com/matwey/django-eremaea2 Author: Matwey V. Kornilov Author-email: matwey.korni...@gmail.com License: BSD-2-Clause -Description: # django-eremaea2 - - [](https://travis-ci.org/matwey/django-eremaea2) - [](https://badge.fury.io/py/django-eremaea2) - - django-eremaea2 is a simple [Django] application to store and manage webcam image snapshots. - The application is built on top of [django-rest-framework] and provides REST API to access the files. - - There are three kind of resources available through REST API interface. - A *collection* is a collection of *snapshots*. - A *snapshot* is image file in essence. - For any *snapshot* there is a *retention policy* associated with to specify how long store the file. - - ## Installation - - The following prerequisites are required to operate django-eremaea2: - * [django-rest-framework] - powerful and flexible toolkit that makes it easy to build Web APIs. - * [dj-inmemorystorage] - a non-persistent in-memory data storage backend for Django (required for testing). - - To use django-eremaea2 in your django project, include the following code into your ```settings.py```: - ``` - INSTALLED_APPS = ( - #... - 'rest_framework', - 'eremaea', - ) - ``` - - Into your ```urls.py``` you have to add the following: - ``` - urlpatterns = patterns('', - #... - url(r'^eremaea/', include('eremaea.urls')), - ) - ``` - - ## Configuration - The whole configuration is stored into the project database, there is not separate dedicated config file. - - The ```RetentionPolicy``` model has two parameters: a lookup field ```name``` and ```duration``` that specifies time-to-live for associated objects. - To perform actual cleanup a POST request to the endpoint ```http://example.com/eremaea/retention_policies/{name}/purge``` is required. - The ```Collection``` model has two parameters: a lookup field ```name``` and ```default_retention_policy```. - The ```Snapshot``` model has the following field: associated ```collection``` and ```retention_policy```, ```file``` object, and auto-now ```date```. - New images are uploaded by POST request to the endpoint ```http://example.com/eremaea/snapshots/?collection=collection_name&retention_policy=retention_policy_name```. - The latest query parameter is optional one. - - The other ways to configure the application are Django fixtures, Django admin interface, [django-rest-framework] web browsable interface, and REST API itself. - - ## Authentication and permissions - You may utilise all possible options provided by [django-rest-framework]. See [Tutorial](http://www.django-rest-framework.org/tutorial/4-authentication-and-permissions/) for reference. - - ## Caching - You may utilise all caching mechanisms provided by [Django] framework. See [Django's cache framework](https://docs.djangoproject.com/en/dev/topics/cache/). - - ## Feedback - If you have any questions, issues, or pull-requests, you are welcome to use GitHub infrastructure. - - ## License - - Copyright (c) 2016, Matwey V. Kornilov - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - [Django]:https://www.djangoproject.com/ - [django-rest-framework]:http://www.django-rest-framework.org - [dj-inmemorystorage]:https://pypi.python.org/pypi/dj-inmemorystorage - Platform: UNKNOWN Classifier: Environment :: Web Environment Classifier: Framework :: Django @@ -92,3 +17,81 @@ Classifier: Topic :: Internet :: WWW/HTTP Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content Description-Content-Type: text/markdown +License-File: LICENSE + +# django-eremaea2 + +[](https://github.com/matwey/django-eremaea2/actions/workflows/django.yml) +[](https://badge.fury.io/py/django-eremaea2) + +django-eremaea2 is a simple [Django] application to store and manage webcam image snapshots. +The application is built on top of [django-rest-framework] and provides REST API to access the files. + +There are three kind of resources available through REST API interface. +A *collection* is a collection of *snapshots*. +A *snapshot* is image file in essence. +For any *snapshot* there is a *retention policy* associated with to specify how long store the file. + +## Installation + +The following prerequisites are required to operate django-eremaea2: +* [django-rest-framework] - powerful and flexible toolkit that makes it easy to build Web APIs. +* [dj-inmemorystorage] - a non-persistent in-memory data storage backend for Django (required for testing). + +To use django-eremaea2 in your django project, include the following code into your ```settings.py```: +``` +INSTALLED_APPS = ( + #... + 'rest_framework', + 'eremaea', +) +``` + +Into your ```urls.py``` you have to add the following: +``` +urlpatterns = patterns('', + #... + url(r'^eremaea/', include('eremaea.urls')), +) +``` + +## Configuration +The whole configuration is stored into the project database, there is not separate dedicated config file. + +The ```RetentionPolicy``` model has two parameters: a lookup field ```name``` and ```duration``` that specifies time-to-live for associated objects. +To perform actual cleanup a POST request to the endpoint ```http://example.com/eremaea/retention_policies/{name}/purge``` is required. +The ```Collection``` model has two parameters: a lookup field ```name``` and ```default_retention_policy```. +The ```Snapshot``` model has the following field: associated ```collection``` and ```retention_policy```, ```file``` object, and auto-now ```date```. +New images are uploaded by POST request to the endpoint ```http://example.com/eremaea/snapshots/?collection=collection_name&retention_policy=retention_policy_name```. +The latest query parameter is optional one. + +The other ways to configure the application are Django fixtures, Django admin interface, [django-rest-framework] web browsable interface, and REST API itself. + +## Authentication and permissions +You may utilise all possible options provided by [django-rest-framework]. See [Tutorial](http://www.django-rest-framework.org/tutorial/4-authentication-and-permissions/) for reference. + +## Caching +You may utilise all caching mechanisms provided by [Django] framework. See [Django's cache framework](https://docs.djangoproject.com/en/dev/topics/cache/). + +## Feedback +If you have any questions, issues, or pull-requests, you are welcome to use GitHub infrastructure. + +## License + +Copyright (c) 2016, Matwey V. Kornilov + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +[Django]:https://www.djangoproject.com/ +[django-rest-framework]:http://www.django-rest-framework.org +[dj-inmemorystorage]:https://pypi.python.org/pypi/dj-inmemorystorage + + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-eremaea2-2.0.16/README.md new/django-eremaea2-2.0.17/README.md --- old/django-eremaea2-2.0.16/README.md 2020-12-01 04:36:06.000000000 +0100 +++ new/django-eremaea2-2.0.17/README.md 2021-12-26 13:45:26.000000000 +0100 @@ -1,6 +1,6 @@ # django-eremaea2 -[](https://travis-ci.org/matwey/django-eremaea2) +[](https://github.com/matwey/django-eremaea2/actions/workflows/django.yml) [](https://badge.fury.io/py/django-eremaea2) django-eremaea2 is a simple [Django] application to store and manage webcam image snapshots. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-eremaea2-2.0.16/django_eremaea2.egg-info/PKG-INFO new/django-eremaea2-2.0.17/django_eremaea2.egg-info/PKG-INFO --- old/django-eremaea2-2.0.16/django_eremaea2.egg-info/PKG-INFO 2020-12-01 04:36:37.000000000 +0100 +++ new/django-eremaea2-2.0.17/django_eremaea2.egg-info/PKG-INFO 2021-12-26 13:45:36.000000000 +0100 @@ -1,86 +1,11 @@ Metadata-Version: 2.1 Name: django-eremaea2 -Version: 2.0.16 +Version: 2.0.17 Summary: A simple Django application to store and show webcam snapshots Home-page: https://github.com/matwey/django-eremaea2 Author: Matwey V. Kornilov Author-email: matwey.korni...@gmail.com License: BSD-2-Clause -Description: # django-eremaea2 - - [](https://travis-ci.org/matwey/django-eremaea2) - [](https://badge.fury.io/py/django-eremaea2) - - django-eremaea2 is a simple [Django] application to store and manage webcam image snapshots. - The application is built on top of [django-rest-framework] and provides REST API to access the files. - - There are three kind of resources available through REST API interface. - A *collection* is a collection of *snapshots*. - A *snapshot* is image file in essence. - For any *snapshot* there is a *retention policy* associated with to specify how long store the file. - - ## Installation - - The following prerequisites are required to operate django-eremaea2: - * [django-rest-framework] - powerful and flexible toolkit that makes it easy to build Web APIs. - * [dj-inmemorystorage] - a non-persistent in-memory data storage backend for Django (required for testing). - - To use django-eremaea2 in your django project, include the following code into your ```settings.py```: - ``` - INSTALLED_APPS = ( - #... - 'rest_framework', - 'eremaea', - ) - ``` - - Into your ```urls.py``` you have to add the following: - ``` - urlpatterns = patterns('', - #... - url(r'^eremaea/', include('eremaea.urls')), - ) - ``` - - ## Configuration - The whole configuration is stored into the project database, there is not separate dedicated config file. - - The ```RetentionPolicy``` model has two parameters: a lookup field ```name``` and ```duration``` that specifies time-to-live for associated objects. - To perform actual cleanup a POST request to the endpoint ```http://example.com/eremaea/retention_policies/{name}/purge``` is required. - The ```Collection``` model has two parameters: a lookup field ```name``` and ```default_retention_policy```. - The ```Snapshot``` model has the following field: associated ```collection``` and ```retention_policy```, ```file``` object, and auto-now ```date```. - New images are uploaded by POST request to the endpoint ```http://example.com/eremaea/snapshots/?collection=collection_name&retention_policy=retention_policy_name```. - The latest query parameter is optional one. - - The other ways to configure the application are Django fixtures, Django admin interface, [django-rest-framework] web browsable interface, and REST API itself. - - ## Authentication and permissions - You may utilise all possible options provided by [django-rest-framework]. See [Tutorial](http://www.django-rest-framework.org/tutorial/4-authentication-and-permissions/) for reference. - - ## Caching - You may utilise all caching mechanisms provided by [Django] framework. See [Django's cache framework](https://docs.djangoproject.com/en/dev/topics/cache/). - - ## Feedback - If you have any questions, issues, or pull-requests, you are welcome to use GitHub infrastructure. - - ## License - - Copyright (c) 2016, Matwey V. Kornilov - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - [Django]:https://www.djangoproject.com/ - [django-rest-framework]:http://www.django-rest-framework.org - [dj-inmemorystorage]:https://pypi.python.org/pypi/dj-inmemorystorage - Platform: UNKNOWN Classifier: Environment :: Web Environment Classifier: Framework :: Django @@ -92,3 +17,81 @@ Classifier: Topic :: Internet :: WWW/HTTP Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content Description-Content-Type: text/markdown +License-File: LICENSE + +# django-eremaea2 + +[](https://github.com/matwey/django-eremaea2/actions/workflows/django.yml) +[](https://badge.fury.io/py/django-eremaea2) + +django-eremaea2 is a simple [Django] application to store and manage webcam image snapshots. +The application is built on top of [django-rest-framework] and provides REST API to access the files. + +There are three kind of resources available through REST API interface. +A *collection* is a collection of *snapshots*. +A *snapshot* is image file in essence. +For any *snapshot* there is a *retention policy* associated with to specify how long store the file. + +## Installation + +The following prerequisites are required to operate django-eremaea2: +* [django-rest-framework] - powerful and flexible toolkit that makes it easy to build Web APIs. +* [dj-inmemorystorage] - a non-persistent in-memory data storage backend for Django (required for testing). + +To use django-eremaea2 in your django project, include the following code into your ```settings.py```: +``` +INSTALLED_APPS = ( + #... + 'rest_framework', + 'eremaea', +) +``` + +Into your ```urls.py``` you have to add the following: +``` +urlpatterns = patterns('', + #... + url(r'^eremaea/', include('eremaea.urls')), +) +``` + +## Configuration +The whole configuration is stored into the project database, there is not separate dedicated config file. + +The ```RetentionPolicy``` model has two parameters: a lookup field ```name``` and ```duration``` that specifies time-to-live for associated objects. +To perform actual cleanup a POST request to the endpoint ```http://example.com/eremaea/retention_policies/{name}/purge``` is required. +The ```Collection``` model has two parameters: a lookup field ```name``` and ```default_retention_policy```. +The ```Snapshot``` model has the following field: associated ```collection``` and ```retention_policy```, ```file``` object, and auto-now ```date```. +New images are uploaded by POST request to the endpoint ```http://example.com/eremaea/snapshots/?collection=collection_name&retention_policy=retention_policy_name```. +The latest query parameter is optional one. + +The other ways to configure the application are Django fixtures, Django admin interface, [django-rest-framework] web browsable interface, and REST API itself. + +## Authentication and permissions +You may utilise all possible options provided by [django-rest-framework]. See [Tutorial](http://www.django-rest-framework.org/tutorial/4-authentication-and-permissions/) for reference. + +## Caching +You may utilise all caching mechanisms provided by [Django] framework. See [Django's cache framework](https://docs.djangoproject.com/en/dev/topics/cache/). + +## Feedback +If you have any questions, issues, or pull-requests, you are welcome to use GitHub infrastructure. + +## License + +Copyright (c) 2016, Matwey V. Kornilov + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +[Django]:https://www.djangoproject.com/ +[django-rest-framework]:http://www.django-rest-framework.org +[dj-inmemorystorage]:https://pypi.python.org/pypi/dj-inmemorystorage + + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-eremaea2-2.0.16/eremaea/models.py new/django-eremaea2-2.0.17/eremaea/models.py --- old/django-eremaea2-2.0.16/eremaea/models.py 2020-12-01 04:36:06.000000000 +0100 +++ new/django-eremaea2-2.0.17/eremaea/models.py 2021-12-26 13:45:26.000000000 +0100 @@ -3,16 +3,31 @@ from django.utils import timezone from os import path from eremaea.conf import settings +import magic import mimetypes +def guess_extension(instance, filename): + content_type = getattr(instance.file.file, 'content_type', None) + _, ext = path.splitext(filename) + + if content_type is not None: + valid_exts = mimetypes.guess_all_extensions(content_type) + if ext in valid_exts: + return ext + elif len(valid_exts): + return valid_exts[0] + + if not ext: + content_type = magic.from_buffer(next(instance.file.file.chunks()), mime=True) + return mimetypes.guess_extension(content_type) + + return ext + def snapshot_upload_to(instance, filename): prefix = settings.PATH - (mimetype, encoding) = mimetypes.guess_type(filename) - if not mimetype and hasattr(instance.file.file, 'content_type'): - mimetype = instance.file.file.content_type - ext = mimetypes.guess_extension(mimetype) collection = instance.collection.name date = instance.date.strftime("%Y-%m-%d-%H-%M-%S") + ext = guess_extension(instance, filename) newfilename = "{0}-{1}{2}".format(collection, date, ext) return path.join(prefix, collection, newfilename) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-eremaea2-2.0.16/eremaea/urls.py new/django-eremaea2-2.0.17/eremaea/urls.py --- old/django-eremaea2-2.0.16/eremaea/urls.py 2020-12-01 04:36:06.000000000 +0100 +++ new/django-eremaea2-2.0.17/eremaea/urls.py 2021-12-26 13:45:26.000000000 +0100 @@ -1,4 +1,4 @@ -from django.conf.urls import url, include +import django from eremaea import views from rest_framework.routers import DefaultRouter @@ -7,6 +7,11 @@ router.register(r'snapshots', views.SnapshotViewSet) router.register(r'retention_policies', views.RetentionPolicyViewSet, basename='retention_policy') +if django.VERSION[0] > 1: + from django.urls import include, re_path +else: + from django.conf.urls import include, url as re_path + urlpatterns = [ - url(r'^', include(router.urls)), + re_path(r'^', include(router.urls)), ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-eremaea2-2.0.16/setup.py new/django-eremaea2-2.0.17/setup.py --- old/django-eremaea2-2.0.16/setup.py 2020-12-01 04:36:06.000000000 +0100 +++ new/django-eremaea2-2.0.17/setup.py 2021-12-26 13:45:26.000000000 +0100 @@ -9,7 +9,7 @@ setup( name='django-eremaea2', - version='2.0.16', + version='2.0.17', packages=['eremaea','eremaea.ctl','eremaea.migrations'], entry_points={'console_scripts': [ 'eremaeactl = eremaea.ctl.commandline:execute_from_commandline', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-eremaea2-2.0.16/tests/snapshot.py new/django-eremaea2-2.0.17/tests/snapshot.py --- old/django-eremaea2-2.0.16/tests/snapshot.py 2020-12-01 04:36:06.000000000 +0100 +++ new/django-eremaea2-2.0.17/tests/snapshot.py 2021-12-26 13:45:26.000000000 +0100 @@ -3,6 +3,8 @@ from rest_framework import status from rest_framework.reverse import reverse from rest_framework.test import APIClient +from mimetypes import guess_all_extensions +from os.path import splitext from eremaea import models from datetime import timedelta from six.moves.urllib.parse import urlparse @@ -47,6 +49,31 @@ url = reverse('snapshot-list') + '?collection=mycol' response = self.client.post(url, content, content_type='image/jpeg', HTTP_CONTENT_DISPOSITION='attachment; filename=upload.jpg') self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + def test_snapshot_create5(self): + url = reverse('snapshot-list') + '?collection=mycol' + response = self.client.post(url, {}, content_type='image/jpeg', HTTP_CONTENT_DISPOSITION='attachment; filename=upload.png') + self.assertEqual(response.status_code, status.HTTP_201_CREATED) + snapshot = models.Snapshot.objects.all()[0] + self.assertIn(splitext(snapshot.file.name)[1], guess_all_extensions('image/jpeg')) + def test_snapshot_create6(self): + url = reverse('snapshot-list') + '?collection=mycol' + response = self.client.post(url, {}, content_type='image/jpeg', HTTP_CONTENT_DISPOSITION='attachment; filename=upload.jpg') + self.assertEqual(response.status_code, status.HTTP_201_CREATED) + snapshot = models.Snapshot.objects.all()[0] + self.assertEqual(splitext(snapshot.file.name)[1], ".jpg") + def test_snapshot_create7(self): + url = reverse('snapshot-list') + '?collection=mycol' + response = self.client.post(url, {}, HTTP_CONTENT_DISPOSITION='attachment; filename=upload.png') + self.assertEqual(response.status_code, status.HTTP_201_CREATED) + snapshot = models.Snapshot.objects.all()[0] + self.assertEqual(splitext(snapshot.file.name)[1], ".png") + def test_snapshot_create8(self): + content = b'\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\x00\x00\x01\x00\x00\x00\x01\x08\x04\x00\x00\x00\xb5\x1c\x0c\x02\x00\x00\x00\x0b\x49\x44\x41\x54\x78\x9c\x63\x62\x60\x00\x00\x00\x09\x00\x03\x19\x11\xd9\xe4\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82' + url = reverse('snapshot-list') + '?collection=mycol' + response = self.client.post(url, content, content_type='application/x-null', HTTP_CONTENT_DISPOSITION='attachment; filename=upload') + self.assertEqual(response.status_code, status.HTTP_201_CREATED) + snapshot = models.Snapshot.objects.all()[0] + self.assertEqual(splitext(snapshot.file.name)[1], ".png") def test_snapshot_get1(self): file = ContentFile(b"123") file.name = "file.jpg" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-eremaea2-2.0.16/tests/urls.py new/django-eremaea2-2.0.17/tests/urls.py --- old/django-eremaea2-2.0.16/tests/urls.py 2020-12-01 04:36:06.000000000 +0100 +++ new/django-eremaea2-2.0.17/tests/urls.py 2021-12-26 13:45:26.000000000 +0100 @@ -1,5 +1,10 @@ -from django.conf.urls import include, url +import django + +if django.VERSION[0] > 1: + from django.urls import include, re_path +else: + from django.conf.urls import include, url as re_path urlpatterns = [ - url(r'', include('eremaea.urls')), + re_path(r'', include('eremaea.urls')), ]