Commit 9d0c2c8765c93c838f7d0d05b907e7f0f5937831

Authored by Zambom
1 parent 3dea456f

Adjusting subjects accordion

amadeus/static/js/course.js
... ... @@ -109,23 +109,27 @@ function replicate_course(url, course) {
109 109 $('.collapse').on('show.bs.collapse', function (e) {
110 110 if($(this).is(e.target)){
111 111 var btn = $(this).parent().find('.fa-angle-right');
  112 +
  113 + btn = btn[0];
112 114  
113   - btn.switchClass("fa-angle-right", "fa-angle-down", 250, "easeInOutQuad");
  115 + $(btn).switchClass("fa-angle-right", "fa-angle-down", 250, "easeInOutQuad");
114 116  
115 117 var url = $(this).parent().find('.log_url').val();
116 118 var log_input = $(this).parent().find('.log_id');
117 119  
118   - $.ajax({
119   - url: url,
120   - data: {'action': 'open'},
121   - dataType: 'json',
122   - success: function (data) {
123   - log_input.val(data.log_id);
124   - },
125   - error: function (data) {
126   - console.log(data);
127   - }
128   - });
  120 + if (typeof(url) != 'undefined') {
  121 + $.ajax({
  122 + url: url,
  123 + data: {'action': 'open'},
  124 + dataType: 'json',
  125 + success: function (data) {
  126 + log_input.val(data.log_id);
  127 + },
  128 + error: function (data) {
  129 + console.log(data);
  130 + }
  131 + });
  132 + }
129 133 }
130 134 });
131 135  
... ... @@ -133,21 +137,25 @@ $('.collapse').on('hide.bs.collapse', function (e) {
133 137 if($(this).is(e.target)){
134 138 var btn = $(this).parent().find('.fa-angle-down');
135 139  
136   - btn.switchClass("fa-angle-down", "fa-angle-right", 250, "easeInOutQuad");
  140 + btn = btn[0];
  141 +
  142 + $(btn).switchClass("fa-angle-down", "fa-angle-right", 250, "easeInOutQuad");
137 143  
138 144 var url = $(this).parent().find('.log_url').val();
139 145 var log_id = $(this).parent().find('.log_id').val();
140 146  
141   - $.ajax({
142   - url: url,
143   - data: {'action': 'close', 'log_id': log_id},
144   - dataType: 'json',
145   - success: function (data) {
146   - console.log(data.message);
147   - },
148   - error: function (data) {
149   - console.log(data);
150   - }
151   - });
  147 + if (typeof(url) != 'undefined') {
  148 + $.ajax({
  149 + url: url,
  150 + data: {'action': 'close', 'log_id': log_id},
  151 + dataType: 'json',
  152 + success: function (data) {
  153 + console.log(data.message);
  154 + },
  155 + error: function (data) {
  156 + console.log(data);
  157 + }
  158 + });
  159 + }
152 160 }
153 161 });
154 162 \ No newline at end of file
... ...
subjects/templates/subjects/list.html
... ... @@ -42,165 +42,131 @@
42 42 <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
43 43 {% for category in categories %}
44 44 {% if category.visible %}
45   -
46   -
47   - <div class="panel panel-info">
48   - <div class="panel-heading">
49   - <div class="row">
50   - <div class="col-md-12 category-header">
51   - <h4 class="panel-title">
52   - <a class="category-course-link pull-left" data-parent="#accordion" data-toggle="collapse" href="#{{category.slug}}">
53   - <button class="btn btn-default btn-xs text-center cat-selector"><i class="fa fa-angle-right fa-2x" aria-hidden="true"></i></button> {{category.name}}
54   - </a>
55   - </h4>
56   - {% if user.is_staff or user in category.coordinators.all %}
57   - <div class=" divMoreActions">
58   - <div class="btn-group">
59   - <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
60   - <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i>
61   - </button>
62   - <ul class="dropdown-menu pull-right" aria-labelledby="moreActions">
63   - {% if user.is_staff %}
64   - <li><a href="{% url 'categories:replicate' category.slug %}"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i>{% trans 'Replicate' %}</a></li>
65   - {% endif %}
66   - <li><a href="{% url 'categories:update' category.slug %}"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i>{% trans 'Edit' %}</a></li>
67   - <li><a href="javascript:delete_course.get('{% url 'categories:delete' category.slug %}?view=index','#category','#modal_course')"><i class="fa fa-trash fa-fw" aria-hidden="true"></i>&nbsp;{% trans 'Remove' %}</a></li>
68   - </ul>
  45 + <div class="panel panel-info">
  46 + <div class="panel-heading">
  47 + <div class="row">
  48 + <div class="col-md-12 category-header">
  49 + <h4 class="panel-title">
  50 + <a class="category-course-link pull-left" data-parent="#accordion" data-toggle="collapse" href="#{{category.slug}}">
  51 + <button class="btn btn-default btn-xs text-center cat-selector"><i class="fa fa-angle-right fa-2x" aria-hidden="true"></i></button> {{category.name}}
  52 + </a>
  53 + </h4>
  54 + {% if user.is_staff or user in category.coordinators.all %}
  55 + <div class=" divMoreActions">
  56 + <div class="btn-group">
  57 + <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  58 + <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i>
  59 + </button>
  60 + <ul class="dropdown-menu pull-right" aria-labelledby="moreActions">
  61 + {% if user.is_staff %}
  62 + <li><a href="{% url 'categories:replicate' category.slug %}"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i>{% trans 'Replicate' %}</a></li>
  63 + {% endif %}
  64 + <li><a href="{% url 'categories:update' category.slug %}"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i>{% trans 'Edit' %}</a></li>
  65 + <li><a href="javascript:delete_course.get('{% url 'categories:delete' category.slug %}?view=index','#category','#modal_course')"><i class="fa fa-trash fa-fw" aria-hidden="true"></i>&nbsp;{% trans 'Remove' %}</a></li>
  66 + </ul>
  67 + </div>
69 68 </div>
70   - </div>
71   - {% else %}
72   - <div class=" divMoreActions">
73   - </div>
74   - {% endif %}
75   -
  69 + {% else %}
  70 + <div class=" divMoreActions">
  71 + </div>
  72 + {% endif %}
  73 +
76 74 <div class="col-md-5 pull-right category-card-items">
77 75 <a href="" ><i class="fa fa-list" aria-hidden="true"></i></a>
78 76 <a href=""><i class="fa fa-envelope-o" aria-hidden="true"></i></a>
79 77 <a href=""><i class="fa fa-exclamation-triangle" aria-hidden="true"></i></a>
80 78 <a href=""><i class="fa fa-bar-chart" aria-hidden="true"></i></a>
81 79 </div>
82   -
  80 + </div>
83 81 </div>
84 82 </div>
85   - </div>
86   - <div id="{{category.slug}}" class="panel-collapse panel-body collapse category-panel-content">
87   - <input type="hidden" class="log_url" value="{% url 'categories:view_log' category.id %}" />
88   - <input type="hidden" class="log_id" value="" />
89   - {% if category.coordinators.all|length > 0 %}
90   - <h4><b>{% trans "Coordinator(s) " %}: </b>
91   - {{ category.coordinators.all|join:', ' }}
92   - </h4>
93   - {% else %}
94   - <h4> {% trans "It doesn't possess coordinators" %} </h4>
95   - {% endif %}
96   -
97   - {{category.description|safe}}
98   -
99   - {% if user in category.coordinators.all %}
100   - <a href="{% url 'subjects:create' category.slug %}"><button class="create-subject-btn"> {% trans "Create new subject" %} </button></a>
101   - {% endif %}
  83 + <div id="{{category.slug}}" class="panel-collapse panel-body collapse category-panel-content">
  84 + <input type="hidden" class="log_url" value="{% url 'categories:view_log' category.id %}" />
  85 + <input type="hidden" class="log_id" value="" />
  86 + {% if category.coordinators.all|length > 0 %}
  87 + <h4><b>{% trans "Coordinator(s) " %}: </b>
  88 + {{ category.coordinators.all|join:', ' }}
  89 + </h4>
  90 + {% else %}
  91 + <h4> {% trans "It doesn't possess coordinators" %} </h4>
  92 + {% endif %}
  93 +
  94 + {{category.description|safe}}
102 95  
103   - <div class="panel-group" id="subject-accordion" role="tablist" aria-multiselectable="true">
104   - {% for subject in category.subject_category.all %}
105   - {% include "subjects/subject_card.html" %}
106   - {% endfor %}
  96 + {% if user in category.coordinators.all %}
  97 + <a href="{% url 'subjects:create' category.slug %}"><button class="create-subject-btn"> {% trans "Create new subject" %} </button></a>
  98 + {% endif %}
  99 +
  100 + <div class="panel-group" id="{{ category.slug }}-accordion" role="tablist" aria-multiselectable="true">
  101 + {% for subject in category.subject_category.all %}
  102 + {% include "subjects/subject_card.html" %}
  103 + {% endfor %}
  104 + </div>
107 105 </div>
108   -
109   -
110 106 </div>
111   -
112   -
113   -
114   -
115   - {% comment %}
116   - <div id="{{category.slug}}" class="panel-collapse collapse">
117   - {% for subject in subjects %}
118   - {% include "categories/category_card.html" %}
119   - {% endfor %}
120   - </div>
121   - {% endcomment %}
122   - </div>
123   -
124 107 {% elif request.user in category.coordinators.all %}
125   -
126   -
127   -
128   - <div class="panel panel-danger">
129   - <div class="panel-heading">
130   - <div class="row">
131   - <div class="col-md-12 category-header">
132   - <h4 class="panel-title">
133   - <a class="category-course-link pull-left" data-parent="#accordion" data-toggle="collapse" href="#{{category.slug}}">
134   - <button class="btn btn-default btn-xs text-center cat-selector"><i class="fa fa-angle-right fa-2x" aria-hidden="true"></i></button> {{category.name}}
135   - </a>
136   - </h4>
137   - {% if user.is_staff or user in category.coordinators.all %}
138   - <div class=" divMoreActions">
139   - <div class="btn-group">
140   - <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
141   - <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i>
142   - </button>
143   - <ul class="dropdown-menu pull-right" aria-labelledby="moreActions">
144   - {% if user.is_staff %}
145   - <li><a href="{% url 'categories:replicate' category.slug %}"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i>{% trans 'Replicate' %}</a></li>
146   - {% endif %}
147   - <li><a href="{% url 'categories:update' category.slug %}"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i>{% trans 'Edit' %}</a></li>
148   - <li><a href="javascript:delete_course.get('{% url 'categories:delete' category.slug %}?view=index','#category','#modal_course')"><i class="fa fa-trash fa-fw" aria-hidden="true"></i>&nbsp;{% trans 'Remove' %}</a></li>
149   - </ul>
  108 + <div class="panel panel-danger">
  109 + <div class="panel-heading">
  110 + <div class="row">
  111 + <div class="col-md-12 category-header">
  112 + <h4 class="panel-title">
  113 + <a class="category-course-link pull-left" data-parent="#accordion" data-toggle="collapse" href="#{{category.slug}}">
  114 + <button class="btn btn-default btn-xs text-center cat-selector"><i class="fa fa-angle-right fa-2x" aria-hidden="true"></i></button> {{category.name}}
  115 + </a>
  116 + </h4>
  117 + {% if user.is_staff or user in category.coordinators.all %}
  118 + <div class=" divMoreActions">
  119 + <div class="btn-group">
  120 + <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  121 + <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i>
  122 + </button>
  123 + <ul class="dropdown-menu pull-right" aria-labelledby="moreActions">
  124 + {% if user.is_staff %}
  125 + <li><a href="{% url 'categories:replicate' category.slug %}"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i>{% trans 'Replicate' %}</a></li>
  126 + {% endif %}
  127 + <li><a href="{% url 'categories:update' category.slug %}"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i>{% trans 'Edit' %}</a></li>
  128 + <li><a href="javascript:delete_course.get('{% url 'categories:delete' category.slug %}?view=index','#category','#modal_course')"><i class="fa fa-trash fa-fw" aria-hidden="true"></i>&nbsp;{% trans 'Remove' %}</a></li>
  129 + </ul>
  130 + </div>
150 131 </div>
151   - </div>
152   - {% else %}
153   - <div class=" divMoreActions">
154   - </div>
155   - {% endif %}
156   -
  132 + {% else %}
  133 + <div class=" divMoreActions">
  134 + </div>
  135 + {% endif %}
  136 +
157 137 <div class="col-md-5 pull-right category-card-items">
158 138 <a href="" ><i class="fa fa-list" aria-hidden="true"></i></a>
159 139 <a href=""><i class="fa fa-envelope-o" aria-hidden="true"></i></a>
160 140 <a href=""><i class="fa fa-exclamation-triangle" aria-hidden="true"></i></a>
161 141 <a href=""><i class="fa fa-bar-chart" aria-hidden="true"></i></a>
162 142 </div>
163   -
  143 + </div>
164 144 </div>
165 145 </div>
166   - </div>
167   - <div id="{{category.slug}}" class="panel-collapse panel-body collapse category-panel-content">
168   - <input type="hidden" class="log_url" value="{% url 'categories:view_log' category.id %}" />
169   - <input type="hidden" class="log_id" value="" />
170   - {% if category.coordinators.all|length > 0 %}
171   - <h4><b>{% trans "Coordinator(s) " %}: </b>
172   - {{ category.coordinators.all|join:', ' }}
173   - </h4>
174   - {% else %}
175   - <h4> {% trans "It doesn't possess coordinators" %} </h4>
176   - {% endif %}
177   -
178   - {{category.description|safe}}
179   -
180   - {% if user in category.coordinators.all %}
181   - <a href="{% url 'subjects:create' category.slug %}"><button class="create-subject-btn"> {% trans "Create new subject" %} </button></a>
182   - {% endif %}
183   - <div class="panel-group" id="subject-accordion" role="tablist" aria-multiselectable="true">
184   - {% for subject in category.subjects %}
185   - {% include "subjects/subject_card.html" %}
186   - {% endfor %}
187   - </div>
188   -
189   -
190   - </div>
  146 + <div id="{{category.slug}}" class="panel-collapse panel-body collapse category-panel-content">
  147 + <input type="hidden" class="log_url" value="{% url 'categories:view_log' category.id %}" />
  148 + <input type="hidden" class="log_id" value="" />
  149 + {% if category.coordinators.all|length > 0 %}
  150 + <h4><b>{% trans "Coordinator(s) " %}: </b>
  151 + {{ category.coordinators.all|join:', ' }}
  152 + </h4>
  153 + {% else %}
  154 + <h4> {% trans "It doesn't possess coordinators" %} </h4>
  155 + {% endif %}
  156 +
  157 + {{category.description|safe}}
  158 +
  159 + {% if user in category.coordinators.all %}
  160 + <a href="{% url 'subjects:create' category.slug %}"><button class="create-subject-btn"> {% trans "Create new subject" %} </button></a>
  161 + {% endif %}
191 162  
192   -
193   -
194   -
195   - {% comment %}
196   - <div id="{{category.slug}}" class="panel-collapse collapse">
197   - {% for subject in subjects %}
198   - {% include "categories/category_card.html" %}
199   - {% endfor %}
  163 + <div class="panel-group" id="{{ category.slug }}-accordion" role="tablist" aria-multiselectable="true">
  164 + {% for subject in category.subject_category.all %}
  165 + {% include "subjects/subject_card.html" %}
  166 + {% endfor %}
  167 + </div>
200 168 </div>
201   - {% endcomment %}
202   - </div>
203   -
  169 + </div>
204 170 {% endif %}
205 171 {% endfor %}
206 172 </div>
... ...
subjects/templates/subjects/subject_card.html
1 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   - {% if request.user in subject.professor.all or request.user in category.coordinators.all %}
13   - <div class="divMoreActions" >
14   - <div class="btn-group">
15   - <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
16   - <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i>
17   - </button>
18   - <ul class="dropdown-menu pull-right" aria-labelledby="moreActions">
19   - <li><a href="#"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i>{% trans 'Replicate' %}</a></li>
20   - <li><a href="#"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i>{% trans 'Edit' %}</a></li>
21   - <li><a href="#"><i class="fa fa-trash fa-fw" aria-hidden="true"></i>&nbsp;{% trans 'Remove' %}</a></li>
22   - </ul>
23   - </div>
24   - </div>
25   - {% endif %}
26   - <div class="col-md-5 pull-right category-card-items">
27   - <a href="" ><i class="fa fa-list" aria-hidden="true"></i></a>
28   - <a href=""><i class="fa fa-envelope-o" aria-hidden="true"></i></a>
29   - <a href=""><i class="fa fa-exclamation-triangle" aria-hidden="true"></i></a>
30   - <a href=""><i class="fa fa-bar-chart" aria-hidden="true"></i></a>
31   - </div>
32   -
  2 +
  3 +<div class="panel panel-info">
  4 + <div class="panel-heading">
  5 + <div class="row">
  6 + <div class="col-md-12 category-header">
  7 + <h4 class="panel-title">
  8 + <a class="category-course-link pull-left" data-parent="#{{ subject.category.slug }}-accordion" data-toggle="collapse" href="#{{subject.slug}}">
  9 + <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}}
  10 + </a>
  11 + </h4>
  12 + {% if request.user in subject.professor.all or request.user in category.coordinators.all %}
  13 + <div class="divMoreActions" >
  14 + <div class="btn-group">
  15 + <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  16 + <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i>
  17 + </button>
  18 + <ul class="dropdown-menu pull-right" aria-labelledby="moreActions">
  19 + <li><a href="#"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i>{% trans 'Replicate' %}</a></li>
  20 + <li><a href="#"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i>{% trans 'Edit' %}</a></li>
  21 + <li><a href="#"><i class="fa fa-trash fa-fw" aria-hidden="true"></i>&nbsp;{% trans 'Remove' %}</a></li>
  22 + </ul>
  23 + </div>
