Commit 386b06695f12b70e96ced4a3d615fe91f85cc0d9

Authored by Felipe Bormann
1 parent 3e7ba4fc

added category selector for admin and coordinators inside categories_dashboard page

dashboards/static/.sass-cache/ca9fbb140c72645dd684674b13e9ea087dfd18ab/dashboards_category.sassc 0 → 100644
No preview for this file type
dashboards/static/dashboards/.sass-cache/d1f4112ca6d0e14bdf64d22b0b14a2322f24cc83/dashboards_category.sassc 0 → 100644
No preview for this file type
dashboards/static/dashboards/css/dashboards_category.css 0 → 100644
... ... @@ -0,0 +1,17 @@
  1 +#category-selector {
  2 + background: transparent;
  3 + font-size: 1.5em;
  4 + font-weight: 700;
  5 + color: #5b8583;
  6 + border: none;
  7 + border-right: 2px solid;
  8 + border-left: 2px solid; }
  9 +
  10 +#category-selector option {
  11 + background: #ffffff;
  12 + color: #5b8583; }
  13 +
  14 +#category-selector option:hover {
  15 + background: red; }
  16 +
  17 +/*# sourceMappingURL=dashboards_category.css.map */
... ...
dashboards/static/dashboards/css/dashboards_category.css.map 0 → 100644
... ... @@ -0,0 +1,7 @@
  1 +{
  2 +"version": 3,
  3 +"mappings": "AAAA,kBAAkB;EACjB,UAAU,EAAE,WAAW;EACvB,SAAS,EAAE,KAAK;EAChB,WAAW,EAAE,GAAG;EAChB,KAAK,EAAE,OAAO;EACd,MAAM,EAAE,IAAI;EACZ,YAAY,EAAE,SAAS;EACvB,WAAW,EAAE,SAAS;;AAEvB,yBAAyB;EACxB,UAAU,EAAE,OAAO;EACnB,KAAK,EAAE,OAAO;;AAEf,+BAA+B;EAC9B,UAAU,EAAE,GAAG",
  4 +"sources": ["dashboards_category.sass"],
  5 +"names": [],
  6 +"file": "dashboards_category.css"
  7 +}
0 8 \ No newline at end of file
... ...
dashboards/static/dashboards/css/dashboards_category.sass 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +#category-selector
  2 + background: transparent
  3 + font-size: 1.5em
  4 + font-weight: 700
  5 + color: #5b8583
  6 + border: none
  7 + border-right: 2px solid
  8 + border-left: 2px solid
  9 +
  10 +#category-selector option
  11 + background: #ffffff
  12 + color: #5b8583
  13 +
  14 +#category-selector option:hover
  15 + background: red
0 16 \ No newline at end of file
... ...
dashboards/static/dashboards/js/behavior_categories.js 0 → 100644
dashboards/templates/dashboards/category.html
... ... @@ -4,11 +4,11 @@
4 4 {% load django_bootstrap_breadcrumbs %}
5 5 {% block style %}
6 6 <link rel="stylesheet" type="text/css" href="{% static 'analytics/general.css' %}">
  7 + <link rel="stylesheet" type="text/css" href="{% static 'dashboards/css/dashboards_category.css' %}">
7 8 {% endblock style %}
8 9  
9 10 {% block javascript %}
10 11 <script type="text/javascript" src="{% static "analytics/js/charts.js" %}"></script>
11   - <script type="text/javascript" src=" {% static "dashboards/js/behavior.js" %} "></script>
12 12 {% endblock javascript %}
13 13  
14 14 {% block breadcrumbs %}
... ... @@ -24,11 +24,13 @@
24 24 <section id="core-subjects-options-div">
25 25 <nav>
26 26 <ul class="core-subjects-options report-menu-choice">
27   -
28   - <li>
  27 + {% if user.is_staff %}
  28 + <a href="{% url 'dashboards:view_general' %}"><li>
29 29 {% trans "Platform Report" %}
30   - </li>
31   - <a href="{% url 'dashboards:' %}"><li class="active">
  30 + </li></a>
  31 + {% endif %}
  32 +
  33 + <a href="{% url 'dashboards:view_categories' %}"><li class="active">
32 34 {% trans "Category Report" %}
33 35 </li></a>
34 36 <li>
... ... @@ -42,7 +44,11 @@
42 44 <section id="general-report">
43 45 <header id="general-report-header">
44 46 <h3>{{category.name}} {% trans "Category Report" %}</h3>
45   -
  47 + <select id="category-selector">
  48 + {% for category in categories %}
  49 + <option>{{category.name}}</option>
  50 + {% endfor %}
  51 + </select>
46 52 <ul id="report-header-options">
47 53 <li class="selected">
48 54 {% trans "Focus" %}
... ...
dashboards/templates/dashboards/general.html
... ... @@ -29,7 +29,7 @@
29 29 <li class="active">
30 30 {% trans "Platform Report" %}
31 31 </li>
32   - <a href=""><li>
  32 + <a href="{% url 'dashboards:view_categories' %}"><li>
33 33 {% trans "Category Report" %}
34 34 </li></a>
35 35 <li>
... ...
dashboards/urls.py
... ... @@ -4,5 +4,5 @@ from . import views
4 4  
5 5 urlpatterns = [
6 6 url(r'^general/$', views.GeneralView.as_view(), name='view_general'),
7   -
  7 + url(r'^categories/$', views.CategoryView.as_view(), name='view_categories'),
8 8 ]
9 9 \ No newline at end of file
... ...
dashboards/views.py
... ... @@ -17,6 +17,8 @@ from datetime import date, timedelta, datetime
17 17 import calendar
18 18 from collections import OrderedDict
19 19  
  20 +from categories.models import Category
  21 +
20 22  
21 23 class GeneralView(generic.TemplateView):
22 24 template_name = "dashboards/general.html"
... ... @@ -24,7 +26,7 @@ class GeneralView(generic.TemplateView):
24 26 def dispatch(self, request, *args, **kwargs):
25 27  
26 28 if not request.user.is_staff:
27   - return redirect('analytics:view_category_data')
  29 + return redirect('dashboards:view_categories')
28 30 return super(GeneralView, self).dispatch(request, *args, **kwargs)
29 31  
30 32  
... ... @@ -44,5 +46,14 @@ class CategoryView(generic.TemplateView):
44 46  
45 47 def get_context_data(self, **kwargs):
46 48 context = {}
  49 +
  50 + context['categories'] = self.categories_associated_with_user(self.request.user)
47 51  
48   - return context
49 52 \ No newline at end of file
  53 + return context
  54 +
  55 + def categories_associated_with_user(self, user):
  56 + if user.is_staff:
  57 + categories = Category.objects.all()
  58 + else:
  59 + categories = Category.objects.filter(coordinators__in = [user])
  60 + return categories
50 61 \ No newline at end of file
... ...