Linter and format fixes
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
ff2d88493b
commit
c6d7566c72
|
|
@ -1,6 +1,4 @@
|
||||||
from django.apps import (
|
from django.apps import AppConfig
|
||||||
AppConfig,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class CommonConfig(AppConfig):
|
class CommonConfig(AppConfig):
|
||||||
|
|
|
||||||
|
|
@ -3,18 +3,21 @@ import re
|
||||||
CONTENT_RANGE_HEADER = "HTTP_CONTENT_RANGE"
|
CONTENT_RANGE_HEADER = "HTTP_CONTENT_RANGE"
|
||||||
CONTENT_RANGE_HEADER_PATTERN = re.compile(r"^bytes (?P<start>\d+)-(?P<end>\d+)$")
|
CONTENT_RANGE_HEADER_PATTERN = re.compile(r"^bytes (?P<start>\d+)-(?P<end>\d+)$")
|
||||||
|
|
||||||
|
|
||||||
class UPLOAD_STATUS_TYPES:
|
class UPLOAD_STATUS_TYPES:
|
||||||
UPLOADING = "uploading"
|
UPLOADING = "uploading"
|
||||||
COMPLETED = "completed"
|
COMPLETED = "completed"
|
||||||
ABANDONED = "abandoned"
|
ABANDONED = "abandoned"
|
||||||
ERROR = "error"
|
ERROR = "error"
|
||||||
|
|
||||||
|
|
||||||
class UPLOAD_ERROR_CODES:
|
class UPLOAD_ERROR_CODES:
|
||||||
FILE_MISSING = "file_missing"
|
FILE_MISSING = "file_missing"
|
||||||
CHUNK_MISMATCH = "chunk_mismatch"
|
CHUNK_MISMATCH = "chunk_mismatch"
|
||||||
|
|
||||||
# Config
|
# Config
|
||||||
|
|
||||||
|
|
||||||
CONFIG_KEYS = {
|
CONFIG_KEYS = {
|
||||||
"ABANDONED_DELTA_MINUTES": {
|
"ABANDONED_DELTA_MINUTES": {
|
||||||
"description": "Date created + this delta at which a file is marked as abandoned",
|
"description": "Date created + this delta at which a file is marked as abandoned",
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,11 @@ class Config(NamedTuple):
|
||||||
value: Any
|
value: Any
|
||||||
source: str
|
source: str
|
||||||
|
|
||||||
|
|
||||||
def normalize_string(string, form="NFKC"):
|
def normalize_string(string, form="NFKC"):
|
||||||
return normalize(form, string)
|
return normalize(form, string)
|
||||||
|
|
||||||
|
|
||||||
def cast_to_native_type(key, value, native_type):
|
def cast_to_native_type(key, value, native_type):
|
||||||
|
|
||||||
if native_type == list:
|
if native_type == list:
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
|
from common.constants import CONFIG_KEYS
|
||||||
|
from common.serializers import ConfigSerializer
|
||||||
|
from common.utils import get_config
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from rest_framework.decorators import api_view
|
from rest_framework.decorators import api_view
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
|
||||||
from common.constants import CONFIG_KEYS
|
|
||||||
from common.serializers import ConfigSerializer
|
|
||||||
from common.utils import get_config
|
|
||||||
|
|
||||||
|
|
||||||
def get_all_configs():
|
def get_all_configs():
|
||||||
return [get_config(key, value_only=False)._asdict() for key in CONFIG_KEYS]
|
return [get_config(key, value_only=False)._asdict() for key in CONFIG_KEYS]
|
||||||
|
|
||||||
|
|
||||||
@api_view(["GET"])
|
@api_view(["GET"])
|
||||||
def configs(request, key=None):
|
def configs(request, key=None):
|
||||||
if key:
|
if key:
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ from pathlib import Path
|
||||||
# TODO: LOG MEEEEE
|
# TODO: LOG MEEEEE
|
||||||
# TODO: Figure out file owner in system, permissions, GUID
|
# TODO: Figure out file owner in system, permissions, GUID
|
||||||
# Whats the default path if not provided? // docker volume
|
# Whats the default path if not provided? // docker volume
|
||||||
|
|
||||||
|
|
||||||
def validate_paths(media_path):
|
def validate_paths(media_path):
|
||||||
try:
|
try:
|
||||||
Path(media_path).mkdir(exist_ok=True)
|
Path(media_path).mkdir(exist_ok=True)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from storage.models import File
|
from storage.models import File
|
||||||
|
|
||||||
|
|
||||||
class FileAdmin(admin.ModelAdmin):
|
class FileAdmin(admin.ModelAdmin):
|
||||||
readonly_fields = File.readonly_fields
|
readonly_fields = File.readonly_fields
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(File, FileAdmin)
|
admin.site.register(File, FileAdmin)
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
from hashlib import md5
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from common.constants import UPLOAD_STATUS_TYPES, UPLOAD_ERROR_CODES
|
|
||||||
|
from common.constants import UPLOAD_ERROR_CODES, UPLOAD_STATUS_TYPES
|
||||||
from common.models import LockboxBase
|
from common.models import LockboxBase
|
||||||
from common.utils import get_config, get_max_size_chunk_bytes
|
from common.utils import get_config, get_max_size_chunk_bytes
|
||||||
|
from django.conf import settings
|
||||||
from django.db import models, transaction
|
from django.db import models, transaction
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.conf import settings
|
|
||||||
from hashlib import md5
|
|
||||||
|
|
||||||
|
|
||||||
class UploadError(Exception):
|
class UploadError(Exception):
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
from django.urls import include, path
|
from django.urls import include, path
|
||||||
from rest_framework.routers import SimpleRouter
|
from rest_framework.routers import SimpleRouter
|
||||||
from rest_framework_nested.routers import NestedSimpleRouter
|
|
||||||
|
|
||||||
from storage import views_api, views_client
|
from storage import views_api, views_client
|
||||||
|
|
||||||
router = SimpleRouter()
|
router = SimpleRouter()
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,11 @@
|
||||||
from common.constants import (
|
from common.constants import CONTENT_RANGE_HEADER, CONTENT_RANGE_HEADER_PATTERN
|
||||||
CONTENT_RANGE_HEADER,
|
from django.core.exceptions import ValidationError
|
||||||
CONTENT_RANGE_HEADER_PATTERN
|
|
||||||
)
|
|
||||||
|
|
||||||
# from common.utils import get_config
|
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from rest_framework.response import Response
|
|
||||||
from rest_framework.viewsets import ModelViewSet
|
|
||||||
from rest_framework.exceptions import NotFound
|
from rest_framework.exceptions import NotFound
|
||||||
from rest_framework.exceptions import ValidationError as UserValidationError
|
from rest_framework.exceptions import ValidationError as UserValidationError
|
||||||
from rest_framework.parsers import FileUploadParser
|
from rest_framework.response import Response
|
||||||
|
from rest_framework.viewsets import ModelViewSet
|
||||||
from django.core.exceptions import ValidationError
|
|
||||||
|
|
||||||
from storage.models import File, UploadError
|
from storage.models import File, UploadError
|
||||||
from storage.serializers import FileSerializer
|
from storage.serializers import FileSerializer
|
||||||
|
|
||||||
|
|
@ -36,7 +28,7 @@ class FileModelViewSet(ModelViewSet):
|
||||||
chunk_data = self.get_content_range(request)
|
chunk_data = self.get_content_range(request)
|
||||||
if not chunk_data:
|
if not chunk_data:
|
||||||
raise UserValidationError(
|
raise UserValidationError(
|
||||||
f"Missing content range headers"
|
"Missing content-range headers"
|
||||||
)
|
)
|
||||||
|
|
||||||
chunk_file = request.FILES["Content"]
|
chunk_file = request.FILES["Content"]
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
from common.utils import get_config
|
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.views import View
|
from django.views import View
|
||||||
|
|
||||||
|
|
||||||
# Static view
|
# Static view
|
||||||
class FileUploadView(View):
|
class FileUploadView(View):
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from user.models import LockboxUser
|
from user.models import LockboxUser
|
||||||
|
|
||||||
|
|
||||||
class LockboxUserAdmin(admin.ModelAdmin):
|
class LockboxUserAdmin(admin.ModelAdmin):
|
||||||
readonly_fields = LockboxUser.readonly_fields
|
readonly_fields = LockboxUser.readonly_fields
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(LockboxUser, LockboxUserAdmin)
|
admin.site.register(LockboxUser, LockboxUserAdmin)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from user.models import LockboxUser
|
from user.models import LockboxUser
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -201,6 +201,20 @@ files = [
|
||||||
{file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"},
|
{file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "isort"
|
||||||
|
version = "5.13.2"
|
||||||
|
description = "A Python utility / library to sort Python imports."
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.8.0"
|
||||||
|
files = [
|
||||||
|
{file = "isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6"},
|
||||||
|
{file = "isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
colors = ["colorama (>=0.4.6)"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mccabe"
|
name = "mccabe"
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
|
|
@ -373,4 +387,4 @@ brotli = ["brotli"]
|
||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "~3.12"
|
python-versions = "~3.12"
|
||||||
content-hash = "d8ff6440e16bd3eb499933ec438f2490a91e8caab975ab40505a64daab72cf9e"
|
content-hash = "155d31f2edffb6e6ea604c7a1115fa072072a5370e012eea577644e0a337f0b0"
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ pytest = "^8.0.0"
|
||||||
pytest-django = "^4.8.0"
|
pytest-django = "^4.8.0"
|
||||||
pytest-cov = "^4.1.0"
|
pytest-cov = "^4.1.0"
|
||||||
flake8-pyproject = "^1.2.3"
|
flake8-pyproject = "^1.2.3"
|
||||||
|
isort = "^5.13.2"
|
||||||
|
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ drf-nested-routers==0.93.5 ; python_version >= "3.12" and python_version < "3.13
|
||||||
flake8-pyproject==1.2.3 ; python_version >= "3.12" and python_version < "3.13"
|
flake8-pyproject==1.2.3 ; python_version >= "3.12" and python_version < "3.13"
|
||||||
flake8==7.1.1 ; python_version >= "3.12" and python_version < "3.13"
|
flake8==7.1.1 ; python_version >= "3.12" and python_version < "3.13"
|
||||||
iniconfig==2.0.0 ; python_version >= "3.12" and python_version < "3.13"
|
iniconfig==2.0.0 ; python_version >= "3.12" and python_version < "3.13"
|
||||||
|
isort==5.13.2 ; python_version >= "3.12" and python_version < "3.13"
|
||||||
mccabe==0.7.0 ; python_version >= "3.12" and python_version < "3.13"
|
mccabe==0.7.0 ; python_version >= "3.12" and python_version < "3.13"
|
||||||
packaging==24.1 ; python_version >= "3.12" and python_version < "3.13"
|
packaging==24.1 ; python_version >= "3.12" and python_version < "3.13"
|
||||||
pluggy==1.5.0 ; python_version >= "3.12" and python_version < "3.13"
|
pluggy==1.5.0 ; python_version >= "3.12" and python_version < "3.13"
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
printf "\n\n|| Starting ruff check ||\n\n"
|
printf "\n\n|| Starting lint check ||\n\n"
|
||||||
ruff check --config=./pyproject.toml
|
flake8
|
||||||
Loading…
Reference in New Issue