コード例 #1
0
ファイル: views.py プロジェクト: belzner/pixelicity
def index(request):
	name = ""
	un = ""
	locations = []
	allLocs = []
	achievements = []
	allAch = []
	stats = []
	new = False
	character = None
	if request.user.is_authenticated():
		name = request.user.first_name
		un = request.user.username
		userLoc = UserLocs.objects.get(user=request.user)
		locations = userLoc.locations.all()
		allLocs = Locations.objects.all().exclude(locType="residential")
		userCollect = Collection.objects.get(user=request.user)
		newAch = []
		numResi = len(userLoc.locations.filter(locType="residential"))
		numRest = len(userLoc.locations.filter(locType="restaurant"))
		numShop = len(userLoc.locations.filter(locType="shopping"))
		numItem = len(userCollect.items.all())
		newAch = collectAch(request.user, userLoc)
		if newAch:
			new = True
		userAch = UserAchieve.objects.get(user=request.user)
		achievements = userAch.achievements.all()
		allAch = Achievement.objects.all()
		for charac in Character.objects.all():
			if charac.achieve in achievements and charac not in userCollect.characters.all():
				character = charac
		numChar = len(userCollect.characters.all())
		stats = [len(locations), numResi, numRest, len(achievements), request.user.date_joined, numShop, numChar, numItem]
	return render(request, 'index.html', {'name': name, 'username': un, 'locations': locations, 'allLocs': allLocs, 'achievements': achievements, 'new': new, 'allAch': allAch, 'stats': stats, 'character': character})
コード例 #2
0
def index(request):
    name = ""
    un = ""
    locations = []
    allLocs = []
    achievements = []
    allAch = []
    stats = []
    new = False
    character = None
    if request.user.is_authenticated():
        name = request.user.first_name
        un = request.user.username
        userLoc = UserLocs.objects.get(user=request.user)
        locations = userLoc.locations.all()
        allLocs = Locations.objects.all().exclude(locType="residential")
        userCollect = Collection.objects.get(user=request.user)
        newAch = []
        numResi = len(userLoc.locations.filter(locType="residential"))
        numRest = len(userLoc.locations.filter(locType="restaurant"))
        numShop = len(userLoc.locations.filter(locType="shopping"))
        numItem = len(userCollect.items.all())
        newAch = collectAch(request.user, userLoc)
        if newAch:
            new = True
        userAch = UserAchieve.objects.get(user=request.user)
        achievements = userAch.achievements.all()
        allAch = Achievement.objects.all()
        for charac in Character.objects.all():
            if charac.achieve in achievements and charac not in userCollect.characters.all(
            ):
                character = charac
        numChar = len(userCollect.characters.all())
        stats = [
            len(locations), numResi, numRest,
            len(achievements), request.user.date_joined, numShop, numChar,
            numItem
        ]
    return render(
        request, 'index.html', {
            'name': name,
            'username': un,
            'locations': locations,
            'allLocs': allLocs,
            'achievements': achievements,
            'new': new,
            'allAch': allAch,
            'stats': stats,
            'character': character
        })
コード例 #3
0
ファイル: views.py プロジェクト: belzner/pixelicity
def addloc(request):
	ul = UserLocs.objects.get(user=request.user)
	numAch = len(UserAchieve.objects.get(user=request.user).achievements.all())
	numResi = len(ul.locations.filter(locType="residential"))
	numRest = len(ul.locations.filter(locType="restaurant"))
	results = {'success': False, 'id': 0, 'newAch': False, 'numAch': numAch, 'numResi': numResi, 'numRest': numRest}
	if request.user.is_authenticated():
		if request.method == u'GET':
			GET = request.GET
			if GET.has_key(u'li'):
				li = int(GET[u'li'])
				loc = Locations.objects.get(locId=li)
				ul.locations.add(loc)
				ul.save()
				newAch = collectAch(request.user, ul)
				numAch = len(UserAchieve.objects.get(user=request.user).achievements.all())
				numResi = len(ul.locations.filter(locType="residential"))
				numRest = len(ul.locations.filter(locType="restaurant"))
				numShop = len(ul.locations.filter(locType="shopping"))
				results = {'success': True, 'id': li, 'newAch': newAch, 'numAch': numAch, 'numResi': numResi, 'numRest': numRest, 'numShop': numShop}
	jsonRes = json.dumps(results)
	return HttpResponse(jsonRes, mimetype='application/json')
コード例 #4
0
def addloc(request):
    ul = UserLocs.objects.get(user=request.user)
    numAch = len(UserAchieve.objects.get(user=request.user).achievements.all())
    numResi = len(ul.locations.filter(locType="residential"))
    numRest = len(ul.locations.filter(locType="restaurant"))
    results = {
        'success': False,
        'id': 0,
        'newAch': False,
        'numAch': numAch,
        'numResi': numResi,
        'numRest': numRest
    }
    if request.user.is_authenticated():
        if request.method == u'GET':
            GET = request.GET
            if GET.has_key(u'li'):
                li = int(GET[u'li'])
                loc = Locations.objects.get(locId=li)
                ul.locations.add(loc)
                ul.save()
                newAch = collectAch(request.user, ul)
                numAch = len(
                    UserAchieve.objects.get(
                        user=request.user).achievements.all())
                numResi = len(ul.locations.filter(locType="residential"))
                numRest = len(ul.locations.filter(locType="restaurant"))
                numShop = len(ul.locations.filter(locType="shopping"))
                results = {
                    'success': True,
                    'id': li,
                    'newAch': newAch,
                    'numAch': numAch,
                    'numResi': numResi,
                    'numRest': numRest,
                    'numShop': numShop
                }
    jsonRes = json.dumps(results)
    return HttpResponse(jsonRes, mimetype='application/json')