Commit 74e082e13997b8e03e49b909d5ee5509564e14e5

Authored by Jailson Dias
2 parents 0967b82c eda3e645

Merge branch 'refactoring' of https://github.com/amadeusproject/amadeuslms into refactoring

amadeus/templates/base.html
... ... @@ -145,7 +145,7 @@
145 145 </ul>
146 146 </li>
147 147 <li style="width:40px;">
148   - <a href="" id="contrast_button">
  148 + <a href="{% url 'themes:contrast' %}" id="contrast_button">
149 149 <i style="font-size:15px;right: 150%;" class="glyphicon glyphicon-adjust"></i>
150 150 </a>
151 151  
... ... @@ -209,11 +209,11 @@
209 209 $("#contrast_button" ).click(function() {
210 210 if (Cookies.get('contrast_check')) {
211 211 Cookies.remove('contrast_check')
212   - location.reload()
  212 + //location.reload()
213 213 }
214 214 else {
215 215 Cookies.set('contrast_check','contrast')
216   - location.reload()
  216 + //location.reload()
217 217 }
218 218  
219 219 });
... ...
analytics/static/.sass-cache/01cecb7b42e56765f6ed49ed3c70281ebdc742c7/general.sassc 0 → 100644
No preview for this file type
analytics/static/analytics/general.css
... ... @@ -3,7 +3,8 @@
3 3 border-radius: 20px;
4 4 padding: 10px;
5 5 overflow: auto;
6   - width: 100%; }
  6 + width: 100%;
  7 + background-color: #ffffff; }
7 8  
8 9 #general-report-header {
9 10 height: 10%;
... ... @@ -14,21 +15,22 @@
14 15 float: right;
15 16 display: inline-flex;
16 17 width: 50%;
17   - height: 15%; }
  18 + margin-bottom: 0px; }
18 19 #general-report-header ul li {
19 20 margin-right: 2%;
20 21 width: 50%;
21   - color: white; }
22   - #general-report-header ul li div.selected {
23   - background-color: #4dcfbd;
24   - width: 100%;
25   - text-align: center;
26   - border-radius: 20px; }
27   - #general-report-header ul li div {
28   - background-color: #0f8a9a;
29   - width: 100%;
30   - text-align: center;
31   - border-radius: 20px; }
  22 + color: white;
  23 + font-size: 20px;
  24 + background-color: #0f8a9a;
  25 + width: 100%;
  26 + text-align: center;
  27 + border-radius: 20px;
  28 + height: 30px; }
  29 + #general-report-header ul li.selected {
  30 + background-color: #4dcfbd;
  31 + width: 100%;
  32 + text-align: center;
  33 + border-radius: 20px; }
32 34  
33 35 #most-used-tags-header {
34 36 background: linear-gradient(to right, #0e8999, #6bf0ce);
... ... @@ -40,21 +42,19 @@
40 42 #most-used-tags-header h4 {
41 43 margin-left: 1%; }
42 44  
43   -.data-container {
44   - width: 80px;
45   - height: 40px; }
46   -
47 45 .tag-cloud {
48 46 border-radius: 25px;
49   - color: #ffffff;
50   - width: 80px; }
  47 + color: #ffffff; }
