Skip to content

Commit

Permalink
add chief coordinator and and add chief coordinator to text message i…
Browse files Browse the repository at this point in the history
…n show_contact
  • Loading branch information
Zh-Andrew committed Aug 29, 2023
1 parent 4e8b78f commit 8af870f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 26 deletions.
8 changes: 7 additions & 1 deletion src/bot/handlers/show_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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="Главный",
),
),
]
3 changes: 3 additions & 0 deletions src/bot/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "Координаторы"
Expand Down

0 comments on commit 8af870f

Please sign in to comment.