From 3808c5791fc6b95c7daf8a3d701fde7455a43f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D1=8C=D0=B3=D0=B0=20=D0=96=D0=BE=D0=BB=D1=83?= =?UTF-8?q?=D0=B4=D0=B5=D0=B2=D0=B0?= Date: Thu, 31 Aug 2023 10:01:42 +0300 Subject: [PATCH 01/11] =?UTF-8?q?=D0=92=D0=BD=D0=B5=D1=81=D0=BB=D0=B0=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D1=81=D0=BE=D0=B3=D0=BB?= =?UTF-8?q?=D0=B0=D1=81=D0=BD=D0=BE=20=D0=A2=D0=97.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- poetry.lock | 46 ++++++++++++++++++++++--------------- requirements/develop.txt | 8 +++---- requirements/production.txt | 2 +- src/bot/admin.py | 4 ++-- src/bot/models.py | 9 ++++---- 5 files changed, 39 insertions(+), 30 deletions(-) diff --git a/poetry.lock b/poetry.lock index 28e474cb..2a71e9d4 100644 --- a/poetry.lock +++ b/poetry.lock @@ -408,13 +408,13 @@ doc = ["Sphinx", "sphinx-rtd-theme", "sphinxcontrib-spelling"] [[package]] name = "faker" -version = "19.3.0" +version = "19.3.1" description = "Faker is a Python package that generates fake data for you." optional = false python-versions = ">=3.8" files = [ - {file = "Faker-19.3.0-py3-none-any.whl", hash = "sha256:bee54278d6e1289573317604ab6f4782acca724396bf261eaf1890de228e553d"}, - {file = "Faker-19.3.0.tar.gz", hash = "sha256:7d6ed00de3eef9bd57504500c67ee034cab959e4248f9c24aca33e08af82ca93"}, + {file = "Faker-19.3.1-py3-none-any.whl", hash = "sha256:e2722fdf622cf24e974aaba15a3dee97a6f8b98d869bd827ff1af9c87695af46"}, + {file = "Faker-19.3.1.tar.gz", hash = "sha256:a6624d9574623bb27dfca33fff94581cd7b23b562901db8ad59acbde9a52543e"}, ] [package.dependencies] @@ -422,18 +422,18 @@ python-dateutil = ">=2.4" [[package]] name = "filelock" -version = "3.12.2" +version = "3.12.3" description = "A platform independent file lock." optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "filelock-3.12.2-py3-none-any.whl", hash = "sha256:cbb791cdea2a72f23da6ac5b5269ab0a0d161e9ef0100e653b69049a7706d1ec"}, - {file = "filelock-3.12.2.tar.gz", hash = "sha256:002740518d8aa59a26b0c76e10fb8c6e15eae825d34b6fdf670333fd7b938d81"}, + {file = "filelock-3.12.3-py3-none-any.whl", hash = "sha256:f067e40ccc40f2b48395a80fcbd4728262fab54e232e090a4063ab804179efeb"}, + {file = "filelock-3.12.3.tar.gz", hash = "sha256:0ecc1dd2ec4672a10c8550a8182f1bd0c0a5088470ecd5a125e45f49472fac3d"}, ] [package.extras] -docs = ["furo (>=2023.5.20)", "sphinx (>=7.0.1)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)"] -testing = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "diff-cover (>=7.5)", "pytest (>=7.3.1)", "pytest-cov (>=4.1)", "pytest-mock (>=3.10)", "pytest-timeout (>=2.1)"] +docs = ["furo (>=2023.7.26)", "sphinx (>=7.1.2)", "sphinx-autodoc-typehints (>=1.24)"] +testing = ["covdefaults (>=2.3)", "coverage (>=7.3)", "diff-cover (>=7.7)", "pytest (>=7.4)", "pytest-cov (>=4.1)", "pytest-mock (>=3.11.1)", "pytest-timeout (>=2.1)"] [[package]] name = "flake8" @@ -649,13 +649,13 @@ test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4)", "pytest-co [[package]] name = "pluggy" -version = "1.2.0" +version = "1.3.0" description = "plugin and hook calling mechanisms for python" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "pluggy-1.2.0-py3-none-any.whl", hash = "sha256:c2fd55a7d7a3863cba1a013e4e2414658b1d07b6bc57b3919e0c63c9abb99849"}, - {file = "pluggy-1.2.0.tar.gz", hash = "sha256:d12f0c4b579b15f5e054301bb226ee85eeeba08ffec228092f8defbaa3a4c4b3"}, + {file = "pluggy-1.3.0-py3-none-any.whl", hash = "sha256:d89c696a773f8bd377d18e5ecda92b7a3793cbe66c87060a6fb58c7b6e1061f7"}, + {file = "pluggy-1.3.0.tar.gz", hash = "sha256:cf61ae8f126ac6f7c451172cf30e3e43d3ca77615509771b3a984a0730651e12"}, ] [package.extras] @@ -977,6 +977,7 @@ files = [ {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, + {file = "PyYAML-6.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290"}, {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, @@ -984,8 +985,15 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, + {file = "PyYAML-6.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b"}, {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, + {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, + {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, + {file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"}, {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, @@ -1002,6 +1010,7 @@ files = [ {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, + {file = "PyYAML-6.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6"}, {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, @@ -1009,6 +1018,7 @@ files = [ {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, + {file = "PyYAML-6.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5"}, {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, @@ -1275,13 +1285,13 @@ standard = ["colorama (>=0.4)", "httptools (>=0.5.0)", "python-dotenv (>=0.13)", [[package]] name = "virtualenv" -version = "20.24.3" +version = "20.24.4" description = "Virtual Python Environment builder" optional = false python-versions = ">=3.7" files = [ - {file = "virtualenv-20.24.3-py3-none-any.whl", hash = "sha256:95a6e9398b4967fbcb5fef2acec5efaf9aa4972049d9ae41f95e0972a683fd02"}, - {file = "virtualenv-20.24.3.tar.gz", hash = "sha256:e5c3b4ce817b0b328af041506a2a299418c98747c4b1e68cb7527e74ced23efc"}, + {file = "virtualenv-20.24.4-py3-none-any.whl", hash = "sha256:29c70bb9b88510f6414ac3e55c8b413a1f96239b6b789ca123437d5e892190cb"}, + {file = "virtualenv-20.24.4.tar.gz", hash = "sha256:772b05bfda7ed3b8ecd16021ca9716273ad9f4467c801f27e83ac73430246dca"}, ] [package.dependencies] @@ -1290,10 +1300,10 @@ filelock = ">=3.12.2,<4" platformdirs = ">=3.9.1,<4" [package.extras] -docs = ["furo (>=2023.5.20)", "proselint (>=0.13)", "sphinx (>=7.0.1)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] +docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"] [metadata] lock-version = "2.0" python-versions = "^3.11.1" -content-hash = "03a56e6a6d84f459588eb5f27d47be1b795f02df1a398a5c91c707645e14b84a" +content-hash = "4acb280b9d68e1247102aa089d6a829ce185ba2f5206e6e6e04ee71af6092487" diff --git a/requirements/develop.txt b/requirements/develop.txt index 745fafde..99ca13d1 100644 --- a/requirements/develop.txt +++ b/requirements/develop.txt @@ -18,8 +18,8 @@ django==4.2.4 ; python_full_version >= "3.11.1" and python_version < "4.0" dnspython==2.4.2 ; python_full_version >= "3.11.1" and python_version < "4.0" email-validator==2.0.0.post2 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" factory-boy==3.3.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" -faker==19.3.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" -filelock==3.12.2 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" +faker==19.3.1 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" +filelock==3.12.3 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" flake8-docstrings==1.7.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" flake8==6.1.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" h11==0.14.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" @@ -35,7 +35,7 @@ nodeenv==1.8.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0. packaging==23.1 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" pathspec==0.11.2 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" platformdirs==3.10.0 ; python_full_version >= "3.11.1" and python_version < "4.0" -pluggy==1.2.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" +pluggy==1.3.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" pre-commit==3.3.3 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" psycopg2-binary==2.9.7 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" pycodestyle==2.11.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" @@ -66,4 +66,4 @@ tzdata==2023.3 ; python_full_version >= "3.11.1" and python_version < "4.0" and url-normalize==1.4.3 ; python_full_version >= "3.11.1" and python_version < "4.0" urllib3==2.0.4 ; python_full_version >= "3.11.1" and python_version < "4.0" uvicorn==0.23.2 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" -virtualenv==20.24.3 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" +virtualenv==20.24.4 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" diff --git a/requirements/production.txt b/requirements/production.txt index 9be3fe6e..4e522614 100644 --- a/requirements/production.txt +++ b/requirements/production.txt @@ -24,7 +24,7 @@ iniconfig==2.0.0 ; python_full_version >= "3.11.1" and python_full_version < "4. mccabe==0.7.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" packaging==23.1 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" platformdirs==3.10.0 ; python_full_version >= "3.11.1" and python_version < "4.0" -pluggy==1.2.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" +pluggy==1.3.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" psycopg2-binary==2.9.7 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" pycodestyle==2.11.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" pydantic[email]==1.10.12 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" diff --git a/src/bot/admin.py b/src/bot/admin.py index 63ec548f..51a7f168 100644 --- a/src/bot/admin.py +++ b/src/bot/admin.py @@ -41,7 +41,7 @@ def get_question(self, obj): """Display questions in admin panel.""" return obj.question[:100] - @admin.display(description="Короткое описание") + @admin.display(description="Текст на кнопке") def get_short_description(self, obj): """Display short_descriptions in admin panel.""" return obj.short_description[:100] @@ -95,7 +95,7 @@ def get_title(self, obj): """Display title in admin panel.""" return obj.title[:100] - @admin.display(description="Короткое описание") + @admin.display(description="Текст на кнопке") def get_short_description(self, obj): """Display short_description in admin panel.""" return obj.short_description[:100] diff --git a/src/bot/models.py b/src/bot/models.py index 338a2e5b..338cb0ef 100644 --- a/src/bot/models.py +++ b/src/bot/models.py @@ -90,12 +90,11 @@ class Meta: # noqa class HelpTypes(models.TextChoices): """Supporting model to make choices field.""" - LEGAL_ASSISTANCE = "LEGAL_ASSISTANCE", _("Юридическая помощь") - SOCIAL_ASSISTANCE = "SOCIAL_ASSISTANCE", _("Социальная помощь") - PSYCHOLOGICAL_ASSISTANCE = "PSYCHOLOGICAL_ASSISTANCE", _( + LEGAL_ASSISTANCE = "Юридическая помощь", _("Юридическая помощь") + SOCIAL_ASSISTANCE = "Социальная помощь", _("Социальная помощь") + PSYCHOLOGICAL_ASSISTANCE = "Психологическая помощь", _( "Психологическая помощь" ) - COMMON_QUESTION = "COMMON_QUESTION", _("Общий вопрос") class Question(BaseModel): @@ -153,7 +152,7 @@ class FundProgram(BaseModel): ) short_description = models.CharField( max_length=20, - verbose_name="Короткое описание", + verbose_name="Текст на кнопке", help_text="Введите название кнопки в боте для данной программы", ) regions = models.ManyToManyField( From 350dee4057ff593ac2479722966da103ed058285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D1=8C=D0=B3=D0=B0=20=D0=96=D0=BE=D0=BB=D1=83?= =?UTF-8?q?=D0=B4=D0=B5=D0=B2=D0=B0?= Date: Thu, 31 Aug 2023 10:17:17 +0300 Subject: [PATCH 02/11] =?UTF-8?q?=D0=92=D0=BD=D0=B5=D1=81=D0=BB=D0=B0=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D1=81=D0=BE=D0=B3=D0=BB?= =?UTF-8?q?=D0=B0=D1=81=D0=BD=D0=BE=20=D0=A2=D0=97.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bot/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bot/admin.py b/src/bot/admin.py index 51a7f168..bafd6ed1 100644 --- a/src/bot/admin.py +++ b/src/bot/admin.py @@ -95,7 +95,7 @@ def get_title(self, obj): """Display title in admin panel.""" return obj.title[:100] - @admin.display(description="Текст на кнопке") + @admin.display(description="Текст на кнопке ") def get_short_description(self, obj): """Display short_description in admin panel.""" return obj.short_description[:100] From fc7f9732a74d049f73d3a6d99d97a3907fcc7965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D1=8C=D0=B3=D0=B0=20=D0=96=D0=BE=D0=BB=D1=83?= =?UTF-8?q?=D0=B4=D0=B5=D0=B2=D0=B0?= Date: Thu, 31 Aug 2023 10:35:59 +0300 Subject: [PATCH 03/11] =?UTF-8?q?=D0=92=D0=BD=D0=B5=D1=81=D0=BB=D0=B0=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D1=81=D0=BE=D0=B3=D0=BB?= =?UTF-8?q?=D0=B0=D1=81=D0=BD=D0=BE=20=D0=A2=D0=97.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ..._fundprogram_short_description_and_more.py | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/bot/migrations/0005_alter_fundprogram_short_description_and_more.py diff --git a/src/bot/migrations/0005_alter_fundprogram_short_description_and_more.py b/src/bot/migrations/0005_alter_fundprogram_short_description_and_more.py new file mode 100644 index 00000000..29c77032 --- /dev/null +++ b/src/bot/migrations/0005_alter_fundprogram_short_description_and_more.py @@ -0,0 +1,38 @@ +# Generated by Django 4.2.4 on 2023-08-31 07:33 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + """Migrations for bot.""" + + dependencies = [ + ("bot", "0004_alter_coordinator_options_coordinator_is_chief"), + ] + + operations = [ + migrations.AlterField( + model_name="fundprogram", + name="short_description", + field=models.CharField( + help_text="Введите название кнопки в боте для данной программы", + max_length=20, + verbose_name="Текст на кнопке", + ), + ), + migrations.AlterField( + model_name="question", + name="question_type", + field=models.CharField( + choices=[ + ("Юридическая помощь", "Юридическая помощь"), + ("Социальная помощь", "Социальная помощь"), + ("Психологическая помощь", "Психологическая помощь"), + ], + default="Юридическая помощь", + help_text="Выберите тип помощи для вопроса", + max_length=100, + verbose_name="Тип вопроса", + ), + ), + ] From 17928eeafc32c8ba3b2612ebcd8f84df59a1f34d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D1=8C=D0=B3=D0=B0=20=D0=96=D0=BE=D0=BB=D1=83?= =?UTF-8?q?=D0=B4=D0=B5=D0=B2=D0=B0?= Date: Thu, 31 Aug 2023 11:10:20 +0300 Subject: [PATCH 04/11] Fixed a bug --- src/config/settings.py | 1 + src/core/mailing.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/config/settings.py b/src/config/settings.py index 562ee1ad..e2647db1 100644 --- a/src/config/settings.py +++ b/src/config/settings.py @@ -113,6 +113,7 @@ EMAIL_BACKEND = env.str( "EMAIL_BACKEND", default="django.core.mail.backends.console.EmailBackend" ) +EMAIL_TEMPLATE_NAME = "email.html" EMAIL_HOST = env.str("EMAIL_HOST") try: EMAIL_PORT = env.int("EMAIL_PORT") diff --git a/src/core/mailing.py b/src/core/mailing.py index 60715739..31110fe9 100644 --- a/src/core/mailing.py +++ b/src/core/mailing.py @@ -2,10 +2,10 @@ from typing import Sequence from asgiref.sync import sync_to_async -from django.conf import settings from django.core.mail import EmailMultiAlternatives from django.template.loader import get_template +from config import settings from core.validators import MailValidator logger = logging.getLogger("core") From 56afc22df7f962d02ac990b19f8577aa85af7ad1 Mon Sep 17 00:00:00 2001 From: Konstantin Raikhert <69113745+KonstantinRaikhert@users.noreply.github.com> Date: Thu, 31 Aug 2023 21:11:42 +0300 Subject: [PATCH 05/11] =?UTF-8?q?Revert=20"=D0=92=D0=BD=D0=B5=D1=81=D0=BB?= =?UTF-8?q?=D0=B0=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D1=81=D0=BE?= =?UTF-8?q?=D0=B3=D0=BB=D0=B0=D1=81=D0=BD=D0=BE=20=D0=A2=D0=97."=20(#251)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- poetry.lock | 46 ++++++++----------- requirements/develop.txt | 8 ++-- requirements/production.txt | 2 +- src/bot/admin.py | 4 +- ..._fundprogram_short_description_and_more.py | 38 --------------- src/bot/models.py | 9 ++-- 6 files changed, 30 insertions(+), 77 deletions(-) delete mode 100644 src/bot/migrations/0005_alter_fundprogram_short_description_and_more.py diff --git a/poetry.lock b/poetry.lock index 2a71e9d4..28e474cb 100644 --- a/poetry.lock +++ b/poetry.lock @@ -408,13 +408,13 @@ doc = ["Sphinx", "sphinx-rtd-theme", "sphinxcontrib-spelling"] [[package]] name = "faker" -version = "19.3.1" +version = "19.3.0" description = "Faker is a Python package that generates fake data for you." optional = false python-versions = ">=3.8" files = [ - {file = "Faker-19.3.1-py3-none-any.whl", hash = "sha256:e2722fdf622cf24e974aaba15a3dee97a6f8b98d869bd827ff1af9c87695af46"}, - {file = "Faker-19.3.1.tar.gz", hash = "sha256:a6624d9574623bb27dfca33fff94581cd7b23b562901db8ad59acbde9a52543e"}, + {file = "Faker-19.3.0-py3-none-any.whl", hash = "sha256:bee54278d6e1289573317604ab6f4782acca724396bf261eaf1890de228e553d"}, + {file = "Faker-19.3.0.tar.gz", hash = "sha256:7d6ed00de3eef9bd57504500c67ee034cab959e4248f9c24aca33e08af82ca93"}, ] [package.dependencies] @@ -422,18 +422,18 @@ python-dateutil = ">=2.4" [[package]] name = "filelock" -version = "3.12.3" +version = "3.12.2" description = "A platform independent file lock." optional = false -python-versions = ">=3.8" +python-versions = ">=3.7" files = [ - {file = "filelock-3.12.3-py3-none-any.whl", hash = "sha256:f067e40ccc40f2b48395a80fcbd4728262fab54e232e090a4063ab804179efeb"}, - {file = "filelock-3.12.3.tar.gz", hash = "sha256:0ecc1dd2ec4672a10c8550a8182f1bd0c0a5088470ecd5a125e45f49472fac3d"}, + {file = "filelock-3.12.2-py3-none-any.whl", hash = "sha256:cbb791cdea2a72f23da6ac5b5269ab0a0d161e9ef0100e653b69049a7706d1ec"}, + {file = "filelock-3.12.2.tar.gz", hash = "sha256:002740518d8aa59a26b0c76e10fb8c6e15eae825d34b6fdf670333fd7b938d81"}, ] [package.extras] -docs = ["furo (>=2023.7.26)", "sphinx (>=7.1.2)", "sphinx-autodoc-typehints (>=1.24)"] -testing = ["covdefaults (>=2.3)", "coverage (>=7.3)", "diff-cover (>=7.7)", "pytest (>=7.4)", "pytest-cov (>=4.1)", "pytest-mock (>=3.11.1)", "pytest-timeout (>=2.1)"] +docs = ["furo (>=2023.5.20)", "sphinx (>=7.0.1)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)"] +testing = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "diff-cover (>=7.5)", "pytest (>=7.3.1)", "pytest-cov (>=4.1)", "pytest-mock (>=3.10)", "pytest-timeout (>=2.1)"] [[package]] name = "flake8" @@ -649,13 +649,13 @@ test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4)", "pytest-co [[package]] name = "pluggy" -version = "1.3.0" +version = "1.2.0" description = "plugin and hook calling mechanisms for python" optional = false -python-versions = ">=3.8" +python-versions = ">=3.7" files = [ - {file = "pluggy-1.3.0-py3-none-any.whl", hash = "sha256:d89c696a773f8bd377d18e5ecda92b7a3793cbe66c87060a6fb58c7b6e1061f7"}, - {file = "pluggy-1.3.0.tar.gz", hash = "sha256:cf61ae8f126ac6f7c451172cf30e3e43d3ca77615509771b3a984a0730651e12"}, + {file = "pluggy-1.2.0-py3-none-any.whl", hash = "sha256:c2fd55a7d7a3863cba1a013e4e2414658b1d07b6bc57b3919e0c63c9abb99849"}, + {file = "pluggy-1.2.0.tar.gz", hash = "sha256:d12f0c4b579b15f5e054301bb226ee85eeeba08ffec228092f8defbaa3a4c4b3"}, ] [package.extras] @@ -977,7 +977,6 @@ files = [ {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, - {file = "PyYAML-6.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290"}, {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, @@ -985,15 +984,8 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, - {file = "PyYAML-6.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b"}, {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, - {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, - {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, - {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, - {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, - {file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"}, {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, @@ -1010,7 +1002,6 @@ files = [ {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, - {file = "PyYAML-6.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6"}, {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, @@ -1018,7 +1009,6 @@ files = [ {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, - {file = "PyYAML-6.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5"}, {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, @@ -1285,13 +1275,13 @@ standard = ["colorama (>=0.4)", "httptools (>=0.5.0)", "python-dotenv (>=0.13)", [[package]] name = "virtualenv" -version = "20.24.4" +version = "20.24.3" description = "Virtual Python Environment builder" optional = false python-versions = ">=3.7" files = [ - {file = "virtualenv-20.24.4-py3-none-any.whl", hash = "sha256:29c70bb9b88510f6414ac3e55c8b413a1f96239b6b789ca123437d5e892190cb"}, - {file = "virtualenv-20.24.4.tar.gz", hash = "sha256:772b05bfda7ed3b8ecd16021ca9716273ad9f4467c801f27e83ac73430246dca"}, + {file = "virtualenv-20.24.3-py3-none-any.whl", hash = "sha256:95a6e9398b4967fbcb5fef2acec5efaf9aa4972049d9ae41f95e0972a683fd02"}, + {file = "virtualenv-20.24.3.tar.gz", hash = "sha256:e5c3b4ce817b0b328af041506a2a299418c98747c4b1e68cb7527e74ced23efc"}, ] [package.dependencies] @@ -1300,10 +1290,10 @@ filelock = ">=3.12.2,<4" platformdirs = ">=3.9.1,<4" [package.extras] -docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] +docs = ["furo (>=2023.5.20)", "proselint (>=0.13)", "sphinx (>=7.0.1)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"] [metadata] lock-version = "2.0" python-versions = "^3.11.1" -content-hash = "4acb280b9d68e1247102aa089d6a829ce185ba2f5206e6e6e04ee71af6092487" +content-hash = "03a56e6a6d84f459588eb5f27d47be1b795f02df1a398a5c91c707645e14b84a" diff --git a/requirements/develop.txt b/requirements/develop.txt index 99ca13d1..745fafde 100644 --- a/requirements/develop.txt +++ b/requirements/develop.txt @@ -18,8 +18,8 @@ django==4.2.4 ; python_full_version >= "3.11.1" and python_version < "4.0" dnspython==2.4.2 ; python_full_version >= "3.11.1" and python_version < "4.0" email-validator==2.0.0.post2 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" factory-boy==3.3.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" -faker==19.3.1 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" -filelock==3.12.3 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" +faker==19.3.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" +filelock==3.12.2 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" flake8-docstrings==1.7.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" flake8==6.1.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" h11==0.14.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" @@ -35,7 +35,7 @@ nodeenv==1.8.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0. packaging==23.1 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" pathspec==0.11.2 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" platformdirs==3.10.0 ; python_full_version >= "3.11.1" and python_version < "4.0" -pluggy==1.3.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" +pluggy==1.2.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" pre-commit==3.3.3 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" psycopg2-binary==2.9.7 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" pycodestyle==2.11.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" @@ -66,4 +66,4 @@ tzdata==2023.3 ; python_full_version >= "3.11.1" and python_version < "4.0" and url-normalize==1.4.3 ; python_full_version >= "3.11.1" and python_version < "4.0" urllib3==2.0.4 ; python_full_version >= "3.11.1" and python_version < "4.0" uvicorn==0.23.2 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" -virtualenv==20.24.4 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" +virtualenv==20.24.3 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" diff --git a/requirements/production.txt b/requirements/production.txt index 4e522614..9be3fe6e 100644 --- a/requirements/production.txt +++ b/requirements/production.txt @@ -24,7 +24,7 @@ iniconfig==2.0.0 ; python_full_version >= "3.11.1" and python_full_version < "4. mccabe==0.7.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" packaging==23.1 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" platformdirs==3.10.0 ; python_full_version >= "3.11.1" and python_version < "4.0" -pluggy==1.3.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" +pluggy==1.2.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" psycopg2-binary==2.9.7 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" pycodestyle==2.11.0 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" pydantic[email]==1.10.12 ; python_full_version >= "3.11.1" and python_full_version < "4.0.0" diff --git a/src/bot/admin.py b/src/bot/admin.py index bafd6ed1..63ec548f 100644 --- a/src/bot/admin.py +++ b/src/bot/admin.py @@ -41,7 +41,7 @@ def get_question(self, obj): """Display questions in admin panel.""" return obj.question[:100] - @admin.display(description="Текст на кнопке") + @admin.display(description="Короткое описание") def get_short_description(self, obj): """Display short_descriptions in admin panel.""" return obj.short_description[:100] @@ -95,7 +95,7 @@ def get_title(self, obj): """Display title in admin panel.""" return obj.title[:100] - @admin.display(description="Текст на кнопке ") + @admin.display(description="Короткое описание") def get_short_description(self, obj): """Display short_description in admin panel.""" return obj.short_description[:100] diff --git a/src/bot/migrations/0005_alter_fundprogram_short_description_and_more.py b/src/bot/migrations/0005_alter_fundprogram_short_description_and_more.py deleted file mode 100644 index 29c77032..00000000 --- a/src/bot/migrations/0005_alter_fundprogram_short_description_and_more.py +++ /dev/null @@ -1,38 +0,0 @@ -# Generated by Django 4.2.4 on 2023-08-31 07:33 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - """Migrations for bot.""" - - dependencies = [ - ("bot", "0004_alter_coordinator_options_coordinator_is_chief"), - ] - - operations = [ - migrations.AlterField( - model_name="fundprogram", - name="short_description", - field=models.CharField( - help_text="Введите название кнопки в боте для данной программы", - max_length=20, - verbose_name="Текст на кнопке", - ), - ), - migrations.AlterField( - model_name="question", - name="question_type", - field=models.CharField( - choices=[ - ("Юридическая помощь", "Юридическая помощь"), - ("Социальная помощь", "Социальная помощь"), - ("Психологическая помощь", "Психологическая помощь"), - ], - default="Юридическая помощь", - help_text="Выберите тип помощи для вопроса", - max_length=100, - verbose_name="Тип вопроса", - ), - ), - ] diff --git a/src/bot/models.py b/src/bot/models.py index 338cb0ef..338a2e5b 100644 --- a/src/bot/models.py +++ b/src/bot/models.py @@ -90,11 +90,12 @@ class Meta: # noqa class HelpTypes(models.TextChoices): """Supporting model to make choices field.""" - LEGAL_ASSISTANCE = "Юридическая помощь", _("Юридическая помощь") - SOCIAL_ASSISTANCE = "Социальная помощь", _("Социальная помощь") - PSYCHOLOGICAL_ASSISTANCE = "Психологическая помощь", _( + LEGAL_ASSISTANCE = "LEGAL_ASSISTANCE", _("Юридическая помощь") + SOCIAL_ASSISTANCE = "SOCIAL_ASSISTANCE", _("Социальная помощь") + PSYCHOLOGICAL_ASSISTANCE = "PSYCHOLOGICAL_ASSISTANCE", _( "Психологическая помощь" ) + COMMON_QUESTION = "COMMON_QUESTION", _("Общий вопрос") class Question(BaseModel): @@ -152,7 +153,7 @@ class FundProgram(BaseModel): ) short_description = models.CharField( max_length=20, - verbose_name="Текст на кнопке", + verbose_name="Короткое описание", help_text="Введите название кнопки в боте для данной программы", ) regions = models.ManyToManyField( From df7b67f7b3ab6ffca2856132dfbd3ddd5e1adb57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D1=82=D0=BE=D0=BD=20=D0=A2=D0=B5=D1=80=D1=8F?= =?UTF-8?q?=D0=B5=D0=B2?= <110157871+teryaev-anton@users.noreply.github.com> Date: Fri, 1 Sep 2023 02:31:08 +0500 Subject: [PATCH 06/11] remove user_region and user_role from models and admin (#249) * remove user_region and user_role from models and admin * some changes and refactor * admin botsettings refactor --------- Co-authored-by: Konstantin Raikhert --- infra/init.sh | 4 -- src/bot/constants/messages.py | 12 ----- src/bot/forms.py | 2 + ...lter_coordinator_email_address_and_more.py | 50 +++++++++++++++++ src/bot/models.py | 22 ++++++-- src/bot/services.py | 0 src/bot_settings/admin.py | 4 +- src/bot_settings/models.py | 2 +- .../0002_alter_region_region_name.py | 24 +++++++++ src/core/models.py | 7 ++- src/core/views.py | 0 src/users/admin.py | 53 ++++++++++++++----- ...002_remove_user_region_remove_user_role.py | 22 ++++++++ src/users/models.py | 13 ----- 14 files changed, 164 insertions(+), 51 deletions(-) delete mode 100755 infra/init.sh create mode 100644 src/bot/migrations/0005_alter_coordinator_email_address_and_more.py delete mode 100644 src/bot/services.py create mode 100644 src/core/migrations/0002_alter_region_region_name.py delete mode 100644 src/core/views.py create mode 100644 src/users/migrations/0002_remove_user_region_remove_user_role.py diff --git a/infra/init.sh b/infra/init.sh deleted file mode 100755 index eb1c3e98..00000000 --- a/infra/init.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -docker exec -it spread-wings-bot python manage.py migrate -docker exec -it spread-wings-bot python manage.py collectstatic --noinput -docker exec -it spread-wings-bot python manage.py createsuperuser --email example@yandex.ru --noinput diff --git a/src/bot/constants/messages.py b/src/bot/constants/messages.py index e98cb0eb..ed48c7c4 100644 --- a/src/bot/constants/messages.py +++ b/src/bot/constants/messages.py @@ -1,18 +1,6 @@ -START_MESSAGE = 'Здравствуйте! Это бот фонда "Расправь крылья".' -HELP_MESSAGE = ( - "[Заглушка]Здесь выводится краткое описание возможностей бота (/help)" -) -ASSISTANCE_MESSAGE = ( - '[Заглушка]Сообщение после нажатия на кнопку "Получить помощь" ' - "(Выбор региона)" -) -CHOOSE_REGION_MESSAGE = "Выберите, пожалуйста, регион" ASSISTANCE_TYPE_MESSAGE = ( "[Заглушка]Сообщение в момент выбора юр., соц., психол., помощи и т.д." ) -HOW_CAN_WE_HELP = "Чем мы можем помочь?" -MENU_MESSAGE = "Команды и меню обновлены" -CONTACT_US_MESSAGE = "[Заглушка] Задать вопрос." SELECT_FUND_PROGRAM = "Выбор программы из списка" SELECT_QUESTION = "Выбор вопроса из списка" diff --git a/src/bot/forms.py b/src/bot/forms.py index 884a2465..d575b296 100644 --- a/src/bot/forms.py +++ b/src/bot/forms.py @@ -11,6 +11,7 @@ class Meta: model = Question widgets = { + "question": forms.Textarea(attrs={"rows": 3, "cols": 50}), "answer": forms.Textarea(attrs={"rows": 10, "cols": 80}), "regions": forms.CheckboxSelectMultiple, } @@ -25,6 +26,7 @@ class Meta: models = FundProgram widgets = { + "title": forms.Textarea(attrs={"rows": 3, "cols": 50}), "regions": forms.CheckboxSelectMultiple, } fields = "__all__" diff --git a/src/bot/migrations/0005_alter_coordinator_email_address_and_more.py b/src/bot/migrations/0005_alter_coordinator_email_address_and_more.py new file mode 100644 index 00000000..5fb326ef --- /dev/null +++ b/src/bot/migrations/0005_alter_coordinator_email_address_and_more.py @@ -0,0 +1,50 @@ +# Generated by Django 4.2.4 on 2023-08-31 21:06 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + """Migrations for bot.""" + + dependencies = [ + ("core", "0002_alter_region_region_name"), + ("bot", "0004_alter_coordinator_options_coordinator_is_chief"), + ] + + operations = [ + migrations.AlterField( + model_name="coordinator", + name="email_address", + field=models.EmailField( + help_text="Введите адрес электронной почты", + max_length=254, + unique=True, + verbose_name="Email", + ), + ), + migrations.AlterField( + model_name="coordinator", + name="region", + field=models.OneToOneField( + help_text="Выберите регион из списка", + on_delete=django.db.models.deletion.PROTECT, + primary_key=True, + related_name="coordinators", + serialize=False, + to="core.region", + verbose_name="Регион", + ), + ), + migrations.AlterField( + model_name="fundprogram", + name="regions", + field=models.ManyToManyField( + blank=True, + help_text="Выберите регион(ы) для программы", + related_name="programs", + to="core.region", + verbose_name="Регионы", + ), + ), + ] diff --git a/src/bot/models.py b/src/bot/models.py index 338a2e5b..3210f8da 100644 --- a/src/bot/models.py +++ b/src/bot/models.py @@ -31,8 +31,13 @@ class Coordinator(BaseModel): primary_key=True, related_name="coordinators", verbose_name="Регион", + help_text="Выберите регион из списка", + ) + email_address = models.EmailField( + unique=True, + verbose_name="Email", + help_text="Введите адрес электронной почты", ) - email_address = models.EmailField(unique=True, verbose_name="Email") phone_number = models.CharField( max_length=20, unique=True, @@ -78,7 +83,7 @@ def __repr__(self): def __str__(self): return f"{self.first_name} {self.last_name}" - class Meta: # noqa + class Meta: verbose_name = "Координатор" verbose_name_plural = "Координаторы" ordering = ( @@ -131,7 +136,10 @@ class Question(BaseModel): help_text="Выберите тип помощи для вопроса", ) - class Meta: # noqa + def __str__(self): + return self.short_description + + class Meta: verbose_name = "Вопрос" verbose_name_plural = "Вопросы" ordering = ("question",) @@ -161,9 +169,13 @@ class FundProgram(BaseModel): related_name="programs", blank=True, verbose_name="Регионы", + help_text="Выберите регион(ы) для программы", ) - class Meta: # noqa + def __str__(self): + return self.short_description + + class Meta: verbose_name = "Программа фонда" verbose_name_plural = "Программы фонда" ordering = ("title",) @@ -172,7 +184,7 @@ class Meta: # noqa class ProxyRegion(Region): """ProxyRegion model.""" - class Meta: # noqa + class Meta: proxy = True verbose_name_plural = "Регионы" verbose_name = "Регион" diff --git a/src/bot/services.py b/src/bot/services.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/bot_settings/admin.py b/src/bot_settings/admin.py index f8a7c662..83b20cb8 100644 --- a/src/bot_settings/admin.py +++ b/src/bot_settings/admin.py @@ -8,10 +8,10 @@ class BotSettingsAdmin(admin.ModelAdmin): """Base admin configuration for BotSettings model.""" list_display = ("get_title", "type", "get_value") - list_filter = ("title", "type", "value") + list_filter = ("type",) search_fields = ("title", "type", "value") readonly_fields = ("type",) - exclude = ("key",) + exclude = ("key", "title") def has_delete_permission(self, request, obj=None): """Disable delete permission for BotSettings model.""" diff --git a/src/bot_settings/models.py b/src/bot_settings/models.py index d967cba5..56964fc4 100644 --- a/src/bot_settings/models.py +++ b/src/bot_settings/models.py @@ -41,7 +41,7 @@ def clean(self): URLValidator()(self.value) def __str__(self): - return f"" + return self.title class Meta: """Meta for BotSettings model.""" diff --git a/src/core/migrations/0002_alter_region_region_name.py b/src/core/migrations/0002_alter_region_region_name.py new file mode 100644 index 00000000..415899a3 --- /dev/null +++ b/src/core/migrations/0002_alter_region_region_name.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.4 on 2023-08-31 21:06 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + """Migrations for bot.""" + + dependencies = [ + ("core", "0001_initial"), + ] + + operations = [ + migrations.AlterField( + model_name="region", + name="region_name", + field=models.CharField( + help_text="Это название так же будет отображаться на кнопках бота", + max_length=200, + unique=True, + verbose_name="Название региона", + ), + ), + ] diff --git a/src/core/models.py b/src/core/models.py index ea2561d9..7f7e3721 100644 --- a/src/core/models.py +++ b/src/core/models.py @@ -17,7 +17,12 @@ class Meta: class Region(BaseModel): """Region model.""" - region_name = models.CharField(max_length=200, unique=True) + region_name = models.CharField( + max_length=200, + unique=True, + verbose_name="Название региона", + help_text="Это название так же будет отображаться на кнопках бота", + ) region_key = models.CharField(max_length=200, unique=True) def save( diff --git a/src/core/views.py b/src/core/views.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/users/admin.py b/src/users/admin.py index a61d7462..dff58ce4 100644 --- a/src/users/admin.py +++ b/src/users/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin from django.contrib.auth.admin import UserAdmin as BaseUserAdmin -from django.contrib.auth.models import Group +from django.contrib.auth.models import Group, Permission from django.utils.translation import gettext_lazy as _ from utils.emailing.reset_password import send_password_reset_email @@ -46,22 +46,29 @@ class UserAdmin(BaseUserAdmin): ), ) list_display = ( - "id", - "first_name", - "last_name", + "get_fullname", "email", - "region", - "is_staff", "is_active", - "role", + "is_staff", + "is_superuser", + "last_login", ) - list_editable = ("role",) - search_fields = ( - "first_name", - "last_name", - "email", + search_fields = ("first_name", "last_name", "email") + ordering = ("last_name",) + + list_filter = ("is_active",) + + readonly_fields = ( + "date_joined", + "last_login", ) - ordering = ("region",) + + @admin.display(description="Имя и Фамилия") + def get_fullname(self, obj): + """Display fullname user in admin panel.""" + if not obj.first_name: + return "User" + return f"{obj.first_name} {obj.last_name}" @admin.action(description="Сбросить пароль") def reset_password(self, request, queryset): @@ -72,3 +79,23 @@ def reset_password(self, request, queryset): admin.site.register(User, UserAdmin) admin.site.unregister(Group) + + +def permissions_new_unicode(self): + """Translate default permissions.""" + class_name = str(self.content_type) + permissions_name = str(self.name) + + if "Can delete" in permissions_name: + permissions_name = "разрешено удалять" + elif "Can add" in permissions_name: + permissions_name = "разрешено добавлять" + elif "Can change" in permissions_name: + permissions_name = "разрешено изменять" + elif "Can view" in permissions_name: + permissions_name = "разрешено просматривать" + + return "%s - %s" % (class_name.title(), permissions_name) + + +Permission.__str__ = permissions_new_unicode diff --git a/src/users/migrations/0002_remove_user_region_remove_user_role.py b/src/users/migrations/0002_remove_user_region_remove_user_role.py new file mode 100644 index 00000000..80ec2c10 --- /dev/null +++ b/src/users/migrations/0002_remove_user_region_remove_user_role.py @@ -0,0 +1,22 @@ +# Generated by Django 4.2.4 on 2023-08-31 02:41 + +from django.db import migrations + + +class Migration(migrations.Migration): + """Migrations for users.""" + + dependencies = [ + ("users", "0001_initial"), + ] + + operations = [ + migrations.RemoveField( + model_name="user", + name="region", + ), + migrations.RemoveField( + model_name="user", + name="role", + ), + ] diff --git a/src/users/models.py b/src/users/models.py index 4f001a31..5d7a3fa3 100644 --- a/src/users/models.py +++ b/src/users/models.py @@ -2,8 +2,6 @@ from django.db import models from django.utils.translation import gettext_lazy as _ -from core.models import Region - from .manager import UserManager @@ -26,17 +24,6 @@ class UserRole(models.TextChoices): email = models.EmailField( unique=True, verbose_name="Адрес электронной почты" ) - role = models.CharField( - max_length=12, - choices=UserRole.choices, - verbose_name="Роль пользователя", - ) - region = models.ForeignKey( - Region, - on_delete=models.SET_NULL, - null=True, - verbose_name="Регион пользователя", - ) objects = UserManager() From 7cfae555f35df192a3bb757dfb40693599ab3186 Mon Sep 17 00:00:00 2001 From: Aleksei Koznov Date: Fri, 1 Sep 2023 19:01:49 +0300 Subject: [PATCH 07/11] change question type display in admin (#260) * change question type display in admin * some fix --------- Co-authored-by: Konstantin Raikhert --- src/bot/admin.py | 19 ++-------- src/bot/handlers/assistance.py | 3 +- ..._fundprogram_short_description_and_more.py | 36 +++++++++++++++++++ .../0007_alter_question_short_description.py | 23 ++++++++++++ src/bot/models.py | 5 ++- src/bot_settings/admin.py | 7 +++- 6 files changed, 70 insertions(+), 23 deletions(-) create mode 100644 src/bot/migrations/0006_alter_fundprogram_short_description_and_more.py create mode 100644 src/bot/migrations/0007_alter_question_short_description.py diff --git a/src/bot/admin.py b/src/bot/admin.py index 63ec548f..c0eb4419 100644 --- a/src/bot/admin.py +++ b/src/bot/admin.py @@ -23,8 +23,8 @@ class QuestionAdmin(RegionForAdmin): form = QuestionAdminForm list_display = ( "get_question", - "get_short_description", - "get_question_type", + "short_description", + "question_type", "get_answer", "get_regions", ) @@ -41,16 +41,6 @@ def get_question(self, obj): """Display questions in admin panel.""" return obj.question[:100] - @admin.display(description="Короткое описание") - def get_short_description(self, obj): - """Display short_descriptions in admin panel.""" - return obj.short_description[:100] - - @admin.display(description="Тип вопроса") - def get_question_type(self, obj): - """Display question_type in admin panel.""" - return obj.question_type[:100] - @admin.display(description="Ответ") def get_answer(self, obj): """Display answer in admin panel.""" @@ -95,11 +85,6 @@ def get_title(self, obj): """Display title in admin panel.""" return obj.title[:100] - @admin.display(description="Короткое описание") - def get_short_description(self, obj): - """Display short_description in admin panel.""" - return obj.short_description[:100] - @admin.display(description="Описание программы") def get_fund_text(self, obj): """Display fund_text in admin panel.""" diff --git a/src/bot/handlers/assistance.py b/src/bot/handlers/assistance.py index 54db260e..3ef2ef3f 100644 --- a/src/bot/handlers/assistance.py +++ b/src/bot/handlers/assistance.py @@ -20,7 +20,6 @@ ) from bot.keyboards.assistance_types import assistance_types_keyboard_markup from bot.keyboards.utils.callback_data_parse import parse_callback_data -from bot.models import HelpTypes from bot_settings.models import BotSettings DEFAULT_PAGE = 1 @@ -139,7 +138,7 @@ async def contact_with_us( ) -> States: """Ask question and show contacts.""" query = update.callback_query - context.user_data[States.QUESTION_TYPE] = HelpTypes.COMMON_QUESTION.value + context.user_data[States.QUESTION_TYPE] = "COMMON_QUESTION" await query.answer() await query.edit_message_text( text=CONTACT_SHOW_MESSAGE, diff --git a/src/bot/migrations/0006_alter_fundprogram_short_description_and_more.py b/src/bot/migrations/0006_alter_fundprogram_short_description_and_more.py new file mode 100644 index 00000000..b1518f22 --- /dev/null +++ b/src/bot/migrations/0006_alter_fundprogram_short_description_and_more.py @@ -0,0 +1,36 @@ +# Generated by Django 4.2.4 on 2023-09-01 10:51 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("bot", "0005_alter_coordinator_email_address_and_more"), + ] + + operations = [ + migrations.AlterField( + model_name="fundprogram", + name="short_description", + field=models.CharField( + help_text="Введите название кнопки в боте для данной программы", + max_length=20, + verbose_name="Текст на кнопке", + ), + ), + migrations.AlterField( + model_name="question", + name="question_type", + field=models.CharField( + choices=[ + ("LEGAL_ASSISTANCE", "Юридическая помощь"), + ("SOCIAL_ASSISTANCE", "Социальная помощь"), + ("PSYCHOLOGICAL_ASSISTANCE", "Психологическая помощь"), + ], + default="LEGAL_ASSISTANCE", + help_text="Выберите тип помощи для вопроса", + max_length=100, + verbose_name="Тип вопроса", + ), + ), + ] diff --git a/src/bot/migrations/0007_alter_question_short_description.py b/src/bot/migrations/0007_alter_question_short_description.py new file mode 100644 index 00000000..209e2534 --- /dev/null +++ b/src/bot/migrations/0007_alter_question_short_description.py @@ -0,0 +1,23 @@ +# Generated by Django 4.2.4 on 2023-09-01 15:43 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + """Migrations for bot.""" + + dependencies = [ + ("bot", "0006_alter_fundprogram_short_description_and_more"), + ] + + operations = [ + migrations.AlterField( + model_name="question", + name="short_description", + field=models.CharField( + help_text="Введите название кнопки в боте для данного вопроса", + max_length=20, + verbose_name="Текст на кнопке", + ), + ), + ] diff --git a/src/bot/models.py b/src/bot/models.py index 3210f8da..f87828bd 100644 --- a/src/bot/models.py +++ b/src/bot/models.py @@ -100,7 +100,6 @@ class HelpTypes(models.TextChoices): PSYCHOLOGICAL_ASSISTANCE = "PSYCHOLOGICAL_ASSISTANCE", _( "Психологическая помощь" ) - COMMON_QUESTION = "COMMON_QUESTION", _("Общий вопрос") class Question(BaseModel): @@ -118,7 +117,7 @@ class Question(BaseModel): ) short_description = models.CharField( max_length=20, - verbose_name="Короткое описание", + verbose_name="Текст на кнопке", help_text="Введите название кнопки в боте для данного вопроса", ) regions = models.ManyToManyField( @@ -161,7 +160,7 @@ class FundProgram(BaseModel): ) short_description = models.CharField( max_length=20, - verbose_name="Короткое описание", + verbose_name="Текст на кнопке", help_text="Введите название кнопки в боте для данной программы", ) regions = models.ManyToManyField( diff --git a/src/bot_settings/admin.py b/src/bot_settings/admin.py index 83b20cb8..2809e632 100644 --- a/src/bot_settings/admin.py +++ b/src/bot_settings/admin.py @@ -7,7 +7,7 @@ class BotSettingsAdmin(admin.ModelAdmin): """Base admin configuration for BotSettings model.""" - list_display = ("get_title", "type", "get_value") + list_display = ("get_title", "get_type", "get_value") list_filter = ("type",) search_fields = ("title", "type", "value") readonly_fields = ("type",) @@ -22,6 +22,11 @@ def get_title(self, obj): """Display title of settings in admin panel.""" return obj.title[:100] + @admin.display(description="Тип значения") + def get_type(self, obj): + """Display type of settings in admin panel.""" + return obj.get_type_display()[:100] + @admin.display(description="Значение настройки") def get_value(self, obj): """Display value of settings in admin panel.""" From 97819b21458298927dc0decab757a8c88becf21e Mon Sep 17 00:00:00 2001 From: Vladimir Date: Fri, 1 Sep 2023 19:34:32 +0300 Subject: [PATCH 08/11] fixed: settings, makefile (#250) * fixed: settings, makefile * fixed: settings * moved: ckeditor_add-on directory; fixed: settings.py * added: createsuperuser in Makefile * fixed: settings.py * fix staticdirs * delete double DEBUG env * delete old notations --------- Co-authored-by: Konstantin Raikhert --- .gitignore | 2 +- Makefile | 6 +++++- infra/dev/docker-compose.stage.yaml | 2 +- infra/prod/docker-compose.prod.yaml | 2 +- src/config/settings.py | 12 ++++++------ .../ckeditor}/plugins/autocomplete/plugin.js | 0 .../plugins/autocomplete/skins/default.css | 0 .../ckeditor/ckeditor}/plugins/button/plugin.js | 0 .../ckeditor}/plugins/emoji/assets/iconsall.png | Bin .../ckeditor}/plugins/emoji/assets/iconsall.svg | 0 .../ckeditor/ckeditor}/plugins/emoji/emoji.json | 0 .../ckeditor}/plugins/emoji/icons/emojipanel.png | Bin .../plugins/emoji/icons/hidpi/emojipanel.png | Bin .../ckeditor/ckeditor}/plugins/emoji/lang/cs.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/da.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/de-ch.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/de.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/el.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/en-au.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/en.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/et.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/fa.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/fr.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/gl.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/hr.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/hu.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/it.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/nl.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/pl.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/pt-br.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/sk.js | 0 .../ckeditor}/plugins/emoji/lang/sr-latn.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/sr.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/sv.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/tr.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/uk.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/zh-cn.js | 0 .../ckeditor/ckeditor}/plugins/emoji/lang/zh.js | 0 .../ckeditor/ckeditor}/plugins/emoji/plugin.js | 0 .../ckeditor}/plugins/emoji/samples/emoji.html | 0 .../ckeditor}/plugins/emoji/skins/default.css | 0 .../ckeditor}/plugins/panelbutton/plugin.js | 0 .../ckeditor/ckeditor}/plugins/textmatch/plugin.js | 0 .../ckeditor}/plugins/textwatcher/plugin.js | 0 .../ckeditor/ckeditor}/skins/n1theme/dialog.css | 0 .../ckeditor/ckeditor}/skins/n1theme/dialog_ie.css | 0 .../ckeditor/ckeditor}/skins/n1theme/dialog_ie8.css | 0 .../ckeditor}/skins/n1theme/dialog_iequirks.css | 0 .../ckeditor/ckeditor}/skins/n1theme/editor.css | 0 .../ckeditor}/skins/n1theme/editor_gecko.css | 0 .../ckeditor/ckeditor}/skins/n1theme/editor_ie.css | 0 .../ckeditor/ckeditor}/skins/n1theme/editor_ie8.css | 0 .../ckeditor}/skins/n1theme/editor_iequirks.css | 0 .../ckeditor/ckeditor}/skins/n1theme/icons.png | Bin .../ckeditor}/skins/n1theme/icons_hidpi.png | Bin .../ckeditor}/skins/n1theme/images/arrow.png | Bin .../ckeditor}/skins/n1theme/images/close.png | Bin .../ckeditor}/skins/n1theme/images/hidpi/close.png | Bin .../skins/n1theme/images/hidpi/lock-open.png | Bin .../ckeditor}/skins/n1theme/images/hidpi/lock.png | Bin .../skins/n1theme/images/hidpi/refresh.png | Bin .../ckeditor}/skins/n1theme/images/lock-open.png | Bin .../ckeditor}/skins/n1theme/images/lock.png | Bin .../ckeditor}/skins/n1theme/images/refresh.png | Bin .../ckeditor}/skins/n1theme/images/spinner.gif | Bin .../ckeditor/ckeditor}/skins/n1theme/readme.md | 0 .../static/ckeditor/ckeditor}/skins/n1theme/skin.js | 0 67 files changed, 14 insertions(+), 10 deletions(-) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/autocomplete/plugin.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/autocomplete/skins/default.css (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/button/plugin.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/assets/iconsall.png (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/assets/iconsall.svg (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/emoji.json (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/icons/emojipanel.png (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/icons/hidpi/emojipanel.png (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/cs.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/da.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/de-ch.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/de.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/el.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/en-au.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/en.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/et.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/fa.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/fr.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/gl.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/hr.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/hu.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/it.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/nl.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/pl.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/pt-br.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/sk.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/sr-latn.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/sr.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/sv.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/tr.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/uk.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/zh-cn.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/lang/zh.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/plugin.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/samples/emoji.html (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/emoji/skins/default.css (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/panelbutton/plugin.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/textmatch/plugin.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/plugins/textwatcher/plugin.js (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/dialog.css (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/dialog_ie.css (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/dialog_ie8.css (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/dialog_iequirks.css (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/editor.css (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/editor_gecko.css (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/editor_ie.css (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/editor_ie8.css (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/editor_iequirks.css (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/icons.png (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/icons_hidpi.png (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/images/arrow.png (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/images/close.png (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/images/hidpi/close.png (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/images/hidpi/lock-open.png (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/images/hidpi/lock.png (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/images/hidpi/refresh.png (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/images/lock-open.png (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/images/lock.png (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/images/refresh.png (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/images/spinner.gif (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/readme.md (100%) rename {ckeditor_add-on => src/core/static/ckeditor/ckeditor}/skins/n1theme/skin.js (100%) diff --git a/.gitignore b/.gitignore index 52ceaa86..006002f7 100644 --- a/.gitignore +++ b/.gitignore @@ -60,7 +60,7 @@ coverage.xml local_settings.py db.sqlite3 db.sqlite3-journal -static/ +staticfiles/ media/ logs/ diff --git a/Makefile b/Makefile index e0451651..7d0e8ccc 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ help: # Show help .PHONY: runbot-init -runbot-init: deletedb rundb migrate filldb runbot-db # Build and run Database Docker-image +runbot-init: deletedb rundb migrate filldb collectstatic createsuperuser runbot-db # Build and run Database Docker-image @echo -e "$(COLOR_YELLOW)Starting initialization...$(COLOR_RESET)" @source $$(poetry env info -p)/bin/activate @@ -90,6 +90,10 @@ migrate: # Commit migrations to Database @sleep 3; @echo -e "$(COLOR_GREEN)Migrated$(COLOR_RESET)" +.PHONY: createsuperuser +createsuperuser: + @echo -e "$(COLOR_YELLOW)Creating Django superuser...$(COLOR_RESET)" + @poetry run python src/manage.py createsuperuser .PHONY: run_tests run_tests: run_unit_tests # Run all tests diff --git a/infra/dev/docker-compose.stage.yaml b/infra/dev/docker-compose.stage.yaml index 27b8e37c..8f65f46c 100644 --- a/infra/dev/docker-compose.stage.yaml +++ b/infra/dev/docker-compose.stage.yaml @@ -45,7 +45,7 @@ services: - redis - db volumes: - - ../../static:/app/src/static + - ../../static:/app/src/staticfiles - ../../media:/app/src/media - ./logs/bot/:/app/src/logs restart: always diff --git a/infra/prod/docker-compose.prod.yaml b/infra/prod/docker-compose.prod.yaml index 743a781b..b3e20a05 100644 --- a/infra/prod/docker-compose.prod.yaml +++ b/infra/prod/docker-compose.prod.yaml @@ -45,7 +45,7 @@ services: - redis - db volumes: - - ../../static:/app/src/static + - ../../static:/app/src/staticfiles - ../../media:/app/src/media - ./logs/bot/:/app/src/logs restart: always diff --git a/src/config/settings.py b/src/config/settings.py index e2647db1..8c4ade0c 100644 --- a/src/config/settings.py +++ b/src/config/settings.py @@ -55,7 +55,7 @@ }, ] -WSGI_APPLICATION = "config.wsgi.application" +ASGI_APPLICATION = "config.asgi.application" DATABASES = { @@ -101,13 +101,13 @@ USE_TZ = True STATIC_URL = "/static/" -STATIC_ROOT = BASE_DIR / "static" -STATIC_ROOT.mkdir(exist_ok=True) -STATICFILES_DIRS = [ - ("ckeditor/ckeditor/plugins", "ckeditor_add-on/plugins/"), - ("ckeditor/ckeditor/skins", "ckeditor_add-on/skins/"), +STATIC_ROOT = str(BASE_DIR / "staticfiles") +STATICFILES_FINDERS = [ + "django.contrib.staticfiles.finders.FileSystemFinder", + "django.contrib.staticfiles.finders.AppDirectoriesFinder", ] + DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" EMAIL_BACKEND = env.str( diff --git a/ckeditor_add-on/plugins/autocomplete/plugin.js b/src/core/static/ckeditor/ckeditor/plugins/autocomplete/plugin.js similarity index 100% rename from ckeditor_add-on/plugins/autocomplete/plugin.js rename to src/core/static/ckeditor/ckeditor/plugins/autocomplete/plugin.js diff --git a/ckeditor_add-on/plugins/autocomplete/skins/default.css b/src/core/static/ckeditor/ckeditor/plugins/autocomplete/skins/default.css similarity index 100% rename from ckeditor_add-on/plugins/autocomplete/skins/default.css rename to src/core/static/ckeditor/ckeditor/plugins/autocomplete/skins/default.css diff --git a/ckeditor_add-on/plugins/button/plugin.js b/src/core/static/ckeditor/ckeditor/plugins/button/plugin.js similarity index 100% rename from ckeditor_add-on/plugins/button/plugin.js rename to src/core/static/ckeditor/ckeditor/plugins/button/plugin.js diff --git a/ckeditor_add-on/plugins/emoji/assets/iconsall.png b/src/core/static/ckeditor/ckeditor/plugins/emoji/assets/iconsall.png similarity index 100% rename from ckeditor_add-on/plugins/emoji/assets/iconsall.png rename to src/core/static/ckeditor/ckeditor/plugins/emoji/assets/iconsall.png diff --git a/ckeditor_add-on/plugins/emoji/assets/iconsall.svg b/src/core/static/ckeditor/ckeditor/plugins/emoji/assets/iconsall.svg similarity index 100% rename from ckeditor_add-on/plugins/emoji/assets/iconsall.svg rename to src/core/static/ckeditor/ckeditor/plugins/emoji/assets/iconsall.svg diff --git a/ckeditor_add-on/plugins/emoji/emoji.json b/src/core/static/ckeditor/ckeditor/plugins/emoji/emoji.json similarity index 100% rename from ckeditor_add-on/plugins/emoji/emoji.json rename to src/core/static/ckeditor/ckeditor/plugins/emoji/emoji.json diff --git a/ckeditor_add-on/plugins/emoji/icons/emojipanel.png b/src/core/static/ckeditor/ckeditor/plugins/emoji/icons/emojipanel.png similarity index 100% rename from ckeditor_add-on/plugins/emoji/icons/emojipanel.png rename to src/core/static/ckeditor/ckeditor/plugins/emoji/icons/emojipanel.png diff --git a/ckeditor_add-on/plugins/emoji/icons/hidpi/emojipanel.png b/src/core/static/ckeditor/ckeditor/plugins/emoji/icons/hidpi/emojipanel.png similarity index 100% rename from ckeditor_add-on/plugins/emoji/icons/hidpi/emojipanel.png rename to src/core/static/ckeditor/ckeditor/plugins/emoji/icons/hidpi/emojipanel.png diff --git a/ckeditor_add-on/plugins/emoji/lang/cs.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/cs.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/cs.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/cs.js diff --git a/ckeditor_add-on/plugins/emoji/lang/da.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/da.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/da.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/da.js diff --git a/ckeditor_add-on/plugins/emoji/lang/de-ch.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/de-ch.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/de-ch.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/de-ch.js diff --git a/ckeditor_add-on/plugins/emoji/lang/de.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/de.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/de.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/de.js diff --git a/ckeditor_add-on/plugins/emoji/lang/el.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/el.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/el.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/el.js diff --git a/ckeditor_add-on/plugins/emoji/lang/en-au.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/en-au.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/en-au.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/en-au.js diff --git a/ckeditor_add-on/plugins/emoji/lang/en.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/en.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/en.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/en.js diff --git a/ckeditor_add-on/plugins/emoji/lang/et.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/et.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/et.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/et.js diff --git a/ckeditor_add-on/plugins/emoji/lang/fa.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/fa.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/fa.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/fa.js diff --git a/ckeditor_add-on/plugins/emoji/lang/fr.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/fr.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/fr.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/fr.js diff --git a/ckeditor_add-on/plugins/emoji/lang/gl.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/gl.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/gl.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/gl.js diff --git a/ckeditor_add-on/plugins/emoji/lang/hr.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/hr.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/hr.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/hr.js diff --git a/ckeditor_add-on/plugins/emoji/lang/hu.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/hu.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/hu.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/hu.js diff --git a/ckeditor_add-on/plugins/emoji/lang/it.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/it.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/it.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/it.js diff --git a/ckeditor_add-on/plugins/emoji/lang/nl.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/nl.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/nl.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/nl.js diff --git a/ckeditor_add-on/plugins/emoji/lang/pl.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/pl.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/pl.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/pl.js diff --git a/ckeditor_add-on/plugins/emoji/lang/pt-br.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/pt-br.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/pt-br.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/pt-br.js diff --git a/ckeditor_add-on/plugins/emoji/lang/sk.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/sk.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/sk.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/sk.js diff --git a/ckeditor_add-on/plugins/emoji/lang/sr-latn.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/sr-latn.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/sr-latn.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/sr-latn.js diff --git a/ckeditor_add-on/plugins/emoji/lang/sr.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/sr.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/sr.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/sr.js diff --git a/ckeditor_add-on/plugins/emoji/lang/sv.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/sv.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/sv.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/sv.js diff --git a/ckeditor_add-on/plugins/emoji/lang/tr.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/tr.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/tr.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/tr.js diff --git a/ckeditor_add-on/plugins/emoji/lang/uk.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/uk.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/uk.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/uk.js diff --git a/ckeditor_add-on/plugins/emoji/lang/zh-cn.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/zh-cn.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/zh-cn.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/zh-cn.js diff --git a/ckeditor_add-on/plugins/emoji/lang/zh.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/lang/zh.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/lang/zh.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/lang/zh.js diff --git a/ckeditor_add-on/plugins/emoji/plugin.js b/src/core/static/ckeditor/ckeditor/plugins/emoji/plugin.js similarity index 100% rename from ckeditor_add-on/plugins/emoji/plugin.js rename to src/core/static/ckeditor/ckeditor/plugins/emoji/plugin.js diff --git a/ckeditor_add-on/plugins/emoji/samples/emoji.html b/src/core/static/ckeditor/ckeditor/plugins/emoji/samples/emoji.html similarity index 100% rename from ckeditor_add-on/plugins/emoji/samples/emoji.html rename to src/core/static/ckeditor/ckeditor/plugins/emoji/samples/emoji.html diff --git a/ckeditor_add-on/plugins/emoji/skins/default.css b/src/core/static/ckeditor/ckeditor/plugins/emoji/skins/default.css similarity index 100% rename from ckeditor_add-on/plugins/emoji/skins/default.css rename to src/core/static/ckeditor/ckeditor/plugins/emoji/skins/default.css diff --git a/ckeditor_add-on/plugins/panelbutton/plugin.js b/src/core/static/ckeditor/ckeditor/plugins/panelbutton/plugin.js similarity index 100% rename from ckeditor_add-on/plugins/panelbutton/plugin.js rename to src/core/static/ckeditor/ckeditor/plugins/panelbutton/plugin.js diff --git a/ckeditor_add-on/plugins/textmatch/plugin.js b/src/core/static/ckeditor/ckeditor/plugins/textmatch/plugin.js similarity index 100% rename from ckeditor_add-on/plugins/textmatch/plugin.js rename to src/core/static/ckeditor/ckeditor/plugins/textmatch/plugin.js diff --git a/ckeditor_add-on/plugins/textwatcher/plugin.js b/src/core/static/ckeditor/ckeditor/plugins/textwatcher/plugin.js similarity index 100% rename from ckeditor_add-on/plugins/textwatcher/plugin.js rename to src/core/static/ckeditor/ckeditor/plugins/textwatcher/plugin.js diff --git a/ckeditor_add-on/skins/n1theme/dialog.css b/src/core/static/ckeditor/ckeditor/skins/n1theme/dialog.css similarity index 100% rename from ckeditor_add-on/skins/n1theme/dialog.css rename to src/core/static/ckeditor/ckeditor/skins/n1theme/dialog.css diff --git a/ckeditor_add-on/skins/n1theme/dialog_ie.css b/src/core/static/ckeditor/ckeditor/skins/n1theme/dialog_ie.css similarity index 100% rename from ckeditor_add-on/skins/n1theme/dialog_ie.css rename to src/core/static/ckeditor/ckeditor/skins/n1theme/dialog_ie.css diff --git a/ckeditor_add-on/skins/n1theme/dialog_ie8.css b/src/core/static/ckeditor/ckeditor/skins/n1theme/dialog_ie8.css similarity index 100% rename from ckeditor_add-on/skins/n1theme/dialog_ie8.css rename to src/core/static/ckeditor/ckeditor/skins/n1theme/dialog_ie8.css diff --git a/ckeditor_add-on/skins/n1theme/dialog_iequirks.css b/src/core/static/ckeditor/ckeditor/skins/n1theme/dialog_iequirks.css similarity index 100% rename from ckeditor_add-on/skins/n1theme/dialog_iequirks.css rename to src/core/static/ckeditor/ckeditor/skins/n1theme/dialog_iequirks.css diff --git a/ckeditor_add-on/skins/n1theme/editor.css b/src/core/static/ckeditor/ckeditor/skins/n1theme/editor.css similarity index 100% rename from ckeditor_add-on/skins/n1theme/editor.css rename to src/core/static/ckeditor/ckeditor/skins/n1theme/editor.css diff --git a/ckeditor_add-on/skins/n1theme/editor_gecko.css b/src/core/static/ckeditor/ckeditor/skins/n1theme/editor_gecko.css similarity index 100% rename from ckeditor_add-on/skins/n1theme/editor_gecko.css rename to src/core/static/ckeditor/ckeditor/skins/n1theme/editor_gecko.css diff --git a/ckeditor_add-on/skins/n1theme/editor_ie.css b/src/core/static/ckeditor/ckeditor/skins/n1theme/editor_ie.css similarity index 100% rename from ckeditor_add-on/skins/n1theme/editor_ie.css rename to src/core/static/ckeditor/ckeditor/skins/n1theme/editor_ie.css diff --git a/ckeditor_add-on/skins/n1theme/editor_ie8.css b/src/core/static/ckeditor/ckeditor/skins/n1theme/editor_ie8.css similarity index 100% rename from ckeditor_add-on/skins/n1theme/editor_ie8.css rename to src/core/static/ckeditor/ckeditor/skins/n1theme/editor_ie8.css diff --git a/ckeditor_add-on/skins/n1theme/editor_iequirks.css b/src/core/static/ckeditor/ckeditor/skins/n1theme/editor_iequirks.css similarity index 100% rename from ckeditor_add-on/skins/n1theme/editor_iequirks.css rename to src/core/static/ckeditor/ckeditor/skins/n1theme/editor_iequirks.css diff --git a/ckeditor_add-on/skins/n1theme/icons.png b/src/core/static/ckeditor/ckeditor/skins/n1theme/icons.png similarity index 100% rename from ckeditor_add-on/skins/n1theme/icons.png rename to src/core/static/ckeditor/ckeditor/skins/n1theme/icons.png diff --git a/ckeditor_add-on/skins/n1theme/icons_hidpi.png b/src/core/static/ckeditor/ckeditor/skins/n1theme/icons_hidpi.png similarity index 100% rename from ckeditor_add-on/skins/n1theme/icons_hidpi.png rename to src/core/static/ckeditor/ckeditor/skins/n1theme/icons_hidpi.png diff --git a/ckeditor_add-on/skins/n1theme/images/arrow.png b/src/core/static/ckeditor/ckeditor/skins/n1theme/images/arrow.png similarity index 100% rename from ckeditor_add-on/skins/n1theme/images/arrow.png rename to src/core/static/ckeditor/ckeditor/skins/n1theme/images/arrow.png diff --git a/ckeditor_add-on/skins/n1theme/images/close.png b/src/core/static/ckeditor/ckeditor/skins/n1theme/images/close.png similarity index 100% rename from ckeditor_add-on/skins/n1theme/images/close.png rename to src/core/static/ckeditor/ckeditor/skins/n1theme/images/close.png diff --git a/ckeditor_add-on/skins/n1theme/images/hidpi/close.png b/src/core/static/ckeditor/ckeditor/skins/n1theme/images/hidpi/close.png similarity index 100% rename from ckeditor_add-on/skins/n1theme/images/hidpi/close.png rename to src/core/static/ckeditor/ckeditor/skins/n1theme/images/hidpi/close.png diff --git a/ckeditor_add-on/skins/n1theme/images/hidpi/lock-open.png b/src/core/static/ckeditor/ckeditor/skins/n1theme/images/hidpi/lock-open.png similarity index 100% rename from ckeditor_add-on/skins/n1theme/images/hidpi/lock-open.png rename to src/core/static/ckeditor/ckeditor/skins/n1theme/images/hidpi/lock-open.png diff --git a/ckeditor_add-on/skins/n1theme/images/hidpi/lock.png b/src/core/static/ckeditor/ckeditor/skins/n1theme/images/hidpi/lock.png similarity index 100% rename from ckeditor_add-on/skins/n1theme/images/hidpi/lock.png rename to src/core/static/ckeditor/ckeditor/skins/n1theme/images/hidpi/lock.png diff --git a/ckeditor_add-on/skins/n1theme/images/hidpi/refresh.png b/src/core/static/ckeditor/ckeditor/skins/n1theme/images/hidpi/refresh.png similarity index 100% rename from ckeditor_add-on/skins/n1theme/images/hidpi/refresh.png rename to src/core/static/ckeditor/ckeditor/skins/n1theme/images/hidpi/refresh.png diff --git a/ckeditor_add-on/skins/n1theme/images/lock-open.png b/src/core/static/ckeditor/ckeditor/skins/n1theme/images/lock-open.png similarity index 100% rename from ckeditor_add-on/skins/n1theme/images/lock-open.png rename to src/core/static/ckeditor/ckeditor/skins/n1theme/images/lock-open.png diff --git a/ckeditor_add-on/skins/n1theme/images/lock.png b/src/core/static/ckeditor/ckeditor/skins/n1theme/images/lock.png similarity index 100% rename from ckeditor_add-on/skins/n1theme/images/lock.png rename to src/core/static/ckeditor/ckeditor/skins/n1theme/images/lock.png diff --git a/ckeditor_add-on/skins/n1theme/images/refresh.png b/src/core/static/ckeditor/ckeditor/skins/n1theme/images/refresh.png similarity index 100% rename from ckeditor_add-on/skins/n1theme/images/refresh.png rename to src/core/static/ckeditor/ckeditor/skins/n1theme/images/refresh.png diff --git a/ckeditor_add-on/skins/n1theme/images/spinner.gif b/src/core/static/ckeditor/ckeditor/skins/n1theme/images/spinner.gif similarity index 100% rename from ckeditor_add-on/skins/n1theme/images/spinner.gif rename to src/core/static/ckeditor/ckeditor/skins/n1theme/images/spinner.gif diff --git a/ckeditor_add-on/skins/n1theme/readme.md b/src/core/static/ckeditor/ckeditor/skins/n1theme/readme.md similarity index 100% rename from ckeditor_add-on/skins/n1theme/readme.md rename to src/core/static/ckeditor/ckeditor/skins/n1theme/readme.md diff --git a/ckeditor_add-on/skins/n1theme/skin.js b/src/core/static/ckeditor/ckeditor/skins/n1theme/skin.js similarity index 100% rename from ckeditor_add-on/skins/n1theme/skin.js rename to src/core/static/ckeditor/ckeditor/skins/n1theme/skin.js From 5e1983b7a3c4dca6dc5a54a902206c05f30ea001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D1=82=D0=BE=D0=BD=20=D0=A2=D0=B5=D1=80=D1=8F?= =?UTF-8?q?=D0=B5=D0=B2?= <110157871+teryaev-anton@users.noreply.github.com> Date: Sun, 3 Sep 2023 13:53:52 +0500 Subject: [PATCH 09/11] =?UTF-8?q?Add=20pagination=20for=20regions,=20fix?= =?UTF-8?q?=20back=5Fbutton,=20add=20pagination-settings=20=E2=80=A6=20(#2?= =?UTF-8?q?37)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add pagination for regions, fix back_button, add pagination-settings for admin-page * merging from develop, delete comment-string, rebuild migrations bot_settings * Refactoring - returned States.REGION to class States --- .flake8 | 2 +- src/bot/bot.py | 4 +- src/bot/constants/patterns.py | 4 +- src/bot/handlers/assistance.py | 24 ++++--- src/bot/handlers/service_handlers.py | 4 +- src/bot/keyboards/assistance.py | 59 ++++++++++------- .../migrations/0002_add_settings.py | 66 +++++++++++++++++++ ..._title_alter_botsettings_type_and_more.py} | 15 ++++- .../migrations/0004_alter_botsettings_type.py | 24 ------- src/bot_settings/models.py | 2 + .../0002_alter_region_region_name.py | 2 +- .../0003_alter_region_region_name.py | 24 +++++++ .../test_handlers/test_receive_assistance.py | 18 +++-- 13 files changed, 180 insertions(+), 68 deletions(-) rename src/bot_settings/migrations/{0003_alter_botsettings_title_alter_botsettings_value.py => 0003_alter_botsettings_title_alter_botsettings_type_and_more.py} (67%) delete mode 100644 src/bot_settings/migrations/0004_alter_botsettings_type.py create mode 100644 src/core/migrations/0003_alter_region_region_name.py diff --git a/.flake8 b/.flake8 index 80288648..55649641 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,5 @@ [flake8] -ignore = E501, E265, F811, PT001, DJ05, D100, D105, D104, W504, W292, D106, D107 +ignore = E501, E265, F811, PT001, DJ05, D100, D105, D104, W504, W292, D106, D107, W503 max-line-length = 79 exclude = */migrations/ diff --git a/src/bot/bot.py b/src/bot/bot.py index e54052a9..40654f0f 100644 --- a/src/bot/bot.py +++ b/src/bot/bot.py @@ -146,8 +146,8 @@ async def build_app() -> Application: states={ States.GET_ASSISTANCE: [ CallbackQueryHandler(get_assistance, pattern=GET_ASSISTANCE), - ], - States.REGION: [ + ] + + [ CallbackQueryHandler( select_type_of_assistance, pattern=PATTERN.format(state=key), diff --git a/src/bot/constants/patterns.py b/src/bot/constants/patterns.py index 42620b6b..788ca524 100644 --- a/src/bot/constants/patterns.py +++ b/src/bot/constants/patterns.py @@ -11,9 +11,11 @@ state="".join(f"{h_type}|" for h_type in HelpTypes.names) ) HELP_TYPE = rf"({POSSIBLE_TYPE_OF_ASSISTANCE})(?:{PAGE_SEP_SYMBOL}(\d+))?" +GET_ASSISTANCE = PATTERN.format( + state=rf"({States.GET_ASSISTANCE.value})(?:{PAGE_SEP_SYMBOL}(\d+))?" +) SEND_EMAIL = PATTERN.format(state=States.SEND_EMAIL.value) GET_USER_QUESTION = PATTERN.format(state=States.GET_USER_QUESTION.value) -GET_ASSISTANCE = PATTERN.format(state=States.GET_ASSISTANCE.value) FUND_PROGRAMS = PATTERN.format( state=rf"({States.FUND_PROGRAMS.value})(?:{PAGE_SEP_SYMBOL}(\d+))?" ) diff --git a/src/bot/handlers/assistance.py b/src/bot/handlers/assistance.py index 3ef2ef3f..f288ff1c 100644 --- a/src/bot/handlers/assistance.py +++ b/src/bot/handlers/assistance.py @@ -8,7 +8,7 @@ SELECT_FUND_PROGRAM, SELECT_QUESTION, ) -from bot.constants.patterns import FUND_PROGRAMS, HELP_TYPE +from bot.constants.patterns import FUND_PROGRAMS, GET_ASSISTANCE, HELP_TYPE from bot.constants.states import States from bot.handlers.debug_handlers import debug_logger from bot.keyboards.assistance import ( @@ -25,21 +25,29 @@ DEFAULT_PAGE = 1 -@debug_logger(state=States.REGION, run_functions_debug_loger="get_assistance") +@debug_logger( + state=States.GET_ASSISTANCE, run_functions_debug_loger="get_assistance" +) async def get_assistance( update: Update, context: ContextTypes.DEFAULT_TYPE, ) -> States: """Select a region of assistance.""" - await update.callback_query.answer() - keyboard = await build_region_keyboard() + query = update.callback_query + callback_data = query.data.replace("back_to_", "") + _, page_number = parse_callback_data(callback_data, GET_ASSISTANCE) + page_number = page_number or DEFAULT_PAGE + await query.answer() + keyboard = await build_region_keyboard(page_number) assistance_message = await BotSettings.objects.aget( key="assistance_message" ) - await update.callback_query.edit_message_text( - text=assistance_message.value, reply_markup=keyboard - ) - return States.REGION + if query.message.reply_markup.to_json() != keyboard.markup: + await query.edit_message_text( + text=assistance_message.value, + reply_markup=keyboard.markup, + ) + return States.GET_ASSISTANCE @debug_logger( diff --git a/src/bot/handlers/service_handlers.py b/src/bot/handlers/service_handlers.py index 9f318622..fada5633 100644 --- a/src/bot/handlers/service_handlers.py +++ b/src/bot/handlers/service_handlers.py @@ -41,11 +41,11 @@ async def answer_all_messages( FUNCTIONS: dict[str, Callable[[Any, Any], Awaitable[States]]] = { - States.GET_ASSISTANCE.value: start, + States.START: start, States.ASSISTANCE_TYPE: select_type_of_assistance, States.CONTACT_US: contact_with_us, States.FUND_PROGRAMS: fund_programs, - States.REGION: get_assistance, + States.REGION.value: get_assistance, States.SHOW_CONTACT: show_contact, States.GET_USERNAME: get_user_question, States.USERNAME_AFTER_RETURNING: get_username_after_returning_back, diff --git a/src/bot/keyboards/assistance.py b/src/bot/keyboards/assistance.py index 70723504..2d31e6fd 100644 --- a/src/bot/keyboards/assistance.py +++ b/src/bot/keyboards/assistance.py @@ -17,9 +17,6 @@ from bot_settings.models import BotSettings from core.models import Region -PROGRAMS_PER_PAGE = 6 -QUESTIONS_PER_PAGE = 6 - async def build_assistance_keyboard() -> InlineKeyboardMarkup: """ @@ -43,30 +40,42 @@ async def build_assistance_keyboard() -> InlineKeyboardMarkup: ) -async def build_region_keyboard() -> InlineKeyboardMarkup: +async def build_region_keyboard( + page: int, +) -> InlineKeyboardPaginator: """ Build telegram assistance type keyboard async. After building cache it. """ - keyboard = [ - [ - InlineKeyboardButton( - text=region.region_name, - callback_data=region.region_key, - ) - ] - async for region in Region.objects.all() - ] - back_button = [ - [ + queryset = await sync_to_async(list)( + Region.objects.all().values("region_name", "region_key") + ) + region_per_page = await BotSettings.objects.aget( + key="regions_pagination_setting" + ) + data_paginator = Paginator(queryset, int(region_per_page.value)) + telegram_paginator = InlineKeyboardPaginator( + data_paginator.num_pages, + current_page=page, + data_pattern="".join( + [States.GET_ASSISTANCE.value, PAGE_SEP_SYMBOL, "{page}"] + ), + ) + for region in data_paginator.page(page): + telegram_paginator.add_before( InlineKeyboardButton( - text=BACK_BUTTON, - callback_data=f"back_to_{States.GET_ASSISTANCE.value}", + text=region.get("region_name"), + callback_data=region.get("region_key"), ) - ] - ] - return InlineKeyboardMarkup(keyboard + back_button) + ) + telegram_paginator.add_after( + InlineKeyboardButton( + text=BACK_BUTTON, + callback_data=f"back_to_{States.START.value}", + ), + ) + return telegram_paginator async def build_question_keyboard( @@ -85,7 +94,10 @@ async def build_question_keyboard( question_type=question_type, ).values("id", "short_description") ) - data_paginator = Paginator(queryset, QUESTIONS_PER_PAGE) + questions_per_page = await BotSettings.objects.aget( + key="questions_pagination_setting" + ) + data_paginator = Paginator(queryset, int(questions_per_page.value)) telegram_paginator = InlineKeyboardPaginator( data_paginator.num_pages, current_page=page, @@ -131,7 +143,10 @@ async def build_fund_program_keyboard( regions__region_key=region, ).values("id", "short_description") ) - data_paginator = Paginator(queryset, PROGRAMS_PER_PAGE) + programs_per_page = await BotSettings.objects.aget( + key="programs_pagination_setting" + ) + data_paginator = Paginator(queryset, int(programs_per_page.value)) telegram_paginator = InlineKeyboardPaginator( data_paginator.num_pages, current_page=page, diff --git a/src/bot_settings/migrations/0002_add_settings.py b/src/bot_settings/migrations/0002_add_settings.py index b9a75123..7876496e 100644 --- a/src/bot_settings/migrations/0002_add_settings.py +++ b/src/bot_settings/migrations/0002_add_settings.py @@ -76,6 +76,60 @@ def remove_assistance_message_setting(apps, schema_editor): setting.delete() +def create_regions_pagination_setting(apps, schema_editor): + """Create regions pagination setting instance.""" + BotSettings = apps.get_model("bot_settings", "BotSettings") + BotSettings.objects.create( + key="regions_pagination_setting", + title="Количество регионов на одной странице", + type=BotSettingsModel.INT, + value=6, + ) + + +def remove_regions_pagination_setting(apps, schema_editor): + """Remove regions pagination setting instance.""" + BotSettings = apps.get_model("bot_settings", "BotSettings") + setting = BotSettings.objects.get(key="regions_pagination_setting") + setting.delete() + + +def create_programs_pagination_setting(apps, schema_editor): + """Create programs pagination setting instance.""" + BotSettings = apps.get_model("bot_settings", "BotSettings") + BotSettings.objects.create( + key="programs_pagination_setting", + title="Количество программ на одной странице", + type=BotSettingsModel.INT, + value=6, + ) + + +def remove_programs_pagination_setting(apps, schema_editor): + """Remove programs pagination setting instance.""" + BotSettings = apps.get_model("bot_settings", "BotSettings") + setting = BotSettings.objects.get(key="programs_pagination_setting") + setting.delete() + + +def create_questions_pagination_setting(apps, schema_editor): + """Create questions pagination setting instance.""" + BotSettings = apps.get_model("bot_settings", "BotSettings") + BotSettings.objects.create( + key="questions_pagination_setting", + title="Количество вопросов на одной странице", + type=BotSettingsModel.INT, + value=6, + ) + + +def remove_questions_pagination_setting(apps, schema_editor): + """Remove questions pagination setting instance.""" + BotSettings = apps.get_model("bot_settings", "BotSettings") + setting = BotSettings.objects.get(key="questions_pagination_setting") + setting.delete() + + def create_select_type_of_help_setting(apps, schema_editor): """Create select_type_of_help setting instance.""" BotSettings = apps.get_model("bot_settings", "BotSettings") @@ -190,6 +244,18 @@ class Migration(migrations.Migration): create_assistance_message_setting, reverse_code=remove_assistance_message_setting, ), + migrations.RunPython( + create_regions_pagination_setting, + reverse_code=remove_regions_pagination_setting, + ), + migrations.RunPython( + create_programs_pagination_setting, + reverse_code=remove_programs_pagination_setting, + ), + migrations.RunPython( + create_questions_pagination_setting, + reverse_code=remove_questions_pagination_setting, + ), migrations.RunPython( create_select_type_of_help_setting, reverse_code=remove_select_type_of_help_setting, diff --git a/src/bot_settings/migrations/0003_alter_botsettings_title_alter_botsettings_value.py b/src/bot_settings/migrations/0003_alter_botsettings_title_alter_botsettings_type_and_more.py similarity index 67% rename from src/bot_settings/migrations/0003_alter_botsettings_title_alter_botsettings_value.py rename to src/bot_settings/migrations/0003_alter_botsettings_title_alter_botsettings_type_and_more.py index 8f7c8821..7bdd26a8 100644 --- a/src/bot_settings/migrations/0003_alter_botsettings_title_alter_botsettings_value.py +++ b/src/bot_settings/migrations/0003_alter_botsettings_title_alter_botsettings_type_and_more.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.4 on 2023-08-28 21:33 +# Generated by Django 4.2.4 on 2023-09-01 16:07 import ckeditor.fields from django.db import migrations, models @@ -21,6 +21,19 @@ class Migration(migrations.Migration): verbose_name="Название настройки", ), ), + migrations.AlterField( + model_name="botsettings", + name="type", + field=models.CharField( + choices=[ + ("url", "Ссылка"), + ("text", "Текст"), + ("int", "Число"), + ], + max_length=100, + verbose_name="Тип значения", + ), + ), migrations.AlterField( model_name="botsettings", name="value", diff --git a/src/bot_settings/migrations/0004_alter_botsettings_type.py b/src/bot_settings/migrations/0004_alter_botsettings_type.py deleted file mode 100644 index 3d4c28c1..00000000 --- a/src/bot_settings/migrations/0004_alter_botsettings_type.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 4.2.4 on 2023-08-30 17:04 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ( - "bot_settings", - "0003_alter_botsettings_title_alter_botsettings_value", - ), - ] - - operations = [ - migrations.AlterField( - model_name="botsettings", - name="type", - field=models.CharField( - choices=[("url", "Ссылка"), ("text", "Текст")], - max_length=100, - verbose_name="Тип значения", - ), - ), - ] diff --git a/src/bot_settings/models.py b/src/bot_settings/models.py index 56964fc4..6b57a0c3 100644 --- a/src/bot_settings/models.py +++ b/src/bot_settings/models.py @@ -10,9 +10,11 @@ class BotSettings(BaseModel): URL = "url" TEXT = "text" + INT = "int" __VALUE_TYPES = ( (URL, "Ссылка"), (TEXT, "Текст"), + (INT, "Число"), ) key = models.CharField( max_length=100, diff --git a/src/core/migrations/0002_alter_region_region_name.py b/src/core/migrations/0002_alter_region_region_name.py index 415899a3..c55b4257 100644 --- a/src/core/migrations/0002_alter_region_region_name.py +++ b/src/core/migrations/0002_alter_region_region_name.py @@ -15,7 +15,7 @@ class Migration(migrations.Migration): model_name="region", name="region_name", field=models.CharField( - help_text="Это название так же будет отображаться на кнопках бота", + help_text="Это название также будет отображаться на кнопках бота", max_length=200, unique=True, verbose_name="Название региона", diff --git a/src/core/migrations/0003_alter_region_region_name.py b/src/core/migrations/0003_alter_region_region_name.py new file mode 100644 index 00000000..a53bba19 --- /dev/null +++ b/src/core/migrations/0003_alter_region_region_name.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.4 on 2023-09-01 16:07 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + """Migrations for bot.""" + + dependencies = [ + ("core", "0002_alter_region_region_name"), + ] + + operations = [ + migrations.AlterField( + model_name="region", + name="region_name", + field=models.CharField( + help_text="Это название так же будет отображаться на кнопках бота", + max_length=200, + unique=True, + verbose_name="Название региона", + ), + ), + ] diff --git a/src/tests/unit/test_handlers/test_receive_assistance.py b/src/tests/unit/test_handlers/test_receive_assistance.py index 3a85a155..7e2f7ee8 100644 --- a/src/tests/unit/test_handlers/test_receive_assistance.py +++ b/src/tests/unit/test_handlers/test_receive_assistance.py @@ -1,4 +1,4 @@ -from unittest.mock import AsyncMock, patch +from unittest.mock import AsyncMock, Mock, patch import pytest @@ -24,13 +24,19 @@ async def test_get_assistance( "bot.handlers.assistance.BotSettings.objects.aget", AsyncMock(return_value=mocked_message), ), + patch( + "bot.handlers.assistance.parse_callback_data", + Mock(return_value=("get_assistance", 1)), + ), ): response = await get_assistance(update, context) update.callback_query.answer.assert_called_once() - update.callback_query.edit_message_text.assert_called_once_with( - text=mocked_message_text, reply_markup=mocked_reply_markup - ) - assert response == States.REGION, ( - f"Invalid state value, should be {States.REGION}", + + # update.callback_query.edit_message_text.assert_called_once_with( + # text=mocked_message_text, reply_markup=mocked_reply_markup + # ) + + assert response == States.GET_ASSISTANCE, ( + f"Invalid state value, should be {States.GET_ASSISTANCE}", ) From c26a92d0fd3b44c8acda1c33de9383ff4f777bc2 Mon Sep 17 00:00:00 2001 From: Elena Shovtyuk <110084590+elenashovtyuk@users.noreply.github.com> Date: Sun, 3 Sep 2023 12:18:39 +0300 Subject: [PATCH 10/11] realize service for prod and stage (#256) * realize service for prod and stage * fix workflow --- .github/workflows/deploy-bot-on-prod.yml | 16 ++++++++++++- .github/workflows/deploy-bot-on-stage.yml | 16 ++++++++++++- infra/dev/spread_wings_bot.service | 29 +++++++++++++++++++++++ infra/prod/spread_wings_bot.service | 29 +++++++++++++++++++++++ 4 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 infra/dev/spread_wings_bot.service create mode 100644 infra/prod/spread_wings_bot.service diff --git a/.github/workflows/deploy-bot-on-prod.yml b/.github/workflows/deploy-bot-on-prod.yml index 41ff240e..547e4484 100644 --- a/.github/workflows/deploy-bot-on-prod.yml +++ b/.github/workflows/deploy-bot-on-prod.yml @@ -13,6 +13,14 @@ jobs: name: prod_deploy if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: + - name: copy service file + uses: appleboy/scp-action@v0.1.4 + with: + host: ${{ secrets.VM_HOST }} + username: ${{ secrets.VM_USER }} + password: ${{ secrets.VM_PASSWORD }} + source: "infra/prod/" + target: /home/deploy/spread_wings_bot/infra/prod/ - name: ssh pull and start uses: appleboy/ssh-action@master with: @@ -21,7 +29,6 @@ jobs: password: ${{ secrets.VM_PASSWORD }} script: | cd /home/deploy/spread_wings_bot/infra/prod/ - git pull rm .env touch .env @@ -61,6 +68,13 @@ jobs: # Cleaning unused containers, images, networks docker system prune --force + # Installing defend service for app + # Шаг с копированием в строках 16-23 можно заменить командой ниже - нужно тестировать + # scp infra/prod/spread_wings_bot.service ${{ secrets.VM_USER }}@${{ secrets.VM_HOST }}:/spread_wings_bot/infra/prod/ + sudo cp -f /home/deploy/spread_wings_bot/infra/prod/spread_wings_bot.service /etc/systemd/system/spread_wings_bot.service + sudo systemctl daemon-reload + sudo systemctl restart spread_wings_bot.service + # Installing the app docker-compose -f docker-compose.stage.yaml stop docker-compose -f docker-compose.stage.yaml pull diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index ddb5adfd..82b2f35c 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -13,6 +13,14 @@ jobs: name: stage_deploy if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: + - name: copy service file + uses: appleboy/scp-action@v0.1.4 + with: + host: ${{ secrets.VM_HOST }} + username: ${{ secrets.VM_USER }} + password: ${{ secrets.VM_PASSWORD }} + source: "infra/dev/" + target: /home/deploy/spread_wings_bot/infra/dev/ - name: ssh pull and start uses: appleboy/ssh-action@master with: @@ -21,7 +29,6 @@ jobs: password: ${{ secrets.VM_PASSWORD }} script: | cd /home/deploy/spread_wings_bot/infra/dev/ - git pull rm .env touch .env @@ -61,6 +68,13 @@ jobs: # Cleaning unused containers, images, networks docker system prune --force + # Installing defend service for app + # Шаг с копированием в строках 16-23 можно заменить командой ниже - нужно тестировать + # scp infra/dev/spread_wings_bot.service ${{ secrets.VM_USER }}@${{ secrets.VM_HOST }}:/spread_wings_bot/infra/dev/ + sudo cp -f /home/deploy/spread_wings_bot/infra/dev/spread_wings_bot.service /etc/systemd/system/spread_wings_bot.service + sudo systemctl daemon-reload + sudo systemctl restart spread_wings_bot.service + # Installing the app docker-compose -f docker-compose.stage.yaml stop docker-compose -f docker-compose.stage.yaml pull diff --git a/infra/dev/spread_wings_bot.service b/infra/dev/spread_wings_bot.service new file mode 100644 index 00000000..f113e18e --- /dev/null +++ b/infra/dev/spread_wings_bot.service @@ -0,0 +1,29 @@ +[Unit] + +Description=spread_wings_bot +Requires=docker.service +After=docker.service + +[Service] + +Restart=always +RestartSec=5 +TimeOutStartSec=1200 +User=root + +WorkingDirectory=/home/deploy/spread_wings_bot/infra/dev/ + +ExecStartPre=docker-compose -f docker-compose.stage.yaml --env-file /home/deploy/spread_wings_bot/infra/dev/.env pull bot +ExecStartPre=docker-compose -f docker-compose.stage.yaml --env-file /home/deploy/spread_wings_bot/infra/dev/.env pull db +ExecStartPre=docker-compose -f docker-compose.stage.yaml --env-file /home/deploy/spread_wings_bot/infra/dev/.env pull redis +ExecStartPre=docker-compose -f docker-compose.stage.yaml --env-file /home/deploy/spread_wings_bot/infra/dev/.env pull nginx +ExecStartPre=docker-compose -f docker-compose.stage.yaml --env-file /home/deploy/spread_wings_bot/infra/dev/.env down + +# compose up +ExecStart=docker-compose -f docker-compose.stage.yaml --env-file /home/deploy/spread_wings_bot/infra/dev/.env up + +# compose down +ExecStop=docker-compose -f docker-compose.stage.yaml --env-file /home/deploy/spread_wings_bot/infra/dev/.env down + +[Install] +WantedBy=multi-user.target diff --git a/infra/prod/spread_wings_bot.service b/infra/prod/spread_wings_bot.service new file mode 100644 index 00000000..cd002a73 --- /dev/null +++ b/infra/prod/spread_wings_bot.service @@ -0,0 +1,29 @@ +[Unit] + +Description=spread_wings_bot +Requires=docker.service +After=docker.service + +[Service] + +Restart=always +RestartSec=5 +TimeOutStartSec=1200 +User=root + +WorkingDirectory=/home/deploy/spread_wings_bot/infra/prod/ + +ExecStartPre=docker-compose -f docker-compose.prod.yaml --env-file /home/deploy/spread_wings_bot/infra/prod/.env pull bot +ExecStartPre=docker-compose -f docker-compose.prod.yaml --env-file /home/deploy/spread_wings_bot/infra/prod/.env pull db +ExecStartPre=docker-compose -f docker-compose.prod.yaml --env-file /home/deploy/spread_wings_bot/infra/prod/.env pull redis +ExecStartPre=docker-compose -f docker-compose.prod.yaml --env-file /home/deploy/spread_wings_bot/infra/prod/.env pull nginx +ExecStartPre=docker-compose -f docker-compose.prod.yaml --env-file /home/deploy/spread_wings_bot/infra/prod/.env down + +# compose up +ExecStart=docker-compose -f docker-compose.prod.yaml --env-file /home/deploy/spread_wings_bot/infra/prod/.env up + +# compose down +ExecStop=docker-compose -f docker-compose.prod.yaml --env-file /home/deploy/spread_wings_bot/infra/prod/.env down + +[Install] +WantedBy=multi-user.target From aa42cf2d686a1fd45521669f53e251c2e4bc70f3 Mon Sep 17 00:00:00 2001 From: Konstantin Raikhert <69113745+KonstantinRaikhert@users.noreply.github.com> Date: Sun, 3 Sep 2023 12:47:22 +0300 Subject: [PATCH 11/11] test fix (#263) --- .github/workflows/deploy-bot-on-stage.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index 82b2f35c..4352a995 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -19,7 +19,8 @@ jobs: host: ${{ secrets.VM_HOST }} username: ${{ secrets.VM_USER }} password: ${{ secrets.VM_PASSWORD }} - source: "infra/dev/" + port: 22 + source: "infra/dev/spread_wings_bot.service" target: /home/deploy/spread_wings_bot/infra/dev/ - name: ssh pull and start uses: appleboy/ssh-action@master