Skip to content

Commit

Permalink
admin botsettings refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
KonstantinRaikhert committed Aug 31, 2023
1 parent ce34c35 commit d4c898f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/bot/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand All @@ -25,6 +26,7 @@ class Meta:

models = FundProgram
widgets = {
"title": forms.Textarea(attrs={"rows": 3, "cols": 50}),
"regions": forms.CheckboxSelectMultiple,
}
fields = "__all__"
4 changes: 2 additions & 2 deletions src/bot_settings/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion src/bot_settings/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def clean(self):
URLValidator()(self.value)

def __str__(self):
return f"<BotSettings: {self.key} - {self.title} - {self.value}>"
return self.title

class Meta:
"""Meta for BotSettings model."""
Expand Down

0 comments on commit d4c898f

Please sign in to comment.