51 48  
52 49 .tag-name {
53 50 color: #ffffff;
54 51 font-size: 10px; }
55 52  
56 53 #left-data-selector {
57   - background: linear-gradient(#0e8999, #6bf0ce); }
  54 + background: linear-gradient(#0e8999, #6bf0ce);
  55 + margin-top: 5%;
  56 + padding-top: 3%;
  57 + padding-bottom: 2%; }
58 58  
59 59 .chart {
60 60 width: 30%;
... ... @@ -64,11 +64,11 @@
64 64  
65 65 .selector {
66 66 width: 90%;
67   - height: 20%;
  67 + height: 40px;
68 68 color: white;
69 69 padding-left: 5px;
70 70 background-color: #009688;
71   - margin-top: 10px;
  71 + margin-top: 5px;
72 72 border-radius: 0px 20px 20px 0px; }
73 73 .selector p {
74 74 padding-top: 10px;
... ... @@ -87,13 +87,31 @@
87 87 background-color: #52b7bd;
88 88 width: 80%;
89 89 margin-left: 2%;
90   - margin-top: 2%;
  90 + margin-top: 4%;
  91 + position: relative;
91 92 padding-left: 0;
92 93 color: white;
  94 + border: 2px solid #52b7bd;
93 95 transition: width 2s, height 2s, background-color 2s, transform 2s; }
94 96 .most-accessed-list li {
95 97 padding-left: 1%; }
96 98  
  99 +.most-accessed-list:after, .most-accessed-list:before {
  100 + bottom: 100%;
  101 + left: 50%;
  102 + border: solid transparent;
  103 + content: " ";
  104 + height: 0;
  105 + width: 0;
  106 + position: absolute;
  107 + pointer-events: none; }
  108 +
  109 +.most-accessed-list:before {
  110 + border-width: 12px;
  111 + margin-left: -50%;
  112 + border-color: rgba(136, 183, 213, 0);
  113 + border-bottom-color: #52b7bd; }
  114 +
97 115 .most-accessed-item:hover {
98 116 background-color: #3aa7ad; }
99 117  
... ...
analytics/static/analytics/general.css.map
1 1 {
2 2 "version": 3,
3   -"mappings": "AAEA,YAAY;EACR,MAAM,EAAE,iBAAiB;EACzB,aAAa,EAAE,IAAI;EACnB,OAAO,EAAE,IAAI;EACb,QAAQ,EAAE,IAAI;EACd,KAAK,EAAE,IAAI;;AAEf,sBAAsB;EAClB,MAAM,EAAE,GAAG;EACX,OAAO,EAAE,KAAK;EACd,yBAAE;IACE,KAAK,EAbC,OAAO;EAejB,yBAAE;IACE,KAAK,EAAE,KAAK;IACZ,OAAO,EAAE,WAAW;IACpB,KAAK,EAAE,GAAG;IACV,MAAM,EAAE,GAAG;IAEX,4BAAE;MACE,YAAY,EAAE,EAAE;MAChB,KAAK,EAAE,GAAG;MACV,KAAK,EAAE,KAAK;MAEZ,yCAAY;QACR,gBAAgB,EAAE,OAAO;QACzB,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,MAAM;QAClB,aAAa,EAAE,IAAI;MAEvB,gCAAG;QACC,gBAAgB,EAAE,OAAO;QACzB,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,MAAM;QAClB,aAAa,EAAE,IAAI;;AAInC,sBAAsB;EAClB,UAAU,EAAE,2CAA2C;EACvD,MAAM,EAAE,IAAI;EACZ,aAAa,EAAE,IAAI;EACnB,KAAK,EAAE,OAAO;EACd,WAAW,EAAE,GAAG;EAChB,UAAU,EAAE,IAAI;EAEhB,yBAAE;IACE,WAAW,EAAE,EAAE;;AAEvB,eAAe;EACX,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,IAAI;;AAEhB,UAAU;EACN,aAAa,EAAE,IAAI;EACnB,KAAK,EAAE,OAAO;EACd,KAAK,EAAE,IAAI;;AAIf,SAAS;EACL,KAAK,EAAE,OAAO;EACd,SAAS,EAAE,IAAI;;AAGnB,mBAAmB;EACf,UAAU,EAAE,iCAAmC;;AAEnD,MAAM;EACF,KAAK,EAAE,GAAG;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AE;EACd,QAAQ,EAAE,QAAQ;EAClB,YAAY,EAAE,CAAC;EACf,KAAK,EAAE,KAAK;EACZ,MAAM,EAAE,iBAAiB;EACzB,UAAU,EAAE,sDAAsD;EAElE,sBAAE;IACE,YAAY,EAAE,EAAE;;AAExB,qDAAqD;EACjD,MAAM,EAAE,IAAI;EACZ,IAAI,EAAE,GAAG;EACT,MAAM,EAAE,iBAAiB;EACzB,OAAO,EAAE,GAAG;EACZ,MAAM,EAAE,CAAC;EACT,KAAK,EAAE,CAAC;EACR,QAAQ,EAAE,QAAQ;EAClB,cAAc,EAAE,IAAI;;AAGxB,0BAA0B;EACtB,YAAY,EAAE,IAAI;EAClB,WAAW,EAAE,IAAI;EACjB,YAAY,EAAE,sBAAsB;EACpC,mBAAmB,EAAE,OAAO;;AAEhC,yBAAyB;EACrB,gBAAgB,EAAE,OAAO",
4 4 "sources": ["general.sass"],
5 5 "names": [],
6 6 "file": "general.css"
... ...
analytics/static/analytics/general.sass
... ... @@ -6,6 +6,7 @@ $title-color: #009688
6 6 padding: 10px
7 7 overflow: auto
8 8 width: 100%
  9 + background-color: #ffffff
9 10  
10 11 #general-report-header
11 12 height: 10%
... ... @@ -17,25 +18,28 @@ $title-color: #009688
17 18 float: right
18 19 display: inline-flex
19 20 width: 50%
20   - height: 15%
  21 + margin-bottom: 0px
21 22  
22 23 li
23 24 margin-right: 2%
24 25 width: 50%
25 26 color: white
  27 + font-size: 20px
  28 + background-color: #0f8a9a
  29 + width: 100%
  30 + text-align: center
  31 + border-radius: 20px
  32 + height: 30px
26 33  
27   - div.selected
28   - background-color: #4dcfbd
29   - width: 100%
30   - text-align: center
31   - border-radius: 20px
32 34  
33   - div
34   - background-color: #0f8a9a
35   - width: 100%
36   - text-align: center
37   - border-radius: 20px
  35 + li.selected
  36 + background-color: #4dcfbd
  37 + width: 100%
  38 + text-align: center
  39 + border-radius: 20px
38 40  
  41 +
  42 +
39 43  
40 44  
41 45 #most-used-tags-header
... ... @@ -49,14 +53,11 @@ $title-color: #009688
49 53 h4
50 54 margin-left: 1%
51 55  
52   -.data-container
53   - width: 80px
54   - height: 40px
55 56  
56 57 .tag-cloud
57 58 border-radius: 25px
58 59 color: #ffffff
59   - width: 80px
  60 +
60 61  
61 62  
62 63  
... ... @@ -67,6 +68,9 @@ $title-color: #009688
67 68  
68 69 #left-data-selector
69 70 background: linear-gradient( #0e8999, #6bf0ce )
  71 + margin-top: 5%
  72 + padding-top: 3%
  73 + padding-bottom: 2%
70 74  
71 75 .chart
72 76 width: 30%
... ... @@ -76,11 +80,11 @@ $title-color: #009688
76 80  
77 81 .selector
78 82 width: 90%
79   - height: 20%
  83 + height: 40px
80 84 color: white
81 85 padding-left: 5px
82 86 background-color: #009688
83   - margin-top: 10px
  87 + margin-top: 5px
84 88 border-radius: 0px 20px 20px 0px
85 89 p
86 90 padding-top: 10px
... ... @@ -101,13 +105,32 @@ $title-color: #009688
101 105 background-color: #52b7bd
102 106 width: 80%
103 107 margin-left: 2%
104   - margin-top: 2%
  108 + margin-top: 4%
  109 + position: relative
105 110 padding-left: 0
106 111 color: white
  112 + border: 2px solid #52b7bd
107 113 transition: width 2s, height 2s, background-color 2s, transform 2s
108 114  
109 115 li
110 116 padding-left: 1%
111 117  
  118 +.most-accessed-list:after, .most-accessed-list:before
  119 + bottom: 100%
  120 + left: 50%
  121 + border: solid transparent
  122 + content: " "
  123 + height: 0
  124 + width: 0
  125 + position: absolute
  126 + pointer-events: none
  127 +
  128 +
  129 +.most-accessed-list:before
  130 + border-width: 12px
  131 + margin-left: -50%
  132 + border-color: rgba(136, 183, 213, 0)
  133 + border-bottom-color: #52b7bd
  134 +
112 135 .most-accessed-item:hover
113 136 background-color: #3aa7ad
114 137 \ No newline at end of file
... ...
analytics/static/analytics/js/behavior.js
... ... @@ -56,20 +56,13 @@ var selectors_options = {
56 56  
57 57 $(e).after(string_build);
58 58 var new_elem = $(e).next();
59   - new_elem.slideDown();
  59 + new_elem.slideDown({easing: 'easeInOutSine'}, 5000);
60 60 $(e).attr("opened", true);
61 61  
62 62 },
63 63 deleteChildren: function(e){
64   - console.log("delete children");
65 64 var most_accessed_list = $(e).next();
66   - $(most_accessed_list).animate(
67   - {height: 0,
68   - opacity: 0.1
69   - }, 1000, function(){
70   - $(this).remove(); //remove list from UI
71   - });
72   -
  65 + $(most_accessed_list).slideUp({easing: 'easeInOutSine'}, 1200);
73 66 $(e).removeAttr("opened"); //remove attribute so it can call API again
74 67 },
75 68 };
... ...
analytics/static/analytics/js/charts.js
... ... @@ -208,17 +208,17 @@ var charts = {
208 208  
209 209 groups.on("mouseover", function(d){
210 210 //$("#"+"user_tooltip_"+d['user_id']).show();
211   - tooltip_div.transition().duration(200).style("opacity", .9);
  211 + tooltip_div.transition().duration(500).style("opacity", .9);
212 212 tooltip_div.html(d['user'] + '</br>' + d['count'] + ' acessos')
213 213 .style("left", (d3.event.pageX) + "px")
214 214 .style("top", (d3.event.pageY - 28) + "px");
215   - console.log(d3.event.pageX);
216   - console.log(d3.event.pageY);
217 215 });
218 216  
219 217  
220 218 groups.on("mouseout", function(d){
221 219 //$("#"+"user_tooltip_"+d['user_id']).hide();
  220 + tooltip_div.transition().duration(500).style("opacity", 0);
  221 +
222 222 });
223 223  
224 224  
... ... @@ -253,7 +253,6 @@ var charts = {
253 253 simulation.nodes(dataset)
254 254 .on('tick', ticked); //so all data points are attached to it
255 255  
256   - console.log("finished simulation");
257 256 function ticked(){
258 257 groups.attr("transform", function(d){
259 258 return "translate(" + d.x + "," + d.y + ")";
... ... @@ -371,7 +370,6 @@ var charts = {
371 370 return maximum
372 371 }
373 372  
374   - console.log(dataset);
375 373  
376 374 var container_div = d3.select("#most-used-tags-body");
377 375 var svg = container_div.append("svg").attr("width", "100%").attr("height", height)
... ... @@ -394,7 +392,7 @@ var charts = {
394 392 return Math.floor(Math.random() * (max - min)) + min;
395 393 }
396 394  
397   - var xScale = d3.scaleSqrt().domain([min(), max()]).range([10,50]);
  395 + var xScale = d3.scaleSqrt().domain([min(), max()]).range([10,80]);
398 396 var tag_cloud = svg.selectAll('.tag-cloud-div')
399 397 .data(dataset)
400 398 .enter()
... ... @@ -409,7 +407,7 @@ var charts = {
409 407 return xScale(d['count'])*1.2;
410 408 })
411 409 .attr("height", function(d){
412   - return xScale(d["count"])*0.8;
  410 + return xScale(d["count"])*0.4;
413 411 })
414 412 .attr("fill", function(d, i) {
415 413 return color(getRandomInt(0,3));
... ... @@ -422,8 +420,12 @@ var charts = {
422 420 .text(function(d){
423 421 return d['name'];
424 422 })
425   - .attr("x", 20)
426   - .attr("y", 25)
  423 + .attr("x", function(d){
  424 + return xScale(d['count'])*0.2;
  425 + })
  426 + .attr("y", function(d){
  427 + return xScale(d["count"])*0.2;
  428 + })
427 429 .attr("class", "tag-name")
428 430 .attr("fill", "#ffffff");
429 431  
... ... @@ -432,7 +434,7 @@ var charts = {
432 434 .force("x", d3.forceX(width/2).strength(0.05))
433 435 .force("y", d3.forceY(height/2).strength(0.05))
434 436 .force("collide", d3.forceCollide(function(d){
435   - return 30;
  437 + return xScale(d['count'])*0.4;
436 438 }));
437 439  
438 440 //simulation
... ...
analytics/templates/analytics/category.html 0 → 100644
... ... @@ -0,0 +1,25 @@
  1 +{% extends 'base.html' %}
  2 +
  3 +{% load static i18n pagination %}
  4 +{% load django_bootstrap_breadcrumbs %}
  5 +{% block style %}
  6 + <link rel="stylesheet" type="text/css" href="{% static 'analytics/general.css' %}">
  7 +{% endblock style %}
  8 +
  9 +{% block javascript %}
  10 + <script type="text/javascript" src="{% static "analytics/js/charts.js" %}"></script>
  11 + <script type="text/javascript" src=" {% static "analytics/js/behavior.js" %} "></script>
  12 +{% endblock javascript %}
  13 +
  14 +{% block breadcrumbs %}
  15 + {{ block.super }}
  16 +
  17 + {% trans 'Analytics Category' as category %}
  18 +
  19 + {% breadcrumb category 'dashboard:view_general' %}
  20 +{% endblock %}
  21 +
  22 +
  23 +{% block content %}
  24 + test
  25 +{% endblock content %}
0 26 \ No newline at end of file
... ...
analytics/templates/analytics/general.html
... ... @@ -24,15 +24,17 @@
24 24 <section id="core-subjects-options-div">
25 25 <nav>
26 26 <ul class="core-subjects-options report-menu-choice">
27   - <li class="active">
28   - {% trans "Platform Report" %}
29   - </li>
30   - <li>
31   - {% trans "Category Report" %}
32   - </li>
33   - <li>
34   - {% trans "Subject Report" %}
35   - </li>
  27 +
  28 + <li class="active">
  29 + {% trans "Platform Report" %}
  30 + </li>
  31 + <li>
  32 + {% trans "Category Report" %}
  33 + </li>
  34 + <li>
  35 + {% trans "Subject Report" %}
  36 + </li>
  37 +
36 38 </ul>
37 39 </nav>
38 40 </section>
... ... @@ -42,11 +44,11 @@
42 44 <h3>{% trans "Amadeus Report" %}</h3>
43 45  
44 46 <ul id="report-header-options">
45   - <li >
46   - <div class="selected">{% trans "Focus" %}<div>
  47 + <li class="selected">
  48 + {% trans "Focus" %}
47 49 </li>
48 50 <li>
49   - <div>{% trans "Log" %}<div>
  51 + {% trans "Log" %}
50 52 </li>
51 53 </ul>
52 54 </header>
... ... @@ -65,10 +67,7 @@
65 67 </section>
66 68 <section class="bottom-section">
67 69 <div class="chart left-chart">
68   - <div id="date-selector">
69   - <p>{% trans "Between" %} 20-20-17 {% trans "and" %}
70   - 20-20-17</p>
71   - </div>
  70 +
72 71  
73 72 <div id="left-data-selector">
74 73  
... ...
analytics/views.py
1 1 from django.shortcuts import render
2 2  
3   -# Create your views here.
4 3 from django.views import generic
5 4 from django.db.models import Count
  5 +from django.core.urlresolvers import reverse_lazy
6 6  
7 7 from subjects.models import Tag, Subject
8 8 from topics.models import Resource
9 9 from users.models import User
10 10 from django.http import HttpResponse, JsonResponse
11 11 from log.models import Log
  12 +import operator
  13 +from django.utils.translation import ugettext_lazy as _
  14 +from django.shortcuts import render, get_object_or_404, redirect
12 15  
13 16  
14 17 class GeneralView(generic.TemplateView):
15 18 template_name = "analytics/general.html"
16 19  
  20 + def dispatch(self, request, *args, **kwargs):
  21 +
  22 + if not request.user.is_staff:
  23 + self.template_name = "analytics/category.html"
  24 + return super(GeneralView, self).dispatch(request, *args, **kwargs)
  25 +
  26 +
17 27 def get_context_data(self, **kwargs):
18 28 context = {}
19 29  
... ... @@ -70,7 +80,7 @@ def most_accessed_subjects(request):
70 80  
71 81 #order the values of the dictionary by the count in descendent order
72 82 subjects = sorted(subjects.values(), key = lambda x: x['count'], reverse=True )
73   - subjects = subjects[:30]
  83 + subjects = subjects[:5]
74 84  
75 85 return JsonResponse(subjects, safe=False)
76 86  
... ... @@ -94,10 +104,17 @@ def most_accessed_categories(request):
94 104 return JsonResponse(categories, safe= False)
95 105  
96 106 def most_accessed_resource_kind(request):
97   - resources_names = [cls.__name__ for cls in Resource.__subclasses__()]
98   - print(resources_names)
99   - resources = {}
  107 + resources = Resource.objects.distinct()
100 108  
  109 + data = {}
  110 + for resource in resources:
  111 + key = resource.__dict__['_my_subclass']
  112 + if key in data.keys():
  113 + data[key]['count'] = data[key]['count'] + 1
  114 + else:
  115 + data[key] = {'name': key, 'count': 1}
  116 +
  117 + data = sorted(data.values(), key = lambda x: x['count'], reverse= True)
101 118 mapping = {}
102 119 mapping['pdffile'] = str(_('PDF File'))
103 120 mapping['goals'] = str(_('Topic Goals'))
... ... @@ -107,10 +124,9 @@ def most_accessed_resource_kind(request):
107 124 mapping['ytvideo'] = str(_('YouTube Video'))
108 125 mapping['webpage'] = str(_('WebPage'))
109 126  
110   -
111   -
112   -
113   - return JsonResponse(resources, safe = False)
  127 + data = [ {'name': mapping[resource['name']] , 'count': resource['count']} for resource in data]
  128 + data = data[:5]
  129 + return JsonResponse(data, safe=False)
114 130  
115 131  
116 132 def most_active_users(request):
... ...
themes/urls.py
... ... @@ -5,4 +5,5 @@ urlpatterns = [
5 5 url(r'^$', views.IndexView.as_view(), name = 'manage'),
6 6 url(r'^basic_elements$', views.BasicElementsSettings.as_view(), name = 'basic'),
7 7 url(r'^css_selector$', views.CSSStyleSettings.as_view(), name = 'css'),
  8 + url(r'^contrast$',views.Contrast, name = 'contrast'),
8 9 ]
... ...
themes/views.py
... ... @@ -5,7 +5,7 @@ from django.core.urlresolvers import reverse, reverse_lazy
5 5 from django.utils.translation import ugettext_lazy as _
6 6 from django.http import HttpResponse, JsonResponse, HttpResponseRedirect,HttpRequest
7 7 from django.shortcuts import redirect
8   -
  8 +from log.decorators import log_decorator
9 9 from braces import views as braces_mixins
10 10  
11 11 from .models import Themes
... ... @@ -79,3 +79,8 @@ class CSSStyleSettings(braces_mixins.LoginRequiredMixin, braces_mixins.Staffuser
79 79 context['settings_menu_active'] = "settings_menu_active"
80 80  
81 81 return context
  82 +
  83 +@log_decorator("contrast", "click", "contrast")
  84 +def Contrast(request):
  85 + caminho = request.META.get('HTTP_REFERER')
  86 + return HttpResponseRedirect(caminho)
... ...
topics/urls.py
... ... @@ -10,5 +10,4 @@ urlpatterns = [
10 10 url(r'^view_log/(?P<topic>[\w_-]+)/$', views.topic_view_log, name = 'view_log'),
11 11 url(r'^update_order/$', views.update_order, name = 'update_order'),
12 12 url(r'^update_resource_order/$', views.update_resource_order, name = 'update_resource_order'),
13   - url(r'^count_resources/$', views.getResourceCount, name='resource_count'),
14 13 ]
... ...
topics/views.py
... ... @@ -20,7 +20,6 @@ from subjects.models import Subject
20 20 from .models import Topic, Resource
21 21 from .forms import TopicForm
22 22  
23   -import operator
24 23  
25 24 class CreateView(LoginRequiredMixin, LogMixin, generic.edit.CreateView):
26 25 log_component = 'topic'
... ... @@ -276,27 +275,3 @@ def update_resource_order(request):
276 275 return JsonResponse({'message': 'No data received'})
277 276  
278 277  
279   -def getResourceCount(request):
280   - resources = Resource.objects.distinct()
281   -
282   - data = {}
283   - for resource in resources:
284   - key = resource.__dict__['_my_subclass']
285   - if key in data.keys():
286   - data[key] = data[key] + 1
287   - else:
288   - data[key] = 1
289   -
290   - data = [(key,value) for key,value in sorted(data.items(), key=operator.itemgetter(1), reverse=True)]
291   -
292   - others = data[4:]
293   - total_others = 0
294   - for key,value in others:
295   - total_others += value
296   -
297   - del data[4:] #remove from the 5th element
298   - data.append(("others", total_others)) #so I have the sum of all other resources added up
299   - real_data = []
300   - for key,value in data:
301   - real_data.append((key,value))
302   - return JsonResponse(real_data, safe=False)
... ...
users/templates/users/login.html
... ... @@ -87,7 +87,7 @@
87 87 <span >[{{LANGUAGE_CODE}}] </span>
88 88  
89 89 </a>
90   - <a href="" id = "contrast_button" style="margin-left:10px;"><i class="glyphicon glyphicon-adjust"></i></a>
  90 + <a href="{% url 'themes:contrast' %}" id = "contrast_button" style="margin-left:10px;"><i class="glyphicon glyphicon-adjust"></i></a>
91 91 <ul class="dropdown-menu">
92 92  
93 93  
... ... @@ -150,11 +150,11 @@
150 150 $("#contrast_button" ).click(function() {
151 151 if (Cookies.get('contrast_check')) {
152 152 Cookies.remove('contrast_check')
153   - location.reload()
  153 + //location.reload()
154 154 }
155 155 else {
156 156 Cookies.set('contrast_check','contrast')
157   - location.reload()
  157 + //location.reload()
158 158 }
159 159  
160 160 });
... ...