reg/views.py
changeset 10 c52d170969f0
parent 9 e29ecb7819e7
child 11 334550460bd7
equal deleted inserted replaced
9:e29ecb7819e7 10:c52d170969f0
    17     """
    17     """
    18 
    18 
    19     user = request.user
    19     user = request.user
    20 
    20 
    21     events = Event.objects.all()[:10]
    21     events = Event.objects.all()[:10]
    22 
       
    23 
    22 
    24 def user_login(request):
    23 def user_login(request):
    25     """ get the user object from e-mail and then check for password.
    24     """ get the user object from e-mail and then check for password.
    26     """
    25     """
    27 
    26 
   105 def view_event(request, key):
   104 def view_event(request, key):
   106     """ get the event by its key and display it.
   105     """ get the event by its key and display it.
   107     """
   106     """
   108 
   107 
   109     user = request.user
   108     user = request.user
   110     is_guest = False if user.is_authenticated() else True
       
   111 
   109 
   112     try:
   110     try:
   113         event = Event.objects.get(key__iexact=key)
   111         event = Event.objects.get(key__iexact=key)
   114     except Event.DoesNotExist:
   112     except Event.DoesNotExist:
   115         return HttpResponse("F off")
   113         return redirect("/reg")
   116 
   114 
   117     return HttpResponse(str(event))
   115     is_guest = False if user.is_authenticated() else True
       
   116     is_attendee = True if user in event.attendees.all() else False
       
   117     is_org = True if user in event.organizers.all() else False
       
   118 
       
   119     context = {'is_guest': is_guest,
       
   120                'is_attendee': is_attendee,
       
   121                'is_org': is_org,
       
   122               }
       
   123     return render_to_response('view_event.html', context)
   118 
   124 
   119 def reset_password(request):
   125 def reset_password(request):
   120     """ check for the existance of e-mail.
   126     """ check for the existance of e-mail.
   121     Then call the event.
   127     Then call the event.
   122     """
   128     """