Beispiel #1
0
def new_puzzle(request):
	if request.method == 'POST':
		user = request.user
		photo = Photo(user = user, image = ImageFile(request.FILES['puzzlaefFile']))
		photo.save()
		make_new_puzzle(user, photo)
		return HttpResponse(simplejson.dumps({"success":True}), mimetype='application/javascript')	
	else:
		return HttpResponse(simplejson.dumps({"error":"Method not POST"}))
Beispiel #2
0
def make_move(request):
	if request.method == 'POST':
		user = request.user
		puzzle_id = long(request.GET['puzzle'])
		puzzle = get_puzzle(puzzle_id)
		photo = Photo(user = user, image = ImageFile(request.FILES['puzzlaefFile']))
		photo.save()
		
		move_made = make_move_with_photo(user, puzzle_id, photo)
		
		if move_made:
			send_mail('Puzzlaef - it is now your turn!', "It's your turn to respond in the puzzle " + str(puzzle), EMAIL_HOST_USER, [user.email], fail_silently=False)	
			
			printer = PuzzlePrinter()
			puzzleAsString = printer.get_user_puzzle_as_string(get_puzzle(puzzle_id), request)											
			return HttpResponse(simplejson.dumps({"success":True, "puzzleAsString":puzzleAsString, "puzzleID": request.GET['puzzle']}), mimetype='application/javascript')	
		else:
			return HttpResponse(simplejson.dumps({"error":"It is not your turn or you do not have access to this puzzle"}))	
	else:
		return HttpResponse(simplejson.dumps({"error":"Method not POST"}))	
Beispiel #3
0
def upload_theme(request):
	if request.method == 'POST':
		theme = ImageFile(request.FILES['puzzlaefFile'])
		photo = Photo()
		photo.image = theme
		photo.user = User.objects.get(id=request.user.id)
		photo.title = split(theme.name, '.')[0]
		photo.isTheme = True
		photo.save()

		return HttpResponse(simplejson.dumps({"success":True}))	
	else:
		return HttpResponse(simplejson.dumps({"error":"Method not POST"}))