Adds transactions and some tooltips++
This commit is contained in:
1 parent
0cbda8e0c5
commit
14f4a9ec3d
10 files changed
+103
-15
No files matched your search
+19
-3
@@ -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,7 +112,21 @@ def deposit(request):
|
||||
|
||||
return render_to_response('deposit.html', locals(), context_instance=RequestContext(request))
|
||||
|
||||
def log(request):
|
||||
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')
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
$(document).ready(function() {
|
||||
$("img.customer").tooltip();
|
||||
$("a.product").tooltip();
|
||||
$("h2").tooltip({placement: 'right'});
|
||||
});
|
||||
@@ -87,4 +87,5 @@ $(document).ready(function() {
|
||||
$("a[data-dismiss=alert]").parent().parent().parent().slideUp();
|
||||
}, 5000);
|
||||
|
||||
$("h2").tooltip({placement: 'right'});
|
||||
});
|
||||
+29
-5
@@ -17,7 +17,7 @@
|
||||
{% endif %}
|
||||
<section id="orders" class="row-fluid">
|
||||
<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">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -34,17 +34,41 @@
|
||||
<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>{% for line in order.orderline_set.all %}
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</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>
|
||||
{% endblock %}
|
||||
{% 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">
|
||||
<a href="#" class="close" data-dismiss="modal">×</a>
|
||||
<h3>Er du sikker?</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<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>
|
||||
Orderen inneholdt:
|
||||
<ul>
|
||||
{% for line in order.orderline_set.all %}
|
||||
<li><span class="bold">{{ line.amount}}</span>
|
||||
<li>
|
||||
<span class="bold">{{ line.amount}}</span>
|
||||
<a href="#" class="product" title="{{ line.unit_price}} per">{{ line.product }}</a>
|
||||
{% if not forloop.last %},{% endif %}</li>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
Totalt: {{ order.order_sum }},-
|
||||
@@ -23,7 +24,7 @@
|
||||
<p>Vil du fortsette?</p>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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
@@ -13,7 +13,7 @@
|
||||
{% 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 = "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 %}
|
||||
<li><a href="/admin">Administrasjon</a></li>
|
||||
{% endif %}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<section id="customer" class="row-fluid">
|
||||
{% if users %}
|
||||
<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 -->
|
||||
<input name="customer_name" id="id_customer_typeahead" value="" data-provide="typeahead" data-source="{{users_js}}" />
|
||||
<!-- Actual customer select field (hidden) -->
|
||||
@@ -90,5 +90,6 @@
|
||||
{% endblock %}
|
||||
{% block tailinc %}
|
||||
<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>
|
||||
{% endblock %}
|
||||
Reference in new issue
Block a user