Commit b011d4486545b73b7eb7334691dfc6397e6c0c60
1 parent
b842d2bc
Exists in
master
and in
3 other branches
fixed template tag rules but still have design alignment issues to solve
Showing
4 changed files
with
45 additions
and
23 deletions
Show diff stats
amadeus/static/css/base/amadeus.css
| ... | ... | @@ -468,7 +468,7 @@ ul, li { |
| 468 | 468 | } |
| 469 | 469 | /* Icon Topic */ |
| 470 | 470 | .divMoreActions { |
| 471 | - text-align: right; height: 37px; float: right; | |
| 471 | + text-align: right; height: 30px; float: right; | |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | .divMoreActions > .btn-group { |
| ... | ... | @@ -476,12 +476,10 @@ ul, li { |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | .moreAccordion { |
| 479 | - height: 37px; | |
| 479 | + height: 30px; | |
| 480 | 480 | } |
| 481 | 481 | /*.divMoreActions div button {padding-left: 10px; padding-right: 10px; padding-bottom: 10px; margin-bottom: 4px; height: 31px;}*/ |
| 482 | -.divMoreActions , .moreAccordion{ | |
| 483 | - padding-top: 3px; | |
| 484 | -} | |
| 482 | + | |
| 485 | 483 | .moreAccordion button{margin-bottom: 0px; margin-top: 8px;} |
| 486 | 484 | .titleTopic {padding-top: 10px; padding-bottom: 10px;} |
| 487 | 485 | .titleTopic a h4, .titleTopic h4{color: white;} | ... | ... |
categories/forms.py
categories/templates/categories/list.html
| ... | ... | @@ -25,6 +25,12 @@ |
| 25 | 25 | |
| 26 | 26 | {% if user.is_staff %} |
| 27 | 27 | <a href="{% url 'categories:create' %}"><button id="create-category"> {% trans "Create Category" %}</button></a> |
| 28 | + | |
| 29 | +{% else %} | |
| 30 | + <ul> | |
| 31 | + <li>{% trans "My subjects" %}</li> | |
| 32 | + <li>{% trans "all subjects" %}</li> | |
| 33 | + </ul> | |
| 28 | 34 | {% endif %} |
| 29 | 35 | |
| 30 | 36 | <!-- Code for listing categories --> |
| ... | ... | @@ -39,8 +45,11 @@ |
| 39 | 45 | <a class="category-course-link" data-toggle="collapse" href="#{{category.slug}}">{{category.name}}</a> |
| 40 | 46 | </h4> |
| 41 | 47 | |
| 42 | - {% if user.is_staff %} | |
| 43 | - <div class="col-xs-6 col-md-6 divMoreActions" > | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + {% if user.is_staff or user in category.coordinators.all %} | |
| 52 | + <div class="col-xs-1 col-md-1 divMoreActions" > | |
| 44 | 53 | <div class="btn-group"> |
| 45 | 54 | <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> |
| 46 | 55 | <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> |
| ... | ... | @@ -52,16 +61,20 @@ |
| 52 | 61 | </ul> |
| 53 | 62 | </div> |
| 54 | 63 | </div> |
| 55 | - | |
| 56 | - {% else %} | |
| 57 | - <a href=""><i class="fa fa-list" aria-hidden="true"></i></a> | |
| 64 | + {% endif %} | |
| 65 | + | |
| 66 | + {% if not user.is_staff %} | |
| 67 | + <div class="col-md-5 pull-right"> | |
| 68 | + | |
| 69 | + <a href=""><i class="fa fa-list" aria-hidden="true"></i></a> | |
| 58 | 70 | <a href=""><i class="fa fa-envelope-o" aria-hidden="true"></i></a> |
| 59 | 71 | |
| 60 | 72 | <a href=""><i class="fa fa-exclamation-triangle" aria-hidden="true"></i></a> |
| 61 | - | |
| 62 | 73 | <a href=""><i class="fa fa-bar-chart" aria-hidden="true"></i></a> |
| 74 | + | |
| 75 | + | |
| 76 | + </div> | |
| 63 | 77 | {% endif %} |
| 64 | - | |
| 65 | 78 | |
| 66 | 79 | |
| 67 | 80 | </div> | ... | ... |
categories/views.py
| ... | ... | @@ -4,6 +4,7 @@ from .models import Category |
| 4 | 4 | from django.core.urlresolvers import reverse_lazy |
| 5 | 5 | from rolepermissions.verifications import has_role |
| 6 | 6 | |
| 7 | +from django.contrib import messages | |
| 7 | 8 | from django.http import HttpResponse |
| 8 | 9 | from django.utils.translation import ugettext_lazy as _ |
| 9 | 10 | |
| ... | ... | @@ -49,15 +50,13 @@ class IndexView(LoginRequiredMixin, ListView): |
| 49 | 50 | context = super(IndexView, self).get_context_data(**kwargs) |
| 50 | 51 | list_categories = None |
| 51 | 52 | categories = self.get_queryset().order_by('name') |
| 52 | - if has_role(self.request.user,'system_admin'): | |
| 53 | - categories = self.get_queryset().order_by('name') | |
| 53 | + | |
| 54 | + for category in categories: | |
| 55 | + print(category.coordinators) | |
| 56 | + #if self.request.user in category.coordinators: | |
| 57 | + # print("here") | |
| 54 | 58 | |
| 55 | - elif has_role(self.request.user,'professor'): | |
| 56 | - pass | |
| 57 | - #list_categories = self.get_queryset().filter(professors__in = [self.request.user]).order_by('name') | |
| 58 | - # categorys_categories = CourseCategory.objects.filter(course_category__professors__name = self.request.user.name).distinct() | |
| 59 | - elif has_role(self.request.user, 'student'): | |
| 60 | - pass | |
| 59 | + | |
| 61 | 60 | |
| 62 | 61 | |
| 63 | 62 | context['title'] = _('Categories') |
| ... | ... | @@ -100,11 +99,20 @@ class CreateCategory(HasRoleMixin, CreateView): |
| 100 | 99 | |
| 101 | 100 | def form_valid(self, form): |
| 102 | 101 | self.object = form.save() |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 103 | 105 | #TODO: Implement log calls |
| 104 | 106 | return super(CreateCategory, self).form_valid(form) |
| 105 | 107 | |
| 108 | + def get_success_url(self): | |
| 109 | + print(self.object.coordinators) | |
| 110 | + objeto = self.object.name | |
| 111 | + messages.success(self.request, _('Category "%s" register successfully!')%(objeto)) | |
| 112 | + return reverse_lazy('categories:index') | |
| 106 | 113 | |
| 107 | -class DeleteCategory(HasRoleMixin, DeleteView): | |
| 114 | + | |
| 115 | +class DeleteCategory(DeleteView): | |
| 108 | 116 | |
| 109 | 117 | login_url = reverse_lazy("users:login") |
| 110 | 118 | redirect_field_name = 'next' |
| ... | ... | @@ -115,9 +123,11 @@ class DeleteCategory(HasRoleMixin, DeleteView): |
| 115 | 123 | def delete(self, request, *args, **kwargs): |
| 116 | 124 | category = get_object_or_404(Category, slug = self.kwargs.get('slug')) |
| 117 | 125 | subjects = Subject.objects.filter(category = category) |
| 118 | - print("aqui 3") | |
| 126 | + | |
| 119 | 127 | if len(subjects) > 0: |
| 120 | - return HttpResponse(_('There are subjects attched to this category')) | |
| 128 | + #objeto = category | |
| 129 | + #messages.success(self.request, _('cannot delete Category "%s" ')%(objeto)) | |
| 130 | + return reverse_lazy('categories:index') | |
| 121 | 131 | |
| 122 | 132 | return super(DeleteCategory, self).delete(self, request, *args, **kwargs) |
| 123 | 133 | ... | ... |