Skip to content

Commit

Permalink
Make constance table look a little better
Browse files Browse the repository at this point in the history
  • Loading branch information
dtcooper committed Sep 21, 2024
1 parent 56f341b commit 6d814fc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
15 changes: 4 additions & 11 deletions server/tomato/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ def validate_reset_times(values):
CONSTANCE_BACKEND = "constance.backends.database.DatabaseBackend"
CONSTANCE_SUPERUSER_ONLY = False
CONSTANCE_IGNORE_ADMIN_VERSION_CHECK = True
_style_full_width = {"style": "width: calc(100% - 5px)"}
CONSTANCE_ADDITIONAL_FIELDS = {
"ui_modes": (
"django.forms.MultipleChoiceField",
Expand Down Expand Up @@ -278,16 +279,7 @@ def validate_reset_times(values):
{
"max_length": 50,
"widget": "django.forms.TextInput",
"widget_kwargs": {"attrs": {"size": 40}},
"required": True,
},
),
"shorter_text": (
"django.forms.CharField",
{
"max_length": 20,
"widget": "django.forms.TextInput",
"widget_kwargs": {"attrs": {"size": 16}},
"widget_kwargs": {"attrs": _style_full_width},
"required": True,
},
),
Expand All @@ -311,7 +303,7 @@ def validate_reset_times(values):
"django.forms.CharField",
{
"widget": "django.forms.Textarea",
"widget_kwargs": {"attrs": {"rows": 8, "cols": 8}},
"widget_kwargs": {"attrs": {"rows": 8, **_style_full_width}},
"validators": (validate_reset_times,),
},
),
Expand All @@ -328,6 +320,7 @@ def validate_reset_times(values):
{"choices": (("", "Off"), ("12h", "12 Hour"), ("24h", "24 Hour")), "required": False},
),
}
del _style_full_width

CONSTANCE_CONFIG = {
"STATION_NAME": ("Tomato Radio Automation", "The name of your station.", "short_text"),
Expand Down
13 changes: 9 additions & 4 deletions server/tomato/templates/admin/constance/change_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
{{ block.super }}

<style>
/* Prevent weird yellow highlighting due to checkbox selected */
#changelist table tbody tr {
background-color: #ffffff !important;
}
{% with widths='50 20 20 10' %}
{% for width in widths.split %}
#changelist table th:nth-child({{ forloop.counter }}),
#changelist table td:nth-child({{ forloop.counter }}) {
width: {{ width }}% !important;
max-width: {{ width }}% !important;
}
{% endfor %}
{% endwith %}
</style>

<script>
Expand Down

0 comments on commit 6d814fc

Please sign in to comment.