sdi/views.py
branchanoop
changeset 120 f9408ab30ace
parent 118 6c3602582f9f
child 122 39cfefd9641c
equal deleted inserted replaced
118:6c3602582f9f 120:f9408ab30ace
     3 from django.contrib.auth.decorators import login_required
     3 from django.contrib.auth.decorators import login_required
     4 from django.utils.datastructures import MultiValueDictKeyError
     4 from django.utils.datastructures import MultiValueDictKeyError
     5 
     5 
     6 from django.contrib.auth import authenticate, login, logout
     6 from django.contrib.auth import authenticate, login, logout
     7 
     7 
     8 from sage_days.sdi.models import Registrant
     8 from sage_days.sdi.models import Registrant, RegistrantInfo, ParticipantInfo
     9 from sage_days.sdi.forms import RegisterForm, SearchForm, EmailForm, LoginForm, UserSelectForm
     9 from sage_days.sdi.forms import RegisterForm, SearchForm, EmailForm, LoginForm, UserSelectForm
    10 from sage_days.sdi.events import send_reg_complete_mail, mail_invi, send_wsp_ptc_confirm
    10 from sage_days.sdi.events import send_reg_complete_mail, mail_invi, send_wsp_ptc_confirm
    11 from sage_days.settings import APACHE_URL_PREFIX as aup
    11 from sage_days.settings import APACHE_URL_PREFIX as aup
    12 
    12 
    13 def register(request):
    13 def register(request):
   186 
   186 
   187         return render_to_response("attending_wsp.html")
   187         return render_to_response("attending_wsp.html")
   188     else:
   188     else:
   189         return render_to_response("cnf_wsp_ptc.html", {"user":user})
   189         return render_to_response("cnf_wsp_ptc.html", {"user":user})
   190 
   190 
       
   191 def confirm_sgd_participation(request, uid):
       
   192     """ match id versus email and take lappy details.
       
   193     """
       
   194 
       
   195     try:
       
   196         email = request.GET['email']
       
   197     except MultiValueDictKeyError:
       
   198         raise Http404
       
   199 
       
   200     try:
       
   201         user = Registrant.objects.get(id=uid, email=email)
       
   202     except Registrant.DoesNotExist:
       
   203         raise Http404
       
   204 
       
   205     user_info = user.registrantinfo_set.all()[0]
       
   206     status = user_info.status_of_attending_sagedays
       
   207     if status == "3":
       
   208         return render_to_response("attending_sgd.html")
       
   209     elif status != 2:
       
   210         raise Http404
       
   211 
       
   212     if request.method == "POST":
       
   213         participant_info = ParticipantInfo()
       
   214         participant_info.participant = user
       
   215         participant_info.save()
       
   216     else:
       
   217         return render_to_response("cnf_sgd_ptc.html", {"user":user})
       
   218 
       
   219 
   191 def admin_login(request):
   220 def admin_login(request):
   192     """ basic login.
   221     """ basic login.
   193     """
   222     """
   194 
   223 
   195     redirect_url = "/%s/registration/stats"%aup
   224     redirect_url = "/%s/registration/stats"%aup