photo-objects 0.9.2__tar.gz → 0.9.4__tar.gz
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.
- {photo_objects-0.9.2 → photo_objects-0.9.4}/PKG-INFO +2 -2
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/api/backup.py +19 -9
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/objsto.py +44 -23
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects.egg-info/PKG-INFO +2 -2
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects.egg-info/requires.txt +1 -1
- {photo_objects-0.9.2 → photo_objects-0.9.4}/pyproject.toml +2 -2
- {photo_objects-0.9.2 → photo_objects-0.9.4}/LICENSE +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/README.md +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/__init__.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/config.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/__init__.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/admin.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/api/__init__.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/api/album.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/api/auth.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/api/photo.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/api/photo_change_request.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/api/utils.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/apps.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/conf.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/context_processors.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/forms.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/management/__init__.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/management/commands/__init__.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/management/commands/clean-scaled-photos.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/management/commands/create-initial-admin-account.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/management/commands/restore-backup.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/migrations/0001_initial.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/migrations/0002_created_at_updated_at.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/migrations/0003_admin_visibility.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/migrations/0004_camera_setup_and_settings.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/migrations/0005_sitesettings.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/migrations/0006_photo_alt_text.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/migrations/0007_backup.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/migrations/__init__.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/models.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/signals.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/templatetags/__init__.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/templatetags/photo_objects_extras.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/tests/__init__.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/tests/test_album.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/tests/test_auth.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/tests/test_commands.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/tests/test_img.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/tests/test_og_meta.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/tests/test_photo.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/tests/test_photo_change_requests.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/tests/test_utils.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/tests/utils.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/urls.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/views/__init__.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/views/api/__init__.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/views/api/album.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/views/api/auth.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/views/api/photo.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/views/api/utils.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/views/ui/__init__.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/views/ui/album.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/views/ui/configuration.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/views/ui/photo.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/views/ui/photo_change_request.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/views/ui/users.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/views/ui/utils.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/views/utils.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/error.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/img.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/utils.py +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects.egg-info/SOURCES.txt +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects.egg-info/dependency_links.txt +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects.egg-info/top_level.txt +0 -0
- {photo_objects-0.9.2 → photo_objects-0.9.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: photo-objects
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.4
|
|
4
4
|
Summary: Application for storing photos in S3 compatible object-storage.
|
|
5
5
|
Author: Toni Kangas
|
|
6
6
|
License: MIT License
|
|
@@ -42,7 +42,7 @@ Requires-Python: >=3.10
|
|
|
42
42
|
Description-Content-Type: text/markdown
|
|
43
43
|
License-File: LICENSE
|
|
44
44
|
Requires-Dist: markdown~=3.7
|
|
45
|
-
Requires-Dist: minio
|
|
45
|
+
Requires-Dist: minio<7.2.19,>=7.2.0
|
|
46
46
|
Requires-Dist: pillow~=10.4
|
|
47
47
|
Dynamic: license-file
|
|
48
48
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from threading import Thread
|
|
2
|
+
|
|
1
3
|
from django.contrib.auth import get_user_model
|
|
2
4
|
from django.contrib.auth.models import Group, Permission
|
|
3
5
|
from django.contrib.sites.models import Site
|
|
@@ -56,18 +58,11 @@ def _group_dict(group: Group):
|
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
|
|
59
|
-
def
|
|
60
|
-
|
|
61
|
-
if get_backup_object(backup.id):
|
|
62
|
-
backup.status = "ready"
|
|
63
|
-
backup.save()
|
|
64
|
-
return
|
|
61
|
+
def _create_backup(backup_id: int):
|
|
62
|
+
backup = Backup.objects.get(id=backup_id)
|
|
65
63
|
|
|
66
64
|
user_model = get_user_model()
|
|
67
65
|
|
|
68
|
-
backup.status = "pending"
|
|
69
|
-
backup.save()
|
|
70
|
-
|
|
71
66
|
try:
|
|
72
67
|
albums = Album.objects.all()
|
|
73
68
|
for album in albums:
|
|
@@ -140,6 +135,21 @@ def create_backup(backup: Backup):
|
|
|
140
135
|
backup.save()
|
|
141
136
|
|
|
142
137
|
|
|
138
|
+
def create_backup(backup: Backup):
|
|
139
|
+
# Check if backup already exists
|
|
140
|
+
if get_backup_object(backup.id):
|
|
141
|
+
backup.status = "ready"
|
|
142
|
+
backup.save()
|
|
143
|
+
return
|
|
144
|
+
|
|
145
|
+
backup.status = "pending"
|
|
146
|
+
backup.save()
|
|
147
|
+
|
|
148
|
+
# Start creating backup in a separate thread
|
|
149
|
+
thread = Thread(target=_create_backup, args=(backup.id,))
|
|
150
|
+
thread.start()
|
|
151
|
+
|
|
152
|
+
|
|
143
153
|
def delete_backup(backup: Backup):
|
|
144
154
|
return delete_backup_objects(backup.id)
|
|
145
155
|
|
|
@@ -42,9 +42,9 @@ def _objsto_access() -> tuple[dict, Minio]:
|
|
|
42
42
|
)
|
|
43
43
|
|
|
44
44
|
return (conf, Minio(
|
|
45
|
-
conf.get('URL'),
|
|
46
|
-
conf.get('ACCESS_KEY'),
|
|
47
|
-
conf.get('SECRET_KEY'),
|
|
45
|
+
endpoint=conf.get('URL'),
|
|
46
|
+
access_key=conf.get('ACCESS_KEY'),
|
|
47
|
+
secret_key=conf.get('SECRET_KEY'),
|
|
48
48
|
http_client=http,
|
|
49
49
|
secure=conf.get('SECURE', True),
|
|
50
50
|
))
|
|
@@ -55,8 +55,8 @@ def _backup_access() -> tuple[Minio, str]:
|
|
|
55
55
|
bucket = conf.get('BACKUP_BUCKET', 'backups')
|
|
56
56
|
|
|
57
57
|
# TODO: move this to management command
|
|
58
|
-
if not client.bucket_exists(bucket):
|
|
59
|
-
client.make_bucket(bucket)
|
|
58
|
+
if not client.bucket_exists(bucket_name=bucket):
|
|
59
|
+
client.make_bucket(bucket_name=bucket)
|
|
60
60
|
|
|
61
61
|
return client, bucket
|
|
62
62
|
|
|
@@ -66,9 +66,12 @@ def _photos_access() -> tuple[Minio, str]:
|
|
|
66
66
|
bucket = conf.get('BUCKET', 'photos')
|
|
67
67
|
|
|
68
68
|
# TODO: move this to management command
|
|
69
|
-
if not client.bucket_exists(bucket):
|
|
70
|
-
client.make_bucket(bucket)
|
|
71
|
-
client.set_bucket_policy(
|
|
69
|
+
if not client.bucket_exists(bucket_name=bucket):
|
|
70
|
+
client.make_bucket(bucket_name=bucket)
|
|
71
|
+
client.set_bucket_policy(
|
|
72
|
+
bucket_name=bucket,
|
|
73
|
+
policy=_anonymous_readonly_policy(bucket),
|
|
74
|
+
)
|
|
72
75
|
|
|
73
76
|
return client, bucket
|
|
74
77
|
|
|
@@ -79,9 +82,9 @@ def _put_json(key, data, access_fn):
|
|
|
79
82
|
|
|
80
83
|
client, bucket = access_fn()
|
|
81
84
|
client.put_object(
|
|
82
|
-
bucket,
|
|
83
|
-
key,
|
|
84
|
-
stream,
|
|
85
|
+
bucket_name=bucket,
|
|
86
|
+
object_name=key,
|
|
87
|
+
data=stream,
|
|
85
88
|
length=-1,
|
|
86
89
|
part_size=10 * MEGABYTE,
|
|
87
90
|
content_type="application/json",
|
|
@@ -92,7 +95,7 @@ def _list_all(client: Minio, bucket: str, prefix: str):
|
|
|
92
95
|
start_after = None
|
|
93
96
|
while True:
|
|
94
97
|
objects = client.list_objects(
|
|
95
|
-
bucket,
|
|
98
|
+
bucket_name=bucket,
|
|
96
99
|
prefix=prefix,
|
|
97
100
|
recursive=True,
|
|
98
101
|
start_after=start_after)
|
|
@@ -112,12 +115,18 @@ def _list_all(client: Minio, bucket: str, prefix: str):
|
|
|
112
115
|
|
|
113
116
|
def _get_all(client: Minio, bucket: str, prefix: str):
|
|
114
117
|
for i in _list_all(client, bucket, prefix):
|
|
115
|
-
yield client.get_object(
|
|
118
|
+
yield client.get_object(
|
|
119
|
+
bucket_name=bucket,
|
|
120
|
+
object_name=i.object_name,
|
|
121
|
+
)
|
|
116
122
|
|
|
117
123
|
|
|
118
124
|
def _delete_all(client: Minio, bucket: str, prefix: str):
|
|
119
125
|
for i in _list_all(client, bucket, prefix):
|
|
120
|
-
client.remove_object(
|
|
126
|
+
client.remove_object(
|
|
127
|
+
bucket_name=bucket,
|
|
128
|
+
object_name=i.object_name,
|
|
129
|
+
)
|
|
121
130
|
yield i.object_name
|
|
122
131
|
|
|
123
132
|
|
|
@@ -141,7 +150,10 @@ def get_backup_object(backup_id: int):
|
|
|
141
150
|
client, bucket = _backup_access()
|
|
142
151
|
|
|
143
152
|
try:
|
|
144
|
-
data = client.get_object(
|
|
153
|
+
data = client.get_object(
|
|
154
|
+
bucket_name=bucket,
|
|
155
|
+
object_name=backup_info_key(backup_id),
|
|
156
|
+
)
|
|
145
157
|
return json.loads(data.read())
|
|
146
158
|
except S3Error as e:
|
|
147
159
|
if e.code == "NoSuchKey":
|
|
@@ -162,7 +174,10 @@ def get_backup_data(id_: int, type_=None):
|
|
|
162
174
|
|
|
163
175
|
def delete_backup_objects(id_: int):
|
|
164
176
|
client, bucket = _backup_access()
|
|
165
|
-
client.remove_object(
|
|
177
|
+
client.remove_object(
|
|
178
|
+
bucket_name=bucket,
|
|
179
|
+
object_name=backup_info_key(id_),
|
|
180
|
+
)
|
|
166
181
|
for _ in _delete_all(client, bucket, backup_data_prefix(id_)):
|
|
167
182
|
continue
|
|
168
183
|
|
|
@@ -198,9 +213,9 @@ def put_photo(album_key, photo_key, size_key, photo_file, image_format=None):
|
|
|
198
213
|
|
|
199
214
|
client, bucket = _photos_access()
|
|
200
215
|
return client.put_object(
|
|
201
|
-
bucket,
|
|
202
|
-
photo_path(album_key, photo_key, size_key),
|
|
203
|
-
photo_file,
|
|
216
|
+
bucket_name=bucket,
|
|
217
|
+
object_name=photo_path(album_key, photo_key, size_key),
|
|
218
|
+
data=photo_file,
|
|
204
219
|
length=-1,
|
|
205
220
|
part_size=10 * MEGABYTE,
|
|
206
221
|
content_type=content_type,
|
|
@@ -211,8 +226,8 @@ def put_photo(album_key, photo_key, size_key, photo_file, image_format=None):
|
|
|
211
226
|
def get_photo(album_key, photo_key, size_key):
|
|
212
227
|
client, bucket = _photos_access()
|
|
213
228
|
return client.get_object(
|
|
214
|
-
bucket,
|
|
215
|
-
photo_path(album_key, photo_key, size_key)
|
|
229
|
+
bucket_name=bucket,
|
|
230
|
+
object_name=photo_path(album_key, photo_key, size_key)
|
|
216
231
|
)
|
|
217
232
|
|
|
218
233
|
|
|
@@ -220,7 +235,10 @@ def delete_photo(album_key, photo_key):
|
|
|
220
235
|
client, bucket = _photos_access()
|
|
221
236
|
|
|
222
237
|
for i in PhotoSize:
|
|
223
|
-
client.remove_object(
|
|
238
|
+
client.remove_object(
|
|
239
|
+
bucket_name=bucket,
|
|
240
|
+
object_name=photo_path(album_key, photo_key, i.value),
|
|
241
|
+
)
|
|
224
242
|
|
|
225
243
|
|
|
226
244
|
def delete_scaled_photos(sizes):
|
|
@@ -251,7 +269,10 @@ def put_photo_sizes(sizes: PhotoSizes):
|
|
|
251
269
|
def get_photo_sizes() -> PhotoSizes:
|
|
252
270
|
client, bucket = _photos_access()
|
|
253
271
|
try:
|
|
254
|
-
data = client.get_object(
|
|
272
|
+
data = client.get_object(
|
|
273
|
+
bucket_name=bucket,
|
|
274
|
+
object_name="photo_sizes.json",
|
|
275
|
+
)
|
|
255
276
|
return parse_photo_sizes(json.loads(data.read()))
|
|
256
277
|
except S3Error as e:
|
|
257
278
|
if e.code == "NoSuchKey":
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: photo-objects
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.4
|
|
4
4
|
Summary: Application for storing photos in S3 compatible object-storage.
|
|
5
5
|
Author: Toni Kangas
|
|
6
6
|
License: MIT License
|
|
@@ -42,7 +42,7 @@ Requires-Python: >=3.10
|
|
|
42
42
|
Description-Content-Type: text/markdown
|
|
43
43
|
License-File: LICENSE
|
|
44
44
|
Requires-Dist: markdown~=3.7
|
|
45
|
-
Requires-Dist: minio
|
|
45
|
+
Requires-Dist: minio<7.2.19,>=7.2.0
|
|
46
46
|
Requires-Dist: pillow~=10.4
|
|
47
47
|
Dynamic: license-file
|
|
48
48
|
|
|
@@ -4,10 +4,10 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "photo-objects"
|
|
7
|
-
version = "0.9.
|
|
7
|
+
version = "0.9.4"
|
|
8
8
|
dependencies = [
|
|
9
9
|
"markdown~=3.7",
|
|
10
|
-
"minio
|
|
10
|
+
"minio>=7.2.0,<7.2.19",
|
|
11
11
|
"pillow~=10.4"
|
|
12
12
|
]
|
|
13
13
|
description = "Application for storing photos in S3 compatible object-storage."
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/api/photo_change_request.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/management/commands/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/migrations/0003_admin_visibility.py
RENAMED
|
File without changes
|
|
File without changes
|
{photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/migrations/0005_sitesettings.py
RENAMED
|
File without changes
|
{photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/migrations/0006_photo_alt_text.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/tests/test_photo_change_requests.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{photo_objects-0.9.2 → photo_objects-0.9.4}/photo_objects/django/views/ui/photo_change_request.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|