diff --git a/main/views.py b/main/views.py index f0bfba3..2dab0bf 100755 --- a/main/views.py +++ b/main/views.py @@ -1,5 +1,7 @@ # coding: utf-8 -# Create your views here. +from datetime import timedelta +from datetime import datetime + from django.contrib.auth import login, logout as auth_logout from django.contrib.auth.decorators import login_required from django.contrib.auth.forms import AuthenticationForm @@ -76,7 +78,7 @@ def register(request): messages.success(request, '{0} kjøpte {1}.'.format(order.customer, ", ".join(orderlines))) return HttpResponseRedirect( reverse('main.views.register') ) else: - # errors + # TODO specify error(s) messages.error(request, 'Skjemaet er ikke gyldig.') orderform = OrderForm(request.POST) formset = OrderLineFormSet(request.POST) @@ -110,9 +112,23 @@ def deposit(request): return render_to_response('deposit.html', locals(), context_instance=RequestContext(request)) -def log(request): - orders = Order.objects.all().order_by('-created') - transactions = Transaction.objects.all().order_by('-created') +def log(request, limit=datetime.now()-timedelta(days=2)): + if limit: + # display last two days of orders and transactions + orders = Order.objects.filter(created__gte=limit).order_by('-created') + transactions = Transaction.objects.filter(created__gte=limit).order_by('-created') + + # no action in the last two days? + # ...then display the last 5 items + if len(orders) == 0: + orders = Order.objects.all().order_by('-created')[:5] + + if len(transactions) == 0: + transactions = Transaction.objects.all().order_by('-created')[:5] + else: + # display everything + orders = Order.objects.all().order_by('-created') + transactions = Transaction.objects.all().order_by('-created') return render_to_response('log.html', locals(), context_instance=RequestContext(request)) diff --git a/static/gaute/sass/screen.scss b/static/gaute/sass/screen.scss index 6194650..13f6f63 100644 --- a/static/gaute/sass/screen.scss +++ b/static/gaute/sass/screen.scss @@ -72,12 +72,24 @@ body { } } } + h2 { + display: inline-block; + } + input[name=customer_name] { + display: block; + } button { margin-top:10px; } } #log { + h2 { + display:inline-block; + } table { + tr{ + text-align: middle; + } .amount { font-size: 2em; font-weight: bold; diff --git a/static/gaute/stylesheets/screen.css b/static/gaute/stylesheets/screen.css index 20f6057..209d104 100644 --- a/static/gaute/stylesheets/screen.css +++ b/static/gaute/stylesheets/screen.css @@ -4324,9 +4324,21 @@ body #register #total div { body #register #total div h2 { color: #ffffff; } +body #register h2 { + display: inline-block; +} +body #register input[name=customer_name] { + display: block; +} body #register button { margin-top: 10px; } +body #log h2 { + display: inline-block; +} +body #log table tr { + text-align: middle; +} body #log table .amount { font-size: 2em; font-weight: bold; diff --git a/static/js/log.js b/static/js/log.js index d4a3f12..b5c10a4 100644 --- a/static/js/log.js +++ b/static/js/log.js @@ -1,2 +1,5 @@ -$("img.customer").tooltip(); -$("a.product").tooltip(); +$(document).ready(function() { + $("img.customer").tooltip(); + $("a.product").tooltip(); + $("h2").tooltip({placement: 'right'}); +}); diff --git a/static/js/register.js b/static/js/register.js index f293fcd..4063c1d 100644 --- a/static/js/register.js +++ b/static/js/register.js @@ -87,4 +87,5 @@ $(document).ready(function() { $("a[data-dismiss=alert]").parent().parent().parent().slideUp(); }, 5000); + $("h2").tooltip({placement: 'right'}); }); diff --git a/templates/log.html b/templates/log.html index 8ffeb93..49db83d 100644 --- a/templates/log.html +++ b/templates/log.html @@ -17,7 +17,7 @@ {% endif %}
-

Siste ordre

+

Siste ordre

@@ -34,17 +34,41 @@ + {{ line.amount}}{{ line.product }}{% if not forloop.last %}, {% endif %}{% endfor %} - + {% endfor %}
{{ order.created }} {% if order.customer.get_profile.image %}{% else %}{{ order.customer.first_name }} {{ order.customer.last_name|slice:":1"}}{% endif %} {% for line in order.orderline_set.all %} - {{ line.amount}} - {{ line.product }}{% if not forloop.last %},{% endif %} - {% endfor %} {{ order.order_sum }}{% include "modal-confirm-delete.html" with order=order %} Slett{% include "modal-delete-order.html" with order=order %} Slett
+
+
+

Siste transaksjoner

+ + + + + + + + + + + {% for t in transactions %} + + + + + + + {% endfor %} + +
NårHvemInnskuddHandling
{{ t.created }}{% if t.user.get_profile.image %}{% else %}{{ t.user.first_name }} {{ t.user.last_name|slice:":1"}}{% endif %}{{ t.amount }}{% include "modal-delete-transaction.html" with t=t %} Slett
+   « Gå tilbake +
+
{% endblock %} {% block tailinc %} diff --git a/templates/modal-confirm-delete.html b/templates/modal-delete-order.html similarity index 51% rename from templates/modal-confirm-delete.html rename to templates/modal-delete-order.html index 84aa134..11f8500 100644 --- a/templates/modal-confirm-delete.html +++ b/templates/modal-delete-order.html @@ -1,18 +1,19 @@ -