diff --git a/nummi/main/migrations/0008_alter_category_options_category_icon.py b/nummi/main/migrations/0008_alter_category_options_category_icon.py new file mode 100644 index 0000000..3c570ed --- /dev/null +++ b/nummi/main/migrations/0008_alter_category_options_category_icon.py @@ -0,0 +1,22 @@ +# Generated by Django 4.0.4 on 2022-05-20 20:13 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("main", "0007_alter_category_options_alter_transaction_options_and_more"), + ] + + operations = [ + migrations.AlterModelOptions( + name="category", + options={"ordering": ["name"]}, + ), + migrations.AddField( + model_name="category", + name="icon", + field=models.CharField(default="folder", max_length=64), + ), + ] diff --git a/nummi/main/models.py b/nummi/main/models.py index f1eea70..1a22b2d 100644 --- a/nummi/main/models.py +++ b/nummi/main/models.py @@ -10,6 +10,7 @@ class Category(models.Model): name = models.CharField( max_length=64, validators=[validate_unicode_slug], default="New Category" ) + icon = models.CharField(max_length=64, default="folder") def __str__(self): return self.name @@ -21,7 +22,7 @@ class Category(models.Model): class CategoryForm(ModelForm): class Meta: model = Category - fields = ["name"] + fields = ["name", "icon"] class Transaction(models.Model): diff --git a/nummi/main/templates/main/category.html b/nummi/main/templates/main/category.html index a489c4a..364590a 100644 --- a/nummi/main/templates/main/category.html +++ b/nummi/main/templates/main/category.html @@ -7,7 +7,7 @@ {% endblock %} {% block body %} -

{{ category }}

+

{{ category }}

{% csrf_token %} diff --git a/nummi/main/templates/main/index.html b/nummi/main/templates/main/index.html index 00ee731..c8e8785 100644 --- a/nummi/main/templates/main/index.html +++ b/nummi/main/templates/main/index.html @@ -27,6 +27,7 @@ {{ trans.trader|default_if_none:"–" }} {% if trans.category %} + {{ trans.category }} @@ -44,7 +45,7 @@

Catégories

{% for cat in categories %} - {{ cat }} + {{ cat }} {% endfor %}
{% endif %}