equal
deleted
inserted
replaced
31 from soc.logic.models.student_proposal import logic as proposal_logic |
31 from soc.logic.models.student_proposal import logic as proposal_logic |
32 |
32 |
33 |
33 |
34 # amount of students to create jobs for before updating |
34 # amount of students to create jobs for before updating |
35 DEF_STUDENT_STEP_SIZE = 10 |
35 DEF_STUDENT_STEP_SIZE = 10 |
36 |
|
37 # property text_data for a sendStudentProposalMail Job |
|
38 DEF_STUDENT_PROPOSAL_MAIL_TEXT_DATA_FMT = '%s/proposal_mail' |
|
39 |
36 |
40 |
37 |
41 def setupStudentProposalMailing(job_entity): |
38 def setupStudentProposalMailing(job_entity): |
42 """Job that setup jobs that will mail students if they have been accepted in |
39 """Job that setup jobs that will mail students if they have been accepted in |
43 a program with a GSoC-like workflow. |
40 a program with a GSoC-like workflow. |
79 job_query_fields = job_fields.copy() |
76 job_query_fields = job_fields.copy() |
80 |
77 |
81 while students: |
78 while students: |
82 # for each student create a mailing job |
79 # for each student create a mailing job |
83 for student in students: |
80 for student in students: |
84 text_data = DEF_STUDENT_PROPOSAL_MAIL_TEXT_DATA_FMT % ( |
|
85 student.key().name()) |
|
86 |
81 |
87 job_query_fields['text_data'] = text_data |
82 job_query_fields['key_data'] = student.key() |
88 mail_job = job_logic.getForFields(job_query_fields, unique=True) |
83 mail_job = job_logic.getForFields(job_query_fields, unique=True) |
89 |
84 |
90 if not mail_job: |
85 if not mail_job: |
91 # this student did not receive mail yet |
86 # this student did not receive mail yet |
92 job_fields['text_data'] = text_data |
|
93 job_fields['key_data'] = [student.key()] |
87 job_fields['key_data'] = [student.key()] |
94 job_logic.updateOrCreateFromFields(job_fields) |
88 job_logic.updateOrCreateFromFields(job_fields) |
95 |
89 |
96 # update our own job |
90 # update our own job |
97 last_student_key = students[-1].key() |
91 last_student_key = students[-1].key() |