photo-objects 0.8.0__py3-none-any.whl → 0.8.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -57,10 +57,7 @@ def get_next_photo_change_request(request: HttpRequest):
57
57
 
58
58
 
59
59
  def get_expected_photo_change_requests(request: HttpRequest):
60
- check_permissions(
61
- request,
62
- 'photo_objects.change_photo',
63
- 'photo_objects.delete_photochangerequest')
60
+ check_permissions(request, 'photo_objects.add_photochangerequest')
64
61
 
65
62
  photos = Photo.objects.filter(
66
63
  alt_text="",
@@ -2,13 +2,13 @@ import json
2
2
  from time import sleep
3
3
 
4
4
  from django.contrib.auth import get_user_model
5
- from django.contrib.auth.models import Permission
6
5
 
7
6
  from photo_objects.django.models import Album
8
7
  from photo_objects.img import utcnow
9
8
 
10
9
  from .utils import (
11
10
  TestCase,
11
+ add_permissions,
12
12
  parse_timestamps,
13
13
  create_dummy_photo,
14
14
  open_test_photo
@@ -101,17 +101,14 @@ class AlbumViewTests(TestCase):
101
101
 
102
102
  has_permission = user.objects.create_user(
103
103
  username='has_permission', password='test')
104
- permissions = [
104
+ add_permissions(
105
+ has_permission,
105
106
  'add_album',
106
107
  'add_photo',
107
108
  'change_album',
108
109
  'delete_album',
109
- 'delete_photo']
110
- for permission in permissions:
111
- has_permission.user_permissions.add(
112
- Permission.objects.get(
113
- content_type__app_label='photo_objects',
114
- codename=permission))
110
+ 'delete_photo',
111
+ )
115
112
 
116
113
  def test_post_album_with_non_json_data_fails(self):
117
114
  login_success = self.client.login(
@@ -5,7 +5,6 @@ from time import sleep
5
5
  from unittest import mock
6
6
 
7
7
  from django.contrib.auth import get_user_model
8
- from django.contrib.auth.models import Permission
9
8
  from PIL import Image
10
9
  from urllib3.exceptions import HTTPError
11
10
 
@@ -13,7 +12,7 @@ from photo_objects.django.models import Album
13
12
  from photo_objects.img import utcnow
14
13
  from photo_objects.django.objsto import get_photo
15
14
 
16
- from .utils import TestCase, open_test_photo, parse_timestamps
15
+ from .utils import TestCase, add_permissions, open_test_photo, parse_timestamps
17
16
 
18
17
 
19
18
  class PhotoViewTests(TestCase):
@@ -23,16 +22,13 @@ class PhotoViewTests(TestCase):
23
22
 
24
23
  has_permission = user.objects.create_user(
25
24
  username='has_permission', password='test')
26
- permissions = [
25
+ add_permissions(
26
+ has_permission,
27
27
  'add_photo',
28
28
  'change_album',
29
29
  'change_photo',
30
- 'delete_photo']
31
- for permission in permissions:
32
- has_permission.user_permissions.add(
33
- Permission.objects.get(
34
- content_type__app_label='photo_objects',
35
- codename=permission))
30
+ 'delete_photo',
31
+ )
36
32
 
37
33
  Album.objects.create(
38
34
  key="test-photo-a",
@@ -1,10 +1,9 @@
1
1
  from django.contrib.auth import get_user_model
2
- from django.contrib.auth.models import Permission
3
2
 
4
3
  from photo_objects.django.models import Album
5
4
 
6
5
 
7
- from .utils import TestCase, create_dummy_photo
6
+ from .utils import TestCase, add_permissions, create_dummy_photo
8
7
 
9
8
 
10
9
  TEST_PREFIX = "test-photo-change-request"
@@ -27,15 +26,7 @@ class PhotoChangeRequestTests(TestCase):
27
26
 
28
27
  has_permission = user.objects.create_user(
29
28
  username='has_permission', password='test')
30
- permissions = [
31
- 'change_photo',
32
- 'delete_photochangerequest',
33
- ]
34
- for permission in permissions:
35
- has_permission.user_permissions.add(
36
- Permission.objects.get(
37
- content_type__app_label='photo_objects',
38
- codename=permission))
29
+ add_permissions(has_permission, 'add_photochangerequest')
39
30
 
40
31
  self.private_album = Album.objects.create(
41
32
  key=f"{TEST_PREFIX}-private", visibility=Album.Visibility.PRIVATE)
@@ -64,13 +55,13 @@ class PhotoChangeRequestTests(TestCase):
64
55
  self.assertEqual(len(photos), expected_count)
65
56
 
66
57
  def test_create_photo_change_requests(self):
67
- self.client.login(username="superuser", password='test')
58
+ self.client.login(username="has_permission", password='test')
68
59
 
69
60
  response = self.client.get(
70
61
  '/api/photo-change-requests/expected')
71
62
  self.assertEqual(response.status_code, 200)
72
63
  photos = _filter_by_test_prefix(response.json())
73
- self.assertEqual(len(photos), 3)
64
+ self.assertEqual(len(photos), 2)
74
65
 
75
66
  response = self.client.post(
76
67
  f'/api/albums/{TEST_PREFIX}-private/photos/001.jpg/change-requests', # noqa: E501
@@ -88,4 +79,4 @@ class PhotoChangeRequestTests(TestCase):
88
79
  '/api/photo-change-requests/expected')
89
80
  self.assertEqual(response.status_code, 200)
90
81
  photos = _filter_by_test_prefix(response.json())
91
- self.assertEqual(len(photos), 2)
82
+ self.assertEqual(len(photos), 1)
@@ -5,6 +5,7 @@ import shutil
5
5
  import tempfile
6
6
 
7
7
  from django.conf import settings
8
+ from django.contrib.auth.models import Permission
8
9
  from django.core.management import call_command
9
10
  from django.test import TestCase as DjangoTestCase, override_settings
10
11
  from django.utils import timezone
@@ -16,6 +17,14 @@ from photo_objects.django.models import Album, Photo
16
17
  from photo_objects.django.objsto import _objsto_access
17
18
 
18
19
 
20
+ def add_permissions(user, *permissions):
21
+ for permission in permissions:
22
+ user.user_permissions.add(
23
+ Permission.objects.get(
24
+ content_type__app_label='photo_objects',
25
+ codename=permission))
26
+
27
+
19
28
  def open_test_photo(filename):
20
29
  path = os.path.join(
21
30
  os.path.dirname(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: photo-objects
3
- Version: 0.8.0
3
+ Version: 0.8.1
4
4
  Summary: Application for storing photos in S3 compatible object-storage.
5
5
  Author: Toni Kangas
6
6
  License: MIT License
@@ -17,7 +17,7 @@ photo_objects/django/api/__init__.py,sha256=inUPmjlTAawHwco4NzjwNEVNnf9c_IIwLH5Z
17
17
  photo_objects/django/api/album.py,sha256=CJDeGLCuYoxGUDcjssZRpFnToxG_KVE9Ii7NduFW2ks,2003
18
18
  photo_objects/django/api/auth.py,sha256=lS0S1tMVH2uN30g4jlixklv3eMnQ2FbQVQvuRXeMGYo,1420
19
19
  photo_objects/django/api/photo.py,sha256=-lo1g6jfBr884wy-WV2DAEPxzH9V-tFUTRtitmA6i28,4471
20
- photo_objects/django/api/photo_change_request.py,sha256=GOaUttPCdm0EJO-8608p1odoliWha5qVgtiha51_vhs,3133
20
+ photo_objects/django/api/photo_change_request.py,sha256=v94RA7SUM60tC9mIZdz8HppbNKfHWeTFNPr_BPw3pys,3075
21
21
  photo_objects/django/api/utils.py,sha256=8r51YgFgKPD05Zjzhstl4jlQ4JM8DtsxUyAzhjXi5Pk,5567
22
22
  photo_objects/django/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  photo_objects/django/management/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -33,15 +33,15 @@ photo_objects/django/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm
33
33
  photo_objects/django/templatetags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
34
  photo_objects/django/templatetags/photo_objects_extras.py,sha256=1L6wweVA96rTWVXqgyf8gSey1wQKi01h6sqv9kZeTIY,1399
35
35
  photo_objects/django/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
- photo_objects/django/tests/test_album.py,sha256=yjxP_M0bddS9Xpg1d1Wk5OyJsmxmkdYuljca4oFJSzc,13316
36
+ photo_objects/django/tests/test_album.py,sha256=Uik36QbhaEojed6g862xqj8YI0d2963StU-lOpqMqAc,13095
37
37
  photo_objects/django/tests/test_auth.py,sha256=hgr1UMVLvSI1x5zY7wTEXSBKfM5E_sNMIFlx8mVWYPY,3928
38
38
  photo_objects/django/tests/test_commands.py,sha256=e3lE1ZhFR39WIq2VSKDNcQHUkSJqSWDYuAcAfu29svs,2955
39
39
  photo_objects/django/tests/test_img.py,sha256=HEAWcr5fpTkzePkhoQ4YrWsDO9TvFOr7my_0LqVbaO4,829
40
40
  photo_objects/django/tests/test_og_meta.py,sha256=Kk5a9KvE88KZ60gLqXSe6rTz5YU-gdjteksYolHd-nw,1804
41
- photo_objects/django/tests/test_photo.py,sha256=aZCZw7PIXIfIYX3q1lUxn8C53mLRBNK0qp18t7X4ZQ4,13696
42
- photo_objects/django/tests/test_photo_change_requests.py,sha256=zYsiRfWuUncrd3QdcrsD9B3XoYTdmAJ0DVh7a_vHbUs,3374
41
+ photo_objects/django/tests/test_photo.py,sha256=JWXN3fF2VtuByMKm2o5b19HnxwDr6ecRwuGzgc5RsBw,13471
42
+ photo_objects/django/tests/test_photo_change_requests.py,sha256=Ld5ytqxxZiEWrqfX8htJ6-5ARU7tqTYD-iUhb7EMcnU,3078
43
43
  photo_objects/django/tests/test_utils.py,sha256=zBLv8lkvcLMCaH4D6GR1KZqUe-rPowhcBkQX19-Kshs,2007
44
- photo_objects/django/tests/utils.py,sha256=s_3hzQEY4tdja_8406s_SQyRC6fCYI_MBPqvFjC8fB4,4345
44
+ photo_objects/django/tests/utils.py,sha256=7oAwFotAFzxIE2YFGysj_a_y-u7E7Z7_K7vl7ycUAzM,4639
45
45
  photo_objects/django/views/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
46
  photo_objects/django/views/utils.py,sha256=AjJK5r5HmTF63E9Q4W3pKggDESuhNXUvbROpS8m70KM,1319
47
47
  photo_objects/django/views/api/__init__.py,sha256=GgywMJMSFmP5aoMEaYut5V666zachd5YFQIDBMr5znU,188
@@ -56,8 +56,8 @@ photo_objects/django/views/ui/photo.py,sha256=flwcET5nSChzfyAEWRTUlklTW2o64przNX
56
56
  photo_objects/django/views/ui/photo_change_request.py,sha256=eaYGXFqtHj8qonDAmPyn4nrEHkL13EBD-1s8Phs0XP4,2098
57
57
  photo_objects/django/views/ui/users.py,sha256=nb73cnzuV98QkJb0j8F2hqPgOGFIWpUFTFu6dXMeVwM,722
58
58
  photo_objects/django/views/ui/utils.py,sha256=YV_YcUbX-zUkdFnBlezPChR6aPDhZJ9loSOHBSzF6Cc,273
59
- photo_objects-0.8.0.dist-info/licenses/LICENSE,sha256=V3w6hTjXfP65F4r_mejveHcV5igHrblxao3-2RlfVlA,1068
60
- photo_objects-0.8.0.dist-info/METADATA,sha256=BnYleSRms4H1v4kO5BAb4Vt5zaMitpBTSyGr3xZi5wg,3605
61
- photo_objects-0.8.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
62
- photo_objects-0.8.0.dist-info/top_level.txt,sha256=SZeL8mhf-WMGdhRtTGFvZc3aIRBboQls9O0cFDMGdQ0,14
63
- photo_objects-0.8.0.dist-info/RECORD,,
59
+ photo_objects-0.8.1.dist-info/licenses/LICENSE,sha256=V3w6hTjXfP65F4r_mejveHcV5igHrblxao3-2RlfVlA,1068
60
+ photo_objects-0.8.1.dist-info/METADATA,sha256=ieM9ijgsXYCJSUp3MCGrcHgcq9lz9AAv6MwlaNlqWDY,3605
61
+ photo_objects-0.8.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
62
+ photo_objects-0.8.1.dist-info/top_level.txt,sha256=SZeL8mhf-WMGdhRtTGFvZc3aIRBboQls9O0cFDMGdQ0,14
63
+ photo_objects-0.8.1.dist-info/RECORD,,