diff --git a/amadeus/settings.py b/amadeus/settings.py
index 88415ea..f7406b9 100644
--- a/amadeus/settings.py
+++ b/amadeus/settings.py
@@ -83,6 +83,7 @@ INSTALLED_APPS = [
'webconference',
'news',
'analytics',
+ 'dashboards',
]
MIDDLEWARE_CLASSES = [
diff --git a/amadeus/templates/base.html b/amadeus/templates/base.html
index ecc415b..e4474e8 100644
--- a/amadeus/templates/base.html
+++ b/amadeus/templates/base.html
@@ -251,7 +251,7 @@
-
+
{% endblock %}
@@ -306,7 +306,7 @@
-
+
diff --git a/amadeus/urls.py b/amadeus/urls.py
index 5382994..74da1a1 100644
--- a/amadeus/urls.py
+++ b/amadeus/urls.py
@@ -46,6 +46,7 @@ urlpatterns = [
url(r'^news/', include('news.urls', namespace='news')),
url(r'^i18n/', include('django.conf.urls.i18n')),
url(r'^analytics/', include('analytics.urls', namespace='analytics')),
+ url(r'^dashboards/', include('dashboards.urls', namespace='dashboards')),
#API
url(r'^o/', include('oauth2_provider.urls', namespace='oauth2_provider')),
#S3Direct
diff --git a/analytics/static/analytics/js/behavior.js b/analytics/static/analytics/js/behavior.js
deleted file mode 100644
index 4e42c01..0000000
--- a/analytics/static/analytics/js/behavior.js
+++ /dev/null
@@ -1,96 +0,0 @@
-
-
-
-$(document).ready(function(){
- selectors_options.init();
-
- //for month selector
-
- $('#month_selector').change(function(){
- $.get('/analytics/amount_active_users_per_day', {month: $(this).val() }).done(function(data){
- charts.month_heatmap(data, '#right-chart-body');
-
- });
- });
- //week date selector at the right-chart field
- $('input.datepicker').datetimepicker({
- format: 'L',
- defaultDate: new Date(),
- }).on('dp.change', function(ev){
- $.get('/analytics/get_days_of_the_week_log', {date: ev.date._i}).done(function(data){
- charts.month_heatmap(data, '#bottom-right-chart-body');
- });
-
- });
-
-
-
-
-});
-
-
-
-var selectors_options = {
- init: function(){
- selectors = $("div.selector");
- selectors.click(function(e){
- selectors_options.loadData(e.currentTarget);
- });
- },
- loadData: function(e){
- if (e){
- opened = $(e).attr('opened');
- if (typeof opened !== typeof undefined && opened !== false){
- selectors_options.deleteChildren(e);
- }else {
- switch(e.attributes['data-url'].value){
- case "subjects":
- var url = "/analytics/most_accessed_subjects";
- break;
- case "categories":
- var url = "/analytics/most_accessed_categories";
- break;
- case "resources":
- var url = "/analytics/most_accessed_resources";
- break;
-
- }
-
- }
- }
- if(url){
- $.get(url, function(dataset){
- return dataset;
- }).done(function(data){
- selectors_options.modifyElement(e, data);
-
- }).fail(function(error){
- console.log("couldn't complete get request");
- });
- }
-
-
- },
- modifyElement: function(e, data){
- var string_build = "";
- string_build += '';
-
- data.forEach(function(datum){
- string_build += '- ' +datum.name+ ' ' + datum.count+ '
';
- });
- string_build += "
";
-
- $(e).after(string_build);
- var new_elem = $(e).next();
- new_elem.slideDown({easing: 'easeInOutSine'}, 5000);
- $(e).attr("opened", true);
-
- },
- deleteChildren: function(e){
- var most_accessed_list = $(e).next();
- $(most_accessed_list).slideUp({easing: 'easeInOutSine'}, 1200);
- $(e).removeAttr("opened"); //remove attribute so it can call API again
- },
-};
-
-
diff --git a/analytics/templates/analytics/category.html b/analytics/templates/analytics/category.html
deleted file mode 100644
index 16674a1..0000000
--- a/analytics/templates/analytics/category.html
+++ /dev/null
@@ -1,25 +0,0 @@
-{% extends 'base.html' %}
-
-{% load static i18n pagination %}
-{% load django_bootstrap_breadcrumbs %}
-{% block style %}
-
-{% endblock style %}
-
-{% block javascript %}
-
-
-{% endblock javascript %}
-
-{% block breadcrumbs %}
- {{ block.super }}
-
- {% trans 'Analytics Category' as category %}
-
- {% breadcrumb category 'dashboard:view_general' %}
-{% endblock %}
-
-
-{% block content %}
-
-{% endblock content %}
\ No newline at end of file
diff --git a/analytics/templates/analytics/general.html b/analytics/templates/analytics/general.html
deleted file mode 100644
index 8454aa4..0000000
--- a/analytics/templates/analytics/general.html
+++ /dev/null
@@ -1,133 +0,0 @@
-{% extends 'base.html' %}
-
-{% load static i18n pagination %}
-{% load django_bootstrap_breadcrumbs %}
-{% block style %}
-
-{% endblock style %}
-
-{% block javascript %}
-
-
-
-{% endblock javascript %}
-
-{% block breadcrumbs %}
- {{ block.super }}
-
- {% trans 'Analytics General' as general %}
-
- {% breadcrumb general 'dashboard:view_general' %}
-{% endblock %}
-
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
-
-
{% trans "Most accessed " %}
-
-
-
-
-
{% trans "Most accessed categories" %}
-
-
-
-
{% trans "Most accessed subjects" %}
-
-
-
-
{% trans "Most accessed resource" %}
-
-
-
-
-
-
-
- {% trans "Most active users" %}
-
-
-
-
-
-
{% trans "Amount of access in: " %}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-{% endblock content %}
\ No newline at end of file
diff --git a/analytics/urls.py b/analytics/urls.py
index c3bddb3..4d3067c 100644
--- a/analytics/urls.py
+++ b/analytics/urls.py
@@ -3,8 +3,6 @@ from . import views
urlpatterns = [
- url(r'^view/general/$', views.GeneralView.as_view(), name='view_general'),
- url(r'^view/category/data$', views.CategoryView.as_view(), name='view_category_data'),
#"api" callls
url(r'^most_used_tags/$', views.most_used_tags, name="most_used_tags"),
diff --git a/analytics/views.py b/analytics/views.py
index e76c4dd..ea1cfeb 100644
--- a/analytics/views.py
+++ b/analytics/views.py
@@ -18,23 +18,6 @@ import calendar
from collections import OrderedDict
-class GeneralView(generic.TemplateView):
- template_name = "analytics/general.html"
-
- def dispatch(self, request, *args, **kwargs):
-
- if not request.user.is_staff:
- return redirect('analytics:view_category_data')
- return super(GeneralView, self).dispatch(request, *args, **kwargs)
-
-
- def get_context_data(self, **kwargs):
- context = {}
-
- context['months'] = [_('January'), _('February'), _('March'), _('April'), _('May'), _('June'), _('July'), _('August'),
- _('September'), _('October'), _('November'), _('December')]
-
- return context
@@ -94,9 +77,7 @@ Subject view that returns a list of the most used subjects """
def most_accessed_subjects(request):
- data = {} #empty response
- data = Log.objects.filter(resource = 'subject')
subjects = get_log_count_of_resource(resource='subject')
#order the values of the dictionary by the count in descendent order
subjects = sorted(subjects.values(), key = lambda x: x['count'], reverse=True )
@@ -119,9 +100,7 @@ def get_log_count_of_resource(resource = ''):
def most_accessed_categories(request):
- data = {}
- data = Log.objects.filter(resource = 'category')
categories = get_log_count_of_resource('category')
@@ -214,5 +193,3 @@ def get_days_of_the_week(date):
return days_set
-class CategoryView(generic.TemplateView):
- template_name = "analytics/category.html"
diff --git a/dashboards/__init__.py b/dashboards/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/dashboards/__init__.py
diff --git a/dashboards/admin.py b/dashboards/admin.py
new file mode 100644
index 0000000..8c38f3f
--- /dev/null
+++ b/dashboards/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/dashboards/apps.py b/dashboards/apps.py
new file mode 100644
index 0000000..d96e43c
--- /dev/null
+++ b/dashboards/apps.py
@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class DashboardsConfig(AppConfig):
+ name = 'dashboards'
diff --git a/dashboards/migrations/__init__.py b/dashboards/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/dashboards/migrations/__init__.py
diff --git a/dashboards/models.py b/dashboards/models.py
new file mode 100644
index 0000000..71a8362
--- /dev/null
+++ b/dashboards/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
diff --git a/dashboards/static/dashboards/js/behavior.js b/dashboards/static/dashboards/js/behavior.js
new file mode 100644
index 0000000..4e42c01
--- /dev/null
+++ b/dashboards/static/dashboards/js/behavior.js
@@ -0,0 +1,96 @@
+
+
+
+$(document).ready(function(){
+ selectors_options.init();
+
+ //for month selector
+
+ $('#month_selector').change(function(){
+ $.get('/analytics/amount_active_users_per_day', {month: $(this).val() }).done(function(data){
+ charts.month_heatmap(data, '#right-chart-body');
+
+ });
+ });
+ //week date selector at the right-chart field
+ $('input.datepicker').datetimepicker({
+ format: 'L',
+ defaultDate: new Date(),
+ }).on('dp.change', function(ev){
+ $.get('/analytics/get_days_of_the_week_log', {date: ev.date._i}).done(function(data){
+ charts.month_heatmap(data, '#bottom-right-chart-body');
+ });
+
+ });
+
+
+
+
+});
+
+
+
+var selectors_options = {
+ init: function(){
+ selectors = $("div.selector");
+ selectors.click(function(e){
+ selectors_options.loadData(e.currentTarget);
+ });
+ },
+ loadData: function(e){
+ if (e){
+ opened = $(e).attr('opened');
+ if (typeof opened !== typeof undefined && opened !== false){
+ selectors_options.deleteChildren(e);
+ }else {
+ switch(e.attributes['data-url'].value){
+ case "subjects":
+ var url = "/analytics/most_accessed_subjects";
+ break;
+ case "categories":
+ var url = "/analytics/most_accessed_categories";
+ break;
+ case "resources":
+ var url = "/analytics/most_accessed_resources";
+ break;
+
+ }
+
+ }
+ }
+ if(url){
+ $.get(url, function(dataset){
+ return dataset;
+ }).done(function(data){
+ selectors_options.modifyElement(e, data);
+
+ }).fail(function(error){
+ console.log("couldn't complete get request");
+ });
+ }
+
+
+ },
+ modifyElement: function(e, data){
+ var string_build = "";
+ string_build += '';
+
+ data.forEach(function(datum){
+ string_build += '- ' +datum.name+ ' ' + datum.count+ '
';
+ });
+ string_build += "
";
+
+ $(e).after(string_build);
+ var new_elem = $(e).next();
+ new_elem.slideDown({easing: 'easeInOutSine'}, 5000);
+ $(e).attr("opened", true);
+
+ },
+ deleteChildren: function(e){
+ var most_accessed_list = $(e).next();
+ $(most_accessed_list).slideUp({easing: 'easeInOutSine'}, 1200);
+ $(e).removeAttr("opened"); //remove attribute so it can call API again
+ },
+};
+
+
diff --git a/dashboards/templates/dashboards/category.html b/dashboards/templates/dashboards/category.html
new file mode 100644
index 0000000..b357b78
--- /dev/null
+++ b/dashboards/templates/dashboards/category.html
@@ -0,0 +1,59 @@
+{% extends 'base.html' %}
+
+{% load static i18n pagination %}
+{% load django_bootstrap_breadcrumbs %}
+{% block style %}
+
+{% endblock style %}
+
+{% block javascript %}
+
+
+{% endblock javascript %}
+
+{% block breadcrumbs %}
+ {{ block.super }}
+
+ {% trans 'Analytics Category' as category %}
+
+ {% breadcrumb category 'dashboard:view_general' %}
+{% endblock %}
+
+
+{% block content %}
+
+
+
+{% endblock content %}
\ No newline at end of file
diff --git a/dashboards/templates/dashboards/general.html b/dashboards/templates/dashboards/general.html
new file mode 100644
index 0000000..07cb2b2
--- /dev/null
+++ b/dashboards/templates/dashboards/general.html
@@ -0,0 +1,133 @@
+{% extends 'base.html' %}
+
+{% load static i18n pagination %}
+{% load django_bootstrap_breadcrumbs %}
+{% block style %}
+
+{% endblock style %}
+
+{% block javascript %}
+
+
+
+{% endblock javascript %}
+
+{% block breadcrumbs %}
+ {{ block.super }}
+
+ {% trans 'Dashboards General' as general %}
+
+ {% breadcrumb general 'dashboard:view_general' %}
+{% endblock %}
+
+
+{% block content %}
+
+
+
+
+
+
+
+
+
+
+
+
{% trans "Most accessed " %}
+
+
+
+
+
{% trans "Most accessed categories" %}
+
+
+
+
{% trans "Most accessed subjects" %}
+
+
+
+
{% trans "Most accessed resource" %}
+
+
+
+
+
+
+
+ {% trans "Most active users" %}
+
+
+
+
+
+
{% trans "Amount of access in: " %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{% endblock content %}
\ No newline at end of file
diff --git a/dashboards/tests.py b/dashboards/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/dashboards/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/dashboards/urls.py b/dashboards/urls.py
new file mode 100644
index 0000000..049faa6
--- /dev/null
+++ b/dashboards/urls.py
@@ -0,0 +1,8 @@
+from django.conf.urls import url, include
+from . import views
+
+
+urlpatterns = [
+ url(r'^view/general/$', views.GeneralView.as_view(), name='view_general'),
+
+]
\ No newline at end of file
diff --git a/dashboards/views.py b/dashboards/views.py
new file mode 100644
index 0000000..7f86680
--- /dev/null
+++ b/dashboards/views.py
@@ -0,0 +1,48 @@
+from django.shortcuts import render
+
+from django.views import generic
+from django.db.models import Count
+from django.core.urlresolvers import reverse_lazy
+
+from subjects.models import Tag, Subject
+from topics.models import Resource
+from users.models import User
+from django.http import HttpResponse, JsonResponse
+from log.models import Log
+import operator
+from django.utils.translation import ugettext_lazy as _
+from django.shortcuts import render, get_object_or_404, redirect
+
+from datetime import date, timedelta, datetime
+import calendar
+from collections import OrderedDict
+
+
+class GeneralView(generic.TemplateView):
+ template_name = "dashboards/general.html"
+
+ def dispatch(self, request, *args, **kwargs):
+
+ if not request.user.is_staff:
+ return redirect('analytics:view_category_data')
+ return super(GeneralView, self).dispatch(request, *args, **kwargs)
+
+
+ def get_context_data(self, **kwargs):
+ context = {}
+
+ context['months'] = [_('January'), _('February'), _('March'), _('April'), _('May'), _('June'), _('July'), _('August'),
+ _('September'), _('October'), _('November'), _('December')]
+
+ return context
+
+class CategoryView(generic.TemplateView):
+ template_name = "dashboards/category.html"
+
+ def dispatch(self, request, *args, **kwargs):
+ return super(CategoryView, self).dispatch(request, *args, **kwargs)
+
+ def get_context_data(self, **kwargs):
+ context = {}
+
+ return context
\ No newline at end of file
--
libgit2 0.21.2