From b9db82e31fcfc2173b3e1afd50ee91bb6c3c68d3 Mon Sep 17 00:00:00 2001 From: Nikolai Kristiansen Date: Mon, 19 Mar 2012 20:40:31 +0100 Subject: [PATCH] Adds order log (no delete yet) and more. --- main/urls.py | 1 + main/views.py | 6 + settings-sample.py | 4 +- static/js/bootstrap-modal.js | 210 ++++++++++++++++++++++++++++ static/js/bootstrap-transition.js | 51 +++++++ static/js/log.js | 2 + templates/log.html | 55 ++++++++ templates/modal-confirm-delete.html | 29 ++++ templates/nav.html | 2 +- 9 files changed, 357 insertions(+), 3 deletions(-) create mode 100644 static/js/bootstrap-modal.js create mode 100644 static/js/bootstrap-transition.js create mode 100644 static/js/log.js create mode 100644 templates/log.html create mode 100644 templates/modal-confirm-delete.html diff --git a/main/urls.py b/main/urls.py index eab47e6..24c3c00 100644 --- a/main/urls.py +++ b/main/urls.py @@ -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'), ) diff --git a/main/views.py b/main/views.py index 2c524bf..f0bfba3 100755 --- a/main/views.py +++ b/main/views.py @@ -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)) diff --git a/settings-sample.py b/settings-sample.py index 05220ca..ff53692 100755 --- a/settings-sample.py +++ b/settings-sample.py @@ -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 diff --git a/static/js/bootstrap-modal.js b/static/js/bootstrap-modal.js new file mode 100644 index 0000000..e929706 --- /dev/null +++ b/static/js/bootstrap-modal.js @@ -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 = $('