1 Commits

Author SHA1 Message Date
dependabot[bot]
14516f429f Bump pygments from 2.14.0 to 2.15.0
Bumps [pygments](https://github.com/pygments/pygments) from 2.14.0 to 2.15.0.
- [Release notes](https://github.com/pygments/pygments/releases)
- [Changelog](https://github.com/pygments/pygments/blob/master/CHANGES)
- [Commits](https://github.com/pygments/pygments/compare/2.14.0...2.15.0)

---
updated-dependencies:
- dependency-name: pygments
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-20 12:11:47 +00:00
10 changed files with 79 additions and 82 deletions

View File

@@ -1,19 +0,0 @@
name: Build and push image
on:
push:
branches: [main]
jobs:
deploy:
runs-on: self-hosted
defaults:
run:
working-directory: /repo
steps:
- name: Checkout repo
run: git pull
- name: Deploy
run: |
docker build . --no-cache -t ajurna/cbwebreader

View File

@@ -6,7 +6,6 @@ Django settings for cbreader project.
import os import os
from datetime import timedelta from datetime import timedelta
from pathlib import Path from pathlib import Path
from typing import Dict, List
import dj_database_url import dj_database_url
from dotenv import load_dotenv from dotenv import load_dotenv
@@ -28,7 +27,7 @@ ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS", "localhost").split(",")
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = (
"django.contrib.admin", "django.contrib.admin",
"django.contrib.auth", "django.contrib.auth",
"django.contrib.contenttypes", "django.contrib.contenttypes",
@@ -47,7 +46,7 @@ INSTALLED_APPS = [
'django_filters', 'django_filters',
'rest_framework', 'rest_framework',
# 'silk' # 'silk'
] )
MIDDLEWARE = [ MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware", "django.middleware.security.SecurityMiddleware",
@@ -59,7 +58,8 @@ MIDDLEWARE = [
"django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware", "django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware",
'csp.middleware.CSPMiddleware', # 'silk.middleware.SilkyMiddleware',
# 'csp.middleware.CSPMiddleware',
] ]
ROOT_URLCONF = "cbreader.urls" ROOT_URLCONF = "cbreader.urls"
@@ -197,10 +197,10 @@ CSP_FONT_SRC = ("'self'",)
CSP_SCRIPT_SRC = ("'self'",) CSP_SCRIPT_SRC = ("'self'",)
CSP_CONNECT_SRC = ("'self'",) CSP_CONNECT_SRC = ("'self'",)
CSP_INCLUDE_NONCE_IN = ['script-src'] CSP_INCLUDE_NONCE_IN = ['script-src']
CSP_SCRIPT_SRC_ATTR = ("'self'",) # "'unsafe-inline'") CSP_SCRIPT_SRC_ATTR = ("'self'",)# "'unsafe-inline'")
PERMISSIONS_POLICY: Dict[str, List] = { PERMISSIONS_POLICY = {
"accelerometer": [], "accelerometer": [],
"ambient-light-sensor": [], "ambient-light-sensor": [],
"autoplay": [], "autoplay": [],

View File

@@ -1,11 +1,30 @@
from .base import INSTALLED_APPS, MIDDLEWARE, SILK_ENABLED from .base import *
INSTALLED_APPS += ["silk"] INSTALLED_APPS = (
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
'silk',
"snowpenguin.django.recaptcha2",
'bootstrap4',
"comic",
"comic_auth",
)
MIDDLEWARE += [ MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
'silk.middleware.SilkyMiddleware', 'silk.middleware.SilkyMiddleware',
] ]
SILK_ENABLED = True # noqa: F811 SILK_ENABLED = True
SILKY_PYTHON_PROFILER = True SILKY_PYTHON_PROFILER = True

View File

@@ -1,6 +1,6 @@
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.contrib.syndication.views import Feed from django.contrib.syndication.views import Feed
from django.db.models import Case, When, PositiveSmallIntegerField, F, QuerySet from django.db.models import Case, When, PositiveSmallIntegerField, F
from django.http import HttpRequest from django.http import HttpRequest
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
@@ -18,7 +18,7 @@ class RecentComicsAPI(Feed):
self.user = user_misc.user self.user = user_misc.user
return user_misc.user return user_misc.user
def items(self) -> QuerySet[ComicBook]: def items(self) -> ComicBook:
comics = ComicBook.objects.order_by("-date_added") comics = ComicBook.objects.order_by("-date_added")
comics = comics.annotate( comics = comics.annotate(
classification=Case( classification=Case(

View File

@@ -1,11 +1,11 @@
from typing import Optional from typing import Optional, Union
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.models import User
from django.core.management.base import BaseCommand, CommandParser from django.core.management.base import BaseCommand, CommandParser
from loguru import logger from loguru import logger
from comic.models import Directory from comic.models import ComicBook, Directory
from comic.processing import generate_directory from comic.processing import generate_directory
@@ -27,11 +27,12 @@ class Command(BaseCommand):
self.OUTPUT = options.get('out', False) self.OUTPUT = options.get('out', False)
self.scan_directory() self.scan_directory()
def scan_directory(self, user: Optional[AbstractBaseUser] = None, directory: Optional[Directory] = None) -> None: def scan_directory(self, user: Optional[User] = None, directory: Optional[Directory] = None) -> None:
if not user: if not user:
user_model = get_user_model() user_model = get_user_model()
user: AbstractBaseUser = user_model.objects.first() user = user_model.objects.first()
for item in generate_directory(user, directory): for item in generate_directory(user, directory):
if item is Directory: item: Union[Directory, ComicBook]
if item.type == 'Directory':
logger.info(item) logger.info(item)
self.scan_directory(user, item) self.scan_directory(user, item)

View File

@@ -6,7 +6,7 @@ from typing import NamedTuple, List, Optional, Union
import rarfile import rarfile
from django.conf import settings from django.conf import settings
from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.models import User
from django.db.models import Count, Q, F, Case, When, PositiveSmallIntegerField, QuerySet, ExpressionWrapper, \ from django.db.models import Count, Q, F, Case, When, PositiveSmallIntegerField, QuerySet, ExpressionWrapper, \
IntegerField IntegerField
@@ -14,8 +14,7 @@ from comic import models
from comic.errors import NotCompatibleArchive from comic.errors import NotCompatibleArchive
def generate_directory(user: AbstractBaseUser, directory: Optional[models.Directory] = None) \ def generate_directory(user: User, directory: Optional[models.Directory] = None) -> List[QuerySet]:
-> List[Union[models.Directory, models.ComicBook]]:
dir_path = Path(settings.COMIC_BOOK_VOLUME, directory.path) if directory else settings.COMIC_BOOK_VOLUME dir_path = Path(settings.COMIC_BOOK_VOLUME, directory.path) if directory else settings.COMIC_BOOK_VOLUME
files = [] files = []
@@ -75,8 +74,7 @@ def clean_directories(directories: QuerySet, dir_path: Path, directory: Optional
models.Directory.objects.get(name=stale_directory.name, parent=directory).delete() models.Directory.objects.get(name=stale_directory.name, parent=directory).delete()
def clean_files(files: QuerySet, user: AbstractBaseUser, dir_path: Path, directory: Optional[models.Directory] = None) \ def clean_files(files: QuerySet, user: User, dir_path: Path, directory: Optional[models.Directory] = None) -> None:
-> None:
file_list = set(x for x in sorted(dir_path.glob('*')) if x.is_file()) file_list = set(x for x in sorted(dir_path.glob('*')) if x.is_file())
files_db_set = set(Path(dir_path, x.file_name) for x in files) files_db_set = set(Path(dir_path, x.file_name) for x in files)

View File

14
poetry.lock generated
View File

@@ -125,13 +125,13 @@ lxml = ["lxml"]
[[package]] [[package]]
name = "certifi" name = "certifi"
version = "2023.7.22" version = "2022.12.7"
description = "Python package for providing Mozilla's CA Bundle." description = "Python package for providing Mozilla's CA Bundle."
optional = false optional = false
python-versions = ">=3.6" python-versions = ">=3.6"
files = [ files = [
{file = "certifi-2023.7.22-py3-none-any.whl", hash = "sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9"}, {file = "certifi-2022.12.7-py3-none-any.whl", hash = "sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18"},
{file = "certifi-2023.7.22.tar.gz", hash = "sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082"}, {file = "certifi-2022.12.7.tar.gz", hash = "sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3"},
] ]
[[package]] [[package]]
@@ -1541,13 +1541,13 @@ files = [
[[package]] [[package]]
name = "pygments" name = "pygments"
version = "2.14.0" version = "2.15.0"
description = "Pygments is a syntax highlighting package written in Python." description = "Pygments is a syntax highlighting package written in Python."
optional = false optional = false
python-versions = ">=3.6" python-versions = ">=3.7"
files = [ files = [
{file = "Pygments-2.14.0-py3-none-any.whl", hash = "sha256:fa7bd7bd2771287c0de303af8bfdfc731f51bd2c6a47ab69d117138893b82717"}, {file = "Pygments-2.15.0-py3-none-any.whl", hash = "sha256:77a3299119af881904cd5ecd1ac6a66214b6e9bed1f2db16993b54adede64094"},
{file = "Pygments-2.14.0.tar.gz", hash = "sha256:b3ed06a9e8ac9a9aae5a6f5dbe78a8a58655d17b43b93c078f094ddc476ae297"}, {file = "Pygments-2.15.0.tar.gz", hash = "sha256:f7e36cffc4c517fbc252861b9a6e4644ca0e5abadf9a113c72d1358ad09b9500"},
] ]
[package.extras] [package.extras]

View File

@@ -12,44 +12,43 @@ license = "Creative Commons Attribution-ShareAlike 4.0 International License"
python = "^3.10" python = "^3.10"
Django = "^4.1" Django = "^4.1"
gunicorn = "^20.0.4" gunicorn = "^20.0.4"
dj-database-url = "^1.3.0" dj-database-url = "^1.0.0"
python-dotenv = "^1.0.0" python-dotenv = "^0.21.0"
loguru = "^0.7.0" loguru = "^0.6.0"
django-silk = "^5.0.0" django-silk = "^5.0.0"
mysqlclient = "^2.0.1" mysqlclient = "^2.0.1"
psycopg2 = "^2.9.6" psycopg2 = "^2.8.6"
rarfile = "^4.0" rarfile = "^4.0"
django-extensions = "^3.2.1" django-extensions = "^3.2.1"
Pillow = "^9.3.0" Pillow = "^9.3.0"
django-imagekit = "^4.0.2" django-imagekit = "^4.0.2"
PyMuPDF = "~1.20.2" PyMuPDF = "~1.20.2"
django-bootstrap4 = "^23.1" django-bootstrap4 = "^22.1"
django-csp = "^3.7" django-csp = "^3.7"
django-boost = "^2.1" django-boost = "^2.1"
django-sri = "^0.5.0" django-sri = "^0.5.0"
django-permissions-policy = "^4.15.0" django-permissions-policy = "^4.9.0"
djangorestframework = "^3.13.1" djangorestframework = "^3.13.1"
django-filter = "^23.1" django-filter = "^22.1"
django-cors-headers = "^3.14.0" django-cors-headers = "^3.13.0"
djangorestframework-simplejwt = "^5.2.0" djangorestframework-simplejwt = "^5.2.0"
django-webpack-loader = "^1.6.0" django-webpack-loader = "^1.6.0"
drf-yasg = "^1.20.0" drf-yasg = "^1.20.0"
drf-extensions = "^0.7.1" drf-extensions = "^0.7.1"
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
mypy = "^1.2.0" mypy = "^1.0.0"
Werkzeug = "^2.2" Werkzeug = "^2.2"
pyOpenSSL = "^22.0.0" pyOpenSSL = "^22.0.0"
ipython = "^8.12.0" ipython = "^8.4.0"
coverage = "^7.2.3" coverage = "^7.1.0"
pre-commit = "^3.2.2" pre-commit = "^3.0.4"
flake8 = "^6.0.0" flake8 = "^6.0.0"
flake8-annotations = "^3.0.0" flake8-annotations = "^3.0.0"
[tool.poetry.group.dev.dependencies] [tool.poetry.group.dev.dependencies]
pylint = "^2.15.0" pylint = "^2.15.0"
pylint-django = "^2.5.3" pylint-django = "^2.5.3"
mypy = "^1.2.0"
[build-system] [build-system]
requires = ["poetry-core>=1.0.0"] requires = ["poetry-core>=1.0.0"]

View File

@@ -1,25 +1,25 @@
asgiref==3.6.0 ; python_version >= "3.10" and python_version < "4.0" asgiref==3.6.0 ; python_version >= "3.10" and python_version < "4.0"
autopep8==2.0.2 ; python_version >= "3.10" and python_version < "4.0" autopep8==2.0.1 ; python_version >= "3.10" and python_version < "4.0"
beautifulsoup4==4.12.2 ; python_version >= "3.10" and python_version < "4.0" beautifulsoup4==4.11.2 ; python_version >= "3.10" and python_version < "4.0"
certifi==2022.12.7 ; python_version >= "3.10" and python_version < "4" certifi==2022.12.7 ; python_version >= "3.10" and python_version < "4"
charset-normalizer==3.1.0 ; python_version >= "3.10" and python_version < "4" charset-normalizer==3.0.1 ; python_version >= "3.10" and python_version < "4"
colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and sys_platform == "win32" colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and sys_platform == "win32"
coreapi==2.3.3 ; python_version >= "3.10" and python_version < "4.0" coreapi==2.3.3 ; python_version >= "3.10" and python_version < "4.0"
coreschema==0.0.4 ; python_version >= "3.10" and python_version < "4.0" coreschema==0.0.4 ; python_version >= "3.10" and python_version < "4.0"
dj-database-url==1.3.0 ; python_version >= "3.10" and python_version < "4.0" dj-database-url==1.2.0 ; python_version >= "3.10" and python_version < "4.0"
django-appconf==1.0.5 ; python_version >= "3.10" and python_version < "4.0" django-appconf==1.0.5 ; python_version >= "3.10" and python_version < "4.0"
django-boost==2.1 ; python_version >= "3.10" and python_version < "4.0" django-boost==2.1 ; python_version >= "3.10" and python_version < "4.0"
django-bootstrap4==23.1 ; python_version >= "3.10" and python_version < "4.0" django-bootstrap4==22.3 ; python_version >= "3.10" and python_version < "4.0"
django-cors-headers==3.14.0 ; python_version >= "3.10" and python_version < "4.0" django-cors-headers==3.13.0 ; python_version >= "3.10" and python_version < "4.0"
django-csp==3.7 ; python_version >= "3.10" and python_version < "4.0" django-csp==3.7 ; python_version >= "3.10" and python_version < "4.0"
django-extensions==3.2.1 ; python_version >= "3.10" and python_version < "4.0" django-extensions==3.2.1 ; python_version >= "3.10" and python_version < "4.0"
django-filter==23.1 ; python_version >= "3.10" and python_version < "4.0" django-filter==22.1 ; python_version >= "3.10" and python_version < "4.0"
django-imagekit==4.1.0 ; python_version >= "3.10" and python_version < "4.0" django-imagekit==4.1.0 ; python_version >= "3.10" and python_version < "4.0"
django-permissions-policy==4.15.0 ; python_version >= "3.10" and python_version < "4.0" django-permissions-policy==4.14.0 ; python_version >= "3.10" and python_version < "4.0"
django-silk==5.0.3 ; python_version >= "3.10" and python_version < "4.0" django-silk==5.0.3 ; python_version >= "3.10" and python_version < "4.0"
django-sri==0.5.0 ; python_version >= "3.10" and python_version < "4.0" django-sri==0.5.0 ; python_version >= "3.10" and python_version < "4.0"
django-webpack-loader==1.8.1 ; python_version >= "3.10" and python_version < "4.0" django-webpack-loader==1.8.1 ; python_version >= "3.10" and python_version < "4.0"
django==4.2 ; python_version >= "3.10" and python_version < "4.0" django==4.1.7 ; python_version >= "3.10" and python_version < "4.0"
djangorestframework-simplejwt==5.2.2 ; python_version >= "3.10" and python_version < "4.0" djangorestframework-simplejwt==5.2.2 ; python_version >= "3.10" and python_version < "4.0"
djangorestframework==3.14.0 ; python_version >= "3.10" and python_version < "4.0" djangorestframework==3.14.0 ; python_version >= "3.10" and python_version < "4.0"
drf-extensions==0.7.1 ; python_version >= "3.10" and python_version < "4.0" drf-extensions==0.7.1 ; python_version >= "3.10" and python_version < "4.0"
@@ -30,31 +30,30 @@ idna==3.4 ; python_version >= "3.10" and python_version < "4"
inflection==0.5.1 ; python_version >= "3.10" and python_version < "4.0" inflection==0.5.1 ; python_version >= "3.10" and python_version < "4.0"
itypes==1.2.0 ; python_version >= "3.10" and python_version < "4.0" itypes==1.2.0 ; python_version >= "3.10" and python_version < "4.0"
jinja2==3.1.2 ; python_version >= "3.10" and python_version < "4.0" jinja2==3.1.2 ; python_version >= "3.10" and python_version < "4.0"
loguru==0.7.0 ; python_version >= "3.10" and python_version < "4.0" loguru==0.6.0 ; python_version >= "3.10" and python_version < "4.0"
markupsafe==2.1.2 ; python_version >= "3.10" and python_version < "4.0" markupsafe==2.1.2 ; python_version >= "3.10" and python_version < "4.0"
mysqlclient==2.1.1 ; python_version >= "3.10" and python_version < "4.0" mysqlclient==2.1.1 ; python_version >= "3.10" and python_version < "4.0"
packaging==23.1 ; python_version >= "3.10" and python_version < "4.0" packaging==23.0 ; python_version >= "3.10" and python_version < "4.0"
pilkit==2.0 ; python_version >= "3.10" and python_version < "4.0" pilkit==2.0 ; python_version >= "3.10" and python_version < "4.0"
pillow==9.5.0 ; python_version >= "3.10" and python_version < "4.0" pillow==9.4.0 ; python_version >= "3.10" and python_version < "4.0"
psycopg2==2.9.6 ; python_version >= "3.10" and python_version < "4.0" psycopg2==2.9.5 ; python_version >= "3.10" and python_version < "4.0"
pycodestyle==2.10.0 ; python_version >= "3.10" and python_version < "4.0" pycodestyle==2.10.0 ; python_version >= "3.10" and python_version < "4.0"
pyjwt==2.6.0 ; python_version >= "3.10" and python_version < "4.0" pyjwt==2.6.0 ; python_version >= "3.10" and python_version < "4.0"
pymupdf==1.20.2 ; python_version >= "3.10" and python_version < "4.0" pymupdf==1.20.2 ; python_version >= "3.10" and python_version < "4.0"
python-dotenv==1.0.0 ; python_version >= "3.10" and python_version < "4.0" python-dotenv==0.21.1 ; python_version >= "3.10" and python_version < "4.0"
pytz==2023.3 ; python_version >= "3.10" and python_version < "4.0" pytz==2022.7.1 ; python_version >= "3.10" and python_version < "4.0"
rarfile==4.0 ; python_version >= "3.10" and python_version < "4.0" rarfile==4.0 ; python_version >= "3.10" and python_version < "4.0"
requests==2.28.2 ; python_version >= "3.10" and python_version < "4" requests==2.28.2 ; python_version >= "3.10" and python_version < "4"
ruamel-yaml-clib==0.2.7 ; platform_python_implementation == "CPython" and python_version < "3.11" and python_version >= "3.10" ruamel-yaml-clib==0.2.7 ; platform_python_implementation == "CPython" and python_version < "3.11" and python_version >= "3.10"
ruamel-yaml==0.17.21 ; python_version >= "3.10" and python_version < "4.0" ruamel-yaml==0.17.21 ; python_version >= "3.10" and python_version < "4.0"
setuptools==67.6.1 ; python_version >= "3.10" and python_version < "4.0" setuptools==67.3.2 ; python_version >= "3.10" and python_version < "4.0"
six==1.16.0 ; python_version >= "3.10" and python_version < "4.0" six==1.16.0 ; python_version >= "3.10" and python_version < "4.0"
soupsieve==2.4.1 ; python_version >= "3.10" and python_version < "4.0" soupsieve==2.4 ; python_version >= "3.10" and python_version < "4.0"
sqlparse==0.4.3 ; python_version >= "3.10" and python_version < "4.0" sqlparse==0.4.3 ; python_version >= "3.10" and python_version < "4.0"
tomli==2.0.1 ; python_version >= "3.10" and python_version < "3.11" tomli==2.0.1 ; python_version >= "3.10" and python_version < "3.11"
typing-extensions==4.5.0 ; python_version >= "3.10" and python_version < "4.0" tzdata==2022.7 ; python_version >= "3.10" and python_version < "4.0" and sys_platform == "win32"
tzdata==2023.3 ; python_version >= "3.10" and python_version < "4.0" and sys_platform == "win32"
ua-parser==0.16.1 ; python_version >= "3.10" and python_version < "4.0" ua-parser==0.16.1 ; python_version >= "3.10" and python_version < "4.0"
uritemplate==4.1.1 ; python_version >= "3.10" and python_version < "4.0" uritemplate==4.1.1 ; python_version >= "3.10" and python_version < "4.0"
urllib3==1.26.15 ; python_version >= "3.10" and python_version < "4" urllib3==1.26.14 ; python_version >= "3.10" and python_version < "4"
user-agents==2.2.0 ; python_version >= "3.10" and python_version < "4.0" user-agents==2.2.0 ; python_version >= "3.10" and python_version < "4.0"
win32-setctime==1.1.0 ; python_version >= "3.10" and python_version < "4.0" and sys_platform == "win32" win32-setctime==1.1.0 ; python_version >= "3.10" and python_version < "4.0" and sys_platform == "win32"