From e484c62461db35464cf40a927497b6441297481a Mon Sep 17 00:00:00 2001 From: Felipe Henrique de Almeida Bormann Date: Mon, 2 Jan 2017 12:28:45 -0300 Subject: [PATCH] fixed coordinators empty option and display on template --- categories/migrations/0004_auto_20170102_1224.py | 21 +++++++++++++++++++++ categories/migrations/0005_auto_20170102_1225.py | 21 +++++++++++++++++++++ categories/models.py | 2 +- categories/templates/categories/list.html | 7 ++++++- subjects/templates/subjects/list.html | 9 +++++++-- 5 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 categories/migrations/0004_auto_20170102_1224.py create mode 100644 categories/migrations/0005_auto_20170102_1225.py diff --git a/categories/migrations/0004_auto_20170102_1224.py b/categories/migrations/0004_auto_20170102_1224.py new file mode 100644 index 0000000..9b4bd7a --- /dev/null +++ b/categories/migrations/0004_auto_20170102_1224.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2017-01-02 15:24 +from __future__ import unicode_literals + +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('categories', '0003_auto_20161226_1358'), + ] + + operations = [ + migrations.AlterField( + model_name='category', + name='coordinators', + field=models.ManyToManyField(null=True, related_name='coordinators', to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/categories/migrations/0005_auto_20170102_1225.py b/categories/migrations/0005_auto_20170102_1225.py new file mode 100644 index 0000000..aabbf31 --- /dev/null +++ b/categories/migrations/0005_auto_20170102_1225.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2017-01-02 15:25 +from __future__ import unicode_literals + +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('categories', '0004_auto_20170102_1224'), + ] + + operations = [ + migrations.AlterField( + model_name='category', + name='coordinators', + field=models.ManyToManyField(blank=True, related_name='coordinators', to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/categories/models.py b/categories/models.py index 67babab..9746049 100644 --- a/categories/models.py +++ b/categories/models.py @@ -10,7 +10,7 @@ class Category(models.Model): slug = AutoSlugField(_("Slug"),populate_from='name',unique=True) description = models.CharField(_("description"), max_length = 300) visible = models.BooleanField(_("visible")) - coordinators = models.ManyToManyField(User, related_name = _("coordinators")) + coordinators = models.ManyToManyField(User, related_name = _("coordinators"), blank=True) create_date = models.DateTimeField(_('Creation Date'), auto_now_add = True) modified_date = models.DateTimeField(_('Modified Date'), auto_now_add = True) diff --git a/categories/templates/categories/list.html b/categories/templates/categories/list.html index 66fa8a8..2aebf73 100755 --- a/categories/templates/categories/list.html +++ b/categories/templates/categories/list.html @@ -81,11 +81,16 @@ -

{% trans "Coordinator(s): " %} + {% if coordinators %} +

{% trans "Coordinator(s): " %} {% for coordinator in category.coordinators.all %} {{coordinator.social_name}} {% endfor %}

+ {% else %} +

{% trans "It doesn't possess coordinators" %}

+ {% endif %} + {{category.description|safe}} diff --git a/subjects/templates/subjects/list.html b/subjects/templates/subjects/list.html index 1891722..c869480 100644 --- a/subjects/templates/subjects/list.html +++ b/subjects/templates/subjects/list.html @@ -73,12 +73,17 @@
- -

{% trans "Coordinator(s): " %} + {% if coordinators %} +

{% trans "Coordinator(s): " %} {% for coordinator in category.coordinators.all %} {{coordinator.social_name}} {% endfor %}

+ {% else %} +

{% trans "It doesn't possess coordinators" %}

+ {% endif %} + + {{category.description|safe}} {% if user in category.coordinators.all %} -- libgit2 0.21.2