Commit e484c62461db35464cf40a927497b6441297481a

Authored by Felipe Henrique de Almeida Bormann
1 parent a2deb60c

fixed coordinators empty option and display on template

categories/migrations/0004_auto_20170102_1224.py 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +# -*- coding: utf-8 -*-
  2 +# Generated by Django 1.10 on 2017-01-02 15:24
  3 +from __future__ import unicode_literals
  4 +
  5 +from django.conf import settings
  6 +from django.db import migrations, models
  7 +
  8 +
  9 +class Migration(migrations.Migration):
  10 +
  11 + dependencies = [
  12 + ('categories', '0003_auto_20161226_1358'),
  13 + ]
  14 +
  15 + operations = [
  16 + migrations.AlterField(
  17 + model_name='category',
  18 + name='coordinators',
  19 + field=models.ManyToManyField(null=True, related_name='coordinators', to=settings.AUTH_USER_MODEL),
  20 + ),
  21 + ]
... ...
categories/migrations/0005_auto_20170102_1225.py 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +# -*- coding: utf-8 -*-
  2 +# Generated by Django 1.10 on 2017-01-02 15:25
  3 +from __future__ import unicode_literals
  4 +
  5 +from django.conf import settings
  6 +from django.db import migrations, models
  7 +
  8 +
  9 +class Migration(migrations.Migration):
  10 +
  11 + dependencies = [
  12 + ('categories', '0004_auto_20170102_1224'),
  13 + ]
  14 +
  15 + operations = [
  16 + migrations.AlterField(
  17 + model_name='category',
  18 + name='coordinators',
  19 + field=models.ManyToManyField(blank=True, related_name='coordinators', to=settings.AUTH_USER_MODEL),
  20 + ),
  21 + ]
... ...
categories/models.py
... ... @@ -10,7 +10,7 @@ class Category(models.Model):
10 10 slug = AutoSlugField(_("Slug"),populate_from='name',unique=True)
11 11 description = models.CharField(_("description"), max_length = 300)
12 12 visible = models.BooleanField(_("visible"))
13   - coordinators = models.ManyToManyField(User, related_name = _("coordinators"))
  13 + coordinators = models.ManyToManyField(User, related_name = _("coordinators"), blank=True)
14 14 create_date = models.DateTimeField(_('Creation Date'), auto_now_add = True)
15 15 modified_date = models.DateTimeField(_('Modified Date'), auto_now_add = True)
16 16  
... ...
categories/templates/categories/list.html
... ... @@ -81,11 +81,16 @@
81 81 <input type="hidden" class="log_url" value="{% url 'categories:view_log' category.id %}" />
82 82 <input type="hidden" class="log_id" value="" />
83 83  
84   - <h4> {% trans "Coordinator(s): " %}
  84 + {% if coordinators %}
  85 + <h4> {% trans "Coordinator(s): " %}
85 86 {% for coordinator in category.coordinators.all %}
86 87 {{coordinator.social_name}}
87 88 {% endfor %}
88 89 </h4>
  90 + {% else %}
  91 + <h4> {% trans "It doesn't possess coordinators" %} </h4>
  92 + {% endif %}
  93 +
89 94  
90 95 {{category.description|safe}}
91 96 </div>
... ...
subjects/templates/subjects/list.html
... ... @@ -73,12 +73,17 @@
73 73 <div id="{{category.slug}}" class="panel-collapse collapse category-panel-content">
74 74 <input type="hidden" class="log_url" value="{% url 'categories:view_log' category.id %}" />
75 75 <input type="hidden" class="log_id" value="" />
76   -
77   - <h4> {% trans "Coordinator(s): " %}
  76 + {% if coordinators %}
  77 + <h4> {% trans "Coordinator(s): " %}
78 78 {% for coordinator in category.coordinators.all %}
79 79 {{coordinator.social_name}}
80 80 {% endfor %}
81 81 </h4>
  82 + {% else %}
  83 + <h4> {% trans "It doesn't possess coordinators" %} </h4>
  84 + {% endif %}
  85 +
  86 +
82 87 {{category.description|safe}}
83 88 {% if user in category.coordinators.all %}
84 89 <button class="create-subject-btn"> {% trans "create new subject" %} </button>
... ...