Ejemplo n.º 1
0
def create_greeting(request):
    if request.method == "POST":
        greeting = Greeting()
        greeting.content = request.POST.get("content")
        greeting.isprivate = request.POST.get("isprivate")
        if greeting.isprivate == None:
            greeting.isprivate = 0

    try:
        user_id = request.session["user_id"]
    except KeyError:
        user_id = User.objects.all().filter(username="******")[0].id
    greeting.author = User.objects.get(id=user_id)

    greeting.save()

    return HttpResponseRedirect("/greeting/")
Ejemplo n.º 2
0
def create_greeting(request):
	if request.method == 'POST':
		greeting = Greeting()
		greeting.content = request.POST.get('content')
		greeting.isprivate = request.POST.get('isprivate')
		if greeting.isprivate == None:
			greeting.isprivate = 0
	
	try:
		user_id = request.session['user_id']
	except KeyError:
		user_id = User.objects.all().filter( username='******')[0].id
	greeting.author = User.objects.get( id = user_id)
	
	greeting.save()
	
	return HttpResponseRedirect('/greeting/')