Commit c490d4482629d47b1b1a8d3ab10b63733dfd7b79

Authored by Felipe Henrique de Almeida Bormann
1 parent 7f3cbd4f

fixed coordinators on subject and improved accordion, still has failures and thi…

…ngs to work on, added other improvements in functionality
amadeus/static/css/base/amadeus.css
@@ -92,17 +92,17 @@ @@ -92,17 +92,17 @@
92 height: 30px; 92 height: 30px;
93 } 93 }
94 94
95 -.core-subjects-options > li{ 95 +.core-subjects-options li{
96 float:left; 96 float:left;
97 padding: 10px; 97 padding: 10px;
98 background-color: #FFFFFF; 98 background-color: #FFFFFF;
99 margin: 1px; 99 margin: 1px;
100 100
101 - border-bottom: 4px; 101 + border-bottom: 10px;
102 border-bottom-style: solid; 102 border-bottom-style: solid;
103 } 103 }
104 104
105 -.core-subjects-options > li.active{ 105 +.core-subjects-options li.active{
106 border-bottom-color: green; 106 border-bottom-color: green;
107 } 107 }
108 108
categories/views.py
@@ -56,10 +56,8 @@ class IndexView(views.SuperuserRequiredMixin, LoginRequiredMixin, ListView): @@ -56,10 +56,8 @@ class IndexView(views.SuperuserRequiredMixin, LoginRequiredMixin, ListView):
56 56
57 def get_context_data(self, **kwargs): 57 def get_context_data(self, **kwargs):
58 context = super(IndexView, self).get_context_data(**kwargs) 58 context = super(IndexView, self).get_context_data(**kwargs)
59 - list_categories = None  
60 - categories = self.get_queryset().order_by('name')  
61 -  
62 59
  60 + categories = self.get_queryset().order_by('name')
63 context['categories'] = categories 61 context['categories'] = categories
64 62
65 return context 63 return context
subjects/templates/subjects/list.html
@@ -22,8 +22,14 @@ @@ -22,8 +22,14 @@
22 {% endif %} 22 {% endif %}
23 <div id="core-subjects-options-div"> 23 <div id="core-subjects-options-div">
24 <ul class="core-subjects-options"> 24 <ul class="core-subjects-options">
25 - <li class="active">{% trans "My subjects" %}</li>  
26 - <li>{% trans "all subjects" %}</li> 25 + {% if all %}
  26 + <a href="{% url 'subjects:index' %}"><li >{% trans "My subjects" %}</li></a>
  27 + <a href="{% url 'subjects:index' 'all' %}" ><li class="active">{% trans "all subjects" %}</li></a>
  28 + {% else %}
  29 + <a href="{% url 'subjects:index' %}"><li class="active">{% trans "My subjects" %}</li></a>
  30 + <a href="{% url 'subjects:index' 'all' %}" ><li>{% trans "all subjects" %}</li></a>
  31 + {% endif %}
  32 +
27 </ul> 33 </ul>
28 </div> 34 </div>
29 35
@@ -70,10 +76,10 @@ @@ -70,10 +76,10 @@
70 </div> 76 </div>
71 </div> 77 </div>
72 </div> 78 </div>
73 - <div id="{{category.slug}}" class="panel-collapse collapse category-panel-content"> 79 + <div id="{{category.slug}}" class="panel-collapse panel-body collapse category-panel-content">
74 <input type="hidden" class="log_url" value="{% url 'categories:view_log' category.id %}" /> 80 <input type="hidden" class="log_url" value="{% url 'categories:view_log' category.id %}" />
75 <input type="hidden" class="log_id" value="" /> 81 <input type="hidden" class="log_id" value="" />
76 - {% if coordinators %} 82 + {% if category.coordinators.all|length > 0 %}
77 <h4> {% trans "Coordinator(s): " %} 83 <h4> {% trans "Coordinator(s): " %}
78 {% for coordinator in category.coordinators.all %} 84 {% for coordinator in category.coordinators.all %}
79 {{coordinator.social_name}} 85 {{coordinator.social_name}}
@@ -85,12 +91,21 @@ @@ -85,12 +91,21 @@
85 91
86 92
87 {{category.description|safe}} 93 {{category.description|safe}}
  94 +
  95 +
  96 +
