created a view to edit and update address anoop
authornishanth
Fri, 03 Sep 2010 16:04:54 +0530
branchanoop
changeset 236 af8cee5a0a27
parent 235 7583311884e1
child 237 53b9c79dfbf0
created a view to edit and update address
sdi/views.py
--- a/sdi/views.py	Fri Sep 03 15:59:06 2010 +0530
+++ b/sdi/views.py	Fri Sep 03 16:04:54 2010 +0530
@@ -6,7 +6,7 @@
 from django.contrib.auth import authenticate, login, logout
 
 from sage_days.sdi.models import Registrant, RegistrantInfo, ParticipantInfo
-from sage_days.sdi.forms import RegisterForm, SearchForm, EmailForm, LoginForm, UserSelectForm, ParticipantInfoForm, SendAccoForm
+from sage_days.sdi.forms import RegisterForm, SearchForm, EmailForm, LoginForm, UserSelectForm, ParticipantInfoForm, SendAccoForm, EditAddressForm
 from sage_days.sdi.events import send_reg_complete_mail, mail_invi, send_sgd_ptc_confirm, send_cnf_email, send_wsp_ptc_confirm, send_acco_confirm_mail
 from sage_days.settings import APACHE_URL_PREFIX as aup
 
@@ -258,6 +258,30 @@
     else:
         return render_to_response("cnf_sgd_ptc.html", {"user":user})
 
+def confirm_address(request, uid):
+    """ match id versus email and let him edit the address
+    """
+
+    try:
+        email = request.GET['email']
+    except MultiValueDictKeyError:
+        raise Http404
+
+    try:
+        user = Registrant.objects.get(id=uid, email=email)
+    except Registrant.DoesNotExist:
+        raise Http404
+
+    form = EditAddressForm(request.POST, instance=user)
+    if request.method == "POST" and form.is_valid():
+        form.save()
+
+        send_addr_upd_email(user)
+
+        return render_to_response("address_updated.html", {"user":user})
+    else:
+        return render_to_response("update_address.html", {"user":user})
+
 def admin_login(request):
     """ basic login.
     """