Commit 056537b26c10fd51de6bb7c1293b41b84660d8d5
1 parent
5bce8d33
Exists in
master
and in
3 other branches
Updating categories breadcrumbs and other adjusts
Showing
6 changed files
with
40 additions
and
13 deletions
Show diff stats
... | ... | @@ -0,0 +1,20 @@ |
1 | +# -*- coding: utf-8 -*- | |
2 | +# Generated by Django 1.10 on 2017-01-02 21:56 | |
3 | +from __future__ import unicode_literals | |
4 | + | |
5 | +from django.db import migrations, models | |
6 | + | |
7 | + | |
8 | +class Migration(migrations.Migration): | |
9 | + | |
10 | + dependencies = [ | |
11 | + ('categories', '0005_auto_20170102_1225'), | |
12 | + ] | |
13 | + | |
14 | + operations = [ | |
15 | + migrations.AlterField( | |
16 | + model_name='category', | |
17 | + name='visible', | |
18 | + field=models.BooleanField(default=True, verbose_name='visible'), | |
19 | + ), | |
20 | + ] | ... | ... |
categories/models.py
... | ... | @@ -6,11 +6,11 @@ from users.models import User |
6 | 6 | class Category(models.Model): |
7 | 7 | """Represents a Course """ |
8 | 8 | |
9 | - name = models.CharField(_("Name"), max_length = 100, blank=False, null=False, unique= True) | |
10 | - slug = AutoSlugField(_("Slug"),populate_from='name',unique=True) | |
9 | + name = models.CharField(_("Name"), max_length = 100, blank = False, null = False, unique = True) | |
10 | + slug = AutoSlugField(_("Slug"), populate_from = 'name', unique = True) | |
11 | 11 | description = models.CharField(_("description"), max_length = 300) |
12 | - visible = models.BooleanField(_("visible")) | |
13 | - coordinators = models.ManyToManyField(User, related_name = _("coordinators"), blank=True) | |
12 | + visible = models.BooleanField(_("visible"), default = True) | |
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/create.html
categories/templates/categories/list.html
... | ... | @@ -81,12 +81,10 @@ |
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 | - {% if coordinators %} | |
85 | - <h4> {% trans "Coordinator(s): " %} | |
86 | - {% for coordinator in category.coordinators.all %} | |
87 | - {{coordinator.social_name}} | |
88 | - {% endfor %} | |
89 | - </h4> | |
84 | + {% if category.coordinators.all|length > 0 %} | |
85 | + <h4><b>{% trans "Coordinator(s) " %}:</b> | |
86 | + {{ category.coordinators.all|join:', ' }} | |
87 | + </h4> | |
90 | 88 | {% else %} |
91 | 89 | <h4> {% trans "It doesn't possess coordinators" %} </h4> |
92 | 90 | {% endif %} | ... | ... |
categories/templates/categories/update.html
categories/views.py
... | ... | @@ -87,7 +87,6 @@ class CreateCategory(views.SuperuserRequiredMixin, HasRoleMixin, LogMixin, Creat |
87 | 87 | initial['name'] = category.name |
88 | 88 | initial['visible'] = category.visible |
89 | 89 | initial['coordinators'] = category.coordinators.all() |
90 | - print(category.coordinators.all()) | |
91 | 90 | |
92 | 91 | self.log_action = 'replicate' |
93 | 92 | |
... | ... | @@ -107,6 +106,11 @@ class CreateCategory(views.SuperuserRequiredMixin, HasRoleMixin, LogMixin, Creat |
107 | 106 | else: |
108 | 107 | context['title'] = _('Create Category') |
109 | 108 | |
109 | + if 'categories' in self.request.META.get('HTTP_REFERER'): | |
110 | + context['template_extends'] = 'categories/list.html' | |
111 | + else: | |
112 | + context['template_extends'] = 'subjects/list.html' | |
113 | + | |
110 | 114 | return context |
111 | 115 | |
112 | 116 | def form_valid(self, form): |
... | ... | @@ -189,6 +193,11 @@ class UpdateCategory(LogMixin, UpdateView): |
189 | 193 | context = super(UpdateCategory, self).get_context_data(**kwargs) |
190 | 194 | context['title'] = _('Update Category') |
191 | 195 | |
196 | + if 'categories' in self.request.META.get('HTTP_REFERER'): | |
197 | + context['template_extends'] = 'categories/list.html' | |
198 | + else: | |
199 | + context['template_extends'] = 'subjects/list.html' | |
200 | + | |
192 | 201 | return context |
193 | 202 | |
194 | 203 | @log_decorator_ajax('category', 'view', 'category') | ... | ... |