Started adding stats (broken)
This commit is contained in:
1 parent
3b2389094d
commit
da554ff9da
9 files changed
+50
-12
No files matched your search
@@ -7,4 +7,5 @@ urlpatterns = patterns('main.views',
|
|||||||
url(r'^log/all$', 'log', kwargs={'limit': None}, name='log-all'),
|
url(r'^log/all$', 'log', kwargs={'limit': None}, name='log-all'),
|
||||||
url(r'^stats/$', 'stats', name='stats'),
|
url(r'^stats/$', 'stats', name='stats'),
|
||||||
url(r'^stats/orders$', 'stats_orders', name='stats-orders'),
|
url(r'^stats/orders$', 'stats_orders', name='stats-orders'),
|
||||||
|
url(r'^stats/products$', 'products', name='stats-products'),
|
||||||
)
|
)
|
||||||
@@ -135,9 +135,26 @@ def log(request, limit=datetime.now()-timedelta(days=2)):
|
|||||||
return render_to_response('log.html', locals(), context_instance=RequestContext(request))
|
return render_to_response('log.html', locals(), context_instance=RequestContext(request))
|
||||||
|
|
||||||
def stats(request):
|
def stats(request):
|
||||||
|
products = Product.objects.filter(active=True)
|
||||||
|
|
||||||
return render_to_response('stats.html', locals(), context_instance=RequestContext(request))
|
return render_to_response('stats.html', locals(), context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
def products(request):
|
||||||
|
products = Product.objects.filter(active=True)
|
||||||
|
|
||||||
|
f_products = []
|
||||||
|
for product in products:
|
||||||
|
for attr in Product._meta.get_all_field_names():
|
||||||
|
if hasattr(product, attr):
|
||||||
|
#print type(product.__getattribute__(attr))
|
||||||
|
if type(product.__getattribute__(attr)) is datetime:
|
||||||
|
# TODO parse datetime
|
||||||
|
f_products.append({attr : product.__getattribute__(attr.())})
|
||||||
|
else:
|
||||||
|
f_products.append({attr : product.__getattribute__(attr)})
|
||||||
|
|
||||||
|
return HttpResponse(json.dumps(f_products), content_type='application/javascript; charset=utf8')
|
||||||
|
|
||||||
def stats_orders(request):
|
def stats_orders(request):
|
||||||
|
|
||||||
total = float(Order.objects.count())
|
total = float(Order.objects.count())
|
||||||
|
|||||||
@@ -124,7 +124,6 @@ INSTALLED_APPS = (
|
|||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
'main',
|
'main',
|
||||||
'gravatar',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# A sample logging configuration. The only tangible logging
|
# A sample logging configuration. The only tangible logging
|
||||||
|
|||||||
+20
-5
@@ -1,4 +1,4 @@
|
|||||||
var chart;
|
var charts;
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// define the options
|
// define the options
|
||||||
var options = {
|
var options = {
|
||||||
@@ -39,9 +39,24 @@ $(document).ready(function() {
|
|||||||
data: [],
|
data: [],
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
var url = '/stats/orders';
|
var products_url = '/stats/products';
|
||||||
$.getJSON(url, function(data) {
|
/* drink beer and */
|
||||||
options.series[0].data = data;
|
$.getJSON(products_url, function(data) {
|
||||||
chart = new Highcharts.Chart(options);
|
var graph_mappings = [
|
||||||
|
['/stats/orders', 'order_chart']
|
||||||
|
];
|
||||||
|
var products = data;
|
||||||
|
for(i in products) {
|
||||||
|
var mapping = ['/stats/product/'+products[i].id, 'product_chart'+products[i].id];
|
||||||
|
graph_mappings.push(mapping);
|
||||||
|
}
|
||||||
|
/* TODO merere her */
|
||||||
|
for(i in graph_mappings) {
|
||||||
|
$.getJSON(graph_mappings, function(data) {
|
||||||
|
options.series[0].data = data;
|
||||||
|
options.chart.renderTo = graph_mappings[i][1];
|
||||||
|
charts.push(new Highcharts.Chart(options));
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load gravatar %}
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
{% include "nav.html" with active="deposit" %}
|
{% include "nav.html" with active="deposit" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -30,7 +29,7 @@
|
|||||||
{% if user.get_profile.image %}
|
{% if user.get_profile.image %}
|
||||||
<img class="profile" src="{{ user.get_profile.image }}" alt="Profile picture"/><br />
|
<img class="profile" src="{{ user.get_profile.image }}" alt="Profile picture"/><br />
|
||||||
{% else %}
|
{% else %}
|
||||||
<img class="profile" src="{% gravatar_for_user user 50 %}" alt="Profile picture" /><br />
|
<img class="profile" src="{{ STATIC_URL }}gaute/img/unknown_person.png" alt="Profile picture" /><br />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<span class="name">{{ user.first_name }} {{ user.last_name|slice:":1"}}</span><br />
|
<span class="name">{{ user.first_name }} {{ user.last_name|slice:":1"}}</span><br />
|
||||||
<span class="balance">{{ user.get_profile.balance }}</span>
|
<span class="balance">{{ user.get_profile.balance }}</span>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load gravatar %}
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
{% include "nav.html" with active="log" %}
|
{% include "nav.html" with active="log" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load gravatar %}
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
{% include "nav.html" with active="register" %}
|
{% include "nav.html" with active="register" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -37,7 +36,7 @@
|
|||||||
{% if user.get_profile.image %}
|
{% if user.get_profile.image %}
|
||||||
<img class="profile" src="{{ user.get_profile.image }}" alt="Profile picture" /><br />
|
<img class="profile" src="{{ user.get_profile.image }}" alt="Profile picture" /><br />
|
||||||
{% else %}
|
{% else %}
|
||||||
<img class="profile" src="{% gravatar_for_user user 50 %}" alt="Profile picture" /><br />
|
<img class="profile" src="{{ STATIC_URL }}gaute/img/unknown_person.png" alt="Profile picture" /><br />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<span class="name">{{ user.first_name }} {{ user.last_name|slice:":1"}}</span><br />
|
<span class="name">{{ user.first_name }} {{ user.last_name|slice:":1"}}</span><br />
|
||||||
<span class="balance">{{ user.get_profile.balance }}</span>
|
<span class="balance">{{ user.get_profile.balance }}</span>
|
||||||
|
|||||||
+10
-1
@@ -1,5 +1,4 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load gravatar %}
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
{% include "nav.html" with active="stats" %}
|
{% include "nav.html" with active="stats" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -13,6 +12,16 @@
|
|||||||
<!--<div id="container" style="width: 800px; height: 400px; margin: 0 auto;"></div> -->
|
<!--<div id="container" style="width: 800px; height: 400px; margin: 0 auto;"></div> -->
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
{% for product in products %}
|
||||||
|
<section id="product_{{ product.id }}" class="row-fluid">
|
||||||
|
<div class="span12">
|
||||||
|
<h2>{{ product }}</h2>
|
||||||
|
<div id="product_{{ product.id }}_chart"></div>
|
||||||
|
<!--<div id="container" style="width: 800px; height: 400px; margin: 0 auto;"></div> -->
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
{% endfor %}
|
||||||
</section>
|
</section>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block tailinc %}
|
{% block tailinc %}
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Reference in new issue
Block a user