From e06bc7dba30a4e397b9ae18e060d9ac61263857a Mon Sep 17 00:00:00 2001 From: thomas girod Date: Mon, 24 Jun 2024 11:24:08 +0200 Subject: [PATCH 1/3] reorganize pyproject.toml --- .github/actions/setup_project/action.yml | 2 +- doc/start/install.rst | 2 +- poetry.lock | 124 +++++++++++------------ pyproject.toml | 32 +++--- 4 files changed, 79 insertions(+), 81 deletions(-) diff --git a/.github/actions/setup_project/action.yml b/.github/actions/setup_project/action.yml index beb091e2..975dbde9 100644 --- a/.github/actions/setup_project/action.yml +++ b/.github/actions/setup_project/action.yml @@ -45,7 +45,7 @@ runs: ${{ runner.os }}-poetry- - name: Install dependencies - run: poetry install -E testing -E docs + run: poetry install --with docs,tests shell: bash - name: Install xapian diff --git a/doc/start/install.rst b/doc/start/install.rst index d07e2ac4..db1a9749 100644 --- a/doc/start/install.rst +++ b/doc/start/install.rst @@ -179,7 +179,7 @@ Cette commande génère la documentation à chacune de ses modifications, inutil Les dépendances pour la documentation sont optionnelles. Avant de commencer à travailler sur la doc, il faut donc les installer - avec la commande :code:`poetry install -E docs` + avec la commande :code:`poetry install --with docs` .. sourcecode:: bash diff --git a/poetry.lock b/poetry.lock index 00ba5bb5..8bf30dcd 100644 --- a/poetry.lock +++ b/poetry.lock @@ -322,67 +322,67 @@ files = [ [[package]] name = "coverage" -version = "5.5" +version = "7.5.4" description = "Code coverage measurement for Python" -optional = true -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" +optional = false +python-versions = ">=3.8" files = [ - {file = "coverage-5.5-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:b6d534e4b2ab35c9f93f46229363e17f63c53ad01330df9f2d6bd1187e5eaacf"}, - {file = "coverage-5.5-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:b7895207b4c843c76a25ab8c1e866261bcfe27bfaa20c192de5190121770672b"}, - {file = "coverage-5.5-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:c2723d347ab06e7ddad1a58b2a821218239249a9e4365eaff6649d31180c1669"}, - {file = "coverage-5.5-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:900fbf7759501bc7807fd6638c947d7a831fc9fdf742dc10f02956ff7220fa90"}, - {file = "coverage-5.5-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:004d1880bed2d97151facef49f08e255a20ceb6f9432df75f4eef018fdd5a78c"}, - {file = "coverage-5.5-cp27-cp27m-win32.whl", hash = "sha256:06191eb60f8d8a5bc046f3799f8a07a2d7aefb9504b0209aff0b47298333302a"}, - {file = "coverage-5.5-cp27-cp27m-win_amd64.whl", hash = "sha256:7501140f755b725495941b43347ba8a2777407fc7f250d4f5a7d2a1050ba8e82"}, - {file = "coverage-5.5-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:372da284cfd642d8e08ef606917846fa2ee350f64994bebfbd3afb0040436905"}, - {file = "coverage-5.5-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:8963a499849a1fc54b35b1c9f162f4108017b2e6db2c46c1bed93a72262ed083"}, - {file = "coverage-5.5-cp27-cp27mu-manylinux2010_i686.whl", hash = "sha256:869a64f53488f40fa5b5b9dcb9e9b2962a66a87dab37790f3fcfb5144b996ef5"}, - {file = "coverage-5.5-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:4a7697d8cb0f27399b0e393c0b90f0f1e40c82023ea4d45d22bce7032a5d7b81"}, - {file = "coverage-5.5-cp310-cp310-macosx_10_14_x86_64.whl", hash = "sha256:8d0a0725ad7c1a0bcd8d1b437e191107d457e2ec1084b9f190630a4fb1af78e6"}, - {file = "coverage-5.5-cp310-cp310-manylinux1_x86_64.whl", hash = "sha256:51cb9476a3987c8967ebab3f0fe144819781fca264f57f89760037a2ea191cb0"}, - {file = "coverage-5.5-cp310-cp310-win_amd64.whl", hash = "sha256:c0891a6a97b09c1f3e073a890514d5012eb256845c451bd48f7968ef939bf4ae"}, - {file = "coverage-5.5-cp35-cp35m-macosx_10_9_x86_64.whl", hash = "sha256:3487286bc29a5aa4b93a072e9592f22254291ce96a9fbc5251f566b6b7343cdb"}, - {file = "coverage-5.5-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:deee1077aae10d8fa88cb02c845cfba9b62c55e1183f52f6ae6a2df6a2187160"}, - {file = "coverage-5.5-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:f11642dddbb0253cc8853254301b51390ba0081750a8ac03f20ea8103f0c56b6"}, - {file = "coverage-5.5-cp35-cp35m-manylinux2010_i686.whl", hash = "sha256:6c90e11318f0d3c436a42409f2749ee1a115cd8b067d7f14c148f1ce5574d701"}, - {file = "coverage-5.5-cp35-cp35m-manylinux2010_x86_64.whl", hash = "sha256:30c77c1dc9f253283e34c27935fded5015f7d1abe83bc7821680ac444eaf7793"}, - {file = "coverage-5.5-cp35-cp35m-win32.whl", hash = "sha256:9a1ef3b66e38ef8618ce5fdc7bea3d9f45f3624e2a66295eea5e57966c85909e"}, - {file = "coverage-5.5-cp35-cp35m-win_amd64.whl", hash = "sha256:972c85d205b51e30e59525694670de6a8a89691186012535f9d7dbaa230e42c3"}, - {file = "coverage-5.5-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:af0e781009aaf59e25c5a678122391cb0f345ac0ec272c7961dc5455e1c40066"}, - {file = "coverage-5.5-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:74d881fc777ebb11c63736622b60cb9e4aee5cace591ce274fb69e582a12a61a"}, - {file = "coverage-5.5-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:92b017ce34b68a7d67bd6d117e6d443a9bf63a2ecf8567bb3d8c6c7bc5014465"}, - {file = "coverage-5.5-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:d636598c8305e1f90b439dbf4f66437de4a5e3c31fdf47ad29542478c8508bbb"}, - {file = "coverage-5.5-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:41179b8a845742d1eb60449bdb2992196e211341818565abded11cfa90efb821"}, - {file = "coverage-5.5-cp36-cp36m-win32.whl", hash = "sha256:040af6c32813fa3eae5305d53f18875bedd079960822ef8ec067a66dd8afcd45"}, - {file = "coverage-5.5-cp36-cp36m-win_amd64.whl", hash = "sha256:5fec2d43a2cc6965edc0bb9e83e1e4b557f76f843a77a2496cbe719583ce8184"}, - {file = "coverage-5.5-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:18ba8bbede96a2c3dde7b868de9dcbd55670690af0988713f0603f037848418a"}, - {file = "coverage-5.5-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:2910f4d36a6a9b4214bb7038d537f015346f413a975d57ca6b43bf23d6563b53"}, - {file = "coverage-5.5-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:f0b278ce10936db1a37e6954e15a3730bea96a0997c26d7fee88e6c396c2086d"}, - {file = "coverage-5.5-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:796c9c3c79747146ebd278dbe1e5c5c05dd6b10cc3bcb8389dfdf844f3ead638"}, - {file = "coverage-5.5-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:53194af30d5bad77fcba80e23a1441c71abfb3e01192034f8246e0d8f99528f3"}, - {file = "coverage-5.5-cp37-cp37m-win32.whl", hash = "sha256:184a47bbe0aa6400ed2d41d8e9ed868b8205046518c52464fde713ea06e3a74a"}, - {file = "coverage-5.5-cp37-cp37m-win_amd64.whl", hash = "sha256:2949cad1c5208b8298d5686d5a85b66aae46d73eec2c3e08c817dd3513e5848a"}, - {file = "coverage-5.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:217658ec7187497e3f3ebd901afdca1af062b42cfe3e0dafea4cced3983739f6"}, - {file = "coverage-5.5-cp38-cp38-manylinux1_i686.whl", hash = "sha256:1aa846f56c3d49205c952d8318e76ccc2ae23303351d9270ab220004c580cfe2"}, - {file = "coverage-5.5-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:24d4a7de75446be83244eabbff746d66b9240ae020ced65d060815fac3423759"}, - {file = "coverage-5.5-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:d1f8bf7b90ba55699b3a5e44930e93ff0189aa27186e96071fac7dd0d06a1873"}, - {file = "coverage-5.5-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:970284a88b99673ccb2e4e334cfb38a10aab7cd44f7457564d11898a74b62d0a"}, - {file = "coverage-5.5-cp38-cp38-win32.whl", hash = "sha256:01d84219b5cdbfc8122223b39a954820929497a1cb1422824bb86b07b74594b6"}, - {file = "coverage-5.5-cp38-cp38-win_amd64.whl", hash = "sha256:2e0d881ad471768bf6e6c2bf905d183543f10098e3b3640fc029509530091502"}, - {file = "coverage-5.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:d1f9ce122f83b2305592c11d64f181b87153fc2c2bbd3bb4a3dde8303cfb1a6b"}, - {file = "coverage-5.5-cp39-cp39-manylinux1_i686.whl", hash = "sha256:13c4ee887eca0f4c5a247b75398d4114c37882658300e153113dafb1d76de529"}, - {file = "coverage-5.5-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:52596d3d0e8bdf3af43db3e9ba8dcdaac724ba7b5ca3f6358529d56f7a166f8b"}, - {file = "coverage-5.5-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:2cafbbb3af0733db200c9b5f798d18953b1a304d3f86a938367de1567f4b5bff"}, - {file = "coverage-5.5-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:44d654437b8ddd9eee7d1eaee28b7219bec228520ff809af170488fd2fed3e2b"}, - {file = "coverage-5.5-cp39-cp39-win32.whl", hash = "sha256:d314ed732c25d29775e84a960c3c60808b682c08d86602ec2c3008e1202e3bb6"}, - {file = "coverage-5.5-cp39-cp39-win_amd64.whl", hash = "sha256:13034c4409db851670bc9acd836243aeee299949bd5673e11844befcb0149f03"}, - {file = "coverage-5.5-pp36-none-any.whl", hash = "sha256:f030f8873312a16414c0d8e1a1ddff2d3235655a2174e3648b4fa66b3f2f1079"}, - {file = "coverage-5.5-pp37-none-any.whl", hash = "sha256:2a3859cb82dcbda1cfd3e6f71c27081d18aa251d20a17d87d26d4cd216fb0af4"}, - {file = "coverage-5.5.tar.gz", hash = "sha256:ebe78fe9a0e874362175b02371bdfbee64d8edc42a044253ddf4ee7d3c15212c"}, + {file = "coverage-7.5.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:6cfb5a4f556bb51aba274588200a46e4dd6b505fb1a5f8c5ae408222eb416f99"}, + {file = "coverage-7.5.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2174e7c23e0a454ffe12267a10732c273243b4f2d50d07544a91198f05c48f47"}, + {file = "coverage-7.5.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2214ee920787d85db1b6a0bd9da5f8503ccc8fcd5814d90796c2f2493a2f4d2e"}, + {file = "coverage-7.5.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1137f46adb28e3813dec8c01fefadcb8c614f33576f672962e323b5128d9a68d"}, + {file = "coverage-7.5.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b385d49609f8e9efc885790a5a0e89f2e3ae042cdf12958b6034cc442de428d3"}, + {file = "coverage-7.5.4-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:b4a474f799456e0eb46d78ab07303286a84a3140e9700b9e154cfebc8f527016"}, + {file = "coverage-7.5.4-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:5cd64adedf3be66f8ccee418473c2916492d53cbafbfcff851cbec5a8454b136"}, + {file = "coverage-7.5.4-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:e564c2cf45d2f44a9da56f4e3a26b2236504a496eb4cb0ca7221cd4cc7a9aca9"}, + {file = "coverage-7.5.4-cp310-cp310-win32.whl", hash = "sha256:7076b4b3a5f6d2b5d7f1185fde25b1e54eb66e647a1dfef0e2c2bfaf9b4c88c8"}, + {file = "coverage-7.5.4-cp310-cp310-win_amd64.whl", hash = "sha256:018a12985185038a5b2bcafab04ab833a9a0f2c59995b3cec07e10074c78635f"}, + {file = "coverage-7.5.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:db14f552ac38f10758ad14dd7b983dbab424e731588d300c7db25b6f89e335b5"}, + {file = "coverage-7.5.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3257fdd8e574805f27bb5342b77bc65578e98cbc004a92232106344053f319ba"}, + {file = "coverage-7.5.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3a6612c99081d8d6134005b1354191e103ec9705d7ba2754e848211ac8cacc6b"}, + {file = "coverage-7.5.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d45d3cbd94159c468b9b8c5a556e3f6b81a8d1af2a92b77320e887c3e7a5d080"}, + {file = "coverage-7.5.4-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ed550e7442f278af76d9d65af48069f1fb84c9f745ae249c1a183c1e9d1b025c"}, + {file = "coverage-7.5.4-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:7a892be37ca35eb5019ec85402c3371b0f7cda5ab5056023a7f13da0961e60da"}, + {file = "coverage-7.5.4-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:8192794d120167e2a64721d88dbd688584675e86e15d0569599257566dec9bf0"}, + {file = "coverage-7.5.4-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:820bc841faa502e727a48311948e0461132a9c8baa42f6b2b84a29ced24cc078"}, + {file = "coverage-7.5.4-cp311-cp311-win32.whl", hash = "sha256:6aae5cce399a0f065da65c7bb1e8abd5c7a3043da9dceb429ebe1b289bc07806"}, + {file = "coverage-7.5.4-cp311-cp311-win_amd64.whl", hash = "sha256:d2e344d6adc8ef81c5a233d3a57b3c7d5181f40e79e05e1c143da143ccb6377d"}, + {file = "coverage-7.5.4-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:54317c2b806354cbb2dc7ac27e2b93f97096912cc16b18289c5d4e44fc663233"}, + {file = "coverage-7.5.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:042183de01f8b6d531e10c197f7f0315a61e8d805ab29c5f7b51a01d62782747"}, + {file = "coverage-7.5.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a6bb74ed465d5fb204b2ec41d79bcd28afccf817de721e8a807d5141c3426638"}, + {file = "coverage-7.5.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b3d45ff86efb129c599a3b287ae2e44c1e281ae0f9a9bad0edc202179bcc3a2e"}, + {file = "coverage-7.5.4-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5013ed890dc917cef2c9f765c4c6a8ae9df983cd60dbb635df8ed9f4ebc9f555"}, + {file = "coverage-7.5.4-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:1014fbf665fef86cdfd6cb5b7371496ce35e4d2a00cda501cf9f5b9e6fced69f"}, + {file = "coverage-7.5.4-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:3684bc2ff328f935981847082ba4fdc950d58906a40eafa93510d1b54c08a66c"}, + {file = "coverage-7.5.4-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:581ea96f92bf71a5ec0974001f900db495488434a6928a2ca7f01eee20c23805"}, + {file = "coverage-7.5.4-cp312-cp312-win32.whl", hash = "sha256:73ca8fbc5bc622e54627314c1a6f1dfdd8db69788f3443e752c215f29fa87a0b"}, + {file = "coverage-7.5.4-cp312-cp312-win_amd64.whl", hash = "sha256:cef4649ec906ea7ea5e9e796e68b987f83fa9a718514fe147f538cfeda76d7a7"}, + {file = "coverage-7.5.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:cdd31315fc20868c194130de9ee6bfd99755cc9565edff98ecc12585b90be882"}, + {file = "coverage-7.5.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:02ff6e898197cc1e9fa375581382b72498eb2e6d5fc0b53f03e496cfee3fac6d"}, + {file = "coverage-7.5.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d05c16cf4b4c2fc880cb12ba4c9b526e9e5d5bb1d81313d4d732a5b9fe2b9d53"}, + {file = "coverage-7.5.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c5986ee7ea0795a4095ac4d113cbb3448601efca7f158ec7f7087a6c705304e4"}, + {file = "coverage-7.5.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5df54843b88901fdc2f598ac06737f03d71168fd1175728054c8f5a2739ac3e4"}, + {file = "coverage-7.5.4-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:ab73b35e8d109bffbda9a3e91c64e29fe26e03e49addf5b43d85fc426dde11f9"}, + {file = "coverage-7.5.4-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:aea072a941b033813f5e4814541fc265a5c12ed9720daef11ca516aeacd3bd7f"}, + {file = "coverage-7.5.4-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:16852febd96acd953b0d55fc842ce2dac1710f26729b31c80b940b9afcd9896f"}, + {file = "coverage-7.5.4-cp38-cp38-win32.whl", hash = "sha256:8f894208794b164e6bd4bba61fc98bf6b06be4d390cf2daacfa6eca0a6d2bb4f"}, + {file = "coverage-7.5.4-cp38-cp38-win_amd64.whl", hash = "sha256:e2afe743289273209c992075a5a4913e8d007d569a406ffed0bd080ea02b0633"}, + {file = "coverage-7.5.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:b95c3a8cb0463ba9f77383d0fa8c9194cf91f64445a63fc26fb2327e1e1eb088"}, + {file = "coverage-7.5.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3d7564cc09dd91b5a6001754a5b3c6ecc4aba6323baf33a12bd751036c998be4"}, + {file = "coverage-7.5.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:44da56a2589b684813f86d07597fdf8a9c6ce77f58976727329272f5a01f99f7"}, + {file = "coverage-7.5.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e16f3d6b491c48c5ae726308e6ab1e18ee830b4cdd6913f2d7f77354b33f91c8"}, + {file = "coverage-7.5.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dbc5958cb471e5a5af41b0ddaea96a37e74ed289535e8deca404811f6cb0bc3d"}, + {file = "coverage-7.5.4-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:a04e990a2a41740b02d6182b498ee9796cf60eefe40cf859b016650147908029"}, + {file = "coverage-7.5.4-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:ddbd2f9713a79e8e7242d7c51f1929611e991d855f414ca9996c20e44a895f7c"}, + {file = "coverage-7.5.4-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:b1ccf5e728ccf83acd313c89f07c22d70d6c375a9c6f339233dcf792094bcbf7"}, + {file = "coverage-7.5.4-cp39-cp39-win32.whl", hash = "sha256:56b4eafa21c6c175b3ede004ca12c653a88b6f922494b023aeb1e836df953ace"}, + {file = "coverage-7.5.4-cp39-cp39-win_amd64.whl", hash = "sha256:65e528e2e921ba8fd67d9055e6b9f9e34b21ebd6768ae1c1723f4ea6ace1234d"}, + {file = "coverage-7.5.4-pp38.pp39.pp310-none-any.whl", hash = "sha256:79b356f3dd5b26f3ad23b35c75dbdaf1f9e2450b6bcefc6d0825ea0aa3f86ca5"}, + {file = "coverage-7.5.4.tar.gz", hash = "sha256:a44963520b069e12789d0faea4e9fdb1e410cdc4aab89d94f7f55cbb7fef0353"}, ] [package.extras] -toml = ["toml"] +toml = ["tomli"] [[package]] name = "cryptography" @@ -1394,7 +1394,7 @@ test = ["cython", "html5lib", "pytest (>=4.6)", "typed_ast"] name = "sphinx-copybutton" version = "0.4.0" description = "Add a copy button to each of your code cells." -optional = true +optional = false python-versions = ">=3.6" files = [ {file = "sphinx-copybutton-0.4.0.tar.gz", hash = "sha256:8daed13a87afd5013c3a9af3575cc4d5bec052075ccd3db243f895c07a689386"}, @@ -1412,7 +1412,7 @@ rtd = ["ipython", "sphinx", "sphinx-book-theme"] name = "sphinx-rtd-theme" version = "1.3.0" description = "Read the Docs theme for Sphinx" -optional = true +optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7" files = [ {file = "sphinx_rtd_theme-1.3.0-py2.py3-none-any.whl", hash = "sha256:46ddef89cc2416a81ecfbeaceab1881948c014b1b6e4450b815311a89fb977b0"}, @@ -1479,7 +1479,7 @@ test = ["html5lib", "pytest"] name = "sphinxcontrib-jquery" version = "4.1" description = "Extension to include jQuery on newer Sphinx releases" -optional = true +optional = false python-versions = ">=2.7" files = [ {file = "sphinxcontrib-jquery-4.1.tar.gz", hash = "sha256:1620739f04e36a2c779f1a131a2dfd49b2fd07351bf1968ced074365933abc7a"}, @@ -1630,11 +1630,7 @@ django = ">=3.2" django-haystack = ">=2.8.0" filelock = ">=3.4" -[extras] -docs = ["Sphinx", "sphinx-copybutton", "sphinx-rtd-theme"] -testing = ["coverage"] - [metadata] lock-version = "2.0" python-versions = "^3.10,<3.12" -content-hash = "1b87ea58b2796016b7f16421fd0d4276d88fc6be217e3e5934f3399b834af1f6" +content-hash = "fe98c5784d71478c6da090c2adae73fbbff3ef47e0cd5fa8893811e4b357949b" diff --git a/pyproject.toml b/pyproject.toml index a27426eb..d1157762 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,26 +48,28 @@ dict2xml = "^1.7.3" Sphinx = "^5" # Needed for building xapian tomli = "^2.0.1" -# Extra optional dependencies -coverage = {version = "^5.5", optional = true} - -# Docs extra dependencies -sphinx-rtd-theme = {version = "^1.0.0", optional = true} -sphinx-copybutton = {version = "^0.4.0", optional = true} - -[tool.xapian] -version = "1.4.25" - -[tool.poetry.extras] -testing = ["coverage"] -docs = ["Sphinx", "sphinx-rtd-theme", "sphinx-copybutton"] - -[tool.poetry.dev-dependencies] +[tool.poetry.group.dev.dependencies] freezegun = "^1.2.2" # used to test time-dependent code django-debug-toolbar = "^4.0.0" ipython = "^7.28.0" black = "^23.3.0" +[tool.poetry.group.tests.dependencies] +coverage = "^7.5.4" + +[tool.poetry.group.tests] +optional = true + +[tool.poetry.group.docs.dependencies] +sphinx-rtd-theme = "^1.0.0" +sphinx-copybutton = "^0.4.0" + +[tool.poetry.group.docs] +optional = true + +[tool.xapian] +version = "1.4.25" + [build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" From 9bdf3fc4ac0e3980f0f2228d6dc276cf377eb408 Mon Sep 17 00:00:00 2001 From: thomas girod Date: Mon, 24 Jun 2024 11:56:38 +0200 Subject: [PATCH 2/3] use ruff for formating Co-authored-by: Bartuccio Antoine --- .github/workflows/ci.yml | 16 ++--- accounting/views.py | 2 +- club/tests.py | 3 +- core/models.py | 8 ++- core/operations.py | 6 +- core/views/__init__.py | 5 +- core/views/files.py | 6 +- core/views/group.py | 2 +- core/views/site.py | 5 +- counter/views.py | 32 ++++++---- doc/start/devtools.rst | 54 ++++++++--------- eboutic/tests.py | 16 ++--- poetry.lock | 126 +++++++++------------------------------ pyproject.toml | 2 +- sith/settings.py | 2 +- sith/urls.py | 1 + 16 files changed, 105 insertions(+), 181 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7cd386d5..74f18dd6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,15 +8,17 @@ on: workflow_dispatch: jobs: - black: - name: Black format + ruff: + name: Ruff lint & format runs-on: ubuntu-latest steps: - - name: Check out repository - uses: actions/checkout@v3 - - name: Setup Project - uses: ./.github/actions/setup_project - - run: poetry run black --check . + - uses: actions/checkout@v4 + - name: ruff format + uses: chartboost/ruff-action@v1 # format + with: + args: format --diff + - name: ruff check + uses: chartboost/ruff-action@v1 # lint tests: name: Run tests and generate coverage report diff --git a/accounting/views.py b/accounting/views.py index 7182ec83..32ebc1c5 100644 --- a/accounting/views.py +++ b/accounting/views.py @@ -599,7 +599,7 @@ class OperationPDFView(CanViewMixin, DetailView): payment_mode = "" for m in settings.SITH_ACCOUNTING_PAYMENT_METHOD: if m[0] == mode: - payment_mode += "[\u00D7]" + payment_mode += "[\u00d7]" else: payment_mode += "[ ]" payment_mode += " %s\n" % (m[1]) diff --git a/club/tests.py b/club/tests.py index 0cc05e89..b333cc48 100644 --- a/club/tests.py +++ b/club/tests.py @@ -861,8 +861,7 @@ class MailingFormTest(TestCase): reverse("club:mailing", kwargs={"club_id": self.bdf.id}), { "action": MailingForm.ACTION_REMOVE_SUBSCRIPTION, - "removal_%d" - % mde.id: [ + "removal_%d" % mde.id: [ user.id for user in mde.subscriptions.filter( user__in=[self.rbatsbak, self.comunity] diff --git a/core/models.py b/core/models.py index c8a38426..c804d30b 100644 --- a/core/models.py +++ b/core/models.py @@ -698,9 +698,11 @@ class User(AbstractBaseUser): %s """ % ( - self.profile_pict.get_download_url() - if self.profile_pict - else staticfiles_storage.url("core/img/unknown.jpg"), + ( + self.profile_pict.get_download_url() + if self.profile_pict + else staticfiles_storage.url("core/img/unknown.jpg") + ), _("Profile"), escape(self.get_display_name()), ) diff --git a/core/operations.py b/core/operations.py index 29740292..10882f22 100644 --- a/core/operations.py +++ b/core/operations.py @@ -23,9 +23,9 @@ # """ - This page is useful for custom migration tricks. - Sometimes, when you need to have a migration hack and you think it can be - useful again, put it there, we never know if we might need the hack again. +This page is useful for custom migration tricks. +Sometimes, when you need to have a migration hack and you think it can be +useful again, put it there, we never know if we might need the hack again. """ from django.db import connection, migrations diff --git a/core/views/__init__.py b/core/views/__init__.py index fc807663..a36147b4 100644 --- a/core/views/__init__.py +++ b/core/views/__init__.py @@ -314,9 +314,8 @@ class QuickNotifMixin: quick_notif_list = [] def dispatch(self, request, *arg, **kwargs): - self.quick_notif_list = ( - [] - ) # In some cases, the class can stay instanciated, so we need to reset the list + # In some cases, the class can stay instanciated, so we need to reset the list + self.quick_notif_list = [] return super(QuickNotifMixin, self).dispatch(request, *arg, **kwargs) def get_success_url(self): diff --git a/core/views/files.py b/core/views/files.py index 986477ab..61d3aec9 100644 --- a/core/views/files.py +++ b/core/views/files.py @@ -97,12 +97,10 @@ class _MultipleFieldMixin: return result -class MultipleFileField(_MultipleFieldMixin, forms.FileField): - ... +class MultipleFileField(_MultipleFieldMixin, forms.FileField): ... -class MultipleImageField(_MultipleFieldMixin, forms.ImageField): - ... +class MultipleImageField(_MultipleFieldMixin, forms.ImageField): ... class AddFilesForm(forms.Form): diff --git a/core/views/group.py b/core/views/group.py index a6b61866..419d699d 100644 --- a/core/views/group.py +++ b/core/views/group.py @@ -15,7 +15,7 @@ # """ - This module contains views to manage Groups +This module contains views to manage Groups """ from django.views.generic.edit import UpdateView, CreateView, DeleteView diff --git a/core/views/site.py b/core/views/site.py index c34cf2c4..c7163488 100644 --- a/core/views/site.py +++ b/core/views/site.py @@ -100,9 +100,8 @@ def search_club(query, as_json=False): if query: clubs = Club.objects.filter(name__icontains=query).all() clubs = clubs[:5] - if ( - as_json - ): # Re-loads json to avoid double encoding by JsonResponse, but still benefit from serializers + if as_json: + # Re-loads json to avoid double encoding by JsonResponse, but still benefit from serializers clubs = json.loads(serializers.serialize("json", clubs, fields=("name"))) else: clubs = list(clubs) diff --git a/counter/views.py b/counter/views.py index 6bbc819d..4c0b167b 100644 --- a/counter/views.py +++ b/counter/views.py @@ -141,9 +141,11 @@ class CounterTabsMixin(TabedViewMixin): "url": reverse_lazy( "counter:details", kwargs={ - "counter_id": self.object.stock_owner.counter.id - if hasattr(self.object, "stock_owner") - else self.object.id + "counter_id": ( + self.object.stock_owner.counter.id + if hasattr(self.object, "stock_owner") + else self.object.id + ) }, ), "slug": "counter", @@ -160,9 +162,11 @@ class CounterTabsMixin(TabedViewMixin): "url": reverse_lazy( "counter:cash_summary", kwargs={ - "counter_id": self.object.stock_owner.counter.id - if hasattr(self.object, "stock_owner") - else self.object.id + "counter_id": ( + self.object.stock_owner.counter.id + if hasattr(self.object, "stock_owner") + else self.object.id + ) }, ), "slug": "cash_summary", @@ -174,9 +178,11 @@ class CounterTabsMixin(TabedViewMixin): "url": reverse_lazy( "counter:last_ops", kwargs={ - "counter_id": self.object.stock_owner.counter.id - if hasattr(self.object, "stock_owner") - else self.object.id + "counter_id": ( + self.object.stock_owner.counter.id + if hasattr(self.object, "stock_owner") + else self.object.id + ) }, ), "slug": "last_ops", @@ -189,9 +195,11 @@ class CounterTabsMixin(TabedViewMixin): "url": reverse_lazy( "stock:take_items", kwargs={ - "stock_id": self.object.stock.id - if hasattr(self.object, "stock") - else self.object.stock_owner.id + "stock_id": ( + self.object.stock.id + if hasattr(self.object, "stock") + else self.object.stock_owner.id + ) }, ), "slug": "take_items_from_stock", diff --git a/doc/start/devtools.rst b/doc/start/devtools.rst index 9256bfb4..80d56a13 100644 --- a/doc/start/devtools.rst +++ b/doc/start/devtools.rst @@ -1,70 +1,66 @@ Configurer son environnement de développement ============================================= -Le projet n'est en aucun cas lié à un quelconque environnement de développement. Il est possible pour chacun de travailler avec les outils dont il a envie et d'utiliser l'éditeur de code avec lequel il est le plus à l'aise. +Le projet n'est en aucun cas lié à un quelconque environnement de développement. +Il est possible pour chacun de travailler avec les outils dont il a envie et d'utiliser l'éditeur de code avec lequel il est le plus à l'aise. Pour donner une idée, Skia a écrit une énorme partie de projet avec l'éditeur *Vim* sur du GNU/Linux alors que Sli a utilisé *Sublime Text* sur MacOS et que Maréchal travaille avec PyCharm -sur Windows muni de WSL. +sur ~~Windows muni de WSL~~ Arch Linux btw. -Configurer Black pour son éditeur +Configurer Ruff pour son éditeur --------------------------------- .. note:: - Black est inclus dans les dépendances du projet. + Ruff est inclus dans les dépendances du projet. Si vous avez réussi à terminer l'installation, vous n'avez donc pas de configuration supplémentaire à effectuer. -Pour utiliser Black, placez-vous à la racine du projet et lancez la commande suivante : +Pour utiliser Ruff, placez-vous à la racine du projet et lancez la commande suivante : .. code-block:: - black . + ruff format # pour formatter le code + ruff check # pour linter le code -Black va alors faire son travail sur l'ensemble du projet puis vous dire quels documents -ont été reformatés. +Ruff va alors faire son travail sur l'ensemble du projet puis vous dire +si des documents ont été reformatés (si vous avez fait `ruff format`) +ou bien s'il y a des erreurs à réparer (si vous avez faire `ruff check`). -Appeler Black en ligne de commandes avant de pousser votre code sur Github +Appeler Ruff en ligne de commandes avant de pousser votre code sur Github est une technique qui marche très bien. Cependant, vous risquez de souvent l'oublier. -Or, lorsque le code est mal formaté, la pipeline bloque les PR sur les branches protégées. +Or, lorsque le code ne respecte pas les standards de qualité, +la pipeline bloque les PR sur les branches protégées. -Pour éviter de vous faire régulièrement blacked, vous pouvez configurer -votre éditeur pour que Black fasse son travail automatiquement à chaque édition d'un fichier. +Pour éviter de vous faire régulièrement avoir, vous pouvez configurer +votre éditeur pour que Ruff fasse son travail automatiquement à chaque édition d'un fichier. Nous tenterons de vous faire ici un résumé pour deux éditeurs de textes populaires que sont VsCode et Sublime Text. VsCode ~~~~~~ -.. warning:: - - Il faut installer black dans son environement virtuel pour cet éditeur - -Black est directement pris en charge par l'extension pour le Python de VsCode, il suffit de rentrer la configuration suivante : +Installez l'extension Ruff pour VsCode. +Ensuite, ajoutez ceci dans votre configuration : .. sourcecode:: json { - "python.formatting.provider": "black", - "editor.formatOnSave": true + "[python]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "charliermarsh.ruff" + } } Sublime Text ~~~~~~~~~~~~ -Il est tout d'abord nécessaire d'installer ce plugin : https://packagecontrol.io/packages/sublack. +Vous devez installer ce plugin : https://packagecontrol.io/packages/LSP-ruff. +Suivez ensuite les instructions données dans la description du plugin. -Il suffit ensuite d'ajouter dans les settings du projet (ou directement dans les settings globales) : - -.. sourcecode:: json - - { - "sublack.black_on_save": true - } - -Si vous utilisez le plugin `anaconda `__, pensez à modifier les paramètres du linter pep8 pour éviter de recevoir des warnings dans le formatage de black comme ceci : +Si vous utilisez le plugin `anaconda `__, pensez à modifier les paramètres du linter pep8 pour éviter de recevoir des warnings dans le formatage de ruff comme ceci : .. sourcecode:: json diff --git a/eboutic/tests.py b/eboutic/tests.py index af0e5850..b37b4a7b 100644 --- a/eboutic/tests.py +++ b/eboutic/tests.py @@ -114,9 +114,7 @@ class EbouticTest(TestCase): def test_submit_basket(self): self.client.login(username="subscriber", password="plop") - self.client.cookies[ - "basket_items" - ] = """[ + self.client.cookies["basket_items"] = """[ {"id": 2, "name": "Cotis 2 semestres", "quantity": 1, "unit_price": 28}, {"id": 4, "name": "Barbar", "quantity": 3, "unit_price": 1.7} ]""" @@ -150,9 +148,7 @@ class EbouticTest(TestCase): def test_submit_invalid_basket(self): self.client.login(username="subscriber", password="plop") max_id = Product.objects.aggregate(res=Max("id"))["res"] - self.client.cookies[ - "basket_items" - ] = f"""[ + self.client.cookies["basket_items"] = f"""[ {{"id": {max_id + 1}, "name": "", "quantity": 1, "unit_price": 28}} ]""" response = self.client.get(reverse("eboutic:command")) @@ -168,9 +164,7 @@ class EbouticTest(TestCase): def test_submit_basket_illegal_quantity(self): self.client.login(username="subscriber", password="plop") - self.client.cookies[ - "basket_items" - ] = """[ + self.client.cookies["basket_items"] = """[ {"id": 4, "name": "Barbar", "quantity": -1, "unit_price": 1.7} ]""" response = self.client.get(reverse("eboutic:command")) @@ -182,9 +176,7 @@ class EbouticTest(TestCase): reverse("core:user_profile", kwargs={"user_id": self.old_subscriber.id}) ) self.assertTrue("Non cotisant" in str(response.content)) - self.client.cookies[ - "basket_items" - ] = """[ + self.client.cookies["basket_items"] = """[ {"id": 2, "name": "Cotis 2 semestres", "quantity": 1, "unit_price": 28} ]""" response = self.client.get(reverse("eboutic:command")) diff --git a/poetry.lock b/poetry.lock index 8bf30dcd..f43c9663 100644 --- a/poetry.lock +++ b/poetry.lock @@ -64,52 +64,6 @@ files = [ {file = "backcall-0.2.0.tar.gz", hash = "sha256:5cbdbf27be5e7cfadb448baf0aa95508f91f2bbc6c6437cd9cd06e2a4c215e1e"}, ] -[[package]] -name = "black" -version = "23.12.1" -description = "The uncompromising code formatter." -optional = false -python-versions = ">=3.8" -files = [ - {file = "black-23.12.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e0aaf6041986767a5e0ce663c7a2f0e9eaf21e6ff87a5f95cbf3675bfd4c41d2"}, - {file = "black-23.12.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c88b3711d12905b74206227109272673edce0cb29f27e1385f33b0163c414bba"}, - {file = "black-23.12.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a920b569dc6b3472513ba6ddea21f440d4b4c699494d2e972a1753cdc25df7b0"}, - {file = "black-23.12.1-cp310-cp310-win_amd64.whl", hash = "sha256:3fa4be75ef2a6b96ea8d92b1587dd8cb3a35c7e3d51f0738ced0781c3aa3a5a3"}, - {file = "black-23.12.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:8d4df77958a622f9b5a4c96edb4b8c0034f8434032ab11077ec6c56ae9f384ba"}, - {file = "black-23.12.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:602cfb1196dc692424c70b6507593a2b29aac0547c1be9a1d1365f0d964c353b"}, - {file = "black-23.12.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9c4352800f14be5b4864016882cdba10755bd50805c95f728011bcb47a4afd59"}, - {file = "black-23.12.1-cp311-cp311-win_amd64.whl", hash = "sha256:0808494f2b2df923ffc5723ed3c7b096bd76341f6213989759287611e9837d50"}, - {file = "black-23.12.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:25e57fd232a6d6ff3f4478a6fd0580838e47c93c83eaf1ccc92d4faf27112c4e"}, - {file = "black-23.12.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2d9e13db441c509a3763a7a3d9a49ccc1b4e974a47be4e08ade2a228876500ec"}, - {file = "black-23.12.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d1bd9c210f8b109b1762ec9fd36592fdd528485aadb3f5849b2740ef17e674e"}, - {file = "black-23.12.1-cp312-cp312-win_amd64.whl", hash = "sha256:ae76c22bde5cbb6bfd211ec343ded2163bba7883c7bc77f6b756a1049436fbb9"}, - {file = "black-23.12.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:1fa88a0f74e50e4487477bc0bb900c6781dbddfdfa32691e780bf854c3b4a47f"}, - {file = "black-23.12.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:a4d6a9668e45ad99d2f8ec70d5c8c04ef4f32f648ef39048d010b0689832ec6d"}, - {file = "black-23.12.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b18fb2ae6c4bb63eebe5be6bd869ba2f14fd0259bda7d18a46b764d8fb86298a"}, - {file = "black-23.12.1-cp38-cp38-win_amd64.whl", hash = "sha256:c04b6d9d20e9c13f43eee8ea87d44156b8505ca8a3c878773f68b4e4812a421e"}, - {file = "black-23.12.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3e1b38b3135fd4c025c28c55ddfc236b05af657828a8a6abe5deec419a0b7055"}, - {file = "black-23.12.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4f0031eaa7b921db76decd73636ef3a12c942ed367d8c3841a0739412b260a54"}, - {file = "black-23.12.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:97e56155c6b737854e60a9ab1c598ff2533d57e7506d97af5481141671abf3ea"}, - {file = "black-23.12.1-cp39-cp39-win_amd64.whl", hash = "sha256:dd15245c8b68fe2b6bd0f32c1556509d11bb33aec9b5d0866dd8e2ed3dba09c2"}, - {file = "black-23.12.1-py3-none-any.whl", hash = "sha256:78baad24af0f033958cad29731e27363183e140962595def56423e626f4bee3e"}, - {file = "black-23.12.1.tar.gz", hash = "sha256:4ce3ef14ebe8d9509188014d96af1c456a910d5b5cbf434a09fef7e024b3d0d5"}, -] - -[package.dependencies] -click = ">=8.0.0" -mypy-extensions = ">=0.4.3" -packaging = ">=22.0" -pathspec = ">=0.9.0" -platformdirs = ">=2" -tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} - -[package.extras] -colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.7.4)", "aiohttp (>=3.7.4,!=3.9.0)"] -jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] -uvloop = ["uvloop (>=0.15.2)"] - [[package]] name = "certifi" version = "2024.6.2" @@ -295,20 +249,6 @@ files = [ {file = "charset_normalizer-3.3.2-py3-none-any.whl", hash = "sha256:3e4d1f6587322d2788836a99c69062fbb091331ec940e02d12d179c1d53e25fc"}, ] -[[package]] -name = "click" -version = "8.1.7" -description = "Composable command line interface toolkit" -optional = false -python-versions = ">=3.7" -files = [ - {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, - {file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"}, -] - -[package.dependencies] -colorama = {version = "*", markers = "platform_system == \"Windows\""} - [[package]] name = "colorama" version = "0.4.6" @@ -868,17 +808,6 @@ files = [ {file = "mistune-0.8.4.tar.gz", hash = "sha256:59a3429db53c50b5c6bcc8a07f8848cb00d7dc8bdb431a4ab41920d201d4756e"}, ] -[[package]] -name = "mypy-extensions" -version = "1.0.0" -description = "Type system extensions for programs checked with the mypy type checker." -optional = false -python-versions = ">=3.5" -files = [ - {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, - {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, -] - [[package]] name = "packaging" version = "24.1" @@ -905,17 +834,6 @@ files = [ qa = ["flake8 (==5.0.4)", "mypy (==0.971)", "types-setuptools (==67.2.0.1)"] testing = ["docopt", "pytest"] -[[package]] -name = "pathspec" -version = "0.12.1" -description = "Utility library for gitignore style pattern matching of file paths." -optional = false -python-versions = ">=3.8" -files = [ - {file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"}, - {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"}, -] - [[package]] name = "pexpect" version = "4.9.0" @@ -1031,22 +949,6 @@ files = [ docs = ["furo", "olefile", "sphinx (>=2.4)", "sphinx-copybutton", "sphinx-inline-tabs", "sphinx-removed-in", "sphinxext-opengraph"] tests = ["check-manifest", "coverage", "defusedxml", "markdown2", "olefile", "packaging", "pyroma", "pytest", "pytest-cov", "pytest-timeout"] -[[package]] -name = "platformdirs" -version = "4.2.2" -description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." -optional = false -python-versions = ">=3.8" -files = [ - {file = "platformdirs-4.2.2-py3-none-any.whl", hash = "sha256:2d7a1657e36a80ea911db832a8a6ece5ee53d8de21edd5cc5879af6530b1bfee"}, - {file = "platformdirs-4.2.2.tar.gz", hash = "sha256:38b7b51f512eed9e84a22788b4bce1de17c0adb134d6becb09836e37d8654cd3"}, -] - -[package.extras] -docs = ["furo (>=2023.9.10)", "proselint (>=0.13)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"] -test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)"] -type = ["mypy (>=1.8)"] - [[package]] name = "prompt-toolkit" version = "3.0.47" @@ -1272,6 +1174,32 @@ urllib3 = ">=1.21.1,<3" socks = ["PySocks (>=1.5.6,!=1.5.7)"] use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] +[[package]] +name = "ruff" +version = "0.4.10" +description = "An extremely fast Python linter and code formatter, written in Rust." +optional = false +python-versions = ">=3.7" +files = [ + {file = "ruff-0.4.10-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:5c2c4d0859305ac5a16310eec40e4e9a9dec5dcdfbe92697acd99624e8638dac"}, + {file = "ruff-0.4.10-py3-none-macosx_11_0_arm64.whl", hash = "sha256:a79489607d1495685cdd911a323a35871abfb7a95d4f98fc6f85e799227ac46e"}, + {file = "ruff-0.4.10-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b1dd1681dfa90a41b8376a61af05cc4dc5ff32c8f14f5fe20dba9ff5deb80cd6"}, + {file = "ruff-0.4.10-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:c75c53bb79d71310dc79fb69eb4902fba804a81f374bc86a9b117a8d077a1784"}, + {file = "ruff-0.4.10-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:18238c80ee3d9100d3535d8eb15a59c4a0753b45cc55f8bf38f38d6a597b9739"}, + {file = "ruff-0.4.10-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:d8f71885bce242da344989cae08e263de29752f094233f932d4f5cfb4ef36a81"}, + {file = "ruff-0.4.10-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:330421543bd3222cdfec481e8ff3460e8702ed1e58b494cf9d9e4bf90db52b9d"}, + {file = "ruff-0.4.10-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9e9b6fb3a37b772628415b00c4fc892f97954275394ed611056a4b8a2631365e"}, + {file = "ruff-0.4.10-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0f54c481b39a762d48f64d97351048e842861c6662d63ec599f67d515cb417f6"}, + {file = "ruff-0.4.10-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:67fe086b433b965c22de0b4259ddfe6fa541c95bf418499bedb9ad5fb8d1c631"}, + {file = "ruff-0.4.10-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:acfaaab59543382085f9eb51f8e87bac26bf96b164839955f244d07125a982ef"}, + {file = "ruff-0.4.10-py3-none-musllinux_1_2_i686.whl", hash = "sha256:3cea07079962b2941244191569cf3a05541477286f5cafea638cd3aa94b56815"}, + {file = "ruff-0.4.10-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:338a64ef0748f8c3a80d7f05785930f7965d71ca260904a9321d13be24b79695"}, + {file = "ruff-0.4.10-py3-none-win32.whl", hash = "sha256:ffe3cd2f89cb54561c62e5fa20e8f182c0a444934bf430515a4b422f1ab7b7ca"}, + {file = "ruff-0.4.10-py3-none-win_amd64.whl", hash = "sha256:67f67cef43c55ffc8cc59e8e0b97e9e60b4837c8f21e8ab5ffd5d66e196e25f7"}, + {file = "ruff-0.4.10-py3-none-win_arm64.whl", hash = "sha256:dd1fcee327c20addac7916ca4e2653fbbf2e8388d8a6477ce5b4e986b68ae6c0"}, + {file = "ruff-0.4.10.tar.gz", hash = "sha256:3aa4f2bc388a30d346c56524f7cacca85945ba124945fe489952aadb6b5cd804"}, +] + [[package]] name = "sentry-sdk" version = "1.45.0" @@ -1633,4 +1561,4 @@ filelock = ">=3.4" [metadata] lock-version = "2.0" python-versions = "^3.10,<3.12" -content-hash = "fe98c5784d71478c6da090c2adae73fbbff3ef47e0cd5fa8893811e4b357949b" +content-hash = "78f859d93ec1f207dbdebd5b608abfac44f87bb254a37ebeafaaf1823f605a71" diff --git a/pyproject.toml b/pyproject.toml index d1157762..0bb1a27f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,7 +52,7 @@ tomli = "^2.0.1" freezegun = "^1.2.2" # used to test time-dependent code django-debug-toolbar = "^4.0.0" ipython = "^7.28.0" -black = "^23.3.0" +ruff = "^0.4.10" [tool.poetry.group.tests.dependencies] coverage = "^7.5.4" diff --git a/sith/settings.py b/sith/settings.py index 5ed279af..df2b4ced 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -567,7 +567,7 @@ SITH_SUBSCRIPTIONS = { "name": _("One year for free(CA offer)"), "price": 0, "duration": 2, - } + }, # To be completed.... } diff --git a/sith/urls.py b/sith/urls.py index 6a098b5e..08e25b3e 100644 --- a/sith/urls.py +++ b/sith/urls.py @@ -29,6 +29,7 @@ Including another URLconf 1. Add an import: from blog import urls as blog_urls 2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) """ + from django.urls import include, path from django.contrib import admin from django.conf import settings From 3143d3d91a5bd9a1859e00615aff74130d21beaf Mon Sep 17 00:00:00 2001 From: thomas girod Date: Mon, 24 Jun 2024 13:07:36 +0200 Subject: [PATCH 3/3] reorganize imports with ruff --- accounting/admin.py | 1 - accounting/migrations/0001_initial.py | 5 +- .../migrations/0002_auto_20160824_2152.py | 2 +- .../migrations/0003_auto_20160824_2203.py | 2 +- .../migrations/0004_auto_20161005_1505.py | 2 +- accounting/models.py | 18 ++-- accounting/tests.py | 14 +-- accounting/views.py | 58 ++++++------- api/admin.py | 2 - api/models.py | 2 - api/tests.py | 2 - api/urls.py | 4 +- api/views/__init__.py | 14 +-- api/views/api.py | 2 +- api/views/club.py | 10 +-- api/views/counter.py | 5 +- api/views/group.py | 3 +- api/views/launderette.py | 5 +- api/views/sas.py | 3 +- api/views/user.py | 5 +- api/views/uv.py | 13 +-- club/forms.py | 11 +-- club/migrations/0001_initial.py | 2 +- club/migrations/0002_auto_20160824_2152.py | 4 +- club/migrations/0004_auto_20160915_1057.py | 4 +- club/migrations/0005_auto_20161120_1149.py | 2 +- club/migrations/0006_auto_20161229_0040.py | 2 +- club/migrations/0007_auto_20170324_0917.py | 2 +- club/migrations/0009_auto_20170822_2232.py | 5 +- club/migrations/0010_auto_20170912_2028.py | 2 +- club/migrations/0011_auto_20180426_2013.py | 5 +- club/models.py | 16 ++-- club/tests.py | 11 ++- club/views.py | 58 ++++++------- com/migrations/0002_news_newsdate.py | 4 +- com/migrations/0003_auto_20170115_2300.py | 4 +- com/migrations/0004_auto_20171221_1614.py | 4 +- com/models.py | 18 ++-- com/tests.py | 7 +- com/views.py | 45 +++++----- core/admin.py | 4 +- core/apps.py | 2 +- core/converters.py | 3 - core/lookups.py | 11 ++- core/management/commands/check_fs.py | 2 +- core/management/commands/compilemessages.py | 1 + core/management/commands/compilestatic.py | 3 +- core/management/commands/documentation.py | 5 +- core/management/commands/install_xapian.py | 5 +- core/management/commands/markdown.py | 1 + core/management/commands/populate.py | 33 ++++--- core/management/commands/repair_fs.py | 2 +- core/management/commands/setup.py | 3 +- core/markdown.py | 3 +- core/middleware.py | 3 +- core/migrations/0001_initial.py | 8 +- core/migrations/0003_auto_20160902_1914.py | 2 +- core/migrations/0004_user_godfathers.py | 2 +- core/migrations/0005_auto_20161105_1035.py | 4 +- core/migrations/0009_auto_20161120_1155.py | 3 +- core/migrations/0011_auto_20161124_0848.py | 3 +- core/migrations/0012_notification.py | 6 +- core/migrations/0015_sithfile_moderator.py | 4 +- core/migrations/0016_auto_20161212_1922.py | 4 +- core/migrations/0020_auto_20170324_0917.py | 2 +- core/migrations/0023_auto_20170902_1226.py | 4 +- core/migrations/0025_auto_20170919_1521.py | 2 +- core/migrations/0027_gift.py | 6 +- core/migrations/0029_auto_20180426_2013.py | 5 +- core/migrations/0034_operationlog.py | 2 +- core/models.py | 43 +++++----- core/scss/finder.py | 1 + core/scss/processor.py | 8 +- core/search_indexes.py | 1 - core/signals.py | 6 +- core/templatetags/renderer.py | 4 +- core/templatetags/search_helpers.py | 2 +- core/urls.py | 4 +- core/utils.py | 2 +- core/views/__init__.py | 27 +++--- core/views/files.py | 31 ++++--- core/views/forms.py | 39 ++++----- core/views/group.py | 13 ++- core/views/page.py | 10 +-- core/views/site.py | 23 +++-- core/views/user.py | 56 ++++++------ counter/app.py | 2 +- counter/forms.py | 10 +-- counter/migrations/0001_initial.py | 6 +- counter/migrations/0002_auto_20160826_1342.py | 7 +- .../migrations/0003_permanency_activity.py | 3 +- counter/migrations/0005_auto_20160826_2330.py | 2 +- counter/migrations/0009_eticket.py | 2 +- .../0013_customer_recorded_products.py | 6 +- counter/migrations/0015_merge.py | 2 +- counter/migrations/0017_studentcard.py | 2 +- counter/migrations/0019_billinginfo.py | 2 +- counter/migrations/0020_auto_20221215_1709.py | 3 +- counter/models.py | 42 +++++---- counter/signals.py | 4 +- counter/tests.py | 4 +- counter/views.py | 85 +++++++++---------- doc/conf.py | 1 + eboutic/forms.py | 2 +- eboutic/migrations/0001_initial.py | 7 +- eboutic/models.py | 9 +- eboutic/tests.py | 5 +- eboutic/tests/test.py | 1 + eboutic/urls.py | 2 +- eboutic/views.py | 14 +-- election/admin.py | 2 +- election/migrations/0001_initial.py | 4 +- election/models.py | 6 +- election/tests.py | 5 +- election/views.py | 29 +++---- forum/admin.py | 1 - forum/migrations/0001_initial.py | 9 +- forum/migrations/0004_auto_20170531_1949.py | 2 +- .../0005_forumtopic_subscribed_users.py | 2 +- forum/migrations/0006_auto_20180426_2013.py | 1 + forum/models.py | 14 +-- forum/tests.py | 2 - forum/views.py | 31 ++++--- .../commands/generate_galaxy_test_data.py | 11 +-- galaxy/management/commands/rule_galaxy.py | 3 +- galaxy/migrations/0001_initial.py | 2 +- galaxy/migrations/0002_auto_20230412_1130.py | 2 +- galaxy/models.py | 9 +- galaxy/tests.py | 1 - galaxy/views.py | 10 +-- launderette/migrations/0001_initial.py | 2 +- launderette/models.py | 8 +- launderette/tests.py | 2 - launderette/views.py | 27 +++--- matmat/admin.py | 2 - matmat/models.py | 2 - matmat/tests.py | 2 - matmat/views.py | 15 ++-- pedagogy/forms.py | 5 +- pedagogy/migrations/0001_initial.py | 4 +- pedagogy/models.py | 11 ++- pedagogy/search_indexes.py | 1 - pedagogy/tests.py | 5 +- pedagogy/views.py | 29 +++---- pyproject.toml | 3 + rootplace/admin.py | 2 - rootplace/models.py | 2 - rootplace/tests.py | 6 +- rootplace/views.py | 2 +- sas/admin.py | 1 - sas/migrations/0001_initial.py | 2 +- sas/migrations/0002_auto_20161119_1241.py | 4 +- sas/models.py | 14 +-- sas/tests.py | 2 - sas/views.py | 32 ++++--- sith/urls.py | 8 +- stock/admin.py | 2 +- stock/migrations/0001_initial.py | 2 +- stock/models.py | 7 +- stock/tests.py | 2 - stock/views.py | 35 +++----- subscription/migrations/0001_initial.py | 2 +- subscription/models.py | 15 ++-- subscription/tests.py | 9 +- subscription/views.py | 22 +++-- trombi/migrations/0001_initial.py | 5 +- .../migrations/0004_trombiclubmembership.py | 2 +- trombi/models.py | 14 +-- trombi/tests.py | 2 - trombi/views.py | 39 +++++---- 170 files changed, 702 insertions(+), 804 deletions(-) diff --git a/accounting/admin.py b/accounting/admin.py index e485392d..95216e59 100644 --- a/accounting/admin.py +++ b/accounting/admin.py @@ -18,7 +18,6 @@ from django.contrib import admin from accounting.models import * - admin.site.register(BankAccount) admin.site.register(ClubAccount) admin.site.register(GeneralJournal) diff --git a/accounting/migrations/0001_initial.py b/accounting/migrations/0001_initial.py index 51add331..b5112cdd 100644 --- a/accounting/migrations/0001_initial.py +++ b/accounting/migrations/0001_initial.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import django.core.validators -import accounting.models import django.db.models.deletion +from django.db import migrations, models + +import accounting.models class Migration(migrations.Migration): diff --git a/accounting/migrations/0002_auto_20160824_2152.py b/accounting/migrations/0002_auto_20160824_2152.py index b0cc051f..d331dd5c 100644 --- a/accounting/migrations/0002_auto_20160824_2152.py +++ b/accounting/migrations/0002_auto_20160824_2152.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/accounting/migrations/0003_auto_20160824_2203.py b/accounting/migrations/0003_auto_20160824_2203.py index 597f582f..cf53223f 100644 --- a/accounting/migrations/0003_auto_20160824_2203.py +++ b/accounting/migrations/0003_auto_20160824_2203.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import phonenumber_field.modelfields +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/accounting/migrations/0004_auto_20161005_1505.py b/accounting/migrations/0004_auto_20161005_1505.py index 993754bd..6e122f7d 100644 --- a/accounting/migrations/0004_auto_20161005_1505.py +++ b/accounting/migrations/0004_auto_20161005_1505.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/accounting/models.py b/accounting/models.py index e10a029d..55bdda46 100644 --- a/accounting/models.py +++ b/accounting/models.py @@ -14,19 +14,19 @@ # # -from django.urls import reverse -from django.core.exceptions import ValidationError -from django.core import validators -from django.db import models -from django.conf import settings -from django.utils.translation import gettext_lazy as _ -from django.template import defaultfilters +from decimal import Decimal +from django.conf import settings +from django.core import validators +from django.core.exceptions import ValidationError +from django.db import models +from django.template import defaultfilters +from django.urls import reverse +from django.utils.translation import gettext_lazy as _ from phonenumber_field.modelfields import PhoneNumberField -from decimal import Decimal -from core.models import User, SithFile from club.models import Club +from core.models import SithFile, User class CurrencyField(models.DecimalField): diff --git a/accounting/tests.py b/accounting/tests.py index 6a4ae2b3..28c7a420 100644 --- a/accounting/tests.py +++ b/accounting/tests.py @@ -14,19 +14,19 @@ # # -from django.test import TestCase -from django.urls import reverse -from django.core.management import call_command from datetime import date, timedelta -from core.models import User +from django.test import TestCase +from django.urls import reverse + from accounting.models import ( - GeneralJournal, - Operation, - Label, AccountingType, + GeneralJournal, + Label, + Operation, SimplifiedAccountingType, ) +from core.models import User class RefoundAccountTest(TestCase): diff --git a/accounting/views.py b/accounting/views.py index 32ebc1c5..f9618beb 100644 --- a/accounting/views.py +++ b/accounting/views.py @@ -14,41 +14,41 @@ # # -from django.views.generic import ListView, DetailView -from django.views.generic.edit import UpdateView, CreateView, DeleteView, FormView -from django.urls import reverse_lazy, reverse -from django.utils.translation import gettext_lazy as _ -from django.forms.models import modelform_factory -from django.core.exceptions import PermissionDenied, ValidationError -from django.forms import HiddenInput -from django.db import transaction -from django.db.models import Sum -from django.conf import settings -from django import forms -from django.http import HttpResponse import collections from ajax_select.fields import AutoCompleteSelectField +from django import forms +from django.conf import settings +from django.core.exceptions import PermissionDenied, ValidationError +from django.db import transaction +from django.db.models import Sum +from django.forms import HiddenInput +from django.forms.models import modelform_factory +from django.http import HttpResponse +from django.urls import reverse, reverse_lazy +from django.utils.translation import gettext_lazy as _ +from django.views.generic import DetailView, ListView +from django.views.generic.edit import CreateView, DeleteView, FormView, UpdateView -from core.views import ( - CanViewMixin, - CanEditMixin, - CanEditPropMixin, - CanCreateMixin, - TabedViewMixin, -) -from core.views.forms import SelectFile, SelectDate from accounting.models import ( + AccountingType, BankAccount, ClubAccount, - GeneralJournal, - Operation, - AccountingType, Company, - SimplifiedAccountingType, + GeneralJournal, Label, + Operation, + SimplifiedAccountingType, ) -from counter.models import Counter, Selling, Product +from core.views import ( + CanCreateMixin, + CanEditMixin, + CanEditPropMixin, + CanViewMixin, + TabedViewMixin, +) +from core.views.forms import SelectDate, SelectFile +from counter.models import Counter, Product, Selling # Main accounting view @@ -521,14 +521,14 @@ class OperationPDFView(CanViewMixin, DetailView): pk_url_kwarg = "op_id" def get(self, request, *args, **kwargs): - from reportlab.pdfgen import canvas - from reportlab.lib.units import cm - from reportlab.platypus import Table, TableStyle from reportlab.lib import colors from reportlab.lib.pagesizes import letter + from reportlab.lib.units import cm from reportlab.lib.utils import ImageReader - from reportlab.pdfbase.ttfonts import TTFont from reportlab.pdfbase import pdfmetrics + from reportlab.pdfbase.ttfonts import TTFont + from reportlab.pdfgen import canvas + from reportlab.platypus import Table, TableStyle pdfmetrics.registerFont(TTFont("DejaVu", "DejaVuSerif.ttf")) diff --git a/api/admin.py b/api/admin.py index 362a5c4f..5531f2a2 100644 --- a/api/admin.py +++ b/api/admin.py @@ -14,6 +14,4 @@ # # -from django.contrib import admin - # Register your models here. diff --git a/api/models.py b/api/models.py index 5672eba4..084dfa73 100644 --- a/api/models.py +++ b/api/models.py @@ -14,6 +14,4 @@ # # -from django.db import models - # Create your models here. diff --git a/api/tests.py b/api/tests.py index 46a200c2..d888e761 100644 --- a/api/tests.py +++ b/api/tests.py @@ -14,6 +14,4 @@ # # -from django.test import TestCase - # Create your tests here. diff --git a/api/urls.py b/api/urls.py index ca267eee..4dde736c 100644 --- a/api/urls.py +++ b/api/urls.py @@ -14,10 +14,10 @@ # # -from django.urls import re_path, path, include +from django.urls import include, path, re_path +from rest_framework import routers from api.views import * -from rest_framework import routers # Router config router = routers.DefaultRouter() diff --git a/api/views/__init__.py b/api/views/__init__.py index ae83fbe5..b0157985 100644 --- a/api/views/__init__.py +++ b/api/views/__init__.py @@ -14,13 +14,13 @@ # # -from rest_framework.response import Response -from rest_framework import viewsets from django.core.exceptions import PermissionDenied -from rest_framework.decorators import action from django.db.models.query import QuerySet +from rest_framework import viewsets +from rest_framework.decorators import action +from rest_framework.response import Response -from core.views import can_view, can_edit +from core.views import can_edit, can_view def check_if(obj, user, test): @@ -64,10 +64,10 @@ class RightModelViewSet(ManageModelMixin, viewsets.ModelViewSet): from .api import * -from .counter import * -from .user import * from .club import * +from .counter import * from .group import * from .launderette import * -from .uv import * from .sas import * +from .user import * +from .uv import * diff --git a/api/views/api.py b/api/views/api.py index 732ee654..4329a98b 100644 --- a/api/views/api.py +++ b/api/views/api.py @@ -14,9 +14,9 @@ # # -from rest_framework.response import Response from rest_framework.decorators import api_view, renderer_classes from rest_framework.renderers import StaticHTMLRenderer +from rest_framework.response import Response from core.templatetags.renderer import markdown diff --git a/api/views/club.py b/api/views/club.py index 24377073..a08d6c4f 100644 --- a/api/views/club.py +++ b/api/views/club.py @@ -14,17 +14,15 @@ # # -from rest_framework.response import Response +from django.conf import settings +from django.core.exceptions import PermissionDenied from rest_framework import serializers from rest_framework.decorators import api_view, renderer_classes from rest_framework.renderers import StaticHTMLRenderer - -from django.conf import settings -from django.core.exceptions import PermissionDenied - -from club.models import Club, Mailing +from rest_framework.response import Response from api.views import RightModelViewSet +from club.models import Club, Mailing class ClubSerializer(serializers.ModelSerializer): diff --git a/api/views/counter.py b/api/views/counter.py index 604cd986..2e633cae 100644 --- a/api/views/counter.py +++ b/api/views/counter.py @@ -15,12 +15,11 @@ # from rest_framework import serializers -from rest_framework.response import Response from rest_framework.decorators import action - -from counter.models import Counter +from rest_framework.response import Response from api.views import RightModelViewSet +from counter.models import Counter class CounterSerializer(serializers.ModelSerializer): diff --git a/api/views/group.py b/api/views/group.py index f6fd7594..a6aa7e2b 100644 --- a/api/views/group.py +++ b/api/views/group.py @@ -16,9 +16,8 @@ from rest_framework import serializers -from core.models import RealGroup - from api.views import RightModelViewSet +from core.models import RealGroup class GroupSerializer(serializers.ModelSerializer): diff --git a/api/views/launderette.py b/api/views/launderette.py index ab7fcf66..a1225274 100644 --- a/api/views/launderette.py +++ b/api/views/launderette.py @@ -15,12 +15,11 @@ # from rest_framework import serializers -from rest_framework.response import Response from rest_framework.decorators import action - -from launderette.models import Launderette, Machine, Token +from rest_framework.response import Response from api.views import RightModelViewSet +from launderette.models import Launderette, Machine, Token class LaunderettePlaceSerializer(serializers.ModelSerializer): diff --git a/api/views/sas.py b/api/views/sas.py index 063b9eab..455edf09 100644 --- a/api/views/sas.py +++ b/api/views/sas.py @@ -1,4 +1,5 @@ from typing import List + from rest_framework.decorators import api_view, renderer_classes from rest_framework.exceptions import PermissionDenied from rest_framework.generics import get_object_or_404 @@ -6,8 +7,8 @@ from rest_framework.renderers import JSONRenderer from rest_framework.request import Request from rest_framework.response import Response -from core.views import can_edit from core.models import User +from core.views import can_edit from sas.models import Picture diff --git a/api/views/user.py b/api/views/user.py index ed3b6b1a..a9ad19a6 100644 --- a/api/views/user.py +++ b/api/views/user.py @@ -17,12 +17,11 @@ import datetime from rest_framework import serializers -from rest_framework.response import Response from rest_framework.decorators import action - -from core.models import User +from rest_framework.response import Response from api.views import RightModelViewSet +from core.models import User class UserSerializer(serializers.ModelSerializer): diff --git a/api/views/uv.py b/api/views/uv.py index e9790e0b..a83a8936 100644 --- a/api/views/uv.py +++ b/api/views/uv.py @@ -1,11 +1,12 @@ -from rest_framework.response import Response +import json +import urllib.request + +from django.conf import settings +from django.core.exceptions import PermissionDenied +from rest_framework import serializers from rest_framework.decorators import api_view, renderer_classes from rest_framework.renderers import JSONRenderer -from django.core.exceptions import PermissionDenied -from django.conf import settings -from rest_framework import serializers -import urllib.request -import json +from rest_framework.response import Response from pedagogy.views import CanCreateUVFunctionMixin diff --git a/club/forms.py b/club/forms.py index dcf88ff5..ca6cb324 100644 --- a/club/forms.py +++ b/club/forms.py @@ -23,18 +23,15 @@ # # -from django.conf import settings +from ajax_select.fields import AutoCompleteSelectMultipleField from django import forms +from django.conf import settings from django.utils.translation import gettext_lazy as _ -from ajax_select.fields import AutoCompleteSelectField, AutoCompleteSelectMultipleField - -from club.models import Mailing, MailingSubscription, Club, Membership - +from club.models import Club, Mailing, MailingSubscription, Membership from core.models import User -from core.views.forms import SelectDate, SelectDateTime +from core.views.forms import SelectDate, TzAwareDateTimeField from counter.models import Counter -from core.views.forms import TzAwareDateTimeField class ClubEditForm(forms.ModelForm): diff --git a/club/migrations/0001_initial.py b/club/migrations/0001_initial.py index 55922e03..4a26270e 100644 --- a/club/migrations/0001_initial.py +++ b/club/migrations/0001_initial.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import django.core.validators import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/club/migrations/0002_auto_20160824_2152.py b/club/migrations/0002_auto_20160824_2152.py index 6b69c1b7..ffc57443 100644 --- a/club/migrations/0002_auto_20160824_2152.py +++ b/club/migrations/0002_auto_20160824_2152.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models -from django.conf import settings import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/club/migrations/0004_auto_20160915_1057.py b/club/migrations/0004_auto_20160915_1057.py index 3f08d9dd..8e0dc244 100644 --- a/club/migrations/0004_auto_20160915_1057.py +++ b/club/migrations/0004_auto_20160915_1057.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models -from django.conf import settings import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/club/migrations/0005_auto_20161120_1149.py b/club/migrations/0005_auto_20161120_1149.py index 5fb949a7..b9eda617 100644 --- a/club/migrations/0005_auto_20161120_1149.py +++ b/club/migrations/0005_auto_20161120_1149.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/club/migrations/0006_auto_20161229_0040.py b/club/migrations/0006_auto_20161229_0040.py index 290ecf5b..fec86868 100644 --- a/club/migrations/0006_auto_20161229_0040.py +++ b/club/migrations/0006_auto_20161229_0040.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import django.utils.timezone +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/club/migrations/0007_auto_20170324_0917.py b/club/migrations/0007_auto_20170324_0917.py index eb3c03cc..e356bac2 100644 --- a/club/migrations/0007_auto_20170324_0917.py +++ b/club/migrations/0007_auto_20170324_0917.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models +from django.db import migrations class Migration(migrations.Migration): diff --git a/club/migrations/0009_auto_20170822_2232.py b/club/migrations/0009_auto_20170822_2232.py index ce7dc337..4e679d09 100644 --- a/club/migrations/0009_auto_20170822_2232.py +++ b/club/migrations/0009_auto_20170822_2232.py @@ -1,11 +1,12 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models -from django.conf import settings import re + import django.core.validators import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/club/migrations/0010_auto_20170912_2028.py b/club/migrations/0010_auto_20170912_2028.py index a9b32d1b..0dbf796a 100644 --- a/club/migrations/0010_auto_20170912_2028.py +++ b/club/migrations/0010_auto_20170912_2028.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +import django.db.models.deletion from django.db import migrations, models from club.models import Club from core.operations import PsqlRunOnly -import django.db.models.deletion def generate_club_pages(apps, schema_editor): diff --git a/club/migrations/0011_auto_20180426_2013.py b/club/migrations/0011_auto_20180426_2013.py index dc3234df..b1b1d362 100644 --- a/club/migrations/0011_auto_20180426_2013.py +++ b/club/migrations/0011_auto_20180426_2013.py @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models -import club.models import django.db.models.deletion +from django.db import migrations, models + +import club.models class Migration(migrations.Migration): diff --git a/club/models.py b/club/models.py index 4d22b8e5..252dc085 100644 --- a/club/models.py +++ b/club/models.py @@ -24,21 +24,19 @@ # from typing import Optional -from django.core.cache import cache -from django.db import models -from django.core import validators from django.conf import settings +from django.core import validators +from django.core.cache import cache +from django.core.exceptions import ObjectDoesNotExist, ValidationError +from django.core.validators import RegexValidator, validate_email +from django.db import models, transaction from django.db.models import Q -from django.utils.timezone import now -from django.utils.translation import gettext_lazy as _ -from django.core.exceptions import ValidationError, ObjectDoesNotExist -from django.db import transaction from django.urls import reverse from django.utils import timezone -from django.core.validators import RegexValidator, validate_email from django.utils.functional import cached_property +from django.utils.translation import gettext_lazy as _ -from core.models import User, MetaGroup, Group, SithFile, RealGroup, Notification, Page +from core.models import Group, MetaGroup, Notification, Page, RealGroup, SithFile, User # Create your models here. diff --git a/club/tests.py b/club/tests.py index b333cc48..73480979 100644 --- a/club/tests.py +++ b/club/tests.py @@ -18,15 +18,14 @@ from datetime import timedelta from django.conf import settings from django.core.cache import cache from django.test import TestCase -from django.utils import timezone, html -from django.utils.timezone import now, localtime -from django.utils.translation import gettext as _ from django.urls import reverse -from django.core.management import call_command +from django.utils import html, timezone +from django.utils.timezone import localtime, now +from django.utils.translation import gettext as _ -from core.models import User, AnonymousUser -from club.models import Club, Membership, Mailing from club.forms import MailingForm +from club.models import Club, Mailing, Membership +from core.models import AnonymousUser, User from sith.settings import SITH_BAR_MANAGER, SITH_MAIN_CLUB_ID diff --git a/club/views.py b/club/views.py index 2470cbb4..dce1c86f 100644 --- a/club/views.py +++ b/club/views.py @@ -26,50 +26,42 @@ import csv from django.conf import settings -from django import forms -from django.views.generic import ListView, DetailView, TemplateView, View -from django.views.generic.edit import DeleteView -from django.views.generic.detail import SingleObjectMixin -from django.views.generic.edit import UpdateView, CreateView +from django.core.exceptions import NON_FIELD_ERRORS, PermissionDenied, ValidationError +from django.core.paginator import InvalidPage, Paginator +from django.db.models import Sum from django.http import ( - HttpResponseRedirect, - HttpResponse, Http404, + HttpResponseRedirect, StreamingHttpResponse, ) +from django.shortcuts import get_object_or_404, redirect from django.urls import reverse, reverse_lazy from django.utils import timezone -from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext as _t -from django.core.exceptions import PermissionDenied, ValidationError, NON_FIELD_ERRORS -from django.core.paginator import Paginator, InvalidPage -from django.shortcuts import get_object_or_404, redirect -from django.db.models import Sum +from django.utils.translation import gettext_lazy as _ +from django.views.generic import DetailView, ListView, TemplateView, View +from django.views.generic.edit import CreateView, DeleteView, UpdateView - -from core.views import ( - CanCreateMixin, - CanViewMixin, - CanEditMixin, - CanEditPropMixin, - UserIsRootMixin, - TabedViewMixin, - PageEditViewBase, - DetailFormView, +from club.forms import ClubEditForm, ClubMemberForm, MailingForm, SellingsForm +from club.models import Club, Mailing, MailingSubscription, Membership +from com.views import ( + PosterCreateBaseView, + PosterDeleteBaseView, + PosterEditBaseView, + PosterListBaseView, ) from core.models import PageRev - -from counter.models import Selling - -from com.views import ( - PosterListBaseView, - PosterCreateBaseView, - PosterEditBaseView, - PosterDeleteBaseView, +from core.views import ( + CanCreateMixin, + CanEditMixin, + CanEditPropMixin, + CanViewMixin, + DetailFormView, + PageEditViewBase, + TabedViewMixin, + UserIsRootMixin, ) - -from club.models import Club, Membership, Mailing, MailingSubscription -from club.forms import MailingForm, ClubEditForm, ClubMemberForm, SellingsForm +from counter.models import Selling class ClubTabsMixin(TabedViewMixin): diff --git a/com/migrations/0002_news_newsdate.py b/com/migrations/0002_news_newsdate.py index da548fdc..51a378f3 100644 --- a/com/migrations/0002_news_newsdate.py +++ b/com/migrations/0002_news_newsdate.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models -from django.conf import settings import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/com/migrations/0003_auto_20170115_2300.py b/com/migrations/0003_auto_20170115_2300.py index 2087f40f..a21196b3 100644 --- a/com/migrations/0003_auto_20170115_2300.py +++ b/com/migrations/0003_auto_20170115_2300.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models -from django.conf import settings import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/com/migrations/0004_auto_20171221_1614.py b/com/migrations/0004_auto_20171221_1614.py index fe9539dc..6b4d4d9d 100644 --- a/com/migrations/0004_auto_20171221_1614.py +++ b/com/migrations/0004_auto_20171221_1614.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models +import django.db.models.deletion import django.utils.timezone from django.conf import settings -import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/com/models.py b/com/models.py index 71da8941..d7a31596 100644 --- a/com/models.py +++ b/com/models.py @@ -23,22 +23,20 @@ # # -from django.shortcuts import render +from django.conf import settings +from django.core.exceptions import ValidationError +from django.core.mail import EmailMultiAlternatives from django.db import models, transaction from django.db.models import Q -from django.utils.translation import gettext_lazy as _ -from django.utils import timezone -from django.urls import reverse -from django.conf import settings +from django.shortcuts import render from django.templatetags.static import static -from django.core.mail import EmailMultiAlternatives -from django.core.exceptions import ValidationError - +from django.urls import reverse from django.utils import timezone +from django.utils.translation import gettext_lazy as _ -from core import utils -from core.models import User, Preferences, RealGroup, Notification, SithFile from club.models import Club +from core import utils +from core.models import Notification, Preferences, RealGroup, User class Sith(models.Model): diff --git a/com/tests.py b/com/tests.py index 6dde46db..0cd01a1d 100644 --- a/com/tests.py +++ b/com/tests.py @@ -13,18 +13,17 @@ # OR WITHIN THE LOCAL FILE "LICENSE" # # +from django.conf import settings from django.core.files.uploadedfile import SimpleUploadedFile from django.test import TestCase -from django.conf import settings from django.urls import reverse -from django.core.management import call_command from django.utils import html from django.utils.timezone import localtime, now from django.utils.translation import gettext as _ from club.models import Club, Membership -from com.models import Sith, News, Weekmail, WeekmailArticle, Poster -from core.models import User, RealGroup, AnonymousUser +from com.models import News, Poster, Sith, Weekmail, WeekmailArticle +from core.models import AnonymousUser, RealGroup, User class ComAlertTest(TestCase): diff --git a/com/views.py b/com/views.py index f8d0119b..774d1c5f 100644 --- a/com/views.py +++ b/com/views.py @@ -23,38 +23,35 @@ # # -from django.shortcuts import redirect, get_object_or_404 -from django.http import HttpResponseRedirect -from django.views.generic import ListView, DetailView, View -from django.views.generic.edit import UpdateView, CreateView, DeleteView -from django.views.generic.detail import SingleObjectMixin -from django.utils.translation import gettext_lazy as _ -from django.urls import reverse, reverse_lazy -from django.core.exceptions import ValidationError -from django.utils import timezone -from django.conf import settings -from django.db.models import Max -from django.forms.models import modelform_factory -from django.core.exceptions import PermissionDenied -from django import forms - from datetime import timedelta from smtplib import SMTPRecipientsRefused -from com.models import Sith, News, NewsDate, Weekmail, WeekmailArticle, Screen, Poster +from django import forms +from django.conf import settings +from django.core.exceptions import PermissionDenied, ValidationError +from django.db.models import Max +from django.forms.models import modelform_factory +from django.http import HttpResponseRedirect +from django.shortcuts import get_object_or_404, redirect +from django.urls import reverse, reverse_lazy +from django.utils import timezone +from django.utils.translation import gettext_lazy as _ +from django.views.generic import DetailView, ListView, View +from django.views.generic.detail import SingleObjectMixin +from django.views.generic.edit import CreateView, DeleteView, UpdateView + +from club.models import Club, Mailing +from com.models import News, NewsDate, Poster, Screen, Sith, Weekmail, WeekmailArticle +from core.models import Notification, RealGroup, User from core.views import ( - CanViewMixin, + CanCreateMixin, CanEditMixin, CanEditPropMixin, - TabedViewMixin, - CanCreateMixin, + CanViewMixin, QuickNotifMixin, + TabedViewMixin, ) -from core.views.forms import SelectDateTime, MarkdownInput -from core.models import Notification, RealGroup, User -from club.models import Club, Mailing -from core.views.forms import TzAwareDateTimeField - +from core.views.forms import MarkdownInput, TzAwareDateTimeField # Sith object diff --git a/core/admin.py b/core/admin.py index 33ce50e4..8b202a30 100644 --- a/core/admin.py +++ b/core/admin.py @@ -14,12 +14,12 @@ # # -from django.contrib import admin from ajax_select import make_ajax_form -from core.models import User, Page, RealGroup, MetaGroup, SithFile +from django.contrib import admin from django.contrib.auth.models import Group as AuthGroup from haystack.admin import SearchModelAdmin +from core.models import MetaGroup, Page, RealGroup, SithFile, User admin.site.unregister(AuthGroup) admin.site.register(MetaGroup) diff --git a/core/apps.py b/core/apps.py index cd131f57..872f34ae 100644 --- a/core/apps.py +++ b/core/apps.py @@ -34,8 +34,8 @@ class SithConfig(AppConfig): verbose_name = "Core app of the Sith" def ready(self): + import core.signals # noqa F401 from forum.models import Forum - import core.signals cache.clear() diff --git a/core/converters.py b/core/converters.py index cb7bc95b..b681564d 100644 --- a/core/converters.py +++ b/core/converters.py @@ -1,6 +1,3 @@ -from core.models import Page - - class FourDigitYearConverter: regex = "[0-9]{4}" diff --git a/core/lookups.py b/core/lookups.py index f245442b..15205194 100644 --- a/core/lookups.py +++ b/core/lookups.py @@ -14,15 +14,14 @@ # # +from ajax_select import LookupChannel, register from django.core.exceptions import PermissionDenied -from ajax_select import register, LookupChannel -from core.views.site import search_user -from core.models import User, Group, SithFile -from club.models import Club -from counter.models import Product, Counter, Customer from accounting.models import ClubAccount, Company -from eboutic.models import BasketItem +from club.models import Club +from core.models import Group, SithFile, User +from core.views.site import search_user +from counter.models import Counter, Customer, Product def check_token(request): diff --git a/core/management/commands/check_fs.py b/core/management/commands/check_fs.py index 7ebc076d..a6fc9597 100644 --- a/core/management/commands/check_fs.py +++ b/core/management/commands/check_fs.py @@ -23,8 +23,8 @@ # import os + from django.core.management.base import BaseCommand -from django.core.management import call_command from core.models import SithFile diff --git a/core/management/commands/compilemessages.py b/core/management/commands/compilemessages.py index b3c336bc..87f1b2de 100644 --- a/core/management/commands/compilemessages.py +++ b/core/management/commands/compilemessages.py @@ -25,6 +25,7 @@ import os + from django.core.management.commands import compilemessages diff --git a/core/management/commands/compilestatic.py b/core/management/commands/compilestatic.py index 31e5c13e..f1268c23 100644 --- a/core/management/commands/compilestatic.py +++ b/core/management/commands/compilestatic.py @@ -24,9 +24,10 @@ # import os + import sass -from django.core.management.base import BaseCommand from django.conf import settings +from django.core.management.base import BaseCommand class Command(BaseCommand): diff --git a/core/management/commands/documentation.py b/core/management/commands/documentation.py index 79f2e0d8..bcaa0664 100644 --- a/core/management/commands/documentation.py +++ b/core/management/commands/documentation.py @@ -24,10 +24,9 @@ # import os -import sys import signal - -from http.server import test, CGIHTTPRequestHandler +import sys +from http.server import CGIHTTPRequestHandler, test from django.core.management.base import BaseCommand from django.utils import autoreload diff --git a/core/management/commands/install_xapian.py b/core/management/commands/install_xapian.py index b2009cd4..9181c151 100644 --- a/core/management/commands/install_xapian.py +++ b/core/management/commands/install_xapian.py @@ -15,11 +15,12 @@ # import os -import tomli import subprocess -from django.core.management.base import BaseCommand, CommandParser from pathlib import Path +import tomli +from django.core.management.base import BaseCommand, CommandParser + class Command(BaseCommand): help = "Install xapian" diff --git a/core/management/commands/markdown.py b/core/management/commands/markdown.py index 1b5a6855..35941ec4 100644 --- a/core/management/commands/markdown.py +++ b/core/management/commands/markdown.py @@ -23,6 +23,7 @@ # import os + from django.core.management.base import BaseCommand from core.markdown import markdown diff --git a/core/management/commands/populate.py b/core/management/commands/populate.py index c78de401..a9285653 100644 --- a/core/management/commands/populate.py +++ b/core/management/commands/populate.py @@ -24,38 +24,37 @@ import os from datetime import date, datetime, timedelta -from io import StringIO, BytesIO +from io import BytesIO, StringIO from pathlib import Path -from django.contrib.auth.models import Permission -from django.core.management.base import BaseCommand -from django.core.management import call_command from django.conf import settings -from django.db import connection +from django.contrib.auth.models import Permission from django.contrib.sites.models import Site +from django.core.management import call_command +from django.core.management.base import BaseCommand +from django.db import connection from django.utils import timezone - from PIL import Image -from core.models import Group, User, Page, PageRev, SithFile from accounting.models import ( - GeneralJournal, + AccountingType, BankAccount, ClubAccount, - Operation, - AccountingType, - SimplifiedAccountingType, Company, + GeneralJournal, + Operation, + SimplifiedAccountingType, ) -from core.utils import resize_image from club.models import Club, Membership -from subscription.models import Subscription -from counter.models import Customer, ProductType, Product, Counter, Selling, StudentCard -from com.models import Sith, Weekmail, News, NewsDate -from election.models import Election, Role, Candidature, ElectionList +from com.models import News, NewsDate, Sith, Weekmail +from core.models import Group, Page, PageRev, SithFile, User +from core.utils import resize_image +from counter.models import Counter, Customer, Product, ProductType, Selling, StudentCard +from election.models import Candidature, Election, ElectionList, Role from forum.models import Forum, ForumTopic from pedagogy.models import UV -from sas.models import Album, Picture, PeoplePictureRelation +from sas.models import Album, PeoplePictureRelation, Picture +from subscription.models import Subscription class Command(BaseCommand): diff --git a/core/management/commands/repair_fs.py b/core/management/commands/repair_fs.py index 055dbc9b..21408084 100644 --- a/core/management/commands/repair_fs.py +++ b/core/management/commands/repair_fs.py @@ -23,8 +23,8 @@ # import os + from django.core.management.base import BaseCommand -from django.core.management import call_command from core.models import SithFile diff --git a/core/management/commands/setup.py b/core/management/commands/setup.py index cc0ee1ca..5c91e1e6 100644 --- a/core/management/commands/setup.py +++ b/core/management/commands/setup.py @@ -15,8 +15,9 @@ # import os -from django.core.management.base import BaseCommand + from django.core.management import call_command +from django.core.management.base import BaseCommand class Command(BaseCommand): diff --git a/core/markdown.py b/core/markdown.py index 72b1cd02..0abe1954 100644 --- a/core/markdown.py +++ b/core/markdown.py @@ -16,8 +16,9 @@ import os import re -from mistune import Renderer, InlineGrammar, InlineLexer, Markdown, escape, escape_link + from django.urls import reverse +from mistune import InlineGrammar, InlineLexer, Markdown, Renderer, escape, escape_link class SithRenderer(Renderer): diff --git a/core/middleware.py b/core/middleware.py index 39afa266..ddc6dea3 100644 --- a/core/middleware.py +++ b/core/middleware.py @@ -16,12 +16,13 @@ import importlib import threading + from django.conf import settings -from django.utils.functional import SimpleLazyObject from django.contrib.auth import get_user from django.contrib.auth.middleware import ( AuthenticationMiddleware as DjangoAuthenticationMiddleware, ) +from django.utils.functional import SimpleLazyObject module, klass = settings.AUTH_ANONYMOUS_MODEL.rsplit(".", 1) AnonymousUser = getattr(importlib.import_module(module), klass) diff --git a/core/migrations/0001_initial.py b/core/migrations/0001_initial.py index 7474e93a..57050f26 100644 --- a/core/migrations/0001_initial.py +++ b/core/migrations/0001_initial.py @@ -1,14 +1,14 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import django.contrib.auth.models -import django.db.models.deletion import django.core.validators -import core.models +import django.db.models.deletion import phonenumber_field.modelfields from django.conf import settings -import django.db.models.deletion +from django.db import migrations, models + +import core.models class Migration(migrations.Migration): diff --git a/core/migrations/0003_auto_20160902_1914.py b/core/migrations/0003_auto_20160902_1914.py index b39d9838..65f11d3a 100644 --- a/core/migrations/0003_auto_20160902_1914.py +++ b/core/migrations/0003_auto_20160902_1914.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import django.core.validators +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/core/migrations/0004_user_godfathers.py b/core/migrations/0004_user_godfathers.py index d068cfc7..d4066cc5 100644 --- a/core/migrations/0004_user_godfathers.py +++ b/core/migrations/0004_user_godfathers.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/core/migrations/0005_auto_20161105_1035.py b/core/migrations/0005_auto_20161105_1035.py index 7d40b163..6f7c487f 100644 --- a/core/migrations/0005_auto_20161105_1035.py +++ b/core/migrations/0005_auto_20161105_1035.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models -from django.conf import settings import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/core/migrations/0009_auto_20161120_1155.py b/core/migrations/0009_auto_20161120_1155.py index c017706a..aafb2c54 100644 --- a/core/migrations/0009_auto_20161120_1155.py +++ b/core/migrations/0009_auto_20161120_1155.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models + import core.models diff --git a/core/migrations/0011_auto_20161124_0848.py b/core/migrations/0011_auto_20161124_0848.py index b3ea7f4a..6475189e 100644 --- a/core/migrations/0011_auto_20161124_0848.py +++ b/core/migrations/0011_auto_20161124_0848.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import django.utils.timezone +from django.db import migrations, models + import core.models diff --git a/core/migrations/0012_notification.py b/core/migrations/0012_notification.py index 360fbcb8..245a38e3 100644 --- a/core/migrations/0012_notification.py +++ b/core/migrations/0012_notification.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models -from django.conf import settings -import django.utils.timezone import django.db.models.deletion +import django.utils.timezone +from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/core/migrations/0015_sithfile_moderator.py b/core/migrations/0015_sithfile_moderator.py index 20d1512f..4e2a438d 100644 --- a/core/migrations/0015_sithfile_moderator.py +++ b/core/migrations/0015_sithfile_moderator.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models -from django.conf import settings import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/core/migrations/0016_auto_20161212_1922.py b/core/migrations/0016_auto_20161212_1922.py index bde89b82..72432467 100644 --- a/core/migrations/0016_auto_20161212_1922.py +++ b/core/migrations/0016_auto_20161212_1922.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models -from django.conf import settings import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/core/migrations/0020_auto_20170324_0917.py b/core/migrations/0020_auto_20170324_0917.py index c026483a..219be979 100644 --- a/core/migrations/0020_auto_20170324_0917.py +++ b/core/migrations/0020_auto_20170324_0917.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import django.core.validators +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/core/migrations/0023_auto_20170902_1226.py b/core/migrations/0023_auto_20170902_1226.py index 2cdc4c85..9bfd01ed 100644 --- a/core/migrations/0023_auto_20170902_1226.py +++ b/core/migrations/0023_auto_20170902_1226.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models -from django.conf import settings import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/core/migrations/0025_auto_20170919_1521.py b/core/migrations/0025_auto_20170919_1521.py index f37a829b..f7bd278c 100644 --- a/core/migrations/0025_auto_20170919_1521.py +++ b/core/migrations/0025_auto_20170919_1521.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import django.core.validators +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/core/migrations/0027_gift.py b/core/migrations/0027_gift.py index 21bf8442..ca8ce67b 100644 --- a/core/migrations/0027_gift.py +++ b/core/migrations/0027_gift.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models -from django.conf import settings -import django.utils.timezone import django.db.models.deletion +import django.utils.timezone +from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/core/migrations/0029_auto_20180426_2013.py b/core/migrations/0029_auto_20180426_2013.py index eadfd558..c591f47b 100644 --- a/core/migrations/0029_auto_20180426_2013.py +++ b/core/migrations/0029_auto_20180426_2013.py @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models -import core.models import django.db.models.deletion +from django.db import migrations, models + +import core.models class Migration(migrations.Migration): diff --git a/core/migrations/0034_operationlog.py b/core/migrations/0034_operationlog.py index df59cd6a..505e2332 100644 --- a/core/migrations/0034_operationlog.py +++ b/core/migrations/0034_operationlog.py @@ -1,8 +1,8 @@ # Generated by Django 2.2.6 on 2019-11-14 15:10 +import django.db.models.deletion from django.conf import settings from django.db import migrations, models -import django.db.models.deletion class Migration(migrations.Migration): diff --git a/core/models.py b/core/models.py index c804d30b..4fba43c3 100644 --- a/core/models.py +++ b/core/models.py @@ -23,36 +23,39 @@ # # import importlib -from typing import Union, Optional, List +import os +import unicodedata +from datetime import date, timedelta +from typing import List, Optional, Union -from django.core.cache import cache -from django.core.mail import send_mail +from django.conf import settings from django.contrib.auth.models import ( AbstractBaseUser, UserManager, - Group as AuthGroup, - GroupManager as AuthGroupManager, +) +from django.contrib.auth.models import ( AnonymousUser as AuthAnonymousUser, ) -from django.utils.translation import gettext_lazy as _ -from django.utils import timezone -from django.core import validators -from django.core.exceptions import ValidationError, PermissionDenied -from django.urls import reverse -from django.conf import settings -from django.db import models, transaction +from django.contrib.auth.models import ( + Group as AuthGroup, +) +from django.contrib.auth.models import ( + GroupManager as AuthGroupManager, +) from django.contrib.staticfiles.storage import staticfiles_storage -from django.utils.html import escape +from django.core import validators +from django.core.cache import cache +from django.core.exceptions import PermissionDenied, ValidationError +from django.core.mail import send_mail +from django.db import models, transaction +from django.urls import reverse +from django.utils import timezone from django.utils.functional import cached_property - -import os -from core import utils - +from django.utils.html import escape +from django.utils.translation import gettext_lazy as _ from phonenumber_field.modelfields import PhoneNumberField -from datetime import timedelta, date - -import unicodedata +from core import utils class RealGroupManager(AuthGroupManager): diff --git a/core/scss/finder.py b/core/scss/finder.py index 3e25279f..0b62fab3 100644 --- a/core/scss/finder.py +++ b/core/scss/finder.py @@ -25,6 +25,7 @@ import os from collections import OrderedDict + from django.conf import settings from django.contrib.staticfiles.finders import FileSystemFinder from django.core.files.storage import FileSystemStorage diff --git a/core/scss/processor.py b/core/scss/processor.py index 6aa334f2..add5e042 100644 --- a/core/scss/processor.py +++ b/core/scss/processor.py @@ -24,12 +24,14 @@ # import os -import sass from urllib.parse import urljoin -from django.utils.encoding import force_bytes, iri_to_uri + +import sass +from django.conf import settings from django.core.files.base import ContentFile from django.templatetags.static import static -from django.conf import settings +from django.utils.encoding import force_bytes, iri_to_uri + from core.scss.storage import ScssFileStorage, find_file diff --git a/core/search_indexes.py b/core/search_indexes.py index b98dc67b..f2448adb 100644 --- a/core/search_indexes.py +++ b/core/search_indexes.py @@ -24,7 +24,6 @@ # from django.db import models - from haystack import indexes, signals from core.models import User diff --git a/core/signals.py b/core/signals.py index 7cda36c7..23e38599 100644 --- a/core/signals.py +++ b/core/signals.py @@ -8,10 +8,10 @@ from core.models import User @receiver(m2m_changed, sender=User.groups.through, dispatch_uid="user_groups_changed") def user_groups_changed(sender, instance: User, **kwargs): """ - Clear the cached clubs of the user + Clear the cached groups of the user """ # As a m2m relationship doesn't live within the model # but rather on an intermediary table, there is no # model method to override, meaning we must use - # a signal to invalidate the cache when a user is removed from a club - cache.delete(f"user_{instance.id}_groups") + # a signal to invalidate the cache when a user is removed from a group + cache.delete(f"user_{instance.pk}_groups") diff --git a/core/templatetags/renderer.py b/core/templatetags/renderer.py index 2ee19a45..86bd6791 100644 --- a/core/templatetags/renderer.py +++ b/core/templatetags/renderer.py @@ -24,15 +24,15 @@ # import datetime -import phonenumbers +import phonenumbers from django import template from django.template.defaultfilters import stringfilter from django.utils.safestring import mark_safe from django.utils.translation import ngettext -from core.scss.processor import ScssProcessor from core.markdown import markdown as md +from core.scss.processor import ScssProcessor register = template.Library() diff --git a/core/templatetags/search_helpers.py b/core/templatetags/search_helpers.py index 537ff357..d38574df 100644 --- a/core/templatetags/search_helpers.py +++ b/core/templatetags/search_helpers.py @@ -1,6 +1,6 @@ -from django.template.exceptions import TemplateSyntaxError from django import template from django.template.defaultfilters import stringfilter +from django.template.exceptions import TemplateSyntaxError register = template.Library() diff --git a/core/urls.py b/core/urls.py index ec42f880..3f6398e8 100644 --- a/core/urls.py +++ b/core/urls.py @@ -25,12 +25,12 @@ from django.urls import path, re_path, register_converter -from core.views import * from core.converters import ( + BooleanStringConverter, FourDigitYearConverter, TwoDigitMonthConverter, - BooleanStringConverter, ) +from core.views import * register_converter(FourDigitYearConverter, "yyyy") register_converter(TwoDigitMonthConverter, "mm") diff --git a/core/utils.py b/core/utils.py index d30e3ebf..62cf04bb 100644 --- a/core/utils.py +++ b/core/utils.py @@ -26,8 +26,8 @@ from typing import Optional import PIL from django.conf import settings from django.core.files.base import ContentFile -from PIL import ExifTags from django.utils import timezone +from PIL import ExifTags def get_git_revision_short_hash() -> str: diff --git a/core/views/__init__.py b/core/views/__init__.py index a36147b4..ad86fe2d 100644 --- a/core/views/__init__.py +++ b/core/views/__init__.py @@ -25,26 +25,21 @@ import types -from sentry_sdk import last_event_id -from django.shortcuts import render +from django.core.exceptions import ( + ImproperlyConfigured, + PermissionDenied, +) from django.http import ( HttpResponseForbidden, HttpResponseNotFound, HttpResponseServerError, ) -from django.template import RequestContext -from django.core.exceptions import ( - PermissionDenied, - ObjectDoesNotExist, - ImproperlyConfigured, -) -from django.views.generic.base import View -from django.views.generic.edit import FormView -from django.views.generic.detail import SingleObjectMixin from django.utils.functional import cached_property -from django.db.models import Count +from django.views.generic.base import View +from django.views.generic.detail import SingleObjectMixin +from django.views.generic.edit import FormView +from sentry_sdk import last_event_id -from core.models import Group from core.views.forms import LoginForm @@ -361,8 +356,8 @@ class DetailFormView(SingleObjectMixin, FormView): return super(DetailFormView, self).get_object() -from .user import * -from .page import * from .files import * -from .site import * from .group import * +from .page import * +from .site import * +from .user import * diff --git a/core/views/files.py b/core/views/files.py index 61d3aec9..7cce06e7 100644 --- a/core/views/files.py +++ b/core/views/files.py @@ -15,29 +15,28 @@ # # This file contains all the views that concern the page model -from django.shortcuts import redirect, get_object_or_404 -from django.utils.http import http_date -from django.views.generic import ListView, DetailView, TemplateView -from django.views.generic.edit import UpdateView, FormMixin, DeleteView -from django.views.generic.detail import SingleObjectMixin -from django.forms.models import modelform_factory -from django.conf import settings -from django.utils.translation import gettext_lazy as _ -from django.http import Http404, HttpResponse -from wsgiref.util import FileWrapper -from django.urls import reverse -from django.core.exceptions import PermissionDenied -from django import forms - import os +from wsgiref.util import FileWrapper from ajax_select import make_ajax_field +from django import forms +from django.conf import settings +from django.core.exceptions import PermissionDenied +from django.forms.models import modelform_factory +from django.http import Http404, HttpResponse +from django.shortcuts import get_object_or_404, redirect +from django.urls import reverse +from django.utils.http import http_date +from django.utils.translation import gettext_lazy as _ +from django.views.generic import DetailView, ListView, TemplateView +from django.views.generic.detail import SingleObjectMixin +from django.views.generic.edit import DeleteView, FormMixin, UpdateView -from core.models import SithFile, RealGroup, Notification +from core.models import Notification, RealGroup, SithFile from core.views import ( - CanViewMixin, CanEditMixin, CanEditPropMixin, + CanViewMixin, can_view, ) from counter.models import Counter diff --git a/core/views/forms.py b/core/views/forms.py index 936abb26..5426ef14 100644 --- a/core/views/forms.py +++ b/core/views/forms.py @@ -21,40 +21,37 @@ # Place - Suite 330, Boston, MA 02111-1307, USA. # # +import datetime +import re +from io import BytesIO + +from ajax_select import make_ajax_field +from ajax_select.fields import AutoCompleteSelectField from captcha.fields import CaptchaField -from django.contrib.auth.forms import UserCreationForm, AuthenticationForm from django import forms from django.conf import settings -from django.db import transaction -from django.templatetags.static import static -from django.urls import reverse +from django.contrib.auth.forms import AuthenticationForm, UserCreationForm from django.core.exceptions import ValidationError +from django.db import transaction from django.forms import ( CheckboxSelectMultiple, - Select, DateInput, - TextInput, DateTimeInput, Textarea, + TextInput, ) -from django.utils.translation import gettext_lazy as _ -from django.utils.translation import gettext -from phonenumber_field.widgets import PhoneNumberInternationalFallbackWidget -from ajax_select.fields import AutoCompleteSelectField -from ajax_select import make_ajax_field -from django.utils.dateparse import parse_datetime -from django.utils import timezone -import datetime from django.forms.utils import to_current_timezone - -import re - -from core.models import User, Page, SithFile, Gift - -from core.utils import resize_image -from io import BytesIO +from django.templatetags.static import static +from django.urls import reverse +from django.utils import timezone +from django.utils.dateparse import parse_datetime +from django.utils.translation import gettext +from django.utils.translation import gettext_lazy as _ +from phonenumber_field.widgets import PhoneNumberInternationalFallbackWidget from PIL import Image +from core.models import Gift, Page, SithFile, User +from core.utils import resize_image # Widgets diff --git a/core/views/group.py b/core/views/group.py index 419d699d..1c598832 100644 --- a/core/views/group.py +++ b/core/views/group.py @@ -18,15 +18,12 @@ This module contains views to manage Groups """ -from django.views.generic.edit import UpdateView, CreateView, DeleteView -from django.views.generic import ListView -from django.views.generic.edit import FormView -from django.urls import reverse_lazy -from django.shortcuts import get_object_or_404 -from django.utils.translation import gettext_lazy as _ -from django import forms - from ajax_select.fields import AutoCompleteSelectMultipleField +from django import forms +from django.urls import reverse_lazy +from django.utils.translation import gettext_lazy as _ +from django.views.generic import ListView +from django.views.generic.edit import CreateView, DeleteView, UpdateView from core.models import RealGroup, User from core.views import CanCreateMixin, CanEditMixin, DetailFormView diff --git a/core/views/page.py b/core/views/page.py index c2c7dbce..5f148235 100644 --- a/core/views/page.py +++ b/core/views/page.py @@ -15,16 +15,16 @@ # # This file contains all the views that concern the page model -from django.urls import reverse_lazy -from django.views.generic import ListView, DetailView -from django.views.generic.edit import UpdateView, CreateView, DeleteView from django.forms.models import modelform_factory from django.http import Http404 from django.shortcuts import redirect +from django.urls import reverse_lazy +from django.views.generic import DetailView, ListView +from django.views.generic.edit import CreateView, DeleteView, UpdateView -from core.models import Page, PageRev, LockError +from core.models import LockError, Page, PageRev +from core.views import CanCreateMixin, CanEditMixin, CanEditPropMixin, CanViewMixin from core.views.forms import MarkdownInput, PageForm, PagePropForm -from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, CanCreateMixin class CanEditPagePropMixin(CanEditPropMixin): diff --git a/core/views/site.py b/core/views/site.py index c7163488..bdd575f4 100644 --- a/core/views/site.py +++ b/core/views/site.py @@ -23,23 +23,22 @@ # # -from django.shortcuts import render, redirect -from django.http import JsonResponse -from django.core import serializers -from django.contrib.auth.decorators import login_required -from django.utils import html -from django.views.generic import ListView, TemplateView -from django.conf import settings -from django.utils.text import slugify -from django.db.models.query import QuerySet - import json +from django.conf import settings +from django.contrib.auth.decorators import login_required +from django.core import serializers +from django.db.models.query import QuerySet +from django.http import JsonResponse +from django.shortcuts import redirect, render +from django.utils import html +from django.utils.text import slugify +from django.views.generic import ListView, TemplateView from haystack.query import SearchQuerySet -from core.models import User, Notification -from core.utils import doku_to_markdown, bbcode_to_markdown from club.models import Club +from core.models import Notification, User +from core.utils import bbcode_to_markdown, doku_to_markdown def index(request, context=None): diff --git a/core/views/user.py b/core/views/user.py index dbd60f13..d8d8d909 100644 --- a/core/views/user.py +++ b/core/views/user.py @@ -24,50 +24,49 @@ # # This file contains all the views that concern the user model -from django.shortcuts import render, redirect, get_object_or_404 +import logging +from datetime import date, timedelta + +from django.conf import settings from django.contrib.auth import views from django.contrib.auth.forms import PasswordChangeForm -from django.utils.translation import gettext as _ -from django.urls import reverse from django.core.exceptions import PermissionDenied, ValidationError +from django.forms import CheckboxSelectMultiple +from django.forms.models import modelform_factory from django.http import Http404, HttpResponse -from django.views.generic.edit import UpdateView +from django.shortcuts import get_object_or_404, redirect, render +from django.template.response import TemplateResponse +from django.urls import reverse, reverse_lazy +from django.utils.translation import gettext as _ from django.views.generic import ( - ListView, - DetailView, - TemplateView, CreateView, DeleteView, + DetailView, + ListView, + TemplateView, ) -from django.forms.models import modelform_factory -from django.forms import CheckboxSelectMultiple -from django.urls import reverse_lazy -from django.template.response import TemplateResponse -from django.conf import settings -from django.views.generic.dates import YearMixin, MonthMixin +from django.views.generic.dates import MonthMixin, YearMixin +from django.views.generic.edit import UpdateView -from datetime import timedelta, date -import logging from api.views.sas import all_pictures_of_user - +from core.models import Gift, Preferences, SithFile, User from core.views import ( - CanViewMixin, CanEditMixin, CanEditPropMixin, - UserIsLoggedMixin, - TabedViewMixin, + CanViewMixin, QuickNotifMixin, + TabedViewMixin, + UserIsLoggedMixin, ) from core.views.forms import ( - RegisteringForm, - UserProfileForm, - LoginForm, - UserGodfathersForm, GiftForm, + LoginForm, + RegisteringForm, + UserGodfathersForm, + UserProfileForm, ) -from core.models import User, SithFile, Preferences, Gift -from subscription.models import Subscription from counter.forms import StudentCardForm +from subscription.models import Subscription from trombi.views import UserTrombiForm @@ -501,9 +500,10 @@ class UserStatsView(UserTabsMixin, CanViewMixin, DetailView): def get_context_data(self, **kwargs): kwargs = super(UserStatsView, self).get_context_data(**kwargs) - from counter.models import Counter from django.db.models import Sum + from counter.models import Counter + foyer = Counter.objects.filter(name="Foyer").first() mde = Counter.objects.filter(name="MDE").first() gommette = Counter.objects.filter(name="La Gommette").first() @@ -601,10 +601,12 @@ class UserUploadProfilePictView(CanEditMixin, DetailView): template_name = "core/user_edit.jinja" def post(self, request, *args, **kwargs): - from core.utils import resize_image from io import BytesIO + from PIL import Image + from core.utils import resize_image + self.object = self.get_object() if self.object.profile_pict: raise ValidationError(_("User already has a profile picture")) diff --git a/counter/app.py b/counter/app.py index c1feefe2..a1165d7c 100644 --- a/counter/app.py +++ b/counter/app.py @@ -31,4 +31,4 @@ class CounterConfig(AppConfig): verbose_name = _("counter") def ready(self): - import counter.signals + import counter.signals # noqa F401 diff --git a/counter/forms.py b/counter/forms.py index a09236e7..7c282f57 100644 --- a/counter/forms.py +++ b/counter/forms.py @@ -3,15 +3,15 @@ from ajax_select.fields import AutoCompleteSelectField, AutoCompleteSelectMultip from django import forms from django.utils.translation import gettext_lazy as _ -from core.views.forms import TzAwareDateTimeField, SelectDate +from core.views.forms import SelectDate, TzAwareDateTimeField from counter.models import ( BillingInfo, - StudentCard, - Customer, - Refilling, Counter, - Product, + Customer, Eticket, + Product, + Refilling, + StudentCard, ) diff --git a/counter/migrations/0001_initial.py b/counter/migrations/0001_initial.py index e9635e5d..aa84e936 100644 --- a/counter/migrations/0001_initial.py +++ b/counter/migrations/0001_initial.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models -import accounting.models import django.db.models.deletion from django.conf import settings -import django.db.models.deletion +from django.db import migrations, models + +import accounting.models class Migration(migrations.Migration): diff --git a/counter/migrations/0002_auto_20160826_1342.py b/counter/migrations/0002_auto_20160826_1342.py index ccc4288c..83e6a83a 100644 --- a/counter/migrations/0002_auto_20160826_1342.py +++ b/counter/migrations/0002_auto_20160826_1342.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models -from django.conf import settings -import accounting.models import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + +import accounting.models class Migration(migrations.Migration): diff --git a/counter/migrations/0003_permanency_activity.py b/counter/migrations/0003_permanency_activity.py index be4e9962..929d8308 100644 --- a/counter/migrations/0003_permanency_activity.py +++ b/counter/migrations/0003_permanency_activity.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import datetime + +from django.db import migrations, models from django.utils.timezone import utc diff --git a/counter/migrations/0005_auto_20160826_2330.py b/counter/migrations/0005_auto_20160826_2330.py index 8e0df744..9dc3fad9 100644 --- a/counter/migrations/0005_auto_20160826_2330.py +++ b/counter/migrations/0005_auto_20160826_2330.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/counter/migrations/0009_eticket.py b/counter/migrations/0009_eticket.py index 68b675ef..96d82e30 100644 --- a/counter/migrations/0009_eticket.py +++ b/counter/migrations/0009_eticket.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/counter/migrations/0013_customer_recorded_products.py b/counter/migrations/0013_customer_recorded_products.py index d6b3cfa8..271491eb 100644 --- a/counter/migrations/0013_customer_recorded_products.py +++ b/counter/migrations/0013_customer_recorded_products.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.utils.translation import gettext_lazy as _ -from django.db import migrations, models from django.conf import settings +from django.db import migrations, models +from django.utils.translation import gettext_lazy as _ from core.models import User -from counter.models import Customer, Product, Selling, Counter +from counter.models import Counter, Customer, Product, Selling def balance_ecocups(apps, schema_editor): diff --git a/counter/migrations/0015_merge.py b/counter/migrations/0015_merge.py index 6dcff021..eba94807 100644 --- a/counter/migrations/0015_merge.py +++ b/counter/migrations/0015_merge.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models +from django.db import migrations class Migration(migrations.Migration): diff --git a/counter/migrations/0017_studentcard.py b/counter/migrations/0017_studentcard.py index a2f62222..267cef25 100644 --- a/counter/migrations/0017_studentcard.py +++ b/counter/migrations/0017_studentcard.py @@ -3,8 +3,8 @@ from __future__ import unicode_literals import django.core.validators -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/counter/migrations/0019_billinginfo.py b/counter/migrations/0019_billinginfo.py index c4c74c39..b348c86a 100644 --- a/counter/migrations/0019_billinginfo.py +++ b/counter/migrations/0019_billinginfo.py @@ -1,8 +1,8 @@ # Generated by Django 3.2.16 on 2023-01-08 12:49 -from django.db import migrations, models import django.db.models.deletion import django_countries.fields +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/counter/migrations/0020_auto_20221215_1709.py b/counter/migrations/0020_auto_20221215_1709.py index 52010133..22db406b 100644 --- a/counter/migrations/0020_auto_20221215_1709.py +++ b/counter/migrations/0020_auto_20221215_1709.py @@ -1,8 +1,9 @@ # Generated by Django 3.2.16 on 2022-12-15 16:09 -import accounting.models from django.db import migrations +import accounting.models + class Migration(migrations.Migration): dependencies = [ diff --git a/counter/models.py b/counter/models.py index 476aaf13..c9972f10 100644 --- a/counter/models.py +++ b/counter/models.py @@ -15,35 +15,33 @@ # from __future__ import annotations -from typing import Tuple, Optional - -from django.db import models -from django.db.models import F, Value, Sum, QuerySet, OuterRef, Exists -from django.db.models.functions import Concat, Length -from django.utils.translation import gettext_lazy as _ -from django.utils import timezone -from django.conf import settings -from django.urls import reverse -from django.core.validators import MinLengthValidator -from django.forms import ValidationError -from django.utils.functional import cached_property - -from datetime import timedelta, date, datetime +import base64 +import os import random import string -import os -import base64 -from dict2xml import dict2xml +from datetime import date, datetime, timedelta +from typing import Optional, Tuple +from dict2xml import dict2xml +from django.conf import settings +from django.core.validators import MinLengthValidator +from django.db import models +from django.db.models import Exists, F, OuterRef, QuerySet, Sum, Value +from django.db.models.functions import Concat, Length +from django.forms import ValidationError +from django.urls import reverse +from django.utils import timezone +from django.utils.functional import cached_property +from django.utils.translation import gettext_lazy as _ +from django_countries.fields import CountryField + +from accounting.models import CurrencyField +from club.models import Club +from core.models import Group, Notification, User from core.utils import get_start_of_semester from sith.settings import SITH_COUNTER_OFFICES, SITH_MAIN_CLUB -from club.models import Club, Membership -from accounting.models import CurrencyField -from core.models import Group, User, Notification from subscription.models import Subscription -from django_countries.fields import CountryField - class Customer(models.Model): """ diff --git a/counter/signals.py b/counter/signals.py index 9c1f4b78..9221494d 100644 --- a/counter/signals.py +++ b/counter/signals.py @@ -24,12 +24,10 @@ from django.db.models.signals import pre_delete from django.dispatch import receiver -from django.conf import settings from core.middleware import get_signal_request from core.models import OperationLog - -from counter.models import Selling, Refilling, Counter +from counter.models import Counter, Refilling, Selling def write_log(instance, operation_type): diff --git a/counter/tests.py b/counter/tests.py index 6079099a..f921a5d4 100644 --- a/counter/tests.py +++ b/counter/tests.py @@ -13,20 +13,18 @@ # OR WITHIN THE LOCAL FILE "LICENSE" # # -from datetime import date, timedelta import json import re import string from django.test import TestCase from django.urls import reverse -from django.core.management import call_command from django.utils import timezone from django.utils.timezone import timedelta from club.models import Club from core.models import User -from counter.models import Counter, Customer, BillingInfo, Permanency, Selling, Product +from counter.models import BillingInfo, Counter, Customer, Permanency, Product, Selling from sith.settings import SITH_MAIN_CLUB diff --git a/counter/views.py b/counter/views.py index 4c0b167b..fe10d0a1 100644 --- a/counter/views.py +++ b/counter/views.py @@ -14,68 +14,65 @@ # # import json +import re +from datetime import datetime, timedelta +from http import HTTPStatus from urllib.parse import parse_qs +import pytz +from django import forms +from django.conf import settings from django.contrib.auth.decorators import login_required -from django.db.models import F -from django.shortcuts import get_object_or_404 -from django.http import Http404 from django.core.exceptions import PermissionDenied +from django.db import DataError, transaction +from django.db.models import F +from django.forms import CheckboxSelectMultiple +from django.forms.models import modelform_factory +from django.http import Http404, HttpResponse, HttpResponseRedirect, JsonResponse +from django.shortcuts import get_object_or_404 +from django.urls import reverse, reverse_lazy +from django.utils import timezone +from django.utils.translation import gettext_lazy as _ from django.views.decorators.http import require_POST -from django.views.generic import ListView, DetailView, RedirectView, TemplateView +from django.views.generic import DetailView, ListView, RedirectView, TemplateView from django.views.generic.base import View from django.views.generic.edit import ( - UpdateView, CreateView, DeleteView, - ProcessFormView, FormMixin, FormView, + ProcessFormView, + UpdateView, ) -from django.forms.models import modelform_factory -from django.forms import CheckboxSelectMultiple -from django.urls import reverse_lazy, reverse -from django.http import HttpResponseRedirect, HttpResponse, JsonResponse -from django.utils import timezone -from django import forms -from django.utils.translation import gettext_lazy as _ -from django.conf import settings -from django.db import DataError, transaction -import json -import re -import pytz -from datetime import timedelta, datetime -from http import HTTPStatus - -from core.utils import get_start_of_semester, get_semester_code -from core.views import CanViewMixin, TabedViewMixin, CanEditMixin -from core.views.forms import LoginForm +from accounting.models import CurrencyField from core.models import User +from core.utils import get_semester_code, get_start_of_semester +from core.views import CanEditMixin, CanViewMixin, TabedViewMixin +from core.views.forms import LoginForm from counter.forms import ( BillingInfoForm, - StudentCardForm, - GetUserForm, - RefillForm, - CounterEditForm, - ProductEditForm, CashSummaryFormBase, + CounterEditForm, EticketForm, + GetUserForm, + ProductEditForm, + RefillForm, + StudentCardForm, ) from counter.models import ( - Counter, - Customer, - StudentCard, - Product, - Selling, - Refilling, - ProductType, + BillingInfo, CashRegisterSummary, CashRegisterSummaryItem, + Counter, + Customer, Eticket, - BillingInfo, + Product, + ProductType, + Refilling, + Selling, + StudentCard, ) -from accounting.models import CurrencyField class CounterAdminMixin(View): @@ -1486,7 +1483,7 @@ class InvoiceCallView(CounterAdminTabsMixin, CounterAdminMixin, TemplateView): end_date = (start_date + timedelta(days=32)).replace( day=1, hour=0, minute=0, microsecond=0 ) - from django.db.models import Sum, Case, When, F + from django.db.models import Case, F, Sum, When kwargs["sum_cb"] = sum( [ @@ -1574,12 +1571,12 @@ class EticketPDFView(CanViewMixin, DetailView): pk_url_kwarg = "selling_id" def get(self, request, *args, **kwargs): - from reportlab.pdfgen import canvas - from reportlab.lib.utils import ImageReader - from reportlab.lib.units import cm - from reportlab.graphics.shapes import Drawing - from reportlab.graphics.barcode.qr import QrCodeWidget from reportlab.graphics import renderPDF + from reportlab.graphics.barcode.qr import QrCodeWidget + from reportlab.graphics.shapes import Drawing + from reportlab.lib.units import cm + from reportlab.lib.utils import ImageReader + from reportlab.pdfgen import canvas if not ( hasattr(self.object, "product") and hasattr(self.object.product, "eticket") diff --git a/doc/conf.py b/doc/conf.py index 2a103e0b..d9f219c9 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -12,6 +12,7 @@ # import os import sys + import django sys.path.insert(0, os.path.abspath("..")) diff --git a/eboutic/forms.py b/eboutic/forms.py index c5842700..3189e330 100644 --- a/eboutic/forms.py +++ b/eboutic/forms.py @@ -25,8 +25,8 @@ import json import re import typing - from urllib.parse import unquote + from django.http import HttpRequest from django.utils.translation import gettext as _ from sentry_sdk import capture_message diff --git a/eboutic/migrations/0001_initial.py b/eboutic/migrations/0001_initial.py index b642642f..f698999c 100644 --- a/eboutic/migrations/0001_initial.py +++ b/eboutic/migrations/0001_initial.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models -import accounting.models -from django.conf import settings import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + +import accounting.models class Migration(migrations.Migration): diff --git a/eboutic/models.py b/eboutic/models.py index 556eb8ab..da048b63 100644 --- a/eboutic/models.py +++ b/eboutic/models.py @@ -14,21 +14,20 @@ # # import hmac -import html import typing from datetime import datetime from typing import List from dict2xml import dict2xml from django.conf import settings -from django.db import models, DataError -from django.db.models import Sum, F +from django.db import DataError, models +from django.db.models import F, Sum from django.utils.functional import cached_property from django.utils.translation import gettext_lazy as _ from accounting.models import CurrencyField -from core.models import Group, User -from counter.models import Counter, Product, Selling, Refilling, BillingInfo, Customer +from core.models import User +from counter.models import BillingInfo, Counter, Customer, Product, Refilling, Selling def get_eboutic_products(user: User) -> List[Product]: diff --git a/eboutic/tests.py b/eboutic/tests.py index b37b4a7b..3435bfc5 100644 --- a/eboutic/tests.py +++ b/eboutic/tests.py @@ -26,15 +26,14 @@ import base64 import json import urllib -from OpenSSL import crypto from django.conf import settings -from django.core.management import call_command from django.db.models import Max from django.test import TestCase from django.urls import reverse +from OpenSSL import crypto from core.models import User -from counter.models import Product, Counter, Customer, Selling +from counter.models import Counter, Customer, Product, Selling from eboutic.models import Basket diff --git a/eboutic/tests/test.py b/eboutic/tests/test.py index 2a4e6cfb..359db7ff 100755 --- a/eboutic/tests/test.py +++ b/eboutic/tests/test.py @@ -7,6 +7,7 @@ # import base64 + from OpenSSL import crypto with open("./private_key.pem") as f: diff --git a/eboutic/urls.py b/eboutic/urls.py index a1bd6ecd..22602aeb 100644 --- a/eboutic/urls.py +++ b/eboutic/urls.py @@ -25,8 +25,8 @@ from django.urls import path, register_converter -from eboutic.views import * from eboutic.converters import PaymentResultConverter +from eboutic.views import * register_converter(PaymentResultConverter, "res") diff --git a/eboutic/views.py b/eboutic/views.py index 885edf43..c240d64d 100644 --- a/eboutic/views.py +++ b/eboutic/views.py @@ -16,23 +16,23 @@ import base64 import json -import sentry_sdk - from datetime import datetime from urllib.parse import unquote -from OpenSSL import crypto + +import sentry_sdk from django.conf import settings from django.contrib.auth.decorators import login_required from django.core.exceptions import SuspiciousOperation -from django.db import transaction, DatabaseError -from django.http import HttpResponse, HttpRequest -from django.shortcuts import render, redirect +from django.db import DatabaseError, transaction +from django.http import HttpRequest, HttpResponse +from django.shortcuts import redirect, render from django.utils.decorators import method_decorator from django.views.decorators.http import require_GET, require_POST from django.views.generic import TemplateView, View +from OpenSSL import crypto from counter.forms import BillingInfoForm -from counter.models import Customer, Counter, Product +from counter.models import Counter, Customer, Product from eboutic.forms import BasketForm from eboutic.models import Basket, Invoice, InvoiceItem, get_eboutic_products diff --git a/election/admin.py b/election/admin.py index 3cd3ce37..fadc9a52 100644 --- a/election/admin.py +++ b/election/admin.py @@ -1,7 +1,7 @@ from ajax_select import make_ajax_form from django.contrib import admin -from election.models import Election, Role, ElectionList, Candidature +from election.models import Candidature, Election, ElectionList, Role @admin.register(Election) diff --git a/election/migrations/0001_initial.py b/election/migrations/0001_initial.py index d3c4c449..04deb469 100644 --- a/election/migrations/0001_initial.py +++ b/election/migrations/0001_initial.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models -from django.conf import settings import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/election/models.py b/election/models.py index f100a1d6..3bcf761f 100644 --- a/election/models.py +++ b/election/models.py @@ -1,9 +1,9 @@ from django.db import models -from ordered_model.models import OrderedModel -from django.utils.translation import gettext_lazy as _ from django.utils import timezone +from django.utils.translation import gettext_lazy as _ +from ordered_model.models import OrderedModel -from core.models import User, Group +from core.models import Group, User class Election(models.Model): diff --git a/election/tests.py b/election/tests.py index 03b46481..3a3de97a 100644 --- a/election/tests.py +++ b/election/tests.py @@ -1,9 +1,8 @@ +from django.conf import settings from django.test import TestCase from django.urls import reverse -from django.core.management import call_command -from django.conf import settings -from core.models import User, Group +from core.models import Group, User from election.models import Election diff --git a/election/views.py b/election/views.py index a223c78c..71be8bfe 100644 --- a/election/views.py +++ b/election/views.py @@ -1,24 +1,19 @@ -from django.shortcuts import get_object_or_404 -from django.views.generic import ListView, DetailView -from django.views.generic.edit import UpdateView, CreateView -from django.views.generic.edit import DeleteView, FormView -from django.urls import reverse_lazy, reverse -from django.utils.translation import gettext_lazy as _ +from ajax_select import make_ajax_field +from ajax_select.fields import AutoCompleteSelectField +from django import forms from django.core.exceptions import PermissionDenied from django.db import transaction -from django.shortcuts import redirect -from django import forms +from django.db.models.query import QuerySet +from django.shortcuts import get_object_or_404, redirect +from django.urls import reverse, reverse_lazy +from django.utils.translation import gettext_lazy as _ +from django.views.generic import DetailView, ListView +from django.views.generic.edit import CreateView, DeleteView, FormView, UpdateView from core.models import User -from core.views import CanViewMixin, CanEditMixin, CanCreateMixin -from django.db.models.query import QuerySet -from core.views.forms import SelectDateTime, MarkdownInput -from election.models import Election, Role, Candidature, ElectionList, Vote -from core.views.forms import TzAwareDateTimeField - -from ajax_select.fields import AutoCompleteSelectField -from ajax_select import make_ajax_field - +from core.views import CanCreateMixin, CanEditMixin, CanViewMixin +from core.views.forms import MarkdownInput, TzAwareDateTimeField +from election.models import Candidature, Election, ElectionList, Role, Vote # Custom form field diff --git a/forum/admin.py b/forum/admin.py index 6d0c088a..eff7d401 100644 --- a/forum/admin.py +++ b/forum/admin.py @@ -17,7 +17,6 @@ from django.contrib import admin from haystack.admin import SearchModelAdmin - from forum.models import * diff --git a/forum/migrations/0001_initial.py b/forum/migrations/0001_initial.py index 6c06b0a6..4ad137d6 100644 --- a/forum/migrations/0001_initial.py +++ b/forum/migrations/0001_initial.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +import datetime + +import django.db.models.deletion +import django.utils.timezone +from django.conf import settings from django.db import migrations, models from django.utils.timezone import utc -from django.conf import settings -import django.utils.timezone -import datetime -import django.db.models.deletion class Migration(migrations.Migration): diff --git a/forum/migrations/0004_auto_20170531_1949.py b/forum/migrations/0004_auto_20170531_1949.py index 152bdaea..ef466a9b 100644 --- a/forum/migrations/0004_auto_20170531_1949.py +++ b/forum/migrations/0004_auto_20170531_1949.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/forum/migrations/0005_forumtopic_subscribed_users.py b/forum/migrations/0005_forumtopic_subscribed_users.py index b1f6d629..b977aadf 100644 --- a/forum/migrations/0005_forumtopic_subscribed_users.py +++ b/forum/migrations/0005_forumtopic_subscribed_users.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/forum/migrations/0006_auto_20180426_2013.py b/forum/migrations/0006_auto_20180426_2013.py index 30248dec..974b9b8e 100644 --- a/forum/migrations/0006_auto_20180426_2013.py +++ b/forum/migrations/0006_auto_20180426_2013.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals from django.db import migrations, models + import forum.models diff --git a/forum/models.py b/forum/models.py index 3894caa7..a7d77c4d 100644 --- a/forum/models.py +++ b/forum/models.py @@ -22,20 +22,20 @@ # # -from django.db import models +from datetime import datetime +from itertools import chain + +import pytz from django.conf import settings -from django.utils.translation import gettext_lazy as _ from django.core.exceptions import ValidationError +from django.db import models from django.urls import reverse from django.utils import timezone from django.utils.functional import cached_property +from django.utils.translation import gettext_lazy as _ -from datetime import datetime -from itertools import chain -import pytz - -from core.models import User, Group from club.models import Club +from core.models import Group, User class Forum(models.Model): diff --git a/forum/tests.py b/forum/tests.py index 46a200c2..d888e761 100644 --- a/forum/tests.py +++ b/forum/tests.py @@ -14,6 +14,4 @@ # # -from django.test import TestCase - # Create your tests here. diff --git a/forum/views.py b/forum/views.py index 9b75794b..74e6bff4 100644 --- a/forum/views.py +++ b/forum/views.py @@ -23,31 +23,30 @@ # # -from django.shortcuts import get_object_or_404 -from django.views.generic import ListView, DetailView, RedirectView -from django.views.generic.edit import UpdateView, CreateView, DeleteView -from django.views.generic.detail import SingleObjectMixin -from django.utils.translation import gettext_lazy as _ -from django.urls import reverse_lazy -from django.utils import timezone, html -from django.conf import settings -from django import forms -from django.core.exceptions import PermissionDenied -from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger - from ajax_select import make_ajax_field +from django import forms +from django.conf import settings +from django.core.exceptions import PermissionDenied +from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator +from django.shortcuts import get_object_or_404 +from django.urls import reverse_lazy +from django.utils import html, timezone +from django.utils.translation import gettext_lazy as _ +from django.views.generic import DetailView, ListView, RedirectView +from django.views.generic.detail import SingleObjectMixin +from django.views.generic.edit import CreateView, DeleteView, UpdateView +from haystack.query import RelatedSearchQuerySet from core.views import ( - CanViewMixin, + CanCreateMixin, CanEditMixin, CanEditPropMixin, - CanCreateMixin, + CanViewMixin, UserIsLoggedMixin, can_view, ) from core.views.forms import MarkdownInput -from forum.models import Forum, ForumMessage, ForumTopic, ForumMessageMeta -from haystack.query import RelatedSearchQuerySet +from forum.models import Forum, ForumMessage, ForumMessageMeta, ForumTopic class ForumSearchView(ListView): diff --git a/galaxy/management/commands/generate_galaxy_test_data.py b/galaxy/management/commands/generate_galaxy_test_data.py index f6442487..191198f7 100644 --- a/galaxy/management/commands/generate_galaxy_test_data.py +++ b/galaxy/management/commands/generate_galaxy_test_data.py @@ -21,7 +21,9 @@ # Place - Suite 330, Boston, MA 02111-1307, USA. # # +import logging import warnings +from datetime import timedelta from typing import Final, Optional from django.conf import settings @@ -29,15 +31,10 @@ from django.core.files.base import ContentFile from django.core.management.base import BaseCommand from django.utils import timezone -from datetime import timedelta - -import logging - from club.models import Club, Membership -from core.models import User, Group, Page, SithFile +from core.models import Group, Page, SithFile, User +from sas.models import Album, PeoplePictureRelation, Picture from subscription.models import Subscription -from sas.models import Album, Picture, PeoplePictureRelation - RED_PIXEL_PNG: Final[bytes] = ( b"\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" diff --git a/galaxy/management/commands/rule_galaxy.py b/galaxy/management/commands/rule_galaxy.py index 55cb9ae9..1743fadc 100644 --- a/galaxy/management/commands/rule_galaxy.py +++ b/galaxy/management/commands/rule_galaxy.py @@ -21,6 +21,7 @@ # Place - Suite 330, Boston, MA 02111-1307, USA. # # +import logging import warnings from django.core.management.base import BaseCommand @@ -28,8 +29,6 @@ from django.db import connection from galaxy.models import Galaxy -import logging - class Command(BaseCommand): help = ( diff --git a/galaxy/migrations/0001_initial.py b/galaxy/migrations/0001_initial.py index ab9a6a06..7c8e8521 100644 --- a/galaxy/migrations/0001_initial.py +++ b/galaxy/migrations/0001_initial.py @@ -1,8 +1,8 @@ # Generated by Django 3.2.16 on 2023-03-02 10:07 +import django.db.models.deletion from django.conf import settings from django.db import migrations, models -import django.db.models.deletion class Migration(migrations.Migration): diff --git a/galaxy/migrations/0002_auto_20230412_1130.py b/galaxy/migrations/0002_auto_20230412_1130.py index be01af99..00a69d00 100644 --- a/galaxy/migrations/0002_auto_20230412_1130.py +++ b/galaxy/migrations/0002_auto_20230412_1130.py @@ -1,8 +1,8 @@ # Generated by Django 3.2.16 on 2023-04-12 09:30 +import django.db.models.deletion from django.conf import settings from django.db import migrations, models -import django.db.models.deletion class Migration(migrations.Migration): diff --git a/galaxy/models.py b/galaxy/models.py index 744cca79..cca7397d 100644 --- a/galaxy/models.py +++ b/galaxy/models.py @@ -24,20 +24,19 @@ from __future__ import annotations -import math import logging +import math import time - -from typing import List, TypedDict, NamedTuple, Union, Optional +from typing import List, NamedTuple, Optional, TypedDict, Union from django.db import models -from django.db.models import Q, Case, F, Value, When, Count +from django.db.models import Case, Count, F, Q, Value, When from django.db.models.functions import Concat from django.utils import timezone from django.utils.translation import gettext_lazy as _ -from core.models import User from club.models import Club +from core.models import User from sas.models import Picture diff --git a/galaxy/tests.py b/galaxy/tests.py index 70314574..2a523af3 100644 --- a/galaxy/tests.py +++ b/galaxy/tests.py @@ -23,7 +23,6 @@ # import json - from pathlib import Path from django.core.management import call_command diff --git a/galaxy/views.py b/galaxy/views.py index 3dda003e..3e0b33da 100644 --- a/galaxy/views.py +++ b/galaxy/views.py @@ -22,18 +22,18 @@ # # -from django.views.generic import DetailView, View -from django.http import JsonResponse, Http404 -from django.db.models import Q, Case, F, When, Value +from django.db.models import Case, F, Q, Value, When from django.db.models.functions import Concat +from django.http import Http404, JsonResponse from django.utils.translation import gettext_lazy as _ +from django.views.generic import DetailView, View +from core.models import User from core.views import ( CanViewMixin, FormerSubscriberMixin, + UserTabsMixin, ) -from core.models import User -from core.views import UserTabsMixin from galaxy.models import Galaxy, GalaxyLane diff --git a/launderette/migrations/0001_initial.py b/launderette/migrations/0001_initial.py index 79f011a7..f1548cd2 100644 --- a/launderette/migrations/0001_initial.py +++ b/launderette/migrations/0001_initial.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/launderette/models.py b/launderette/models.py index 3ca12b2d..c2f344bb 100644 --- a/launderette/models.py +++ b/launderette/models.py @@ -14,14 +14,14 @@ # # -from django.db import models, DataError -from django.utils.translation import gettext_lazy as _ from django.conf import settings +from django.db import DataError, models from django.urls import reverse +from django.utils.translation import gettext_lazy as _ -from counter.models import Counter -from core.models import User from club.models import Club +from core.models import User +from counter.models import Counter # Create your models here. diff --git a/launderette/tests.py b/launderette/tests.py index 46a200c2..d888e761 100644 --- a/launderette/tests.py +++ b/launderette/tests.py @@ -14,6 +14,4 @@ # # -from django.test import TestCase - # Create your tests here. diff --git a/launderette/views.py b/launderette/views.py index 716b41f4..c0b16eed 100644 --- a/launderette/views.py +++ b/launderette/views.py @@ -14,27 +14,26 @@ # # -from datetime import datetime, timedelta from collections import OrderedDict +from datetime import datetime, timedelta + import pytz - -from django.views.generic import ListView, DetailView, TemplateView -from django.views.generic.edit import UpdateView, CreateView, DeleteView, BaseFormView -from django.utils.translation import gettext as _ -from django.utils import dateparse, timezone -from django.urls import reverse_lazy -from django.conf import settings -from django.db import transaction, DataError from django import forms +from django.conf import settings +from django.db import DataError, transaction from django.template import defaultfilters +from django.urls import reverse_lazy +from django.utils import dateparse, timezone +from django.utils.translation import gettext as _ +from django.views.generic import DetailView, ListView, TemplateView +from django.views.generic.edit import BaseFormView, CreateView, DeleteView, UpdateView -from core.models import Page, User from club.models import Club -from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, CanCreateMixin -from launderette.models import Launderette, Token, Machine, Slot -from counter.models import Counter, Customer, Selling +from core.models import Page, User +from core.views import CanCreateMixin, CanEditMixin, CanEditPropMixin, CanViewMixin from counter.forms import GetUserForm - +from counter.models import Counter, Customer, Selling +from launderette.models import Launderette, Machine, Slot, Token # For users diff --git a/matmat/admin.py b/matmat/admin.py index 8c38f3f3..846f6b40 100644 --- a/matmat/admin.py +++ b/matmat/admin.py @@ -1,3 +1 @@ -from django.contrib import admin - # Register your models here. diff --git a/matmat/models.py b/matmat/models.py index 71a83623..6b202199 100644 --- a/matmat/models.py +++ b/matmat/models.py @@ -1,3 +1 @@ -from django.db import models - # Create your models here. diff --git a/matmat/tests.py b/matmat/tests.py index 7ce503c2..a39b155a 100644 --- a/matmat/tests.py +++ b/matmat/tests.py @@ -1,3 +1 @@ -from django.test import TestCase - # Create your tests here. diff --git a/matmat/views.py b/matmat/views.py index 10b2d4f5..eb769c62 100644 --- a/matmat/views.py +++ b/matmat/views.py @@ -24,19 +24,18 @@ from ast import literal_eval from enum import Enum -from django.views.generic import ListView, View -from django.views.generic.edit import FormView -from django.utils.translation import gettext_lazy as _ -from django.views.generic.detail import SingleObjectMixin +from django import forms from django.http.response import HttpResponseRedirect from django.urls import reverse -from django import forms +from django.utils.translation import gettext_lazy as _ +from django.views.generic import ListView, View +from django.views.generic.detail import SingleObjectMixin +from django.views.generic.edit import FormView +from phonenumber_field.widgets import PhoneNumberInternationalFallbackWidget from core.models import User -from core.views import FormerSubscriberMixin +from core.views import FormerSubscriberMixin, search_user from core.views.forms import SelectDate -from core.views import search_user -from phonenumber_field.widgets import PhoneNumberInternationalFallbackWidget # Enum to select search type diff --git a/pedagogy/forms.py b/pedagogy/forms.py index 6a3d29ce..28810e64 100644 --- a/pedagogy/forms.py +++ b/pedagogy/forms.py @@ -24,12 +24,9 @@ from django import forms from django.utils.translation import gettext_lazy as _ -from django.forms.widgets import Widget -from django.templatetags.static import static -from core.views.forms import MarkdownInput from core.models import User - +from core.views.forms import MarkdownInput from pedagogy.models import UV, UVComment, UVCommentReport diff --git a/pedagogy/migrations/0001_initial.py b/pedagogy/migrations/0001_initial.py index e4285277..782e65c4 100644 --- a/pedagogy/migrations/0001_initial.py +++ b/pedagogy/migrations/0001_initial.py @@ -2,10 +2,10 @@ # Generated by Django 1.11.20 on 2019-07-05 14:32 from __future__ import unicode_literals -from django.conf import settings import django.core.validators -from django.db import migrations, models import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/pedagogy/models.py b/pedagogy/models.py index 2278dda6..0de5c230 100644 --- a/pedagogy/models.py +++ b/pedagogy/models.py @@ -22,14 +22,13 @@ # # -from django.db import models -from django.utils.translation import gettext_lazy as _ -from django.utils import timezone -from django.core import validators from django.conf import settings -from django.utils.functional import cached_property +from django.core import validators +from django.db import models from django.urls import reverse - +from django.utils import timezone +from django.utils.functional import cached_property +from django.utils.translation import gettext_lazy as _ from rest_framework import serializers from core.models import User diff --git a/pedagogy/search_indexes.py b/pedagogy/search_indexes.py index 3ea75343..c6bc74af 100644 --- a/pedagogy/search_indexes.py +++ b/pedagogy/search_indexes.py @@ -23,7 +23,6 @@ # from django.db import models - from haystack import indexes, signals from core.search_indexes import BigCharFieldIndex diff --git a/pedagogy/tests.py b/pedagogy/tests.py index baee59bf..c52ee2ae 100644 --- a/pedagogy/tests.py +++ b/pedagogy/tests.py @@ -23,13 +23,12 @@ # from django.conf import settings +from django.core.management import call_command from django.test import TestCase from django.urls import reverse from django.utils.translation import gettext_lazy as _ -from django.core.management import call_command - -from core.models import User, Notification +from core.models import Notification, User from pedagogy.models import UV, UVComment, UVCommentReport diff --git a/pedagogy/views.py b/pedagogy/views.py index 13151c60..89187ca5 100644 --- a/pedagogy/views.py +++ b/pedagogy/views.py @@ -22,38 +22,35 @@ # # +from django.conf import settings +from django.core.exceptions import ObjectDoesNotExist, PermissionDenied +from django.http import HttpResponse +from django.shortcuts import get_object_or_404 +from django.urls import reverse, reverse_lazy +from django.utils import html from django.views.generic import ( CreateView, DeleteView, - UpdateView, - ListView, FormView, + ListView, + UpdateView, View, ) -from django.utils import html -from django.http import HttpResponse -from django.core.exceptions import PermissionDenied, ObjectDoesNotExist -from django.urls import reverse_lazy, reverse -from django.shortcuts import get_object_or_404 -from django.conf import settings - from haystack.query import SearchQuerySet from rest_framework.renderers import JSONRenderer +from core.models import Notification, RealGroup from core.views import ( - DetailFormView, CanCreateMixin, - CanEditMixin, - CanViewMixin, CanEditPropMixin, + CanViewMixin, + DetailFormView, ) -from core.models import RealGroup, Notification - from pedagogy.forms import ( - UVForm, UVCommentForm, - UVCommentReportForm, UVCommentModerationForm, + UVCommentReportForm, + UVForm, ) from pedagogy.models import UV, UVComment, UVCommentReport, UVSerializer diff --git a/pyproject.toml b/pyproject.toml index 0bb1a27f..e9dfe6d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,6 +70,9 @@ optional = true [tool.xapian] version = "1.4.25" +[tool.ruff.lint] +select = ["I", "F401"] + [build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" diff --git a/rootplace/admin.py b/rootplace/admin.py index 362a5c4f..5531f2a2 100644 --- a/rootplace/admin.py +++ b/rootplace/admin.py @@ -14,6 +14,4 @@ # # -from django.contrib import admin - # Register your models here. diff --git a/rootplace/models.py b/rootplace/models.py index 5672eba4..084dfa73 100644 --- a/rootplace/models.py +++ b/rootplace/models.py @@ -14,6 +14,4 @@ # # -from django.db import models - # Create your models here. diff --git a/rootplace/tests.py b/rootplace/tests.py index f1bb174f..80119edf 100644 --- a/rootplace/tests.py +++ b/rootplace/tests.py @@ -15,14 +15,12 @@ # from datetime import date, timedelta -from django.core.management import call_command from django.test import TestCase from django.urls import reverse -from django.utils.timezone import localtime, now from club.models import Club -from core.models import User, RealGroup -from counter.models import Customer, Product, Selling, Counter, Refilling +from core.models import RealGroup, User +from counter.models import Counter, Customer, Product, Refilling, Selling from subscription.models import Subscription diff --git a/rootplace/views.py b/rootplace/views.py index fbb04e79..7a045b73 100644 --- a/rootplace/views.py +++ b/rootplace/views.py @@ -32,7 +32,7 @@ from django.utils.translation import gettext as _ from django.views.generic import ListView from django.views.generic.edit import FormView -from core.models import User, OperationLog, SithFile +from core.models import OperationLog, SithFile, User from core.views import CanEditPropMixin from counter.models import Customer from forum.models import ForumMessageMeta diff --git a/sas/admin.py b/sas/admin.py index d1001ef8..3f6c6f42 100644 --- a/sas/admin.py +++ b/sas/admin.py @@ -18,7 +18,6 @@ from django.contrib import admin from sas.models import * - admin.site.register(Album) # admin.site.register(Picture) admin.site.register(PeoplePictureRelation) diff --git a/sas/migrations/0001_initial.py b/sas/migrations/0001_initial.py index 41ed4dc9..7ef55737 100644 --- a/sas/migrations/0001_initial.py +++ b/sas/migrations/0001_initial.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models +from django.db import migrations class Migration(migrations.Migration): diff --git a/sas/migrations/0002_auto_20161119_1241.py b/sas/migrations/0002_auto_20161119_1241.py index 21f44323..15ba12ad 100644 --- a/sas/migrations/0002_auto_20161119_1241.py +++ b/sas/migrations/0002_auto_20161119_1241.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models -from django.conf import settings import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/sas/models.py b/sas/models.py index e9fe4f97..3342facf 100644 --- a/sas/models.py +++ b/sas/models.py @@ -14,19 +14,19 @@ # # +import os +from io import BytesIO + +from django.conf import settings +from django.core.cache import cache from django.db import models from django.urls import reverse -from django.core.cache import cache -from django.conf import settings -from django.utils.translation import gettext_lazy as _ from django.utils import timezone - +from django.utils.translation import gettext_lazy as _ from PIL import Image -from io import BytesIO -import os from core.models import SithFile, User -from core.utils import resize_image, exif_auto_rotate +from core.utils import exif_auto_rotate, resize_image class SASPictureManager(models.Manager): diff --git a/sas/tests.py b/sas/tests.py index 46a200c2..d888e761 100644 --- a/sas/tests.py +++ b/sas/tests.py @@ -14,6 +14,4 @@ # # -from django.test import TestCase - # Create your tests here. diff --git a/sas/views.py b/sas/views.py index 052f7a4e..c2821bac 100644 --- a/sas/views.py +++ b/sas/views.py @@ -14,26 +14,24 @@ # # -from django.shortcuts import redirect -from django.http import HttpResponse, Http404 -from django.urls import reverse_lazy, reverse -from core.views.forms import SelectDate -from django.views.generic import DetailView, TemplateView -from django.views.generic.edit import UpdateView, FormMixin, FormView -from django.utils.translation import gettext_lazy as _ -from django.conf import settings -from django import forms -from django.core.exceptions import PermissionDenied -from django.core.paginator import Paginator, InvalidPage - from ajax_select import make_ajax_field from ajax_select.fields import AutoCompleteSelectMultipleField +from django import forms +from django.conf import settings +from django.core.exceptions import PermissionDenied +from django.core.paginator import InvalidPage, Paginator +from django.http import Http404, HttpResponse +from django.shortcuts import redirect +from django.urls import reverse, reverse_lazy +from django.utils.translation import gettext_lazy as _ +from django.views.generic import DetailView, TemplateView +from django.views.generic.edit import FormMixin, FormView, UpdateView -from core.views import CanViewMixin, CanEditMixin -from core.views.files import send_file, FileView, MultipleImageField -from core.models import SithFile, User, Notification, RealGroup - -from sas.models import Picture, Album, PeoplePictureRelation +from core.models import Notification, SithFile, User +from core.views import CanEditMixin, CanViewMixin +from core.views.files import FileView, MultipleImageField, send_file +from core.views.forms import SelectDate +from sas.models import Album, PeoplePictureRelation, Picture class SASForm(forms.Form): diff --git a/sith/urls.py b/sith/urls.py index 08e25b3e..106c2851 100644 --- a/sith/urls.py +++ b/sith/urls.py @@ -30,14 +30,12 @@ Including another URLconf 2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) """ -from django.urls import include, path -from django.contrib import admin +from ajax_select import urls as ajax_select_urls from django.conf import settings from django.conf.urls.static import static +from django.contrib import admin +from django.urls import include, path from django.views.i18n import JavaScriptCatalog -from ajax_select import urls as ajax_select_urls - -import core.urls js_info_dict = {"packages": ("sith",)} diff --git a/stock/admin.py b/stock/admin.py index 46567a3b..28985c8c 100644 --- a/stock/admin.py +++ b/stock/admin.py @@ -25,7 +25,7 @@ from django.contrib import admin -from stock.models import Stock, StockItem, ShoppingList, ShoppingListItem +from stock.models import ShoppingList, ShoppingListItem, Stock, StockItem # Register your models here. admin.site.register(Stock) diff --git a/stock/migrations/0001_initial.py b/stock/migrations/0001_initial.py index 43b658ff..e203981a 100644 --- a/stock/migrations/0001_initial.py +++ b/stock/migrations/0001_initial.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/stock/models.py b/stock/models.py index 6c9c1ae7..f93a1544 100644 --- a/stock/models.py +++ b/stock/models.py @@ -23,11 +23,10 @@ # # -from django.db import models -from django.utils.translation import gettext_lazy as _ -from django.urls import reverse from django.conf import settings - +from django.db import models +from django.urls import reverse +from django.utils.translation import gettext_lazy as _ from counter.models import Counter, ProductType diff --git a/stock/tests.py b/stock/tests.py index ad602a5c..884e1b09 100644 --- a/stock/tests.py +++ b/stock/tests.py @@ -23,6 +23,4 @@ # # -from django.test import TestCase - # Create your tests here. diff --git a/stock/views.py b/stock/views.py index 6b4776aa..72a9ab56 100644 --- a/stock/views.py +++ b/stock/views.py @@ -24,36 +24,21 @@ # from collections import OrderedDict -from datetime import datetime, timedelta -from django.utils import timezone -from django.shortcuts import render, get_object_or_404 -from django.views.generic import ListView, DetailView, RedirectView, TemplateView -from django.views.generic.edit import ( - UpdateView, - CreateView, - DeleteView, - ProcessFormView, - FormMixin, - BaseFormView, -) -from django.utils.translation import gettext_lazy as _ from django import forms -from django.http import HttpResponseRedirect, HttpResponse +from django.db import transaction from django.forms.models import modelform_factory -from django.urls import reverse_lazy, reverse -from django.db import transaction, DataError +from django.http import HttpResponseRedirect +from django.urls import reverse, reverse_lazy +from django.utils import timezone +from django.utils.translation import gettext_lazy as _ +from django.views.generic import DetailView, ListView +from django.views.generic.edit import BaseFormView, CreateView, DeleteView, UpdateView -from core.views import ( - CanViewMixin, - CanEditMixin, - CanEditPropMixin, - CanCreateMixin, - TabedViewMixin, -) +from core.views import CanCreateMixin, CanEditMixin, CanEditPropMixin, CanViewMixin +from counter.models import ProductType from counter.views import CounterAdminTabsMixin, CounterTabsMixin -from counter.models import Counter, ProductType -from stock.models import Stock, StockItem, ShoppingList, ShoppingListItem +from stock.models import ShoppingList, ShoppingListItem, Stock, StockItem class StockItemList(CounterAdminTabsMixin, CanCreateMixin, ListView): diff --git a/subscription/migrations/0001_initial.py b/subscription/migrations/0001_initial.py index 3ca942f0..932fafaf 100644 --- a/subscription/migrations/0001_initial.py +++ b/subscription/migrations/0001_initial.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import django.contrib.auth.models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/subscription/models.py b/subscription/models.py index f1c2b2d5..5e47ab75 100644 --- a/subscription/models.py +++ b/subscription/models.py @@ -14,17 +14,16 @@ # # +import math from datetime import date, timedelta -from django.db import models -from django.utils.translation import gettext_lazy as _ -from django.conf import settings -from django.core.exceptions import ValidationError -from django.urls import reverse -from django.contrib.auth.forms import PasswordResetForm from dateutil.relativedelta import relativedelta - -import math +from django.conf import settings +from django.contrib.auth.forms import PasswordResetForm +from django.core.exceptions import ValidationError +from django.db import models +from django.urls import reverse +from django.utils.translation import gettext_lazy as _ from core.models import User from core.utils import get_start_of_semester diff --git a/subscription/tests.py b/subscription/tests.py index 4e8ec5a1..1b9924e8 100644 --- a/subscription/tests.py +++ b/subscription/tests.py @@ -16,12 +16,11 @@ from datetime import date from unittest import mock -from django.test import TestCase -from subscription.models import Subscription -from core.models import User from django.conf import settings -from datetime import datetime -from django.core.management import call_command +from django.test import TestCase + +from core.models import User +from subscription.models import Subscription class FakeDate(date): diff --git a/subscription/views.py b/subscription/views.py index bd10ac2c..ccffd58f 100644 --- a/subscription/views.py +++ b/subscription/views.py @@ -14,21 +14,19 @@ # # -from django.views.generic.edit import CreateView, FormView -from django.utils.translation import gettext_lazy as _ -from django.core.exceptions import PermissionDenied, ValidationError -from django.urls import reverse_lazy -from django import forms -from django.conf import settings - -from ajax_select.fields import AutoCompleteSelectField import random -from subscription.models import Subscription -from core.views.forms import SelectDateTime +from ajax_select.fields import AutoCompleteSelectField +from django import forms +from django.conf import settings +from django.core.exceptions import PermissionDenied, ValidationError +from django.urls import reverse_lazy +from django.utils.translation import gettext_lazy as _ +from django.views.generic.edit import CreateView, FormView + from core.models import User -from core.views.forms import SelectDate -from core.views.forms import TzAwareDateTimeField +from core.views.forms import SelectDate, TzAwareDateTimeField +from subscription.models import Subscription class SelectionDateForm(forms.Form): diff --git a/trombi/migrations/0001_initial.py b/trombi/migrations/0001_initial.py index 0943bad1..3c609c63 100644 --- a/trombi/migrations/0001_initial.py +++ b/trombi/migrations/0001_initial.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models -from django.conf import settings import datetime + import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/trombi/migrations/0004_trombiclubmembership.py b/trombi/migrations/0004_trombiclubmembership.py index 5bb017b4..eb036839 100644 --- a/trombi/migrations/0004_trombiclubmembership.py +++ b/trombi/migrations/0004_trombiclubmembership.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/trombi/models.py b/trombi/models.py index 18f36526..b5e7d1a8 100644 --- a/trombi/models.py +++ b/trombi/models.py @@ -22,17 +22,17 @@ # # -from django.db import models -from django.utils.translation import gettext_lazy as _ -from django.urls import reverse +from datetime import date + from django.conf import settings from django.core.exceptions import ValidationError +from django.db import models +from django.urls import reverse +from django.utils.translation import gettext_lazy as _ -from datetime import timedelta, date - -from core.models import User -from core.utils import get_start_of_semester, get_semester_code from club.models import Club +from core.models import User +from core.utils import get_semester_code class TrombiManager(models.Manager): diff --git a/trombi/tests.py b/trombi/tests.py index de62cd38..087c75b4 100644 --- a/trombi/tests.py +++ b/trombi/tests.py @@ -22,6 +22,4 @@ # # -from django.test import TestCase - # Create your tests here. diff --git a/trombi/views.py b/trombi/views.py index 98bf5fc2..d2bf3231 100644 --- a/trombi/views.py +++ b/trombi/views.py @@ -23,34 +23,33 @@ # # -from django.http import Http404, HttpResponseRedirect -from django.shortcuts import get_object_or_404, redirect -from django.urls import reverse_lazy, reverse -from django.views.generic import DetailView, RedirectView, TemplateView, View -from django.views.generic.edit import UpdateView, CreateView, DeleteView -from django.utils.translation import gettext_lazy as _ -from django import forms -from django.conf import settings -from django.forms.models import modelform_factory -from django.core.exceptions import PermissionDenied - -from ajax_select.fields import AutoCompleteSelectField - from datetime import date -from trombi.models import Trombi, TrombiUser, TrombiComment, TrombiClubMembership -from core.views.forms import SelectDate +from ajax_select.fields import AutoCompleteSelectField +from django import forms +from django.conf import settings +from django.core.exceptions import PermissionDenied +from django.forms.models import modelform_factory +from django.http import Http404, HttpResponseRedirect +from django.shortcuts import get_object_or_404, redirect +from django.urls import reverse, reverse_lazy +from django.utils.translation import gettext_lazy as _ +from django.views.generic import DetailView, RedirectView, TemplateView, View +from django.views.generic.edit import CreateView, DeleteView, UpdateView + +from club.models import Club +from core.models import User from core.views import ( - CanViewMixin, + CanCreateMixin, CanEditMixin, CanEditPropMixin, - TabedViewMixin, - CanCreateMixin, + CanViewMixin, QuickNotifMixin, + TabedViewMixin, UserIsLoggedMixin, ) -from core.models import User -from club.models import Club +from core.views.forms import SelectDate +from trombi.models import Trombi, TrombiClubMembership, TrombiComment, TrombiUser class TrombiTabsMixin(TabedViewMixin):