Started adding stats (broken)
This commit is contained in:
1 parent
3b2389094d
commit
da554ff9da
9 files changed
+49
-11
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'^stats/$', 'stats', name='stats'),
|
||||
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))
|
||||
|
||||
def stats(request):
|
||||
products = Product.objects.filter(active=True)
|
||||
|
||||
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):
|
||||
|
||||
total = float(Order.objects.count())
|
||||
|
||||
@@ -124,7 +124,6 @@ INSTALLED_APPS = (
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.admin',
|
||||
'main',
|
||||
'gravatar',
|
||||
)
|
||||
|
||||
# A sample logging configuration. The only tangible logging
|
||||
|
||||
+19
-4
@@ -1,4 +1,4 @@
|
||||
var chart;
|
||||
var charts;
|
||||
$(document).ready(function() {
|
||||
// define the options
|
||||
var options = {
|
||||
@@ -39,9 +39,24 @@ $(document).ready(function() {
|
||||
data: [],
|
||||
}]
|
||||
}
|
||||
var url = '/stats/orders';
|
||||
$.getJSON(url, function(data) {
|
||||
var products_url = '/stats/products';
|
||||
/* drink beer and */
|
||||
$.getJSON(products_url, function(data) {
|
||||
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;
|
||||
chart = new Highcharts.Chart(options);
|
||||
options.chart.renderTo = graph_mappings[i][1];
|
||||
charts.push(new Highcharts.Chart(options));
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,4 @@
|
||||
{% extends "base.html" %}
|
||||
{% load gravatar %}
|
||||
{% block header %}
|
||||
{% include "nav.html" with active="deposit" %}
|
||||
{% endblock %}
|
||||
@@ -30,7 +29,7 @@
|
||||
{% if user.get_profile.image %}
|
||||
<img class="profile" src="{{ user.get_profile.image }}" alt="Profile picture"/><br />
|
||||
{% 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 %}
|
||||
<span class="name">{{ user.first_name }} {{ user.last_name|slice:":1"}}</span><br />
|
||||
<span class="balance">{{ user.get_profile.balance }}</span>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{% extends "base.html" %}
|
||||
{% load gravatar %}
|
||||
{% block header %}
|
||||
{% include "nav.html" with active="log" %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{% extends "base.html" %}
|
||||
{% load gravatar %}
|
||||
{% block header %}
|
||||
{% include "nav.html" with active="register" %}
|
||||
{% endblock %}
|
||||
@@ -37,7 +36,7 @@
|
||||
{% if user.get_profile.image %}
|
||||
<img class="profile" src="{{ user.get_profile.image }}" alt="Profile picture" /><br />
|
||||
{% 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 %}
|
||||
<span class="name">{{ user.first_name }} {{ user.last_name|slice:":1"}}</span><br />
|
||||
<span class="balance">{{ user.get_profile.balance }}</span>
|
||||
|
||||
+10
-1
@@ -1,5 +1,4 @@
|
||||
{% extends "base.html" %}
|
||||
{% load gravatar %}
|
||||
{% block header %}
|
||||
{% include "nav.html" with active="stats" %}
|
||||
{% endblock %}
|
||||
@@ -13,6 +12,16 @@
|
||||
<!--<div id="container" style="width: 800px; height: 400px; margin: 0 auto;"></div> -->
|
||||
</div>
|
||||
</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>
|
||||
{% endblock %}
|
||||
{% block tailinc %}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Reference in new issue
Block a user