Adds transactions and some tooltips++

This commit is contained in:
nikolark committed 2012-03-19 22:20:32 +01:00
1 parent 0cbda8e0c5
commit 14f4a9ec3d
10 files changed
+108 -20

No files matched your search

+21 -5
View File
@@ -1,5 +1,7 @@
# coding: utf-8 # 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 import login, logout as auth_logout
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import AuthenticationForm 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))) messages.success(request, '{0} kjøpte {1}.'.format(order.customer, ", ".join(orderlines)))
return HttpResponseRedirect( reverse('main.views.register') ) return HttpResponseRedirect( reverse('main.views.register') )
else: else:
# errors # TODO specify error(s)
messages.error(request, 'Skjemaet er ikke gyldig.') messages.error(request, 'Skjemaet er ikke gyldig.')
orderform = OrderForm(request.POST) orderform = OrderForm(request.POST)
formset = OrderLineFormSet(request.POST) formset = OrderLineFormSet(request.POST)
@@ -110,9 +112,23 @@ def deposit(request):
return render_to_response('deposit.html', locals(), context_instance=RequestContext(request)) return render_to_response('deposit.html', locals(), context_instance=RequestContext(request))
def log(request): def log(request, limit=datetime.now()-timedelta(days=2)):
orders = Order.objects.all().order_by('-created') if limit:
transactions = Transaction.objects.all().order_by('-created') # 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)) return render_to_response('log.html', locals(), context_instance=RequestContext(request))
+12
View File
@@ -72,12 +72,24 @@ body {
} }
} }
} }
h2 {
display: inline-block;
}
input[name=customer_name] {
display: block;
}
button { button {
margin-top:10px; margin-top:10px;
} }
} }
#log { #log {
h2 {
display:inline-block;
}
table { table {
tr{
text-align: middle;
}
.amount { .amount {
font-size: 2em; font-size: 2em;
font-weight: bold; font-weight: bold;
+12
View File
@@ -4324,9 +4324,21 @@ body #register #total div {
body #register #total div h2 { body #register #total div h2 {
color: #ffffff; color: #ffffff;
} }
body #register h2 {
display: inline-block;
}
body #register input[name=customer_name] {
display: block;
}
body #register button { body #register button {
margin-top: 10px; margin-top: 10px;
} }
body #log h2 {
display: inline-block;
}
body #log table tr {
text-align: middle;
}
body #log table .amount { body #log table .amount {
font-size: 2em; font-size: 2em;
font-weight: bold; font-weight: bold;
+5 -2
View File
@@ -1,2 +1,5 @@
$("img.customer").tooltip(); $(document).ready(function() {
$("a.product").tooltip(); $("img.customer").tooltip();
$("a.product").tooltip();
$("h2").tooltip({placement: 'right'});
});
+1
View File
@@ -87,4 +87,5 @@ $(document).ready(function() {
$("a[data-dismiss=alert]").parent().parent().parent().slideUp(); $("a[data-dismiss=alert]").parent().parent().parent().slideUp();
}, 5000); }, 5000);
$("h2").tooltip({placement: 'right'});
}); });
+29 -5
View File
@@ -17,7 +17,7 @@
{% endif %} {% endif %}
<section id="orders" class="row-fluid"> <section id="orders" class="row-fluid">
<div class="span12"> <div class="span12">
<h2>Siste ordre</h2> <h2 title="Ordre fra de siste 2 dagene eller de 5 siste ordrene.">Siste ordre</h2>
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
@@ -34,17 +34,41 @@
<td>{{ order.created }}</td> <td>{{ order.created }}</td>
<td>{% if order.customer.get_profile.image %}<img src="{{ order.customer.get_profile.image }}" class="customer" title="{{ order.customer.first_name }} {{ order.customer.last_name|slice:":1"}}" />{% else %}{{ order.customer.first_name }} {{ order.customer.last_name|slice:":1"}}{% endif %}</td> <td>{% if order.customer.get_profile.image %}<img src="{{ order.customer.get_profile.image }}" class="customer" title="{{ order.customer.first_name }} {{ order.customer.last_name|slice:":1"}}" />{% else %}{{ order.customer.first_name }} {{ order.customer.last_name|slice:":1"}}{% endif %}</td>
<td>{% for line in order.orderline_set.all %} <td>{% for line in order.orderline_set.all %}
<span class="amount">{{ line.amount}}</span> <span class="amount">{{ line.amount}}</span> <a href="#" class="product" title="{{ line.unit_price}} per">{{ line.product }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}</td>
<a href="#" class="product" title="{{ line.unit_price}} per">{{ line.product }}</a>{% if not forloop.last %},{% endif %}
{% endfor %}</td>
<td>{{ order.order_sum }}</td> <td>{{ order.order_sum }}</td>
<td>{% include "modal-confirm-delete.html" with order=order %}<a class="btn btn-danger" data-toggle="modal" href="#modal-{{order.id}}"><i class="icon-trash icon-white"></i> Slett</a></td> <td>{% include "modal-delete-order.html" with order=order %}<a class="btn btn-danger" data-toggle="modal" href="#modal-order-{{order.id}}"><i class="icon-trash icon-white"></i> Slett</a></td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</div> </div>
</section> </section>
<section id="transactions" class="row-fluid">
<div class="span12">
<h2 title="Transaksjoner fra de siste 2 dagene eller de 5 siste transaksjonene.">Siste transaksjoner</h2>
<table class="table table-striped">
<thead>
<tr>
<th>Når</th>
<th>Hvem</th>
<th>Innskudd</th>
<th>Handling</th>
</tr>
</thead>
<tbody>
{% for t in transactions %}
<tr>
<td>{{ t.created }}</td>
<td>{% if t.user.get_profile.image %}<img src="{{ t.user.get_profile.image }}" class="customer" title="{{ t.user.first_name }} {{ t.user.last_name|slice:":1"}}" />{% else %}{{ t.user.first_name }} {{ t.user.last_name|slice:":1"}}{% endif %}</td>
<td>{{ t.amount }}</td>
<td>{% include "modal-delete-transaction.html" with t=t %}<a class="btn btn-danger" data-toggle="modal" href="#modal-trans-{{t.id}}"><i class="icon-trash icon-white"></i> Slett</a></td>
</tr>
{% endfor %}
</tbody>
</table>
  <a href="{% url register %}" class="btn">« Gå tilbake</a>
