diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index abc2c21..d48347a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ fail_fast: true repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.5.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -12,7 +12,7 @@ repos: - id: check-added-large-files - repo: https://github.com/pycqa/flake8 - rev: 5.0.4 + rev: 6.1.0 hooks: - id: flake8 additional_dependencies: diff --git a/config/settings/base.py b/config/settings/base.py index 13e4718..8718638 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -133,6 +133,7 @@ "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.common.BrokenLinkEmailsMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", + "allauth.account.middleware.AccountMiddleware", ] # STATIC diff --git a/elearner/contrib/sites/migrations/0001_initial.py b/elearner/contrib/sites/migrations/0001_initial.py index 304cd6d..59647c8 100644 --- a/elearner/contrib/sites/migrations/0001_initial.py +++ b/elearner/contrib/sites/migrations/0001_initial.py @@ -4,7 +4,6 @@ class Migration(migrations.Migration): - dependencies = [] operations = [ diff --git a/elearner/contrib/sites/migrations/0002_alter_domain_unique.py b/elearner/contrib/sites/migrations/0002_alter_domain_unique.py index 2c8d6da..4359049 100644 --- a/elearner/contrib/sites/migrations/0002_alter_domain_unique.py +++ b/elearner/contrib/sites/migrations/0002_alter_domain_unique.py @@ -3,7 +3,6 @@ class Migration(migrations.Migration): - dependencies = [("sites", "0001_initial")] operations = [ diff --git a/elearner/contrib/sites/migrations/0003_set_site_domain_and_name.py b/elearner/contrib/sites/migrations/0003_set_site_domain_and_name.py index a476c15..1606ac9 100644 --- a/elearner/contrib/sites/migrations/0003_set_site_domain_and_name.py +++ b/elearner/contrib/sites/migrations/0003_set_site_domain_and_name.py @@ -28,7 +28,6 @@ def update_site_backward(apps, schema_editor): class Migration(migrations.Migration): - dependencies = [("sites", "0002_alter_domain_unique")] operations = [migrations.RunPython(update_site_forward, update_site_backward)] diff --git a/elearner/contrib/sites/migrations/0004_alter_options_ordering_domain.py b/elearner/contrib/sites/migrations/0004_alter_options_ordering_domain.py index 00c9a74..095ca00 100644 --- a/elearner/contrib/sites/migrations/0004_alter_options_ordering_domain.py +++ b/elearner/contrib/sites/migrations/0004_alter_options_ordering_domain.py @@ -4,14 +4,17 @@ class Migration(migrations.Migration): - dependencies = [ - ('sites', '0003_set_site_domain_and_name'), + ("sites", "0003_set_site_domain_and_name"), ] operations = [ migrations.AlterModelOptions( - name='site', - options={'ordering': ['domain'], 'verbose_name': 'site', 'verbose_name_plural': 'sites'}, + name="site", + options={ + "ordering": ["domain"], + "verbose_name": "site", + "verbose_name_plural": "sites", + }, ), ] diff --git a/elearner/users/admin.py b/elearner/users/admin.py index 3bca5b0..58e8d5e 100644 --- a/elearner/users/admin.py +++ b/elearner/users/admin.py @@ -10,7 +10,6 @@ @admin.register(User) class UserAdmin(auth_admin.UserAdmin): - form = UserChangeForm add_form = UserCreationForm fieldsets = ( diff --git a/elearner/users/apps.py b/elearner/users/apps.py index c940f94..6bd78f3 100644 --- a/elearner/users/apps.py +++ b/elearner/users/apps.py @@ -1,3 +1,5 @@ +import contextlib + from django.apps import AppConfig from django.utils.translation import gettext_lazy as _ @@ -7,7 +9,5 @@ class UsersConfig(AppConfig): verbose_name = _("Users") def ready(self): - try: + with contextlib.suppress(ImportError): import elearner.users.signals # noqa F401 - except ImportError: - pass diff --git a/elearner/users/migrations/0001_initial.py b/elearner/users/migrations/0001_initial.py index ef2c2d9..8896c92 100644 --- a/elearner/users/migrations/0001_initial.py +++ b/elearner/users/migrations/0001_initial.py @@ -5,7 +5,6 @@ class Migration(migrations.Migration): - initial = True dependencies = [("auth", "0008_alter_user_username_max_length")] diff --git a/elearner/users/tests/factories.py b/elearner/users/tests/factories.py index edd306c..c414495 100644 --- a/elearner/users/tests/factories.py +++ b/elearner/users/tests/factories.py @@ -6,7 +6,6 @@ class UserFactory(DjangoModelFactory): - username = Faker("user_name") email = Faker("email") name = Faker("name") diff --git a/elearner/users/views.py b/elearner/users/views.py index c7b846c..f22f5cc 100644 --- a/elearner/users/views.py +++ b/elearner/users/views.py @@ -9,7 +9,6 @@ class UserDetailView(LoginRequiredMixin, DetailView): - model = User slug_field = "username" slug_url_kwarg = "username" @@ -19,7 +18,6 @@ class UserDetailView(LoginRequiredMixin, DetailView): class UserUpdateView(LoginRequiredMixin, SuccessMessageMixin, UpdateView): - model = User fields = ["name"] success_message = _("Information successfully updated") @@ -35,7 +33,6 @@ def get_object(self): class UserRedirectView(LoginRequiredMixin, RedirectView): - permanent = False def get_redirect_url(self): diff --git a/requirements/base.in b/requirements/base.in new file mode 100644 index 0000000..63b7ed4 --- /dev/null +++ b/requirements/base.in @@ -0,0 +1,16 @@ +pytz +python-slugify +Pillow +argon2-cffi +whitenoise +redis +hiredis + +# Django +# ------------------------------------------------------------------------------ +django +django-environ +django-model-utils +django-allauth +django-crispy-forms +django-redis diff --git a/requirements/base.txt b/requirements/base.txt index 3113586..45e8998 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,16 +1,77 @@ -pytz==2021.3 # https://github.com/stub42/pytz -python-slugify==5.0.2 # https://github.com/un33k/python-slugify -Pillow==8.3.2 # https://github.com/python-pillow/Pillow -argon2-cffi==21.1.0 # https://github.com/hynek/argon2_cffi -whitenoise==5.3.0 # https://github.com/evansd/whitenoise -redis==3.5.3 # https://github.com/andymccurdy/redis-py -hiredis==2.0.0 # https://github.com/redis/hiredis-py - -# Django -# ------------------------------------------------------------------------------ -django==3.1.13 # pyup: < 3.2 # https://www.djangoproject.com/ -django-environ==0.7.0 # https://github.com/joke2k/django-environ -django-model-utils==4.1.1 # https://github.com/jazzband/django-model-utils -django-allauth==0.45.0 # https://github.com/pennersr/django-allauth -django-crispy-forms==1.13.0 # https://github.com/django-crispy-forms/django-crispy-forms -django-redis==5.0.0 # https://github.com/jazzband/django-redis +# +# This file is autogenerated by pip-compile with Python 3.11 +# by the following command: +# +# pip-compile requirements/base.in +# +argon2-cffi==23.1.0 + # via -r requirements/base.in +argon2-cffi-bindings==21.2.0 + # via argon2-cffi +asgiref==3.7.2 + # via django +certifi==2023.7.22 + # via requests +cffi==1.16.0 + # via + # argon2-cffi-bindings + # cryptography +charset-normalizer==3.3.0 + # via requests +cryptography==41.0.4 + # via pyjwt +defusedxml==0.7.1 + # via python3-openid +django==4.2.6 + # via + # -r requirements/base.in + # django-allauth + # django-crispy-forms + # django-model-utils + # django-redis +django-allauth==0.57.0 + # via -r requirements/base.in +django-crispy-forms==2.1 + # via -r requirements/base.in +django-environ==0.11.2 + # via -r requirements/base.in +django-model-utils==4.3.1 + # via -r requirements/base.in +django-redis==5.4.0 + # via -r requirements/base.in +hiredis==2.2.3 + # via -r requirements/base.in +idna==3.4 + # via requests +oauthlib==3.2.2 + # via requests-oauthlib +pillow==10.1.0 + # via -r requirements/base.in +pycparser==2.21 + # via cffi +pyjwt[crypto]==2.8.0 + # via django-allauth +python-slugify==8.0.1 + # via -r requirements/base.in +python3-openid==3.2.0 + # via django-allauth +pytz==2023.3.post1 + # via -r requirements/base.in +redis==5.0.1 + # via + # -r requirements/base.in + # django-redis +requests==2.31.0 + # via + # django-allauth + # requests-oauthlib +requests-oauthlib==1.3.1 + # via django-allauth +sqlparse==0.4.4 + # via django +text-unidecode==1.3 + # via python-slugify +urllib3==2.0.7 + # via requests +whitenoise==6.6.0 + # via -r requirements/base.in diff --git a/requirements/local.in b/requirements/local.in new file mode 100644 index 0000000..0301569 --- /dev/null +++ b/requirements/local.in @@ -0,0 +1,36 @@ +-r base.txt + +Werkzeug +ipdb +psycopg2 +pip-tools + +# Testing +# ------------------------------------------------------------------------------ +mypy +django-stubs +pytest +pytest-sugar + +# Documentation +# ------------------------------------------------------------------------------ +sphinx +sphinx-autobuild + +# Code quality +# ------------------------------------------------------------------------------ +flake8 +flake8-isort +coverage +black +pylint-django +pre-commit + +# Django +# ------------------------------------------------------------------------------ +factory-boy + +django-debug-toolbar +django-extensions +django-coverage-plugin +pytest-django diff --git a/requirements/local.txt b/requirements/local.txt index f334b7d..022fdc3 100644 --- a/requirements/local.txt +++ b/requirements/local.txt @@ -1,35 +1,337 @@ --r base.txt +# +# This file is autogenerated by pip-compile with Python 3.11 +# by the following command: +# +# pip-compile requirements/local.in +# +alabaster==0.7.13 + # via sphinx +appnope==0.1.3 + # via ipython +argon2-cffi==23.1.0 + # via -r requirements/base.txt +argon2-cffi-bindings==21.2.0 + # via + # -r requirements/base.txt + # argon2-cffi +asgiref==3.7.2 + # via + # -r requirements/base.txt + # django +astroid==2.15.8 + # via pylint +asttokens==2.4.0 + # via stack-data +babel==2.13.0 + # via sphinx +backcall==0.2.0 + # via ipython +black==23.10.0 + # via -r requirements/local.in +certifi==2023.7.22 + # via + # -r requirements/base.txt + # requests +cffi==1.16.0 + # via + # -r requirements/base.txt + # argon2-cffi-bindings + # cryptography +cfgv==3.4.0 + # via pre-commit +charset-normalizer==3.3.0 + # via + # -r requirements/base.txt + # requests +click==8.1.7 + # via black +colorama==0.4.6 + # via sphinx-autobuild +coverage==7.3.2 + # via + # -r requirements/local.in + # django-coverage-plugin +cryptography==41.0.4 + # via + # -r requirements/base.txt + # pyjwt +decorator==5.1.1 + # via + # ipdb + # ipython +defusedxml==0.7.1 + # via + # -r requirements/base.txt + # python3-openid +dill==0.3.7 + # via pylint +distlib==0.3.7 + # via virtualenv +django==4.2.6 + # via + # -r requirements/base.txt + # django-allauth + # django-crispy-forms + # django-debug-toolbar + # django-extensions + # django-model-utils + # django-redis + # django-stubs + # django-stubs-ext +django-allauth==0.57.0 + # via -r requirements/base.txt +django-coverage-plugin==3.1.0 + # via -r requirements/local.in +django-crispy-forms==2.1 + # via -r requirements/base.txt +django-debug-toolbar==4.2.0 + # via -r requirements/local.in +django-environ==0.11.2 + # via -r requirements/base.txt +django-extensions==3.2.3 + # via -r requirements/local.in +django-model-utils==4.3.1 + # via -r requirements/base.txt +django-redis==5.4.0 + # via -r requirements/base.txt +django-stubs==4.2.5 + # via -r requirements/local.in +django-stubs-ext==4.2.5 + # via django-stubs +docutils==0.20.1 + # via sphinx +executing==2.0.0 + # via stack-data +factory-boy==3.3.0 + # via -r requirements/local.in +faker==19.11.0 + # via factory-boy +filelock==3.12.4 + # via virtualenv +flake8==6.1.0 + # via + # -r requirements/local.in + # flake8-isort +flake8-isort==6.1.0 + # via -r requirements/local.in +hiredis==2.2.3 + # via -r requirements/base.txt +identify==2.5.30 + # via pre-commit +idna==3.4 + # via + # -r requirements/base.txt + # requests +imagesize==1.4.1 + # via sphinx +iniconfig==2.0.0 + # via pytest +ipdb==0.13.13 + # via -r requirements/local.in +ipython==8.16.1 + # via ipdb +isort==5.12.0 + # via + # flake8-isort + # pylint +jedi==0.19.1 + # via ipython +jinja2==3.1.2 + # via sphinx +lazy-object-proxy==1.9.0 + # via astroid +livereload==2.6.3 + # via sphinx-autobuild +markupsafe==2.1.3 + # via + # jinja2 + # werkzeug +matplotlib-inline==0.1.6 + # via ipython +mccabe==0.7.0 + # via + # flake8 + # pylint +mypy==1.6.1 + # via + # -r requirements/local.in + # django-stubs +mypy-extensions==1.0.0 + # via + # black + # mypy +nodeenv==1.8.0 + # via pre-commit +oauthlib==3.2.2 + # via + # -r requirements/base.txt + # requests-oauthlib +packaging==23.2 + # via + # black + # pytest + # pytest-sugar + # sphinx +parso==0.8.3 + # via jedi +pathspec==0.11.2 + # via black +pexpect==4.8.0 + # via ipython +pickleshare==0.7.5 + # via ipython +pillow==10.1.0 + # via -r requirements/base.txt +platformdirs==3.11.0 + # via + # black + # pylint + # virtualenv +pluggy==1.3.0 + # via pytest +pre-commit==3.5.0 + # via -r requirements/local.in +prompt-toolkit==3.0.39 + # via ipython +psycopg2==2.9.9 + # via -r requirements/local.in +ptyprocess==0.7.0 + # via pexpect +pure-eval==0.2.2 + # via stack-data +pycodestyle==2.11.1 + # via flake8 +pycparser==2.21 + # via + # -r requirements/base.txt + # cffi +pyflakes==3.1.0 + # via flake8 +pygments==2.16.1 + # via + # ipython + # sphinx +pyjwt[crypto]==2.8.0 + # via + # -r requirements/base.txt + # django-allauth +pylint==2.17.7 + # via + # pylint-django + # pylint-plugin-utils +pylint-django==2.5.3 + # via -r requirements/local.in +pylint-plugin-utils==0.8.2 + # via pylint-django +pytest==7.4.2 + # via + # -r requirements/local.in + # pytest-django + # pytest-sugar +pytest-django==4.5.2 + # via -r requirements/local.in +pytest-sugar==0.9.7 + # via -r requirements/local.in +python-dateutil==2.8.2 + # via faker +python-slugify==8.0.1 + # via -r requirements/base.txt +python3-openid==3.2.0 + # via + # -r requirements/base.txt + # django-allauth +pytz==2023.3.post1 + # via -r requirements/base.txt +pyyaml==6.0.1 + # via pre-commit +redis==5.0.1 + # via + # -r requirements/base.txt + # django-redis +requests==2.31.0 + # via + # -r requirements/base.txt + # django-allauth + # requests-oauthlib + # sphinx +requests-oauthlib==1.3.1 + # via + # -r requirements/base.txt + # django-allauth +six==1.16.0 + # via + # asttokens + # livereload + # python-dateutil +snowballstemmer==2.2.0 + # via sphinx +sphinx==7.2.6 + # via + # -r requirements/local.in + # sphinx-autobuild + # sphinxcontrib-applehelp + # sphinxcontrib-devhelp + # sphinxcontrib-htmlhelp + # sphinxcontrib-qthelp + # sphinxcontrib-serializinghtml +sphinx-autobuild==2021.3.14 + # via -r requirements/local.in +sphinxcontrib-applehelp==1.0.7 + # via sphinx +sphinxcontrib-devhelp==1.0.5 + # via sphinx +sphinxcontrib-htmlhelp==2.0.4 + # via sphinx +sphinxcontrib-jsmath==1.0.1 + # via sphinx +sphinxcontrib-qthelp==1.0.6 + # via sphinx +sphinxcontrib-serializinghtml==1.1.9 + # via sphinx +sqlparse==0.4.4 + # via + # -r requirements/base.txt + # django + # django-debug-toolbar +stack-data==0.6.3 + # via ipython +termcolor==2.3.0 + # via pytest-sugar +text-unidecode==1.3 + # via + # -r requirements/base.txt + # python-slugify +tomlkit==0.12.1 + # via pylint +tornado==6.3.3 + # via livereload +traitlets==5.11.2 + # via + # ipython + # matplotlib-inline +types-pytz==2023.3.1.1 + # via django-stubs +types-pyyaml==6.0.12.12 + # via django-stubs +typing-extensions==4.8.0 + # via + # django-stubs + # django-stubs-ext + # mypy +urllib3==2.0.7 + # via + # -r requirements/base.txt + # requests +virtualenv==20.24.5 + # via pre-commit +wcwidth==0.2.8 + # via prompt-toolkit +werkzeug==3.0.0 + # via -r requirements/local.in +whitenoise==6.6.0 + # via -r requirements/base.txt +wrapt==1.15.0 + # via astroid -Werkzeug==1.0.1 # https://github.com/pallets/werkzeug -ipdb==0.13.9 # https://github.com/gotcha/ipdb -psycopg2-binary==2.9.1 # https://github.com/psycopg/psycopg2 - -# Testing -# ------------------------------------------------------------------------------ -mypy==0.910 # https://github.com/python/mypy -django-stubs==1.8.0 # https://github.com/typeddjango/django-stubs -pytest==6.2.5 # https://github.com/pytest-dev/pytest -pytest-sugar==0.9.4 # https://github.com/Frozenball/pytest-sugar - -# Documentation -# ------------------------------------------------------------------------------ -sphinx==4.2.0 # https://github.com/sphinx-doc/sphinx -sphinx-autobuild==2021.3.14 # https://github.com/GaretJax/sphinx-autobuild - -# Code quality -# ------------------------------------------------------------------------------ -flake8==3.9.2 # https://github.com/PyCQA/flake8 -flake8-isort==4.0.0 # https://github.com/gforcada/flake8-isort -coverage==5.5 # https://github.com/nedbat/coveragepy -black==21.9b0 # https://github.com/psf/black -pylint-django==2.4.4 # https://github.com/PyCQA/pylint-django -pre-commit==2.15.0 # https://github.com/pre-commit/pre-commit - -# Django -# ------------------------------------------------------------------------------ -factory-boy==3.2.0 # https://github.com/FactoryBoy/factory_boy - -django-debug-toolbar==3.2.2 # https://github.com/jazzband/django-debug-toolbar -django-extensions==3.1.3 # https://github.com/django-extensions/django-extensions -django-coverage-plugin==2.0.0 # https://github.com/nedbat/django_coverage_plugin -pytest-django==4.4.0 # https://github.com/pytest-dev/pytest-django +# The following packages are considered to be unsafe in a requirements file: +# setuptools