Commit e484c62461db35464cf40a927497b6441297481a
1 parent
a2deb60c
Exists in
master
and in
3 other branches
fixed coordinators empty option and display on template
Showing
5 changed files
with
56 additions
and
4 deletions
Show diff stats
| @@ -0,0 +1,21 @@ | @@ -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 | + ] |
| @@ -0,0 +1,21 @@ | @@ -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,7 +10,7 @@ class Category(models.Model): | ||
| 10 | slug = AutoSlugField(_("Slug"),populate_from='name',unique=True) | 10 | slug = AutoSlugField(_("Slug"),populate_from='name',unique=True) |
| 11 | description = models.CharField(_("description"), max_length = 300) | 11 | description = models.CharField(_("description"), max_length = 300) |
| 12 | visible = models.BooleanField(_("visible")) | 12 | visible = models.BooleanField(_("visible")) |
| 13 | - coordinators = models.ManyToManyField(User, related_name = _("coordinators")) | 13 | + coordinators = models.ManyToManyField(User, related_name = _("coordinators"), blank=True) |
| 14 | create_date = models.DateTimeField(_('Creation Date'), auto_now_add = True) | 14 | create_date = models.DateTimeField(_('Creation Date'), auto_now_add = True) |
| 15 | modified_date = models.DateTimeField(_('Modified Date'), auto_now_add = True) | 15 | modified_date = models.DateTimeField(_('Modified Date'), auto_now_add = True) |
| 16 | 16 |
categories/templates/categories/list.html
| @@ -81,11 +81,16 @@ | @@ -81,11 +81,16 @@ | ||
| 81 | <input type="hidden" class="log_url" value="{% url 'categories:view_log' category.id %}" /> | 81 | <input type="hidden" class="log_url" value="{% url 'categories:view_log' category.id %}" /> |
| 82 | <input type="hidden" class="log_id" value="" /> | 82 | <input type="hidden" class="log_id" value="" /> |
| 83 | 83 | ||
| 84 | - <h4> {% trans "Coordinator(s): " %} | 84 | + {% if coordinators %} |
| 85 | + <h4> {% trans "Coordinator(s): " %} | ||
| 85 | {% for coordinator in category.coordinators.all %} | 86 | {% for coordinator in category.coordinators.all %} |
| 86 | {{coordinator.social_name}} | 87 | {{coordinator.social_name}} |
| 87 | {% endfor %} | 88 | {% endfor %} |
| 88 | </h4> | 89 | </h4> |
| 90 | + {% else %} | ||
| 91 | + <h4> {% trans "It doesn't possess coordinators" %} </h4> | ||
| 92 | + {% endif %} | ||
| 93 | + | ||
| 89 | 94 | ||
| 90 | {{category.description|safe}} | 95 | {{category.description|safe}} |
| 91 | </div> | 96 | </div> |
subjects/templates/subjects/list.html
| @@ -73,12 +73,17 @@ | @@ -73,12 +73,17 @@ | ||
| 73 | <div id="{{category.slug}}" class="panel-collapse collapse category-panel-content"> | 73 | <div id="{{category.slug}}" class="panel-collapse collapse category-panel-content"> |
| 74 | <input type="hidden" class="log_url" value="{% url 'categories:view_log' category.id %}" /> | 74 | <input type="hidden" class="log_url" value="{% url 'categories:view_log' category.id %}" /> |
| 75 | <input type="hidden" class="log_id" value="" /> | 75 | <input type="hidden" class="log_id" value="" /> |
| 76 | - | ||
| 77 | - <h4> {% trans "Coordinator(s): " %} | 76 | + {% if coordinators %} |
| 77 | + <h4> {% trans "Coordinator(s): " %} | ||
| 78 | {% for coordinator in category.coordinators.all %} | 78 | {% for coordinator in category.coordinators.all %} |
| 79 | {{coordinator.social_name}} | 79 | {{coordinator.social_name}} |
| 80 | {% endfor %} | 80 | {% endfor %} |
| 81 | </h4> | 81 | </h4> |
| 82 | + {% else %} | ||
| 83 | + <h4> {% trans "It doesn't possess coordinators" %} </h4> | ||
| 84 | + {% endif %} | ||
| 85 | + | ||
| 86 | + | ||
| 82 | {{category.description|safe}} | 87 | {{category.description|safe}} |
| 83 | {% if user in category.coordinators.all %} | 88 | {% if user in category.coordinators.all %} |
| 84 | <button class="create-subject-btn"> {% trans "create new subject" %} </button> | 89 | <button class="create-subject-btn"> {% trans "create new subject" %} </button> |