Added current devcat status to git

master
seba 13 years ago
parent 0f6c60020c
commit 171bc9827d

@ -11,11 +11,21 @@ Noch zu tun:
[ ] doku
[ ] API(wget)-Beispiele
[ ] Authblob erlaubt momentan beliebige größe - beschrängen auf 10kb o.ä.
[ ] API erlauben mehrere Items auf eine Order zu setzen (und damit auch deposit zu getränk zu kaufen)
Nice-to-haf:
[x] Search'n'Buy
[ ] Einstellungen (email bei ueberweisung,...?)
[ ] Django Admin interface in Seite eingeliedern (Normales Kassensystemmenu drueber))
http://www.djangobook.com/en/1.0/chapter17/
http://www.slideshare.net/maheshshtl/the-django-admin-interface
http://www.slideshare.net/lincolnloop/customizing-the-django-admin
[ ] Pagination fuer die Einkaufshistory und ggf. fuer die Buyable sites
https://docs.djangoproject.com/en/dev/topics/pagination/
Open for discussion:
- default value von 10 fuer num bei api history && alte transactions?
Konrad:
Abmeldenutton rechts oder rot?

@ -49,6 +49,11 @@ buyable/
types/
GET (=list)
""" list all types (groups) which an item can belong to """
history/
GET (=list)
""" list the last orders of a user """
num number of entries
account/
transactions/ or transfers/

@ -0,0 +1,68 @@
from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.http import HttpResponse, HttpResponseRedirect
from django.utils.http import urlquote
# taken and modified from
# https://bitbucket.org/yml/django-piston/src/dfb826a31ca8/piston/authentication.py
class DjangoAuthentication(object):
"""
Django authentication.
"""
def __init__(self, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME):
if not login_url:
login_url = settings.LOGIN_URL
self.login_url = login_url
self.redirect_field_name = redirect_field_name
self.request = None
def is_authenticated(self, request):
"""
This method call the `is_authenticated` method of django
User in django.contrib.auth.models.
`is_authenticated`: Will be called when checking for
authentication. It returns True if the user is authenticated
False otherwise.
"""
self.request = request
return request.user.is_authenticated()
def challenge(self):
"""
`challenge`: In cases where `is_authenticated` returns
False, the result of this method will be returned.
This will usually be a `HttpResponse` object with
some kind of challenge headers and 401 code on it.
"""
path = urlquote(self.request.get_full_path())
tup = self.login_url, self.redirect_field_name, path
return HttpResponseRedirect('%s?%s=%s' %tup)
# taken from
# http://staer.github.com/2011/01/21/piston-multi-auth.html
class MultiAuthentication(object):
""" Authenticated Django-Piston against multiple types of authentication """
def __init__(self, auth_types):
""" Takes a list of authenication objects to try against, the default
authentication type to try is the first in the list. """
self.auth_types = auth_types
self.selected_auth = auth_types[0]
def is_authenticated(self, request):
""" Try each authentication type in order and use the first that succeeds """
authenticated = False
for auth in self.auth_types:
authenticated = auth.is_authenticated(request)
if authenticated:
selected_auth = auth
break
return authenticated
def challenge(self):
""" Return the challenge for whatever the selected auth type is (or the default
auth type which is the first in the list)"""
return self.selected_auth.challenge()

@ -78,6 +78,19 @@ class BuyableTypeHandler(BaseHandler):
allowed_methods = ('GET',)
model = BuyableType
class HistoryHandler(BaseHandler):
allowed_methods = ('GET',)
fields = ('id', 'price', 'dateTime', ('purchase_set', (('buyable', ('id', )), 'price', 'name')))
@manglePluginPerms
def read(self, request):
num = getInt(request.GET, 'num', 0)
qset = Order.objects.filter(user=request.user)
if num > 0:
return qset[:num]
return qset
class TransactionTransactHandler(BaseHandler):
allowed_methods = ('GET', 'POST')
model = Transaction

