Skip to content

Commit

Permalink
change question type display in admin
Browse files Browse the repository at this point in the history
  • Loading branch information
alekseikoznov committed Sep 1, 2023
1 parent df7b67f commit 31b7b71
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/bot/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ 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]

@admin.display(description="Тип вопроса")
def get_question_type(self, obj):
"""Display question_type in admin panel."""
return obj.question_type[:100]
return obj.get_question_type_display()[:100]

@admin.display(description="Ответ")
def get_answer(self, obj):
Expand Down Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
@@ -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="Тип вопроса",
),
),
]
3 changes: 1 addition & 2 deletions src/bot/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ class HelpTypes(models.TextChoices):
PSYCHOLOGICAL_ASSISTANCE = "PSYCHOLOGICAL_ASSISTANCE", _(
"Психологическая помощь"
)
COMMON_QUESTION = "COMMON_QUESTION", _("Общий вопрос")


class Question(BaseModel):
Expand Down Expand Up @@ -161,7 +160,7 @@ class FundProgram(BaseModel):
)
short_description = models.CharField(
max_length=20,
verbose_name="Короткое описание",
verbose_name="Текст на кнопке",
help_text="Введите название кнопки в боте для данной программы",
)
regions = models.ManyToManyField(
Expand Down
7 changes: 6 additions & 1 deletion src/bot_settings/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",)
Expand All @@ -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."""
Expand Down

0 comments on commit 31b7b71

Please sign in to comment.