33 24 </div>
  25 + {% endif %}
  26 + <div class="col-md-5 pull-right category-card-items">
  27 + <a href="" ><i class="fa fa-list" aria-hidden="true"></i></a>
  28 + <a href=""><i class="fa fa-envelope-o" aria-hidden="true"></i></a>
  29 + <a href=""><i class="fa fa-exclamation-triangle" aria-hidden="true"></i></a>
  30 + <a href=""><i class="fa fa-bar-chart" aria-hidden="true"></i></a>
34 31 </div>
  32 + </div>
35 33 </div>
36   -
37   - <div id="{{subject.slug}}" class="panel-collapse collapse category-panel-content">
  34 + </div>
  35 + <div id="{{subject.slug}}" class="panel-collapse collapse category-panel-content">
38 36 <div class="row">
39 37 <div class="col-md-6">
40   -
41   -
42   - {% if subject.professor.all|length > 0 %}
43   - <h4><b>{% trans "Professors(s) " %}: </b>
44   - {{ subject.professor.all|join:', ' }}
45   - </h4>
46   - {% else %}
47   - <h4> {% trans "It doesn't possess professors" %} </h4>
48   - {% endif %}
  38 + {% if subject.professor.all|length > 0 %}
  39 + <h4><b>{% trans "Professors(s) " %}: </b>
  40 + {{ subject.professor.all|join:', ' }}
  41 + </h4>
  42 + {% else %}
  43 + <h4> {% trans "It doesn't possess professors" %} </h4>
  44 + {% endif %}
49 45 </div>
50   -
51   -
52 46 <div class="col-xs-6 col-md-3">
53   - <p><b>{% trans "Beginning" %}:</b> {{subject.init_date}}</p>
  47 + <p><b>{% trans "Beginning" %}:</b> {{subject.init_date}}</p>
54 48 </div>
55 49 <div class="col-xs-6 col-md-3">
56   - <p><b>{% trans "End" %}:</b> {{subject.end_date}}</p>
  50 + <p><b>{% trans "End" %}:</b> {{subject.end_date}}</p>
57 51 </div>
58 52 </div>
59   -
60   -
61   -
62   -
63   - <p>{{subject.description_brief|safe}}</p>
64 53  
  54 + <p>{{subject.description_brief|safe}}</p>
65 55  
66 56 {% if request.user in subject.students.all or request.user in subject.professor.all or quest.user.is_staff %}
67 57 <a href="#"><button class="access-subject"> {% trans "Access Subject" %}</button></a>
68 58 {% else %}
69 59 <a href="#"><button class="subscribe-subject"> {% trans "Subscribe to Subject" %}</button></a>
70 60 {% endif %}
71   -
72   -</div>
73   -
  61 + </div>
74 62 </div>
75 63 \ No newline at end of file
... ...