@ -19,6 +19,7 @@ ad = {'authentication': multiAuth}
buyableItemRes = CsrfExemptResource(handler=BuyableItemHandler, **ad)
buyableTypeRes = CsrfExemptResource(handler=BuyableTypeHandler, **ad)
historyRes = CsrfExemptResource(handler=HistoryHandler, **ad)
transactionTransactRes = CsrfExemptResource(handler=TransactionTransactHandler, **ad)
transactionTypeRes = CsrfExemptResource(handler=TransactionTypeHandler, **ad)
@ -34,6 +35,7 @@ urlpatterns = patterns('',
url(r'buyable/item/?$', buyableItemRes),
url(r'buyable/item/(?P<itemId>\d+)/?$', buyableItemRes),
url(r'buyable/types/?$', buyableTypeRes),
url(r'buyable/history/?$', historyRes),
url(r'account/transactions/transact/?$', transactionTransactRes),
url(r'account/transfers/transfer/?$', transactionTransactRes),

@ -2,7 +2,8 @@
{% block "content" %}
{% if history %}
<table>
<h1>Fr&uuml;here Eink&auml;ufe von {{ user }}</h1>
<table width="800px" class="details">
<thead>
<tr>
<th>Buchung</th>
@ -34,6 +35,6 @@
</table>
{% else %}
{{ error }}
Alle alle die Orders :(
Es scheint so, als h&auml;ttest du bisher noch nichts gekauft, {{ user }}.
{% endif %}
{% endblock %}

@ -1,13 +1,20 @@
{% extends "base.html" %}
{% block "content" %}
<p>
{% if not error %}
You got the order {{ order }}
<h1>Danke für deinen Einkauf, {{ order.user }}.</h1>
Du hast soeben
{% for item in order.purchase_set.all %}
{{ item }}
{% endfor %}
{% endfor %} zum Gesamtpreis von {{ order.price|floatformat:2 }}€ gekauft.</a></p>
<p>
<a href="/store/">Noch mehr einkaufen!</a>
{% else %}
{{ error }}
Junge junge junge
<h1>Es ist ein Fehler aufgetreten.</h1>
</p>
<p><a href="/store/">Zurück zum Einkauf</a>
{% endif %}
</p>
{% endblock %}

@ -1,28 +1,69 @@
{% extends "base.html" %}
{% block "content" %}
<p><a href="/store/">Zur Liste aller Items</a></p>
{% if item %}
<table border="1" frame="box" rules="cols" width="40%" cellpadding="5">
<table class="showitem" width="40%">
<tr>
<td colspan="2"><img src="{{ MEDIA_URL }}{{ item.image }}"></td>
<td>
<table width="100%">
<tr>
<td colspan="2" align="center">
<div style="font-size:large">{{ item.name }}</div>
<img src="{{ MEDIA_URL }}{{ item.image }}">
</td>
</tr>
<tr>
<th>
Kategorie{{ item.buyableType.all.count|pluralize:"n"}}:</th>
<td>
{% for type in item.buyableType.all %}
{{ type }} <br/>
{% endfor %}
</td>
</tr>
<tr>
<th>
Preis:
</th>
<td>
{{ item.price|floatformat:2 }} € {% if item.hasDeposit %}(+ Pfand {{ item.deposit|floatformat:2 }} €) {% endif %}
</td>
</tr>
<tr>
<td colspan="2" align="center" style="padding:15px;font-style:italic">
"{{ item.description }}"
</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>Zugeh&ouml;rig zu:</th>
<td>{% for type in item.buyableType.all %}
{{ type }}
{% endfor %}</td>
<td>
<table width="100%">
<tr>
<td width="33%">
{% if item.hasDeposit %}
<a class="button" href="/store/buy/{{ item.id }}/with/deposit/">Kaufen - {{ item.price|floatformat:2 }} € <br/>+ {{ item.deposit|floatformat:2 }} € Pfand</a>
{% else %}
&nbsp;
{% endif %}
</td>
<td width="34%">
<a class="button" href="/store/buy/{{ item.id }}/">Kaufen - {{ item.price|floatformat:2 }} €<br/>{% if item.hasDeposit %} (Ohne Pfand){% endif %}</a>
</td>
<td width="33%">
{% if item.hasDeposit %}
<a class="button" href="/store/buy/{{ item.id }}/only/deposit/">Kaufen <br/>nur {{ item.deposit|floatformat:2 }} € Pfand</a>
{% else %}
&nbsp;
{% endif %}
</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>Kauf {{ item }}:</th>
<td>Buy <a href="/store/buy/{{ item.id }}/">it!</a></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>{% if item.hasDeposit %}
<a href="/store/buy/{{ item.id }}/with/deposit/">it+deposit!</a>
<a href="/store/buy/{{ item.id }}/only/deposit/"> only deposit!</a>
{% endif %}</td>
</tr></table>
</table>
{% else %}
No item found :(
{% endif %}

@ -1,11 +1,37 @@
{% extends "base.html" %}
{% block "content" %}
{% for item in items %}
<div style="float:left; width=200; ">
<a href="/store/show/{{ item.id }}"><img WIDTH=64 HEIGHT=64 src="{{ MEDIA_URL }}{{ item.image }}"></a>
</br> {{ item }}
</br> Buy <a href="/store/buy/{{ item.id }}/">it!</a>
<div style="float:left; width=200;">
<table class="showitem" width="864px" style="border-width:0px">
{% for item in items %}
<tr>
<td width="64px">
<a href="/store/show/{{ item.id }}"><img WIDTH=64 HEIGHT=64 src="{{ MEDIA_URL }}{{ item.image }}"></a>
</td>
<th width="200px" align="center">
<span style="font-size: large">{{ item.name }}</span><br/>
<a href="/store/show/{{ item.id }}">Details</a>
</th>
<td width="200px">
<a class="button" href="/store/buy/{{ item.id }}/">Kaufen f&uuml;r {{ item.price|floatformat:2 }} €<br/>{% if item.hasDeposit %} (Ohne Pfand){% endif %}</a>
</td>
<td width="200px">
{% if item.hasDeposit %}
<a class="button" href="/store/buy/{{ item.id }}/with/deposit/">Kaufen f&uuml;r {{ item.price|floatformat:2 }} € <br/>+ {{ item.deposit|floatformat:2 }} € Pfand</a>
{% else %}
&nbsp;
{% endif %}
</td>
<td width="200px">
{% if item.hasDeposit %}
<a class="button" href="/store/buy/{{ item.id }}/only/deposit/">Kaufen <br/>nur {{ item.deposit|floatformat:2 }} € Pfand</a>
{% else %}
&nbsp;
{% endif %}
</td>
</tr>
{% comment %}
Buy <a href="/store/buy/{{ item.id }}/">it!</a>
{% if item.hasDeposit %}
<a href="/store/buy/{{ item.id }}/with/deposit/">it+deposit!</a>
<a href="/store/buy/{{ item.id }}/only/deposit/"> only deposit!</a>
@ -14,6 +40,7 @@
{% for type in item.buyableType.all %}
{{ type }}
{% endfor %} )
</div>
{% endfor %}
</div>{% endcomment %}
{% endfor %}
</table>
{% endblock %}

@ -338,3 +338,57 @@ html body div#header div.search ul.ui-autocomplete li.ui-menu-item.focus {
.meta:first-line {
font-weight: bold;
}
/* TABLE */
/* Edited by Theri */
table.showitem {
border:1px solid #DFDFDF;
border-collapse: separate;
border-spacing: 5pt;
}
table.showitem td {
vertical-align: middle;
}
table.showitem th {
vertical-align: middle;
text-align:center;
}
table.details {
border-width: 0px;
margin-top: 25px;
}
table.details th {
vertical-align: middle;
text-align: center;
}
table.details td {
vertical-align: middle;
text-align: center;
}
.content a {
color: #3398CC;
text-decoration: none;
}
.content a.button {
text-align: center;
display: block;
margin-top: 7px;
padding: 0 10px;
}
.content a:hover {
background: #3398CC;
color: white;
}
.content h1 {
font: 20px "lucida grande", tahoma, verdana, arial, sans-serif;
text-align: center;
}

@ -74,7 +74,7 @@ LOGIN_REDIRECT_URL = '/'
AUTHENTICATION_BACKENDS = (
# 'main.backend.CustomLDAPBackend',
'django_auth_ldap.backend.LDAPBackend',
# 'django_auth_ldap.backend.LDAPBackend',
'django.contrib.auth.backends.ModelBackend',
)

@ -3,7 +3,7 @@ from models import Transaction
from main.fields import CurrencyField
class TransactionForm(forms.ModelForm):
amount = CurrencyField()
amount = CurrencyField(label='Betrag')
class Meta:
model = Transaction
exclude = ('user', 'dateTime', 'checked')

@ -10,7 +10,7 @@ class TransactionType(models.Model):
class Transaction(models.Model):
user = models.ForeignKey(User)
transactionType = models.ForeignKey(TransactionType)
transactionType = models.ForeignKey(TransactionType, verbose_name='Typ')
dateTime = models.DateTimeField()
amount = models.DecimalField(max_digits=8, decimal_places=2)
checked = models.BooleanField(default=False)

@ -3,33 +3,44 @@
{% block "content" %}
{% if transacted %}
{% if error %}
<font color="red"><b>ARGHZ</b></font>. U broakzt t3h formul4r!
<font color="red"><h1>Es ist beim Aufladen ein Fehler aufgetreten.</h1></font>
{% else %}
<font color="green"><b>YOU DID IT!</b></font>. You transacted money!
<font color="green"><h1>Du hast Geld aufgeladen.</h1></font>
{% endif %}
{% endif %}
<form method="POST" action="/transaction/">
{% csrf_token %}
<table>
{{ form.as_table }}
</table>
<input type="submit" value="Senden">
</form>
<div style="width:800px"><h1>Konto aufladen</h1>
nsactionType:
Amount<form method="POST" action="/transaction/">
{% csrf_token %}
<table width="500px" class="showitem" style="border-width:0px">
{{ form.as_table }}
<tr>
<td>
&nbsp;
</td>
<td>
<input type="submit" value="Senden">
</td>
</tr>
</table>
</form>
</div>
<div style="width:800px;margin-top:25px"><h1>Vergangene Transaktionen:</h1>
{% for transaction in history %}
{% if forloop.first and transacted %}
<b>
{% endif %}
[ {{ transaction.dateTime }} ] {{ transaction.amount|floatformat:2 }} Euronen durch: {{ transaction.transactionType }}
[ {{ transaction.dateTime }} ] {{ transaction.amount|floatformat:2 }} € durch {{ transaction.transactionType }}
{% if not transaction.transactionType.needsCheck or transaction.checked %}
eingegangen
{% else %}
<b> aber noch nicht bestaetigt </b>
<b> aber noch nicht best&auml;tigt </b>
{% endif %}
{% if forloop.first and transacted %}
</b>
{% endif %}
<br />
{% endfor %}
</div>
{% endblock %}

Loading…
Cancel
Save