diff --git a/cash/templates/cash/base.html b/cash/templates/cash/base.html index e8cc3ad..326cf9e 100644 --- a/cash/templates/cash/base.html +++ b/cash/templates/cash/base.html @@ -91,6 +91,51 @@

{% blocktrans with firstname=user.first_name %}Welcome, {{ firstname }}!{% endblocktrans %}

+
+
+
+
+ {% trans "Account information" %} +
+
+
+
{% trans "Username:" %}
+
{{ user.username }}
+
{% trans "Full name:" %}
+
{{ user.first_name }} {{ user.last_name }}
+
{% trans "E-Mail address:" %}
+
{{ user.email }}
+
{% trans "Guthaben:" %}
+
{{ user.account.credit|floatformat:2 }}€
+
+
+
+
+
+
+ {% trans "Last purchased products" %} +
+
+ {% include "cash/includes/product_list.html" with products=latest_purchases class="col-xs-6 col-md-4" only %} +
+
+
+
+
+
+ {% trans "Your transactions in the last 12 hours" %} +
+ {% if latest_transactions %} + {% include "cash/includes/transaction_list.html" with transactions=latest_transactions only %} + {% else %} +
+ {% blocktrans %}There where no transactions in your account in the last 12 hours.{% endblocktrans %} +
+ {% endif %} +
+
+
+ {% endblock %} diff --git a/cash/views.py b/cash/views.py index 7e9885a..339f875 100644 --- a/cash/views.py +++ b/cash/views.py @@ -7,11 +7,31 @@ from django.core import paginator from cash.models import * from django.utils.translation import ugettext as _ from django.utils.translation import ugettext_lazy +import datetime @login_required def overview(request): + a = request.user.account + time = datetime.datetime.now() - datetime.timedelta(hours=12) + transactions = Transaction.objects.filter(account=a).filter(timestamp__gte=time).order_by('-timestamp') + + # FIXME: distinct doesn't work as expected, so fetch 20 rows and hope that there are 3 distinct products + purchases = Product.objects.filter(saleslogentry__account=a).order_by('-saleslogentry__timestamp').distinct()[:20] + + products = [] + # Find 3 products + for p in purchases: + if not p in products: + products.append(p) + + if len(products) == 3: + break + + context = RequestContext(request, { 'latest_transactions': transactions, + 'latest_purchases': products}) + return render_to_response('cash/index.html', - context_instance=RequestContext(request)) + context_instance=context) class ProductView(generic.DetailView):