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, RegistrantInfo, ParticipantInfo |
8 from sage_days.sdi.models import Registrant, RegistrantInfo, ParticipantInfo |
9 from sage_days.sdi.forms import RegisterForm, SearchForm, EmailForm, LoginForm, UserSelectForm, ParticipantInfoForm |
9 from sage_days.sdi.forms import RegisterForm, SearchForm, EmailForm, LoginForm, UserSelectForm, ParticipantInfoForm, SendAccoForm |
10 from sage_days.sdi.events import send_reg_complete_mail, mail_invi, send_sgd_ptc_confirm, send_cnf_email, send_wsp_ptc_confirm |
10 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 |
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): |
14 """ The user register page. |
14 """ The user register page. |
15 """ |
15 """ |
150 attending_ppl = Registrant.objects.filter(registrantinfo__status_of_attending_sagedays ="3") |
150 attending_ppl = Registrant.objects.filter(registrantinfo__status_of_attending_sagedays ="3") |
151 not_confirmed_ppl = Registrant.objects.filter(registrantinfo__status_of_attending_sagedays ="2") |
151 not_confirmed_ppl = Registrant.objects.filter(registrantinfo__status_of_attending_sagedays ="2") |
152 not_selected_ppl = Registrant.objects.filter(registrantinfo__status_of_attending_sagedays ="1") |
152 not_selected_ppl = Registrant.objects.filter(registrantinfo__status_of_attending_sagedays ="1") |
153 |
153 |
154 user_choices = list(not_selected_ppl) + list(not_confirmed_ppl) |
154 user_choices = list(not_selected_ppl) + list(not_confirmed_ppl) |
155 form = UserSelectForm(user_choices, request.POST) |
155 form = SendAccoForm(user_choices, request.POST) |
156 |
156 |
157 if request.method == "POST" and form.is_valid(): |
157 if request.method == "POST" and form.is_valid(): |
158 selected_users = form.cleaned_data['selected_users'] |
158 selected_users = form.cleaned_data['selected_users'] |
159 for user in selected_users: |
159 for user in selected_users: |
160 user_info = user.registrantinfo_set.all()[0] |
160 user_info = user.registrantinfo_set.all()[0] |
192 user_info = user.registrantinfo_set.all()[0] |
192 user_info = user.registrantinfo_set.all()[0] |
193 user_info.status_of_accomodation = "2" |
193 user_info.status_of_accomodation = "2" |
194 user_info.save() |
194 user_info.save() |
195 |
195 |
196 message = form.cleaned_data['message'] |
196 message = form.cleaned_data['message'] |
|
197 send_acco_confirm(user, message) |
197 |
198 |
198 return render_to_response("sent_acco_confirm.html", {"selected_users":selected_users}) |
199 return render_to_response("sent_acco_confirm.html", {"selected_users":selected_users}) |
199 else: |
200 else: |
200 return render_to_response("send_acco_cnf.html", {"rejected": rejected_ppl, |
201 return render_to_response("send_acco_cnf.html", {"rejected": rejected_ppl, |
201 "selected":selected_ppl, |
202 "selected":selected_ppl, |