88 {% if user in category.coordinators.all %} 97 {% if user in category.coordinators.all %}
89 <a href="{% url 'subjects:create' category.slug %}"><button class="create-subject-btn"> {% trans "create new subject" %} </button></a> 98 <a href="{% url 'subjects:create' category.slug %}"><button class="create-subject-btn"> {% trans "create new subject" %} </button></a>
90 {% endif %} 99 {% endif %}
91 - 100 + <div class="panel-group" id="subject-accordion" role="tablist" aria-multiselectable="true">
  101 + {% for subject in category.subjects %}
  102 + {% include "subjects/subject_card.html" %}
  103 + {% endfor %}
  104 + </div>
  105 +
  106 +
92 </div> 107 </div>
93 - 108 +
94 109
95 {% comment %} 110 {% comment %}
96 <div id="{{category.slug}}" class="panel-collapse collapse"> 111 <div id="{{category.slug}}" class="panel-collapse collapse">
subjects/templates/subjects/subject_card.html 0 → 100644
@@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
  1 +{% load static i18n permission_tags %}
  2 + <div class="panel panel-info">
  3 + <div class="panel-heading">
  4 + <div class="row">
  5 + <div class="col-md-12 category-header">
  6 + <h4 class="panel-title">
  7 + <a class="category-course-link pull-left" data-parent="#subject-accordion" data-toggle="collapse" href="#{{subject.slug}}">
  8 + <button class="btn btn-default btn-xs text-center cat-selector"><i class="fa fa-angle-right fa-2x" aria-hidden="true"></i></button> {{subject.name}}
  9 + </a>
  10 + </h4>
  11 +
  12 + <div class="col-md-5 pull-right category-card-items">
  13 + <a href="" ><i class="fa fa-list" aria-hidden="true"></i></a>
  14 + <a href=""><i class="fa fa-envelope-o" aria-hidden="true"></i></a>
  15 + <a href=""><i class="fa fa-exclamation-triangle" aria-hidden="true"></i></a>
  16 + <a href=""><i class="fa fa-bar-chart" aria-hidden="true"></i></a>
  17 + </div>
  18 +
  19 + </div>
  20 + </div>
  21 + </div>
  22 +
  23 + <div id="{{subject.slug}}" class="panel-collapse collapse category-panel-content">
  24 + <p>{{subject.init_date}}</p>
  25 + <p>{{subject.end_date}}</p>
  26 +
  27 + <p>{{subject.description_brief|safe}}</p>
  28 +
  29 +
  30 +
  31 +
  32 +</div>
  33 +
  34 +</div>
0 \ No newline at end of file 35 \ No newline at end of file
subjects/urls.py
@@ -3,5 +3,6 @@ from . import views @@ -3,5 +3,6 @@ from . import views
3 3
4 urlpatterns = [ 4 urlpatterns = [
5 url(r'^$', views.IndexView.as_view(), name='index'), 5 url(r'^$', views.IndexView.as_view(), name='index'),
  6 + url(r'^(?P<option>[\w_-]+)/$', views.IndexView.as_view(), name='index'),
6 url(r'^create/(?P<slug>[\w_-]+)/$', views.SubjectCreateView.as_view(), name='create'), 7 url(r'^create/(?P<slug>[\w_-]+)/$', views.SubjectCreateView.as_view(), name='create'),
7 ] 8 ]
8 \ No newline at end of file 9 \ No newline at end of file
subjects/views.py
@@ -61,11 +61,24 @@ class IndexView(LoginRequiredMixin, ListView): @@ -61,11 +61,24 @@ class IndexView(LoginRequiredMixin, ListView):
61 if self.request.user.is_staff: 61 if self.request.user.is_staff:
62 categories = self.get_queryset().order_by('name') 62 categories = self.get_queryset().order_by('name')
63 else: 63 else:
64 - categories = self.get_queryset().order_by('name').filter(visible=True) 64 + if self.kwargs.get('option'):
  65 + categories = self.get_queryset().order_by('name').filter(visible=True)
  66 + context['all'] = True
  67 + for category in categories:
  68 + category.subjects = Subject.objects.all().filter(category= category)
  69 + else:
  70 + context['all'] = False
  71 + categories = self.get_queryset().filter(visible=True)
  72 + for category in categories:
  73 + category.subjects = Subject.objects.all().filter(category= category)
  74 +
  75 + categories = [category for category in categories if category.subjects.count() > 0 and self.request.user in category.coordinators.all()]
  76 + #So I remove all categories that doesn't have the possibility for the user to be on
  77 +
65 78
  79 + #print(categories[1].subject_set)
66 #Settings subjects for template use 80 #Settings subjects for template use
67 - for category in categories:  
68 - category.subjects = Subject.objects.all().filter(category= category) 81 +
69 82
70 83
71 context['categories'] = categories 84 context['categories'] = categories