|
1 # Note: Most of the code below is hard coded with values. Please change it |
|
2 # required. Reprensented as (HC) for Hard Coded values. |
|
3 |
|
4 from sage_days.sdi.events import send_acco_confirm_mail |
|
5 from sage_days.sdi.events import send_acco_reject_mail |
|
6 from sage_days.sdi.models import ParticipantInfo, RegistrantInfo |
|
7 |
|
8 |
|
9 def allot(): |
|
10 """Performs the allotment of accomodation based on availability for the |
|
11 participants who have requested accommodation. |
|
12 """ |
|
13 |
|
14 # (HC) |
|
15 # Availability for number of people at various locations. Here in the |
|
16 # Order of IITB Hostel, IITB Guest house and then NITIE |
|
17 availability = [30, 20, 20] |
|
18 |
|
19 # (HC) |
|
20 acco_info = ParticipantInfo.objects.filter( |
|
21 participant__acco_required=True) |
|
22 acco_given = acco_info[:65] |
|
23 acco_rejected = acco_info[65:] |
|
24 |
|
25 for participant in acco_given: |
|
26 if availability[0] <= 0: |
|
27 break |
|
28 if participant.will_sprint == '3' or participant.will_sprint == '2': |
|
29 if participant.participant.profession.lower() == 'student': |
|
30 reg_info = participant.participant.registrantinfo_set.get() |
|
31 reg_info.status_of_accomodation = '2' |
|
32 reg_info.acco_location = '0' |
|
33 availability[0] -= 1 |
|
34 reg_info.save() |
|
35 |
|
36 for participant in acco_given: |
|
37 if availability[1] <= 0: |
|
38 break |
|
39 if participant.participant.gender == 'F': |
|
40 reg_info = participant.participant.registrantinfo_set.get() |
|
41 reg_info.status_of_accomodation = '2' |
|
42 reg_info.acco_location = '1' |
|
43 availability[1] -= 1 |
|
44 reg_info.save() |
|
45 if participant.participant.gender == 'M': |
|
46 if (participant.will_sprint == '3' or |
|
47 participant.will_sprint == '2'): |
|
48 if participant.participant.profession.lower() != 'student': |
|
49 reg_info = participant.participant.registrantinfo_set.get() |
|
50 reg_info.status_of_accomodation = '2' |
|
51 reg_info.acco_location = '1' |
|
52 availability[1] -= 1 |
|
53 reg_info.save() |
|
54 |
|
55 for participant in acco_given: |
|
56 if availability[2] <= 0: |
|
57 break |
|
58 if (participant.will_sprint == '1' |
|
59 and participant.participant.gender == 'M'): |
|
60 reg_info = participant.participant.registrantinfo_set.get() |
|
61 reg_info.status_of_accomodation = '2' |
|
62 reg_info.acco_location = '2' |
|
63 availability[2] -= 1 |
|
64 reg_info.save() |
|
65 |
|
66 for participant in acco_given: |
|
67 reg_info = participant.participant.registrantinfo_set.get() |
|
68 reg_info.status_of_accomodation = '3' |
|
69 reg_info.save() |
|
70 |
|
71 def send_mails(): |
|
72 """Sends mails to all those who have been alloted accommodation. |
|
73 """ |
|
74 |
|
75 hostel_participants = RegistrantInfo.objects.filter( |
|
76 status_of_accomodation=2, acco_location=0) |
|
77 ghouse_partiticpants = RegistrantInfo.objects.filter( |
|
78 status_of_accomodation=2, acco_location=1) |
|
79 nitie_participants = RegistrantInfo.objects.filter( |
|
80 status_of_accomodation=2, acco_location=2) |
|
81 acco_rejected = RegistrantInfo.objects.filter( |
|
82 status_of_accomodation=3) |
|
83 |
|
84 for p in hostel_participants: |
|
85 send_acco_confirm_mail(p.registrant, 'IIT Bombay Hostel', |
|
86 '150', True) |
|
87 |
|
88 for p in ghouse_partiticpants: |
|
89 send_acco_confirm_mail(p.registrant, 'IIT Bombay Guest House', '300') |
|
90 |
|
91 for p in nitie_participants: |
|
92 send_acco_confirm_mail(p.registrant, 'NITIE House', '500') |
|
93 |
|
94 for p in acco_rejected: |
|
95 send_acco_reject_mail(p.registrant) |
|
96 |
|
97 |
|
98 #65 |
|
99 #Participants attending sprints: 21 |
|
100 #Female participants attending sprints: 2 |
|
101 #Male participants attending sprints: 19 |
|
102 #Female participants may be attending sprints: 4 |
|
103 #Male participants may beattending sprints: 21 |