-
Notifications
You must be signed in to change notification settings - Fork 2
/
views.py
28 lines (24 loc) · 924 Bytes
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect, Http404
from django.template import RequestContext
from django.contrib.auth.models import User
def main(request):
logged_in = False
user = ''
if request.user.is_authenticated():
user = request.user
logged_in = True
return render_to_response('main.html', { 'logged_in': logged_in, 'user': user })
def userinfo(request, user_id):
if not request.user.is_authenticated():
return HttpResponseRedirect('/')
else:
logged_in = True
try:
user = User.objects.get(pk = user_id)
except User.DoesNotExist:
raise Http404
return render_to_response('userinfo.html',
{ 'user': request.user.username,
'requested_user': user,
'logged_in': logged_in }, context_instance = RequestContext(request))