Commit 0a5efba1 authored by Fefe's avatar Fefe
Browse files

Revue relecture

parent e1bfd7e0
......@@ -8,6 +8,11 @@ coverage = "*"
flake8 = "*"
freezegun = "*"
mypy = "*"
types-Markdown = "*"
types-freezegun = "*"
types-redis = "*"
types-requests = "*"
black = "*"
[packages]
Markdown = "*"
......
{
"_meta": {
"hash": {
"sha256": "9d1fd85e2c60442ccc6e834cc0a03ef834b38b948654120f6e4e88a11489f023"
"sha256": "68f975488caab91b3500fb126943adab48c76a27129ba7cd4d0c37aac8618ad1"
},
"pipfile-spec": 6,
"requires": {},
......@@ -353,6 +353,51 @@
}
},
"develop": {
"black": {
"hashes": [
"sha256:06f9d8846f2340dfac80ceb20200ea5d1b3f181dd0556b47af4e8e0b24fa0a6b",
"sha256:10dbe6e6d2988049b4655b2b739f98785a884d4d6b85bc35133a8fb9a2233176",
"sha256:2497f9c2386572e28921fa8bec7be3e51de6801f7459dffd6e62492531c47e09",
"sha256:30d78ba6bf080eeaf0b7b875d924b15cd46fec5fd044ddfbad38c8ea9171043a",
"sha256:328efc0cc70ccb23429d6be184a15ce613f676bdfc85e5fe8ea2a9354b4e9015",
"sha256:35020b8886c022ced9282b51b5a875b6d1ab0c387b31a065b84db7c33085ca79",
"sha256:5795a0375eb87bfe902e80e0c8cfaedf8af4d49694d69161e5bd3206c18618bb",
"sha256:5891ef8abc06576985de8fa88e95ab70641de6c1fca97e2a15820a9b69e51b20",
"sha256:637a4014c63fbf42a692d22b55d8ad6968a946b4a6ebc385c5505d9625b6a464",
"sha256:67c8301ec94e3bcc8906740fe071391bce40a862b7be0b86fb5382beefecd968",
"sha256:6d2fc92002d44746d3e7db7cf9313cf4452f43e9ea77a2c939defce3b10b5c82",
"sha256:6ee227b696ca60dd1c507be80a6bc849a5a6ab57ac7352aad1ffec9e8b805f21",
"sha256:863714200ada56cbc366dc9ae5291ceb936573155f8bf8e9de92aef51f3ad0f0",
"sha256:9b542ced1ec0ceeff5b37d69838106a6348e60db7b8fdd245294dc1d26136265",
"sha256:a6342964b43a99dbc72f72812bf88cad8f0217ae9acb47c0d4f141a6416d2d7b",
"sha256:ad4efa5fad66b903b4a5f96d91461d90b9507a812b3c5de657d544215bb7877a",
"sha256:bc58025940a896d7e5356952228b68f793cf5fcb342be703c3a2669a1488cb72",
"sha256:cc1e1de68c8e5444e8f94c3670bb48a2beef0e91dddfd4fcc29595ebd90bb9ce",
"sha256:cee3e11161dde1b2a33a904b850b0899e0424cc331b7295f2a9698e79f9a69a0",
"sha256:e3556168e2e5c49629f7b0f377070240bd5511e45e25a4497bb0073d9dda776a",
"sha256:e8477ec6bbfe0312c128e74644ac8a02ca06bcdb8982d4ee06f209be28cdf163",
"sha256:ee8f1f7228cce7dffc2b464f07ce769f478968bfb3dd1254a4c2eeed84928aad",
"sha256:fd57160949179ec517d32ac2ac898b5f20d68ed1a9c977346efbac9c2f1e779d"
],
"index": "pypi",
"version": "==22.3.0"
},
"click": {
"hashes": [
"sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e",
"sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48"
],
"markers": "python_version >= '3.7'",
"version": "==8.1.3"
},
"colorama": {
"hashes": [
"sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b",
"sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"
],
"markers": "platform_system == 'Windows'",
"version": "==0.4.4"
},
"coverage": {
"hashes": [
"sha256:03e2a7826086b91ef345ff18742ee9fc47a6839ccd517061ef8fa1976e652ce9",
......@@ -459,6 +504,21 @@
],
"version": "==0.4.3"
},
"pathspec": {
"hashes": [
"sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a",
"sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"
],
"version": "==0.9.0"
},
"platformdirs": {
"hashes": [
"sha256:027d8e83a2d7de06bbac4e5ef7e023c02b863d7ea5d079477e722bb41ab25788",
"sha256:58c8abb07dcb441e6ee4b11d8df0ac856038f944ab98b7be6b27b2a3c7feef19"
],
"markers": "python_version >= '3.7'",
"version": "==2.5.2"
},
"pycodestyle": {
"hashes": [
"sha256:720f8b39dde8b293825e7ff02c475f3077124006db4f440dcbc9a20b76548a20",
......@@ -499,6 +559,45 @@
"markers": "python_version >= '3.7'",
"version": "==2.0.1"
},
"types-freezegun": {
"hashes": [
"sha256:6f05108d468baecadf999873bd37e57b25ceb35d35d3f83e7a742f25d6fe8b0e",
"sha256:fe1dd73372d96358dcb93e3aeb66d39f6ac63749e0724f13554cc145e2120efe"
],
"index": "pypi",
"version": "==1.1.9"
},
"types-markdown": {
"hashes": [
"sha256:10841332581bd79efdb153fb8f856818ef5cdb40a6e71e5d18505b5db6eba01c",
"sha256:49a406c12be2181346a756086f326d42d5bb3abbfaede8942ccdc9cef367db1f"
],
"index": "pypi",
"version": "==3.3.14"
},
"types-redis": {
"hashes": [
"sha256:616e5331e957832321c14a4bd206b41f967657cf360f62419b21588880af3933",
"sha256:8035a2631591ea2d0484f979f1424789ed757e72b56f0c5d6291a9484540e9c0"
],
"index": "pypi",
"version": "==4.2.2"
},
"types-requests": {
"hashes": [
"sha256:2444905c89731dbcb6bbcd6d873a04252445df7623917c640e463b2b28d2a708",
"sha256:805ae7e38fd9d157153066dc4381cf585fd34dfa212f2fc1fece248c05aac571"
],
"index": "pypi",
"version": "==2.27.25"
},
"types-urllib3": {
"hashes": [
"sha256:2a2578e4b36341ccd240b00fccda9826988ff0589a44ba4a664bbd69ef348d27",
"sha256:5d2388aa76395b1e3999ff789ea5b3283677dad8e9bcf3d9117ba19271fd35d9"
],
"version": "==1.26.14"
},
"typing-extensions": {
"hashes": [
"sha256:6657594ee297170d19f67d55c05852a874e7eb634f4f753dbd667855e07c1708",
......
......@@ -26,15 +26,12 @@ MAX_UNCOMPRESSED_WEIGHT = settings.PHOTO_MAX_UNCOMPRESSED_WEIGHT
def create_thumbnail(realpath, filename):
if not os.path.isdir(os.path.join(realpath, THUMBNAIL_DIRNAME)):
try:
os.mkdir(os.path.join(realpath, THUMBNAIL_DIRNAME))
except FileExistsError:
pass
if os.path.isfile(os.path.join(realpath, THUMBNAIL_DIRNAME, filename)):
return
if not os.path.isdir(os.path.join(realpath, THUMBNAIL_DIRNAME)):
os.mkdir(os.path.join(realpath, THUMBNAIL_DIRNAME))
try:
image = Image.open(os.path.join(realpath, filename))
......@@ -73,15 +70,13 @@ def create_thumbnail(realpath, filename):
def create_compressed_image(realpath, filename):
if not os.path.isdir(os.path.join(realpath, COMPRESSED_DIRNAME)):
try:
os.mkdir(os.path.join(realpath, COMPRESSED_DIRNAME))
except FileExistsError:
pass
if os.path.isfile(os.path.join(realpath, COMPRESSED_DIRNAME, filename)):
return
if not os.path.isdir(os.path.join(realpath, COMPRESSED_DIRNAME)):
os.mkdir(os.path.join(realpath, COMPRESSED_DIRNAME))
try:
image = Image.open(os.path.join(realpath, filename))
......@@ -223,7 +218,7 @@ def render_album(request, path) -> HttpResponse:
def add_file(request, path) -> JsonResponse:
if not request.user.has_perm('photo.add_files'):
return JsonResponse({"status": "error",
"message": "L'utilisateur n'a pas la permisision d'ajouter des fichiers'",
"message": "L'utilisateur n'a pas la permission d'ajouter des fichiers'",
"error": "Permissions insuffisantes"},
status=403)
try:
......@@ -248,10 +243,10 @@ def add_file(request, path) -> JsonResponse:
def create_folder(request, path) -> JsonResponse:
if not request.user.has_perm('photo.add_files'):
return JsonResponse({"status": "error",
"message": "L'utilisateur n'a pas la permisision de créer des dossier",
"message": "L'utilisateur n'a pas la permission de créer des dossiers",
"error": "Permissions insuffisantes"},
status=403)
folder_name = json.loads(request.read().decode()).get("folder_name")
folder_name = json.loads(request.read().decode()).get("folder_name").strip()
realpath = getRealPath(path)
if (folder_name is None) or (len(folder_name) == 0) or folder_name.startswith(".") or folder_name.isspace() \
......@@ -260,6 +255,8 @@ def create_folder(request, path) -> JsonResponse:
folder_path = realpath + folder_name
if os.path.isdir(folder_path):
return JsonResponse({"status": "error", "message": "Ce dossier existe déjà"}, status=409)
if os.path.isfile(folder_path):
return JsonResponse({"status": "error", "message": "Un fichier du même nom existe"}, status=409)
try:
os.mkdir(os.path.join(realpath, folder_name))
......@@ -276,7 +273,7 @@ def create_folder(request, path) -> JsonResponse:
def delete_files(request, path) -> JsonResponse:
if not request.user.has_perm('photo.delete_files'):
return JsonResponse({"status": "error",
"message": "L'utilisateur n'a pas la permisision de supprimer des fichiers'",
"message": "L'utilisateur n'a pas la permission de supprimer des fichiers'",
"error": "Permissions insuffisantes"},
status=403)
if path == "" or path == "/":
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment