From 7868e73b7be99a8042819eb034d5d56a063f4567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Moroz?= Date: Sun, 29 Sep 2024 10:38:42 +0200 Subject: [PATCH] feat: Add description field on Habit --- .../tree/migrations/0039_habit_description.py | 18 ++++++++++++++++++ tasks/apps/tree/models.py | 3 ++- tasks/templates/tree/habit_list.html | 4 ++-- 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 tasks/apps/tree/migrations/0039_habit_description.py diff --git a/tasks/apps/tree/migrations/0039_habit_description.py b/tasks/apps/tree/migrations/0039_habit_description.py new file mode 100644 index 0000000..2bf7fcc --- /dev/null +++ b/tasks/apps/tree/migrations/0039_habit_description.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.16 on 2024-09-29 08:38 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("tree", "0038_alter_habit_slug_alter_habit_tagname"), + ] + + operations = [ + migrations.AddField( + model_name="habit", + name="description", + field=models.TextField(blank=True, null=True), + ), + ] diff --git a/tasks/apps/tree/models.py b/tasks/apps/tree/models.py index db2a055..466811c 100644 --- a/tasks/apps/tree/models.py +++ b/tasks/apps/tree/models.py @@ -91,9 +91,10 @@ class Habit(models.Model): # hashtag for matching tagname = models.SlugField(max_length=255, unique=True, allow_unicode=True) - # XXX event stream id based on name, need rehash on... other field? event_stream_id = models.UUIDField(default=uuid.uuid4, editable=False) + description = models.TextField(null=True, blank=True) + def __str__(self): return self.name diff --git a/tasks/templates/tree/habit_list.html b/tasks/templates/tree/habit_list.html index 28c7522..4f550bc 100644 --- a/tasks/templates/tree/habit_list.html +++ b/tasks/templates/tree/habit_list.html @@ -17,10 +17,10 @@

Habits

{% for habit in object_list %}
- {{ habit.name }} + {{ habit.as_hashtag }} ({{ habit.name }})
- {{ habit.as_hashtag }} + {{ habit.description }}
{% endfor %}