Commit 2eecfa55154b15499fa610638c081cd8fbcf3739
1 parent
a143d808
Exists in
master
and in
3 other branches
handled case about invisble categories
Showing
4 changed files
with
194 additions
and
8 deletions
Show diff stats
amadeus/static/css/base/amadeus.css
categories/templates/categories/list.html
... | ... | @@ -38,6 +38,9 @@ |
38 | 38 | <div class="col-md-12 cards-content"> |
39 | 39 | <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> |
40 | 40 | {% for category in categories %} |
41 | + {% if category.visible %} | |
42 | + | |
43 | + | |
41 | 44 | <div class="panel panel-info"> |
42 | 45 | <div class="panel-heading"> |
43 | 46 | <div class="row"> |
... | ... | @@ -66,23 +69,22 @@ |
66 | 69 | <div class=" divMoreActions"> |
67 | 70 | </div> |
68 | 71 | {% endif %} |
69 | - {% if not user.is_staff %} | |
72 | + | |
70 | 73 | <div class="col-md-5 pull-right category-card-items"> |
71 | 74 | <a href="" ><i class="fa fa-list" aria-hidden="true"></i></a> |
72 | 75 | <a href=""><i class="fa fa-envelope-o" aria-hidden="true"></i></a> |
73 | 76 | <a href=""><i class="fa fa-exclamation-triangle" aria-hidden="true"></i></a> |
74 | 77 | <a href=""><i class="fa fa-bar-chart" aria-hidden="true"></i></a> |
75 | 78 | </div> |
76 | - {% endif %} | |
79 | + | |
77 | 80 | </div> |
78 | 81 | </div> |
79 | 82 | </div> |
80 | - <div id="{{category.slug}}" class="panel-collapse collapse category-panel-content"> | |
83 | + <div id="{{category.slug}}" class="panel-collapse panel-body collapse category-panel-content"> | |
81 | 84 | <input type="hidden" class="log_url" value="{% url 'categories:view_log' category.id %}" /> |
82 | 85 | <input type="hidden" class="log_id" value="" /> |
83 | - | |
84 | - {% if category.coordinators.all|length > 0 %} | |
85 | - <h4><b>{% trans "Coordinator(s) " %}:</b> | |
86 | + {% if category.coordinators.all|length > 0 %} | |
87 | + <h4><b>{% trans "Coordinator(s) " %}: </b> | |
86 | 88 | {{ category.coordinators.all|join:', ' }} |
87 | 89 | </h4> |
88 | 90 | {% else %} |
... | ... | @@ -90,8 +92,101 @@ |
90 | 92 | {% endif %} |
91 | 93 | |
92 | 94 | {{category.description|safe}} |
95 | + | |
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 | + <div class="panel-group" id="subject-accordion" role="tablist" aria-multiselectable="true"> | |
100 | + {% for subject in category.subjects %} | |
101 | + {% include "subjects/subject_card.html" %} | |
102 | + {% endfor %} | |
103 | + </div> | |
104 | + | |
105 | + | |
93 | 106 | </div> |
107 | + | |
108 | + | |
109 | + | |
110 | + | |
111 | + {% comment %} | |
112 | + <div id="{{category.slug}}" class="panel-collapse collapse"> | |
113 | + {% for subject in subjects %} | |
114 | + {% include "categories/category_card.html" %} | |
115 | + {% endfor %} | |
116 | + </div> | |
117 | + {% endcomment %} | |
118 | + </div> | |
119 | + | |
120 | + {% elif request.user in category.coordinators.all or request.user.is_staff %} | |
121 | + | |
122 | + | |
123 | + | |
124 | + <div class="panel panel-invisible"> | |
125 | + <div class="panel-heading"> | |
126 | + <div class="row"> | |
127 | + <div class="col-md-12 category-header"> | |
128 | + <h4 class="panel-title"> | |
129 | + <a class="category-course-link pull-left" data-parent="#accordion" data-toggle="collapse" href="#{{category.slug}}"> | |
130 | + <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}} | |
131 | + </a> | |
132 | + </h4> | |
133 | + {% if user.is_staff or user in category.coordinators.all %} | |
134 | + <div class=" divMoreActions"> | |
135 | + <div class="btn-group"> | |
136 | + <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | |
137 | + <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> | |
138 | + </button> | |
139 | + <ul class="dropdown-menu pull-right" aria-labelledby="moreActions"> | |
140 | + {% if user.is_staff %} | |
141 | + <li><a href="{% url 'categories:replicate' category.slug %}"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i>{% trans 'Replicate' %}</a></li> | |
142 | + {% endif %} | |
143 | + <li><a href="{% url 'categories:update' category.slug %}"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i>{% trans 'Edit' %}</a></li> | |
144 | + <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> {% trans 'Remove' %}</a></li> | |
145 | + </ul> | |
146 | + </div> | |
147 | + </div> | |
148 | + {% else %} | |
149 | + <div class=" divMoreActions"> | |
150 | + </div> | |
151 | + {% endif %} | |
152 | + | |
153 | + <div class="col-md-5 pull-right category-card-items"> | |
154 | + <a href="" ><i class="fa fa-list" aria-hidden="true"></i></a> | |
155 | + <a href=""><i class="fa fa-envelope-o" aria-hidden="true"></i></a> | |
156 | + <a href=""><i class="fa fa-exclamation-triangle" aria-hidden="true"></i></a> | |
157 | + <a href=""><i class="fa fa-bar-chart" aria-hidden="true"></i></a> | |
158 | + </div> | |
159 | + | |
160 | + </div> | |
161 | + </div> | |
162 | + </div> | |
163 | + <div id="{{category.slug}}" class="panel-collapse panel-body collapse category-panel-content"> | |
164 | + <input type="hidden" class="log_url" value="{% url 'categories:view_log' category.id %}" /> | |
165 | + <input type="hidden" class="log_id" value="" /> | |
166 | + {% if category.coordinators.all|length > 0 %} | |
167 | + <h4><b>{% trans "Coordinator(s) " %}: </b> | |
168 | + {{ category.coordinators.all|join:', ' }} | |
169 | + </h4> | |
170 | + {% else %} | |
171 | + <h4> {% trans "It doesn't possess coordinators" %} </h4> | |
172 | + {% endif %} | |
173 | + | |
174 | + {{category.description|safe}} | |
94 | 175 | |
176 | + {% if user in category.coordinators.all %} | |
177 | + <a href="{% url 'subjects:create' category.slug %}"><button class="create-subject-btn"> {% trans "create new subject" %} </button></a> | |
178 | + {% endif %} | |
179 | + <div class="panel-group" id="subject-accordion" role="tablist" aria-multiselectable="true"> | |
180 | + {% for subject in category.subjects %} | |
181 | + {% include "subjects/subject_card.html" %} | |
182 | + {% endfor %} | |
183 | + </div> | |
184 | + | |
185 | + | |
186 | + </div> | |
187 | + | |
188 | + | |
189 | + | |
95 | 190 | |
96 | 191 | {% comment %} |
97 | 192 | <div id="{{category.slug}}" class="panel-collapse collapse"> |
... | ... | @@ -101,6 +196,8 @@ |
101 | 196 | </div> |
102 | 197 | {% endcomment %} |
103 | 198 | </div> |
199 | + | |
200 | + {% endif %} | |
104 | 201 | {% endfor %} |
105 | 202 | </div> |
106 | 203 | </div> | ... | ... |
subjects/templates/subjects/list.html
... | ... | @@ -41,6 +41,9 @@ |
41 | 41 | <div class="col-md-12 cards-content"> |
42 | 42 | <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> |
43 | 43 | {% for category in categories %} |
44 | + {% if category.visible %} | |
45 | + | |
46 | + | |
44 | 47 | <div class="panel panel-info"> |
45 | 48 | <div class="panel-heading"> |
46 | 49 | <div class="row"> |
... | ... | @@ -116,6 +119,88 @@ |
116 | 119 | </div> |
117 | 120 | {% endcomment %} |
118 | 121 | </div> |
122 | + | |
123 | + {% elif request.user in category.coordinators.all %} | |
124 | + | |
125 | + | |
126 | + | |
127 | + <div class="panel panel-danger"> | |
128 | + <div class="panel-heading"> | |
129 | + <div class="row"> | |
130 | + <div class="col-md-12 category-header"> | |
131 | + <h4 class="panel-title"> | |
132 | + <a class="category-course-link pull-left" data-parent="#accordion" data-toggle="collapse" href="#{{category.slug}}"> | |
133 | + <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}} | |
134 | + </a> | |
135 | + </h4> | |
136 | + {% if user.is_staff or user in category.coordinators.all %} | |
137 | + <div class=" divMoreActions"> | |
138 | + <div class="btn-group"> | |
139 | + <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | |
140 | + <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> | |
141 | + </button> | |
142 | + <ul class="dropdown-menu pull-right" aria-labelledby="moreActions"> | |
143 | + {% if user.is_staff %} | |
144 | + <li><a href="{% url 'categories:replicate' category.slug %}"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i>{% trans 'Replicate' %}</a></li> | |
145 | + {% endif %} | |
146 | + <li><a href="{% url 'categories:update' category.slug %}"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i>{% trans 'Edit' %}</a></li> | |
147 | + <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> {% trans 'Remove' %}</a></li> | |
148 | + </ul> | |
149 | + </div> | |
150 | + </div> | |
151 | + {% else %} | |
152 | + <div class=" divMoreActions"> | |
153 | + </div> | |
154 | + {% endif %} | |
155 | + | |
156 | + <div class="col-md-5 pull-right category-card-items"> | |
157 | + <a href="" ><i class="fa fa-list" aria-hidden="true"></i></a> | |
158 | + <a href=""><i class="fa fa-envelope-o" aria-hidden="true"></i></a> | |
159 | + <a href=""><i class="fa fa-exclamation-triangle" aria-hidden="true"></i></a> | |
160 | + <a href=""><i class="fa fa-bar-chart" aria-hidden="true"></i></a> | |
161 | + </div> | |
162 | + | |
163 | + </div> | |
164 | + </div> | |
165 | + </div> | |
166 | + <div id="{{category.slug}}" class="panel-collapse panel-body collapse category-panel-content"> | |
167 | + <input type="hidden" class="log_url" value="{% url 'categories:view_log' category.id %}" /> | |
168 | + <input type="hidden" class="log_id" value="" /> | |
169 | + {% if category.coordinators.all|length > 0 %} | |
170 | + <h4><b>{% trans "Coordinator(s) " %}: </b> | |
171 | + {{ category.coordinators.all|join:', ' }} | |
172 | + </h4> | |
173 | + {% else %} | |
174 | + <h4> {% trans "It doesn't possess coordinators" %} </h4> | |
175 | + {% endif %} | |
176 | + | |
177 | + {{category.description|safe}} | |
178 | + | |
179 | + {% if user in category.coordinators.all %} | |
180 | + <a href="{% url 'subjects:create' category.slug %}"><button class="create-subject-btn"> {% trans "create new subject" %} </button></a> | |
181 | + {% endif %} | |
182 | + <div class="panel-group" id="subject-accordion" role="tablist" aria-multiselectable="true"> | |
183 | + {% for subject in category.subjects %} | |
184 | + {% include "subjects/subject_card.html" %} | |
185 | + {% endfor %} | |
186 | + </div> | |
187 | + | |
188 | + | |
189 | + </div> | |
190 | + | |
191 | + | |
192 | + | |
193 | + | |
194 | + {% comment %} | |
195 | + <div id="{{category.slug}}" class="panel-collapse collapse"> | |
196 | + {% for subject in subjects %} | |
197 | + {% include "categories/category_card.html" %} | |
198 | + {% endfor %} | |
199 | + </div> | |
200 | + {% endcomment %} | |
201 | + </div> | |
202 | + | |
203 | + {% endif %} | |
119 | 204 | {% endfor %} |
120 | 205 | </div> |
121 | 206 | </div> | ... | ... |
subjects/views.py
... | ... | @@ -102,10 +102,10 @@ class IndexView(LoginRequiredMixin, ListView): |
102 | 102 | context['title'] = _('All Subjects') |
103 | 103 | |
104 | 104 | if self.request.user.is_staff: |
105 | - categories = self.get_queryset().order_by('name').filter(visible=True) | |
105 | + categories = self.get_queryset().order_by('name') | |
106 | 106 | else: |
107 | 107 | if self.kwargs.get('option'): |
108 | - categories = self.get_queryset().order_by('name').filter(visible=True) | |
108 | + categories = self.get_queryset().order_by('name') | |
109 | 109 | for category in categories: |
110 | 110 | category.subjects = Subject.objects.filter(category= category) |
111 | 111 | else: | ... | ... |