source: subversion/sites/other/tilesAtHome_tahngo/user/views.py @ 9470

Last change on this file since 9470 was 9470, checked in by spaetz, 12 years ago

use correct user id.

File size: 2.0 KB
Line 
1from django.http import Http404
2from django.shortcuts import render_to_response
3import django.contrib.auth.views
4#from django.contrib.auth.models import User
5from tah.user.models import TahUser
6from tah.requests.models import Request
7
8def index(request):
9    return render_to_response("base_user.html");
10
11def show_user(request):
12    order = request.GET.get('order')
13    if order == 'tiles': sortorder='-renderedTiles'
14    elif order == 'upload':  sortorder='-kb_upload'
15    else:                sortorder='-last_activity'
16    u = TahUser.objects.filter(user__is_active=True).order_by(sortorder) # Get the first user in the system
17    return render_to_response("user_show.html",{'user':u});
18
19def show_single_user(request, searchstring, by):
20    """ display detail page on a single user. 'by' can be 'pk' (primary key)
21        and 'username' and specifies whether we
22        look for a username or id number.
23    """
24    if by == 'pk':
25      try: u = TahUser.objects.get(user__pk=searchstring) # Get the user in the system
26      except TahUser.DoesNotExist: 
27        raise Http404
28    else: 
29      try: u = TahUser.objects.get(user__username=searchstring) # Get the user in the system
30      except TahUser.DoesNotExist:
31        raise Http404
32
33    # if we want the user id, need to look at TahUser.user.pk, not TahUser.pk as we use this for ident
34    active = Request.objects.filter(status=1, client= u.user.pk)
35    finished = Request.objects.filter(status=2, client= u.user.pk)[:20]
36
37    return render_to_response("user_show_specific.html",{'user':u, 'active_reqs': active, 'finished_reqs': finished});
38
39#from django.contrib.auth import authenticate
40#user = authenticate(username='john', password='secret')
41#if user is not None:
42#    if user.is_active:
43#        print "You provided a correct username and password!"
44#        login(request, user)
45#    else:
46#        print "Your account has been disabled!"
47#else:
48#    print "Your username and password were incorrect."
49
50def login(request):
51  return django.contrib.auth.views.login(request,template_name='user_login.html')
Note: See TracBrowser for help on using the repository browser.