diff --git a/src/bot/handlers/show_objects.py b/src/bot/handlers/show_objects.py index c61afb9..4993c62 100644 --- a/src/bot/handlers/show_objects.py +++ b/src/bot/handlers/show_objects.py @@ -17,6 +17,8 @@ EDIT_MESSAGE_PARSE_MODE = "HTML" FUND_PROGRAM_DOES_NOT_EXIST_ERROR_MESSAGE = "Program does not exists!" QUESTION_DOES_NOT_EXIST_ERROR_MESSAGE = "Question does not exists!" +REGION_C = "Региональный координатор:" +CHIEF_C = "Главный координатор:" @debug_logger(state=SHOW_CONTACT, run_functions_debug_loger="show_contact") @@ -28,9 +30,13 @@ async def show_contact( coordinator = await Coordinator.objects.filter( region__region_key=context.user_data[States.REGION] ).afirst() + chief = await Coordinator.objects.filter(is_chief=True).afirst() await query.answer() await query.edit_message_text( - text=f"{coordinator!r}", + text=f"{CHIEF_C if chief and chief != coordinator else ''}\n" + f"{chief.__repr__() if chief and chief != coordinator else ''}\n" + f"\n{REGION_C if chief != coordinator else CHIEF_C}\n" + f"{coordinator!r}", reply_markup=contact_show_keyboard_markup, ) return States.SHOW_CONTACT diff --git a/src/bot/migrations/0003_alter_coordinator_options_coordinator_is_chief.py b/src/bot/migrations/0003_alter_coordinator_options_coordinator_is_chief.py deleted file mode 100644 index d8cbc36..0000000 --- a/src/bot/migrations/0003_alter_coordinator_options_coordinator_is_chief.py +++ /dev/null @@ -1,25 +0,0 @@ -# Generated by Django 4.2.4 on 2023-08-28 15:53 - -from django.db import migrations, models - - -class Migration(migrations.Migration): # noqa - dependencies = [ - ("bot", "0002_alter_coordinator_phone_number"), - ] - - operations = [ - migrations.AlterModelOptions( - name="coordinator", - options={ - "ordering": ("is_chief", "last_name"), - "verbose_name": "Координатор", - "verbose_name_plural": "Координаторы", - }, - ), - migrations.AddField( - model_name="coordinator", - name="is_chief", - field=models.BooleanField(default=False), - ), - ] diff --git a/src/bot/migrations/0004_alter_coordinator_options_coordinator_is_chief.py b/src/bot/migrations/0004_alter_coordinator_options_coordinator_is_chief.py new file mode 100644 index 0000000..218ee04 --- /dev/null +++ b/src/bot/migrations/0004_alter_coordinator_options_coordinator_is_chief.py @@ -0,0 +1,33 @@ +# Generated by Django 4.2.4 on 2023-08-29 18:57 + +from django.db import migrations, models + +import bot.validators + + +class Migration(migrations.Migration): + """Migrations for bot.""" + + dependencies = [ + ("bot", "0003_alter_coordinator_first_name_and_more"), + ] + + operations = [ + migrations.AlterModelOptions( + name="coordinator", + options={ + "ordering": ("-is_chief", "last_name"), + "verbose_name": "Координатор", + "verbose_name_plural": "Координаторы", + }, + ), + migrations.AddField( + model_name="coordinator", + name="is_chief", + field=models.BooleanField( + default=False, + validators=[bot.validators.validate_is_chief], + verbose_name="Главный", + ), + ), + ] diff --git a/src/bot/models.py b/src/bot/models.py index 5678047..338a2e5 100644 --- a/src/bot/models.py +++ b/src/bot/models.py @@ -75,6 +75,9 @@ def __repr__(self): representation += f"Telegram: {self.telegram_account}" return representation + def __str__(self): + return f"{self.first_name} {self.last_name}" + class Meta: # noqa verbose_name = "Координатор" verbose_name_plural = "Координаторы"