Merge branch 'master' of git.someserver.de:k4ever into morejson

This commit is contained in:
Sebastian Lohff 2012-01-27 20:20:41 +01:00
commit 5c480e452f
7 changed files with 59 additions and 5 deletions

View File

@ -10,6 +10,8 @@ from django.contrib.auth.models import User, Group
from piston.utils import rc
from main.models import Plugin, PluginPermission
from settings import PLUGIN_GROUP_ID
def manglePluginPerms(apiFunc):
""" Changes to a given user when the authenticated user is an plugin.
@ -81,7 +83,7 @@ def requirePlugin(apiFunc):
def wrapper(self, request, *args, **kwargs):
try:
if request.user:
group = request.user.groups.get(name="Plugin")
group = request.user.groups.get(pk=PLUGIN_GROUP_ID)
# no exception, exec apiFunc!
request.plugin = Plugin.objects.get(user=request.user)
return apiFunc(self, request, *args, **kwargs)

View File

@ -0,0 +1,16 @@
[
{
"pk": 1,
"model": "buyable.buyabletype",
"fields": {
"name": "Snack"
}
},
{
"pk": 2,
"model": "buyable.buyabletype",
"fields": {
"name": "Getr\u00e4nk"
}
}
]

View File

@ -0,0 +1,10 @@
from django.db.models.signals import post_syncdb
from django.core.management import commands, call_command
import buyable.models
def createBuyableTypes(sender, app, created_models, **kwargs):
if buyable.models.BuyableType in created_models:
call_command("loaddata", "buyable_types")
post_syncdb.connect(createBuyableTypes, sender=buyable.models)

View File

@ -0,0 +1,12 @@
[
{
"pk": 1,
"model": "auth.group",
"fields":
{
"name": "Plugin",
"permissions": []
}
}
]

10
k4ever/main/management.py Normal file
View File

@ -0,0 +1,10 @@
from django.db.models.signals import post_syncdb
from django.core.management import commands, call_command
import django.contrib.auth
def createPluginGroup(sender, app, created_models, **kwargs):
if django.contrib.auth.models.Group in created_models:
call_command("loaddata", "group_plugin")
post_syncdb.connect(createPluginGroup, sender=django.contrib.auth.models)

View File

@ -16,15 +16,15 @@ from django.template import RequestContext
from buyable.models import Purchase, Buyable, BuyableType
from main.helper import getUserFromAuthblob
from main.models import Plugin, PluginPermission
from settings import SNACK_TYPE_ID, DRINK_TYPE_ID
@login_required
def startpage(request):
''' Diese Funktion wird wahrscheinlich viel Last erzeugen, da
sie ueber mehrere Tabellen joined,filtered und wieder reduced.
'''
drinks = BuyableType.objects.get(name="Getränk").buyable_set.all()
snacks = BuyableType.objects.get(name="Snack").buyable_set.all()
drinks = BuyableType.objects.get(pk=DRINK_TYPE_ID).buyable_set.all()
snacks = BuyableType.objects.get(pk=SNACK_TYPE_ID).buyable_set.all()
context = {}
@ -163,7 +163,6 @@ def pluginAuthblob(request, pluginId):
if p.plugin.uniqueAuthblob:
print authblob.split("\n")
for line in authblob.split("\n"):
print "'%s'" % (line,), " <-- "
usr = getUserFromAuthblob(line, plugin)
if usr:
if usr == request.user:

View File

@ -23,6 +23,11 @@ DATABASES = {
}
}
# Default model ids for some purposes
DRINK_TYPE_ID = 2
SNACK_TYPE_ID = 1
PLUGIN_GROUP_ID = 1
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.