Adds order log (no delete yet) and more.

This commit is contained in:
nikolark committed 2012-03-19 20:40:31 +01:00
1 parent 99a8a3aeb4
commit b9db82e31f
9 files changed
+357 -3

No files matched your search

+1
View File
@@ -3,4 +3,5 @@ from django.conf.urls.defaults import patterns, include, url
urlpatterns = patterns('main.views',
url(r'^register/$', 'register', name='register'),
url(r'^deposit/$', 'deposit', name='deposit'),
url(r'^log/$', 'log', name='log'),
)
+6
View File
@@ -110,6 +110,12 @@ 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')
return render_to_response('log.html', locals(), context_instance=RequestContext(request))
def logout(request):
auth_logout(request)
return render_to_response('registration/logout.html', locals(), context_instance=RequestContext(request))
+2 -2
View File
@@ -32,11 +32,11 @@ DATABASES = {
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'
TIME_ZONE = 'Europe/Oslo'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = 'no-nb'
SITE_ID = 1
+210
View File
@@ -0,0 +1,210 @@
/* =========================================================
* bootstrap-modal.js v2.0.2
* http://twitter.github.com/bootstrap/javascript.html#modals
* =========================================================
* Copyright 2012 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================= */
!function( $ ){
"use strict"
/* MODAL CLASS DEFINITION
* ====================== */
var Modal = function ( content, options ) {
this.options = options
this.$element = $(content)
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
}
Modal.prototype = {
constructor: Modal
, toggle: function () {
return this[!this.isShown ? 'show' : 'hide']()
}
, show: function () {
var that = this
if (this.isShown) return
$('body').addClass('modal-open')
this.isShown = true
this.$element.trigger('show')
escape.call(this)
backdrop.call(this, function () {
var transition = $.support.transition && that.$element.hasClass('fade')
!that.$element.parent().length && that.$element.appendTo(document.body) //don't move modals dom position
that.$element
.show()
if (transition) {
that.$element[0].offsetWidth // force reflow
}
that.$element.addClass('in')
transition ?
that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) :
that.$element.trigger('shown')
})
}
, hide: function ( e ) {
e && e.preventDefault()
if (!this.isShown) return
var that = this
this.isShown = false
$('body').removeClass('modal-open')
escape.call(this)
this.$element
.trigger('hide')
.removeClass('in')
$.support.transition && this.$element.hasClass('fade') ?
hideWithTransition.call(this) :
hideModal.call(this)
}
}
/* MODAL PRIVATE METHODS
* ===================== */
function hideWithTransition() {
var that = this
, timeout = setTimeout(function () {
that.$element.off($.support.transition.end)
hideModal.call(that)
}, 500)
this.$element.one($.support.transition.end, function () {
clearTimeout(timeout)
hideModal.call(that)
})
}
function hideModal( that ) {
this.$element
.hide()
.trigger('hidden')
backdrop.call(this)
}
function backdrop( callback ) {
var that = this
, animate = this.$element.hasClass('fade') ? 'fade' : ''
if (this.isShown && this.options.backdrop) {
var doAnimate = $.support.transition && animate
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
.appendTo(document.body)
if (this.options.backdrop != 'static') {
this.$backdrop.click($.proxy(this.hide, this))
}
if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
this.$backdrop.addClass('in')
doAnimate ?
this.$backdrop.one($.support.transition.end, callback) :
callback()
} else if (!this.isShown && this.$backdrop) {
this.$backdrop.removeClass('in')
$.support.transition && this.$element.hasClass('fade')?
this.$backdrop.one($.support.transition.end, $.proxy(removeBackdrop, this)) :
removeBackdrop.call(this)
} else if (callback) {
callback()
}
}
function removeBackdrop() {
this.$backdrop.remove()
this.$backdrop = null
}
function escape() {
var that = this
if (this.isShown && this.options.keyboard) {
$(document).on('keyup.dismiss.modal', function ( e ) {
e.which == 27 && that.hide()
})
} else if (!this.isShown) {
$(document).off('keyup.dismiss.modal')
}
}
/* MODAL PLUGIN DEFINITION
* ======================= */
$.fn.modal = function ( option ) {
return this.each(function () {
var $this = $(this)
, data = $this.data('modal')
, options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
if (!data) $this.data('modal', (data = new Modal(this, options)))
if (typeof option == 'string') data[option]()
else if (options.show) data.show()
})
}
$.fn.modal.defaults = {
backdrop: true
, keyboard: true
, show: true
}
$.fn.modal.Constructor = Modal
/* MODAL DATA-API
* ============== */
$(function () {
$('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
var $this = $(this), href
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
, option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data())
e.preventDefault()
$target.modal(option)
})
})
}( window.jQuery );
+51
View File
@@ -0,0 +1,51 @@
/* ===================================================
* bootstrap-transition.js v2.0.0
* http://twitter.github.com/bootstrap/javascript.html#transitions
* ===================================================
* Copyright 2012 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================== */
!function( $ ) {
$(function () {
"use strict"
/* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
* ======================================================= */
$.support.transition = (function () {
var thisBody = document.body || document.documentElement
, thisStyle = thisBody.style
, support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined
return support && {
end: (function () {
var transitionEnd = "TransitionEnd"
if ( $.browser.webkit ) {
transitionEnd = "webkitTransitionEnd"
} else if ( $.browser.mozilla ) {
transitionEnd = "transitionend"
} else if ( $.browser.opera ) {
transitionEnd = "oTransitionEnd"
}
return transitionEnd
}())
}
})()
})
}( window.jQuery )
+2
View File
@@ -0,0 +1,2 @@
$("img.customer").tooltip();
$("a.product").tooltip();
+55
View File
@@ -0,0 +1,55 @@
{% extends "base.html" %}
{% load gravatar %}
{% block header %}
{% include "nav.html" with active="log" %}
{% endblock %}
{% block content %}
<section id="log" class="row-fluid">
{% if messages %}
<section class="row-fluid">
<div class="span4">
{% for message in messages %}
<div {% if message.tags %}class="alert alert-{{ message.tags }}"{% endif %}>{{ message }}<a class="close" data-dismiss="alert">×</a></div>
{% endfor %}
</div>
</section>
{% endif %}
<section id="orders" class="row-fluid">
<div class="span12">
<h2>Siste ordre</h2>
<table class="table table-striped">
<thead>
<tr>
<th>Når</th>
<th>Hvem</th>
<th>Hva</th>
<th>Sum</th>
<th>Handling</th>
</tr>
</thead>
<tbody>
{% for order in orders %}
<tr>
<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="bold">{{ 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>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</section>
</section>
{% endblock %}
{% block tailinc %}
<script src="{{ STATIC_URL }}js/bootstrap-tooltip.js"></script>
<script src="{{ STATIC_URL }}js/bootstrap-modal.js"></script>
<script src="{{ STATIC_URL }}js/bootstrap-transition.js"></script>
<script src="{{ STATIC_URL }}js/log.js"></script>
{% endblock %}
+29
View File
@@ -0,0 +1,29 @@
<div id="modal-{{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>
<p>
Orderen inneholdt:
<ul>
{% for line in order.orderline_set.all %}
<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>
{% endfor %}
</ul>
Totalt: {{ order.order_sum }},-
</p>
<p>
<strong>{{ order.customer.first_name }} {{ order.customer.last_name|slice:":1"}}</strong> sin saldo vil bli kreditert {{ order.order_sum }} kr.
</p>
<p>Vil du fortsette?</p>
</div>
<div class="modal-footer">
<a href="#" class="btn">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 %}
<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 = "remove_purchase" %}active{% endif %}"><a href="#"> Fjern kjøp</a></li>
<li class="{% if active = "log" %}active{% endif %}"><a href="/log"> Logg</a></li>
{% if request.user.is_superuser %}
<li><a href="/admin">Administrasjon</a></li>
{% endif %}