From 7ea78aad51446faf82dc59143c9fbe89e48b30a2 Mon Sep 17 00:00:00 2001 From: Konstantin Raikhert Date: Fri, 1 Sep 2023 18:54:33 +0300 Subject: [PATCH] some fix --- src/bot/admin.py | 19 ++------------- src/bot/handlers/assistance.py | 3 +-- .../0007_alter_question_short_description.py | 23 +++++++++++++++++++ src/bot/models.py | 2 +- 4 files changed, 27 insertions(+), 20 deletions(-) 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 6f1097e..c0eb441 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.get_question_type_display()[: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 54db260..3ef2ef3 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/0007_alter_question_short_description.py b/src/bot/migrations/0007_alter_question_short_description.py new file mode 100644 index 0000000..209e253 --- /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 3d24a5c..f87828b 100644 --- a/src/bot/models.py +++ b/src/bot/models.py @@ -117,7 +117,7 @@ class Question(BaseModel): ) short_description = models.CharField( max_length=20, - verbose_name="Короткое описание", + verbose_name="Текст на кнопке", help_text="Введите название кнопки в боте для данного вопроса", ) regions = models.ManyToManyField(