</div>
</section>
</section> </section>
{% endblock %} {% endblock %}
{% block tailinc %} {% block tailinc %}
@@ -1,18 +1,19 @@
<div id="modal-{{order.id}}" class="modal" style="display: none;"> <div id="modal-order-{{order.id}}" class="modal" style="display: none;">
<div class="modal-header"> <div class="modal-header">
<a href="#" class="close" data-dismiss="modal">×</a> <a href="#" class="close" data-dismiss="modal">×</a>
<h3>Er du sikker?</h3> <h3>Er du sikker?</h3>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p> <p>
Orderen til {% if order.customer.get_profile.image %}<img src="{{ order.customer.get_profile.image }}" class="customer" title="{{ order.customer.first_name }} {{ order.customer.last_name|slice:":1"}}" />{% else %}<strong>{{ order.customer.first_name }} {{ order.customer.last_name|slice:":1"}}</strong>{% endif %} fra {{ order.created }} vil bli <em>slettet</em>.</p> Orderen til <strong>{{ order.customer.first_name }} {{ order.customer.last_name|slice:":1"}}</strong> fra {{ order.created }} vil bli <em>slettet</em>.</p>
<p> <p>
Orderen inneholdt: Orderen inneholdt:
<ul> <ul>
{% for line in order.orderline_set.all %} {% for line in order.orderline_set.all %}
<li><span class="bold">{{ line.amount}}</span> <li>
<a href="#" class="product" title="{{ line.unit_price}} per">{{ line.product }}</a> <span class="bold">{{ line.amount}}</span>
{% if not forloop.last %},{% endif %}</li> <a href="#" class="product" title="{{ line.unit_price}} per">{{ line.product }}</a>
</li>
{% endfor %} {% endfor %}
</ul> </ul>
Totalt: {{ order.order_sum }},- Totalt: {{ order.order_sum }},-
@@ -23,7 +24,7 @@
<p>Vil du fortsette?</p> <p>Vil du fortsette?</p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<a href="#" class="btn">Nei</a> <a href="#" class="btn" data-dismiss="modal">Nei</a>
<a href="#" class="btn btn-danger"><i class="icon-trash icon-white"></i> Ja</a> <a href="#" class="btn btn-danger"><i class="icon-trash icon-white"></i> Ja</a>
</div> </div>
</div> </div>
+18
View File
@@ -0,0 +1,18 @@
<div id="modal-trans-{{t.id}}" class="modal" style="display: none;">
<div class="modal-header">
<a href="#" class="close" data-dismiss="modal">×</a>
<h3>Er du sikker?</h3>
</div>
<div class="modal-body">
<p>
Inskuddet til <strong>{{ t.user.first_name }} {{ t.user.last_name|slice:":1"}}</strong> på <strong>{{ t.amount }}</strong> fra {{ t.created }} vil bli <em>slettet</em>.</p>
<p>
<strong>{{ t.user.first_name }} {{ t.user.last_name|slice:":1"}}</strong> sin saldo vil debiteres med {{ t.amount }} kr.
</p>
<p>Vil du fortsette?</p>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal">Nei</a>
<a href="#" class="btn btn-danger"><i class="icon-trash icon-white"></i> Ja</a>
</div>
</div>
+1 -1
View File
@@ -13,7 +13,7 @@
{% if active %} {% if active %}
<li class="{% if active = "register" %}active{% endif %}"><a href="/register"><i class="icon-home icon-white"></i> Kjøp drikke</a></li> <li class="{% if active = "register" %}active{% endif %}"><a href="/register"><i class="icon-home icon-white"></i> Kjøp drikke</a></li>
<li class="{% if active = "deposit" %}active{% endif %}"><a href="/deposit">Sett inn penger</a></li> <li class="{% if active = "deposit" %}active{% endif %}"><a href="/deposit">Sett inn penger</a></li>
<li class="{% if active = "log" %}active{% endif %}"><a href="/log"> Logg</a></li> <li class="{% if active = "log" %}active{% endif %}"><a href="/log"> Vis logg</a></li>
{% if request.user.is_superuser %} {% if request.user.is_superuser %}
<li><a href="/admin">Administrasjon</a></li> <li><a href="/admin">Administrasjon</a></li>
{% endif %} {% endif %}
+2 -1
View File
@@ -26,7 +26,7 @@
<section id="customer" class="row-fluid"> <section id="customer" class="row-fluid">
{% if users %} {% if users %}
<div class="span12"> <div class="span12">
<h2>Hvem kjøper?</h2> <h2 title="Sortert etter hvem som kjøpte noe sist.">Hvem kjøper?</h2>
<!-- Typeahead customer field --> <!-- Typeahead customer field -->
<input name="customer_name" id="id_customer_typeahead" value="" data-provide="typeahead" data-source="{{users_js}}" /> <input name="customer_name" id="id_customer_typeahead" value="" data-provide="typeahead" data-source="{{users_js}}" />
<!-- Actual customer select field (hidden) --> <!-- Actual customer select field (hidden) -->
@@ -90,5 +90,6 @@
{% endblock %} {% endblock %}
{% block tailinc %} {% block tailinc %}
<script src="{{ STATIC_URL }}js/bootstrap-typeahead.js"></script> <script src="{{ STATIC_URL }}js/bootstrap-typeahead.js"></script>
<script src="{{ STATIC_URL }}js/bootstrap-tooltip.js"></script>
<script src="{{ STATIC_URL }}js/register.js"></script> <script src="{{ STATIC_URL }}js/register.js"></script>
{% endblock %} {% endblock %}