diff --git a/k4ever/k4ever.db b/k4ever/k4ever.db index 052897f..e8eefa0 100644 Binary files a/k4ever/k4ever.db and b/k4ever/k4ever.db differ diff --git a/k4ever/main/models.py b/k4ever/main/models.py index 83ccfef..f9fd3c9 100644 --- a/k4ever/main/models.py +++ b/k4ever/main/models.py @@ -4,3 +4,6 @@ from django.contrib.auth.models import User class UserProfile(models.Model): user = models.ForeignKey(User, unique=True) balance = models.FloatField() + + def __unicode__(self): + return "%s (Kontostand: %s)" % (self.user ,self.balance) \ No newline at end of file diff --git a/k4ever/main/templates/base.html b/k4ever/main/templates/base.html new file mode 100644 index 0000000..a1b5df5 --- /dev/null +++ b/k4ever/main/templates/base.html @@ -0,0 +1,27 @@ + + + + + Cashboxes are forever... + + +
+ Its Alive - and here could be a logo. Wouldn't that be nice? + {% if user.is_authenticated %} + Logged in as {{ user }} + {% endif %} +
+ +
+ {% block "content" %}{% endblock %} +
+ + diff --git a/k4ever/main/templates/main/navigation-login.html b/k4ever/main/templates/main/navigation-login.html new file mode 100644 index 0000000..f1b53f9 --- /dev/null +++ b/k4ever/main/templates/main/navigation-login.html @@ -0,0 +1,8 @@ +Main
+Buy
+Konto
+History
+{% if user.is_staff %} +
Admin foo
+Admin Interface

{% endif %} +Logout

diff --git a/k4ever/main/templates/main/navigation.html b/k4ever/main/templates/main/navigation.html new file mode 100644 index 0000000..00a7370 --- /dev/null +++ b/k4ever/main/templates/main/navigation.html @@ -0,0 +1,2 @@ +Login

+Registrieren

diff --git a/k4ever/main/templates/main/startpage.html b/k4ever/main/templates/main/startpage.html new file mode 100644 index 0000000..c2888ce --- /dev/null +++ b/k4ever/main/templates/main/startpage.html @@ -0,0 +1,5 @@ +{% extends "base.html" %} + +{% block "content" %} + No content here. +{% endblock %} diff --git a/k4ever/main/templates/registration/login.html b/k4ever/main/templates/registration/login.html new file mode 100644 index 0000000..f8df213 --- /dev/null +++ b/k4ever/main/templates/registration/login.html @@ -0,0 +1,30 @@ +{% extends "base.html" %} + +{% block "content" %} +{% if form.errors %} + + +

Dein Benutzername oder Passwort oder beides ist falsch.
+ Versuch es nochmal, aber achte auf CAPSLOCK und tippe nicht so schnell..

+

Falls du dein Passwort vergessen haben solltest (oder es nicht geht..), dann
+melde dich bei einem Admin deiner Wahl.

