Commit ed2cd2be742c4348f5764d3d8dbb6ab092d46ecb
1 parent
25ed30ee
Exists in
master
and in
3 other branches
Updating profile system functions verification
Showing
4 changed files
with
38 additions
and
13 deletions
Show diff stats
users/models.py
... | ... | @@ -62,15 +62,6 @@ class User(AbstractBaseUser, PermissionsMixin): |
62 | 62 | |
63 | 63 | return _('Is not an admin') |
64 | 64 | |
65 | - def is_coordinator(self): | |
66 | - return _('Is not a coordinator') | |
67 | - | |
68 | - def is_professor(self): | |
69 | - return _('Is not a professor') | |
70 | - | |
71 | - def is_student(self): | |
72 | - return _('Is not a student') | |
73 | - | |
74 | 65 | def has_dependencies(self): |
75 | 66 | if self.is_staff: |
76 | 67 | return True | ... | ... |
users/templates/users/profile.html
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | |
3 | 3 | {% load static i18n %} |
4 | 4 | {% load widget_tweaks %} |
5 | -{% load django_bootstrap_breadcrumbs permission_tags%} | |
5 | +{% load django_bootstrap_breadcrumbs profile_verifies %} | |
6 | 6 | |
7 | 7 | {% block breadcrumbs %} |
8 | 8 | {{ block.super }} |
... | ... | @@ -42,15 +42,15 @@ |
42 | 42 | </div> |
43 | 43 | <div class="form-group"> |
44 | 44 | <label class="control-form">{% trans 'Coordinator in' %}:</label> |
45 | - <input type="text" readonly="readonly" class="form-control" value="{{ user.is_coordinator }}" /> | |
45 | + <input type="text" readonly="readonly" class="form-control" value="{{ user|is_coordinator }}" /> | |
46 | 46 | </div> |
47 | 47 | <div class="form-group"> |
48 | 48 | <label class="control-form">{% trans 'Professor in' %}:</label> |
49 | - <input type="text" readonly="readonly" class="form-control" value="{{ user.is_professor }}" /> | |
49 | + <input type="text" readonly="readonly" class="form-control" value="{{ user|is_professor }}" /> | |
50 | 50 | </div> |
51 | 51 | <div class="form-group"> |
52 | 52 | <label class="control-form">{% trans 'Student in' %}:</label> |
53 | - <input type="text" readonly="readonly" class="form-control" value="{{ user.is_student }}" /> | |
53 | + <input type="text" readonly="readonly" class="form-control" value="{{ user|is_student }}" /> | |
54 | 54 | </div> |
55 | 55 | </div> |
56 | 56 | </div> | ... | ... |
... | ... | @@ -0,0 +1,34 @@ |
1 | +from django import template | |
2 | +from django.utils.translation import ugettext_lazy as _ | |
3 | + | |
4 | +from categories.models import Category | |
5 | +from subjects.models import Subject | |
6 | + | |
7 | +register = template.Library() | |
8 | + | |
9 | +@register.filter(name = 'is_coordinator') | |
10 | +def is_coordinator(user): | |
11 | + cats = Category.objects.filter(coordinators = user) | |
12 | + | |
13 | + if len(cats) > 0: | |
14 | + return ", ".join(cats.values_list('name', flat = True)) | |
15 | + | |
16 | + return _('Is not a coordinator') | |
17 | + | |
18 | +@register.filter(name = 'is_professor') | |
19 | +def is_professor(user): | |
20 | + subs = Subject.objects.filter(professor = user) | |
21 | + | |
22 | + if len(subs) > 0: | |
23 | + return ", ".join(subs.values_list('name', flat = True)) | |
24 | + | |
25 | + return _('Is not a professor') | |
26 | + | |
27 | +@register.filter(name = 'is_student') | |
28 | +def is_student(user): | |
29 | + subs = Subject.objects.filter(students = user) | |
30 | + | |
31 | + if len(subs) > 0: | |
32 | + return ", ".join(subs.values_list('name', flat = True)) | |
33 | + | |
34 | + return _('Is not a student') | ... | ... |