406 |
406 |
407 if request.POST and request.POST.get('result'): |
407 if request.POST and request.POST.get('result'): |
408 # store result in the datastore |
408 # store result in the datastore |
409 fields = {'link_id': program_entity.link_id, |
409 fields = {'link_id': program_entity.link_id, |
410 'scope': program_entity, |
410 'scope': program_entity, |
411 'scope_path': program_entity.key().name(), |
411 'scope_path': program_entity.key().id_or_name(), |
412 'json_representation' : request.POST['result'] |
412 'json_representation' : request.POST['result'] |
413 } |
413 } |
414 key_name = duplicates_logic.getKeyNameFromFields(fields) |
414 key_name = duplicates_logic.getKeyNameFromFields(fields) |
415 duplicates_logic.updateOrCreateFromKeyName(fields, key_name) |
415 duplicates_logic.updateOrCreateFromKeyName(fields, key_name) |
416 |
416 |
430 |
430 |
431 query = org_logic.logic.getQueryForFields(fields) |
431 query = org_logic.logic.getQueryForFields(fields) |
432 |
432 |
433 to_json = { |
433 to_json = { |
434 'nr_of_orgs': query.count(), |
434 'nr_of_orgs': query.count(), |
435 'program_key': program_entity.key().name()} |
435 'program_key': program_entity.key().id_or_name()} |
436 json = simplejson.dumps(to_json) |
436 json = simplejson.dumps(to_json) |
437 context['info'] = json |
437 context['info'] = json |
438 context['offset_length'] = 10 |
438 context['offset_length'] = 10 |
439 |
439 |
440 fields = {'link_id': program_entity.link_id, |
440 fields = {'link_id': program_entity.link_id, |
518 if slots_left_to_assign == 0: |
518 if slots_left_to_assign == 0: |
519 # no slots left so next org |
519 # no slots left so next org |
520 continue |
520 continue |
521 |
521 |
522 # store information about the org |
522 # store information about the org |
523 orgs_data[org.key().name()] = org_data |
523 orgs_data[org.key().id_or_name()] = org_data |
524 |
524 |
525 fields = {'org': org, |
525 fields = {'org': org, |
526 'mentor !=': None, |
526 'mentor !=': None, |
527 'status': 'pending'} |
527 'status': 'pending'} |
528 order = ['-score'] |
528 order = ['-score'] |
534 # store each proposal in the dictionary |
534 # store each proposal in the dictionary |
535 for proposal in student_proposal_entities: |
535 for proposal in student_proposal_entities: |
536 student_entity = proposal.scope |
536 student_entity = proposal.scope |
537 |
537 |
538 proposals_data.append( |
538 proposals_data.append( |
539 {'key_name': proposal.key().name(), |
539 {'key_name': proposal.key().id_or_name(), |
540 'proposal_title': proposal.title, |
540 'proposal_title': proposal.title, |
541 'student_key': student_entity.key().name(), |
541 'student_key': student_entity.key().id_or_name(), |
542 'student_name': student_entity.name(), |
542 'student_name': student_entity.name(), |
543 'student_contact': student_entity.email, |
543 'student_contact': student_entity.email, |
544 'org_key': org.key().name() |
544 'org_key': org.key().id_or_name() |
545 }) |
545 }) |
546 |
546 |
547 # return all the data in JSON format |
547 # return all the data in JSON format |
548 data = {'orgs': orgs_data, |
548 data = {'orgs': orgs_data, |
549 'proposals': proposals_data} |
549 'proposals': proposals_data} |
708 mentor_entity, params, id, user) |
708 mentor_entity, params, id, user) |
709 |
709 |
710 if user and not (student_entity or mentor_entity or org_admin_entity): |
710 if user and not (student_entity or mentor_entity or org_admin_entity): |
711 if timeline_helper.isActivePeriod(timeline_entity, 'student_signup'): |
711 if timeline_helper.isActivePeriod(timeline_entity, 'student_signup'): |
712 # this user does not have a role yet for this program |
712 # this user does not have a role yet for this program |
713 items += [('/student/apply/%s' % (program_entity.key().name()), |
713 items += [('/student/apply/%s' % (program_entity.key().id_or_name()), |
714 "Register as a Student", 'any_access')] |
714 "Register as a Student", 'any_access')] |
715 |
715 |
716 deadline = 'accepted_organization_announced_deadline' |
716 deadline = 'accepted_organization_announced_deadline' |
717 |
717 |
718 if timeline_helper.isAfterEvent(timeline_entity, deadline): |
718 if timeline_helper.isAfterEvent(timeline_entity, deadline): |
720 # add a link to list all the organizations |
720 # add a link to list all the organizations |
721 items += [(url, "List participating Organizations", 'any_access')] |
721 items += [(url, "List participating Organizations", 'any_access')] |
722 |
722 |
723 if not student_entity: |
723 if not student_entity: |
724 # add apply to become a mentor link |
724 # add apply to become a mentor link |
725 items += [('/org/apply_mentor/%s' % (program_entity.key().name()), |
725 items += [('/org/apply_mentor/%s' % (program_entity.key().id_or_name()), |
726 "Apply to become a Mentor", 'any_access')] |
726 "Apply to become a Mentor", 'any_access')] |
727 |
727 |
728 return items |
728 return items |
729 |
729 |
730 def _getStudentEntries(self, program_entity, student_entity, |
730 def _getStudentEntries(self, program_entity, student_entity, |
736 |
736 |
737 timeline_entity = program_entity.timeline |
737 timeline_entity = program_entity.timeline |
738 |
738 |
739 if timeline_helper.isActivePeriod(timeline_entity, 'student_signup'): |
739 if timeline_helper.isActivePeriod(timeline_entity, 'student_signup'): |
740 items += [('/student_proposal/list_orgs/%s' % ( |
740 items += [('/student_proposal/list_orgs/%s' % ( |
741 student_entity.key().name()), |
741 student_entity.key().id_or_name()), |
742 "Submit your Student Proposal", 'any_access')] |
742 "Submit your Student Proposal", 'any_access')] |
743 |
743 |
744 if timeline_helper.isAfterEvent(timeline_entity, 'student_signup_start'): |
744 if timeline_helper.isAfterEvent(timeline_entity, 'student_signup_start'): |
745 items += [(redirects.getListSelfRedirect(student_entity, |
745 items += [(redirects.getListSelfRedirect(student_entity, |
746 {'url_name':'student_proposal'}), |
746 {'url_name':'student_proposal'}), |