Skip to content

Commit

Permalink
Support Markdown in dashboard descriptions
Browse files Browse the repository at this point in the history
Thanks, @toolness - closes #115
  • Loading branch information
toolness authored Jun 6, 2021
1 parent 4a9dcfe commit acb3752
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
18 changes: 18 additions & 0 deletions django_sql_dashboard/migrations/0004_add_description_help_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.3 on 2021-05-25 10:58

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('django_sql_dashboard', '0003_update_metadata'),
]

operations = [
migrations.AlterField(
model_name='dashboard',
name='description',
field=models.TextField(blank=True, help_text='Optional description (Markdown allowed)'),
),
]
4 changes: 3 additions & 1 deletion django_sql_dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
class Dashboard(models.Model):
slug = models.SlugField(unique=True)
title = models.CharField(blank=True, max_length=128)
description = models.TextField(blank=True)
description = models.TextField(
blank=True, help_text="Optional description (Markdown allowed)"
)
owned_by = models.ForeignKey(
settings.AUTH_USER_MODEL,
null=True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{% if user_can_execute_sql %}<p><a href="{% url 'django_sql_dashboard-index' %}">Dashboard index</a></p>{% endif %}
<h1>{% if dashboard.title %}{{ dashboard.title }}{% else %}{{ dashboard.slug }}{% endif %}</h1>
{% if dashboard.description %}
<p>{{ dashboard.description }}</p>
{{ dashboard.description|sql_dashboard_markdown }}
{% endif %}

<p style="color: #666; font-size: 0.9em; margin-top: -1em">
Expand Down
2 changes: 1 addition & 1 deletion django_sql_dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Meta:
widgets = {
"description": Textarea(
attrs={
"placeholder": "Optional description, shown at the top of the dashboard page"
"placeholder": "Optional description, shown at the top of the dashboard page (Markdown allowed)"
}
)
}
Expand Down

0 comments on commit acb3752

Please sign in to comment.