Added multi-authblob submission error msg

This commit is contained in:
theresa 2011-10-13 23:53:44 +02:00
parent a3223e197c
commit 60b16bd532
1 changed files with 16 additions and 9 deletions

View File

@ -20,18 +20,20 @@ def startpage(request):
allMostDrinks = allMost.filter(buyable__in=drinks).annotate(num_buys=Count('buyable')).order_by('-num_buys')
allMostSnacks = allMost.filter(buyable__in=snacks).annotate(num_buys=Count('buyable')).order_by('-num_buys')
usersMostDrinks = allMost.filter(buyable__in=drinks).filter(order__user=request.user.id).annotate(num_buys=Count('buyable')).order_by('-num_buys')
usersMostSnacks = allMost.filter(buyable__in=snacks).filter(order__user=request.user.id).annotate(num_buys=Count('buyable')).order_by('-num_buys')
# usersLastDrinks = allMost.filter(buyable__in=drinks).filter(order__user=request.user.id).annotate(num_buys=Count('buyable')).order_by('-order__dateTime')
# usersLastSnacks = allMost.filter(buyable__in=snacks).filter(order__user=request.user.id).annotate(num_buys=Count('buyable')).order_by('-order__dateTime')
usersLastDrinks = allMost.filter(buyable__in=drinks).filter(order__user=request.user.id).annotate(num_buys=Count('buyable')).order_by('-order__dateTime')
usersLastSnacks = allMost.filter(buyable__in=snacks).filter(order__user=request.user.id).annotate(num_buys=Count('buyable')).order_by('-order__dateTime')
usersLastDrinks = allMost.distinct().filter(buyable__in=drinks).filter(order__user=request.user.id).order_by('-order__dateTime')
usersLastSnacks = allMost.distinct().filter(buyable__in=snacks).filter(order__user=request.user.id).order_by('-order__dateTime')
usersLastDrinks = allMost.filter(buyable__in=drinks).filter(order__user=request.user.id).order_by('-order__dateTime')
usersLastSnacks = allMost.filter(buyable__in=snacks).filter(order__user=request.user.id).order_by('-order__dateTime')
#if someone knows a better way to do this, just replace this code
#purpose: filter usersLast so that it only contains unique items
#hint: distinct() does not work because dateTime is included due to order_by(), so all items appear distinct
usersLastDrinks_unique = []
for x in usersLastDrinks:
if not x in usersLastDrinks_unique:
@ -43,9 +45,10 @@ def startpage(request):
for x in usersLastSnacks:
if not x in usersLastSnacks_unique:
usersLastSnacks_unique.append(x)
#usersLastSnacks_unique = usersLastSnacks.distinct()
usersLastSnacks = usersLastSnacks_unique
return render_to_response("main/startpage.html", {'allMostDrinks' : allMostDrinks[:5], 'allMostSnacks' : allMostSnacks[:5], 'usersMostDrinks': usersMostDrinks[:5], 'usersMostSnacks': usersMostSnacks[:5], 'usersLastDrinks' : usersLastDrinks[:10], 'usersLastSnacks' : usersLastSnacks[:10]}, RequestContext(request))
return render_to_response("main/startpage.html", {'allMostDrinks' : allMostDrinks[:5], 'allMostSnacks' : allMostSnacks[:5], 'usersMostDrinks': usersMostDrinks[:5], 'usersMostSnacks': usersMostSnacks[:5], 'usersLastDrinks' : usersLastDrinks[:5], 'usersLastSnacks' : usersLastSnacks[:5]}, RequestContext(request))
def register(request):
""" The "no registration available" page... """
@ -122,9 +125,13 @@ def pluginAuthblob(request, pluginId):
d['pluginerror'] = "Der Authblob darf für dieses Plugin nicht vom User verändert werden (oder der Authblob war kaputt)"
return render_to_response("settings/settings.html", d, RequestContext(request))
if p.plugin.uniqueAuthblob and PluginPermission.objects.filter(plugin=plugin, authblob=request.POST["authblob"]).count() > 0:
pluginsWithAuthblob = PluginPermission.objects.filter(plugin=plugin, authblob=request.POST["authblob"])
if p.plugin.uniqueAuthblob and pluginsWithAuthblob.count() > 0:
d = getPluginDict(request)
d['pluginerror'] = "Achtung! Dein Authblob wird bereits von einer anderen Person benutzt. Bitte wähle einen anderen (eindeutigen) Authblob!"
if pluginsWithAuthblob[0].user == request.user:
d['pluginerror'] = "Das ist der gleiche Authblob, den du vorher auch hattest."
else:
d['pluginerror'] = "Achtung! Dein Authblob wird bereits von einer anderen Person benutzt. Bitte wähle einen anderen (eindeutigen) Authblob!"
return render_to_response("settings/settings.html", d, RequestContext(request))
p.authblob = request.POST['authblob']