reg/views.py
changeset 18 7dae32a2439b
parent 17 125b6fc8f20b
child 19 115860e87238
--- a/reg/views.py	Mon Apr 12 16:17:53 2010 +0530
+++ b/reg/views.py	Mon Apr 12 18:15:21 2010 +0530
@@ -1,3 +1,5 @@
+from datetime import datetime
+
 from django.contrib.auth.models import User
 from django.contrib.auth import authenticate, login, logout
 from django.contrib.auth.decorators import login_required
@@ -19,9 +21,8 @@
     """
 
     user = request.user
-    events = Event.objects.all()[:10]
 
-    return render_to_response('index.html', {'user':user, 'events':events})
+    return render_to_response('index.html', {'user':user})
 
 def user_login(request):
     """ get the user object from e-mail and then check for password.
@@ -324,4 +325,18 @@
         form = reg_forms.EditProfileForm(old_info)
         return render_to_response('edit_profile.html', {'user':user, 'form':form})
 
+def list_events(request):
+    """ Get all the events including those that are over and list them.
+    """
 
+    user = request.user
+
+    today = datetime.now()
+    context = {'user':user,
+               'upcoming_events': Event.objects.filter(start_date__gt=today),
+               'ongoing_events': Event.objects.filter(start_date__lte=today, stop_date__gte=today),
+               'previous_events': Event.objects.filter(stop_date__lt=today),
+              }
+
+    return render_to_response('list_events.html', context)
+