+{% endif %} + +
+{% csrf_token %} + + + + + + + + + +
{{ form.username.label_tag }}{{ form.username }}
{{ form.password.label_tag }}{{ form.password }}
+ + + +
+ +{% endblock %} diff --git a/k4ever/main/templates/registration/logout.html b/k4ever/main/templates/registration/logout.html new file mode 100644 index 0000000..418f7ce --- /dev/null +++ b/k4ever/main/templates/registration/logout.html @@ -0,0 +1,5 @@ +{% extends "base.html" %} + +{% block "content" %} +FIXME: KKTHXBYE +{% endblock %} diff --git a/k4ever/main/templates/registration/register.html b/k4ever/main/templates/registration/register.html new file mode 100644 index 0000000..9b21223 --- /dev/null +++ b/k4ever/main/templates/registration/register.html @@ -0,0 +1,19 @@ +{% extends "base.html" %} + +{% block "content" %} +
+>>> from frunde import tannek
+>>> tannek.troll(subject="registration_not_avaliable", extended_mode=True)
+ERROR_WHILE_HANDLING_EXCEPTION
+Matestand: -65337
+>>> tannek.insertMate()
+Matestand: -65336
+>>> [tannek.insertMate() for i in range(65337)]
+STACK_SIZE_EXCEEDED
+>>> [tannek.insertMate() for i in range(tannek.STACK_SIZE)] # FUCK YA!
+UNKNOWN_COMMAND
+>>> tannek.fixEverything()
+rebooting ...
+
+You see? No registration right now! I tried and tried and it didn't work. +{% endblock %} \ No newline at end of file diff --git a/k4ever/main/templates/templ.html b/k4ever/main/templates/templ.html new file mode 100644 index 0000000..c2888ce --- /dev/null +++ b/k4ever/main/templates/templ.html @@ -0,0 +1,5 @@ +{% extends "base.html" %} + +{% block "content" %} + No content here. +{% endblock %} diff --git a/k4ever/main/urls.py b/k4ever/main/urls.py new file mode 100644 index 0000000..9f1e042 --- /dev/null +++ b/k4ever/main/urls.py @@ -0,0 +1,10 @@ +from django.conf.urls.defaults import * +from django.conf import settings + + +urlpatterns = patterns('', + (r'^$', 'django.views.generic.simple.redirect_to', {'url': 'login/'}), + (r'^register/$', 'main.views.register'), + (r'^login/$', 'django.contrib.auth.views.login'), + (r'^logout/$', 'django.contrib.auth.views.logout', {'template_name': 'registration/logout.html'}), +) diff --git a/k4ever/main/views.py b/k4ever/main/views.py index 60f00ef..35ba0ec 100644 --- a/k4ever/main/views.py +++ b/k4ever/main/views.py @@ -1 +1,10 @@ -# Create your views here. +from django.shortcuts import render_to_response +from django.template import RequestContext +from django.contrib.auth.decorators import login_required + +@login_required +def startpage(request): + return render_to_response("main/startpage.html", {}, RequestContext(request)) + +def register(request): + return render_to_response("registration/register.html", RequestContext(request)) diff --git a/k4ever/settings.py b/k4ever/settings.py index 065b14f..945b41a 100644 --- a/k4ever/settings.py +++ b/k4ever/settings.py @@ -60,8 +60,10 @@ ADMIN_MEDIA_PREFIX = '/media/admin/' # Make this unique, and don't share it with anybody. SECRET_KEY = 'l(f*a$l)_n_n_5#lh@rvhv(na^!lj1u#bow=c!*90(1w$5%b^j' -# User Profile +# User Profile / Login stuff AUTH_PROFILE_MODULE = 'main.models.UserProfile' +LOGIN_URL = '/user/login/' +LOGIN_REDIRECT_URL = '/' # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( diff --git a/k4ever/transaction/models.py b/k4ever/transaction/models.py index 23c5874..23ee89d 100644 --- a/k4ever/transaction/models.py +++ b/k4ever/transaction/models.py @@ -7,17 +7,17 @@ class TransactionType(models.Model): needsCheck = models.BooleanField(default=True) def __unicode__(self): - return self.name + (self.needsCheck and " (needs Check)" or "") + return unicode(self.name + (self.needsCheck and " (needs Check)" or "")) class Transaction(models.Model): - user = models.ForeignKey(User, unique=True) + user = models.ForeignKey(User) transactionType = models.ForeignKey(TransactionType) dateTime = models.DateTimeField() amount = models.FloatField() checked = models.BooleanField(default=False) def __unicode__(self): - return "%s for user %s (%s), %schecked" % (self.amount, self.user, self.transactionType, (self.checked and "" or "not ")) + return u"%s for user %s (%s), %schecked" % (self.amount, self.user, self.transactionType, (self.checked and "" or "not ")) diff --git a/k4ever/transaction/templates/transaction/overview.html b/k4ever/transaction/templates/transaction/overview.html new file mode 100644 index 0000000..2f07ffe --- /dev/null +++ b/k4ever/transaction/templates/transaction/overview.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} + +{% block "content" %} + + {% for transaction in history %} + {{ transaction.amount }}, got that by {{ transaction.type }} + {% if transaction.checked %} + ist eingegangen + {% else %} + noch nicht da + {% endif %} +
+ {% endfor %} +{% endblock %} diff --git a/k4ever/transaction/urls.py b/k4ever/transaction/urls.py new file mode 100644 index 0000000..60c9fc1 --- /dev/null +++ b/k4ever/transaction/urls.py @@ -0,0 +1,8 @@ +from django.conf.urls.defaults import * + + +urlpatterns = patterns('', + (r'^$', 'transaction.views.overview'), + #(r'^transfer/$', 'transaction.views.transfer'), + #(r'^checkTransfers/$', 'transaction.views.checkTransfers'), +) diff --git a/k4ever/transaction/views.py b/k4ever/transaction/views.py index 60f00ef..8d7115e 100644 --- a/k4ever/transaction/views.py +++ b/k4ever/transaction/views.py @@ -1 +1,20 @@ -# Create your views here. +from django.shortcuts import render_to_response +from django.template import RequestContext +from django.contrib.auth.decorators import login_required +from models import Transaction, TransactionType + +@login_required +def overview(request): + history = Transaction.objects.filter(user=request.user).order_by("dateTime") + return render_to_response("transaction/overview.html", {'history': history}, RequestContext(request)) + +#@login_required +#def transfer(request): +# if request.method == 'POST': +# +# return render_to_response("transaction/transfered.html", RequestContext(request)) + +#@kassenwart_required +#def checkTransfers(request): +# transfers = Transaction.objects.filter(checked=False).sort("dateTime") +# return render_to_response("transaction/uncheckedTransfers.html", {'transfers' : tranfers}, RequestContext(request)) \ No newline at end of file diff --git a/k4ever/urls.py b/k4ever/urls.py index 284af01..434639b 100644 --- a/k4ever/urls.py +++ b/k4ever/urls.py @@ -5,13 +5,18 @@ from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', - # Example: - # (r'^k4ever/', include('k4ever.foo.urls')), - - # Uncomment the admin/doc line below and add 'django.contrib.admindocs' - # to INSTALLED_APPS to enable admin documentation: - # (r'^admin/doc/', include('django.contrib.admindocs.urls')), - - # Uncomment the next line to enable the admin: - (r'^admin/', include(admin.site.urls)), + # Example: + # (r'^k4ever/', include('k4ever.foo.urls')), + + # Uncomment the admin/doc line below and add 'django.contrib.admindocs' + # to INSTALLED_APPS to enable admin documentation: + # (r'^admin/doc/', include('django.contrib.admindocs.urls')), + # user stuff? go to main + (r'^$', 'main.views.startpage'), + (r'^user/', include('main.urls')), + (r'^transaction/', include('transaction.urls')), + #(r'^buy/', include('buyable.urls')), + + # Uncomment the next line to enable the admin: + (r'^admin/', include(admin.site.urls)), )