def _getStudentEntries(self, program_entity, student_entity, params, id, user): """Returns a list with menu items for students in a specific program. """ items = [] timeline_entity = program_entity.timeline if timeline_helper.isActivePeriod(timeline_entity, 'student_signup'): items += [('/student_proposal/list_orgs/%s' % ( student_entity.key().id_or_name()), "Submit your Student Proposal", 'any_access')] if timeline_helper.isAfterEvent(timeline_entity, 'student_signup_start'): items += [(redirects.getListSelfRedirect(student_entity, {'url_name':'student_proposal'}), "List my Student Proposals", 'any_access')] items += [(redirects.getEditRedirect(student_entity, {'url_name': 'student'}), "Edit my Student Profile", 'any_access')] if timeline_helper.isAfterEvent(timeline_entity, 'accepted_students_announced_deadline'): # add a link to show all projects items += [(redirects.getListProjectsRedirect(program_entity, {'url_name':'student'}), "List my Student Projects", 'any_access')] return items
def _getStudentEntries(self, program_entity, student_entity, params, id, user, prefix): """Returns a list with menu items for students in a specific program. """ items = [] timeline_entity = program_entity.timeline if timeline_helper.isActivePeriod(timeline_entity, 'student_signup') and \ student_entity.status == 'active': items += [('/gsoc/student_proposal/list_orgs/%s' % (student_entity.key().id_or_name()), "Submit your Student Proposal", 'any_access')] if timeline_helper.isAfterEvent(timeline_entity, 'student_signup_start'): items += [(redirects.getListSelfRedirect( student_entity, {'url_name': prefix + '/student_proposal'}), "List my Student Proposals", 'any_access')] if timeline_helper.isAfterEvent( timeline_entity, 'accepted_students_announced_deadline'): # add a link to show all projects items += [(redirects.getListProjectsRedirect( program_entity, {'url_name': prefix + '/student'}), "List my Student Projects", 'any_access')] items += super(View, self)._getStudentEntries(program_entity, student_entity, params, id, user, prefix) return items
def _getStudentEntries(self, program_entity, student_entity, params, id, user, prefix): """Returns a list with menu items for students in a specific program. """ items = [] timeline_entity = program_entity.timeline if timeline_helper.isActivePeriod(timeline_entity, 'student_signup') and \ student_entity.status == 'active': items += [('/gsoc/student_proposal/list_orgs/%s' % ( student_entity.key().id_or_name()), "Submit your Student Proposal", 'any_access')] if timeline_helper.isAfterEvent(timeline_entity, 'student_signup_start'): items += [(redirects.getListSelfRedirect(student_entity, {'url_name': prefix + '/student_proposal'}), "List my Student Proposals", 'any_access')] if timeline_helper.isAfterEvent(timeline_entity, 'accepted_students_announced_deadline'): # add a link to show all projects items += [(redirects.getListProjectsRedirect(program_entity, {'url_name': prefix + '/student'}), "List my Student Projects", 'any_access')] if timeline_helper.isBeforeEvent(program_entity.timeline, 'program_end') \ and student_entity.status == 'active': items += [(redirects.getManageRedirect(student_entity, {'url_name': prefix + '/student'}), "Resign as a Student", 'any_access')] items += super(View, self)._getStudentEntries(program_entity, student_entity, params, id, user, prefix) return items
def _getTimeDependentEntries(self, program_entity, params, id, user): """Returns a list with time dependent menu items. """ items = [] #TODO(ljvderijk) Add more timeline dependent entries timeline_entity = program_entity.timeline if timeline_helper.isActivePeriod(timeline_entity, 'org_signup'): # add the organization signup link items += [ (redirects.getApplyRedirect(program_entity, {'url_name': 'org_app'}), "Apply to become an Organization", 'any_access')] if user and timeline_helper.isAfterEvent(timeline_entity, 'org_signup_start'): filter = { 'applicant': user, 'scope': program_entity, } if org_app_logic.logic.getForFields(filter, unique=True): # add the 'List my Organization Applications' link items += [ (redirects.getListSelfRedirect(program_entity, {'url_name' : 'org_app'}), "List My Organization Applications", 'any_access')] # get the student entity for this user and program filter = {'user': user, 'scope': program_entity, 'status': 'active'} student_entity = student_logic.logic.getForFields(filter, unique=True) if student_entity: items += self._getStudentEntries(program_entity, student_entity, params, id, user) # get mentor and org_admin entity for this user and program filter = {'user': user, 'program': program_entity, 'status': 'active'} mentor_entity = mentor_logic.logic.getForFields(filter, unique=True) org_admin_entity = org_admin_logic.logic.getForFields(filter, unique=True) if mentor_entity or org_admin_entity: items += self._getOrganizationEntries(program_entity, org_admin_entity, mentor_entity, params, id, user) if user and not (student_entity or mentor_entity or org_admin_entity): if timeline_helper.isActivePeriod(timeline_entity, 'student_signup'): # this user does not have a role yet for this program items += [('/student/apply/%s' % (program_entity.key().id_or_name()), "Register as a Student", 'any_access')] deadline = 'accepted_organization_announced_deadline' if timeline_helper.isAfterEvent(timeline_entity, deadline): url = redirects.getAcceptedOrgsRedirect(program_entity, params) # add a link to list all the organizations items += [(url, "List participating Organizations", 'any_access')] if not student_entity: # add apply to become a mentor link items += [('/org/apply_mentor/%s' % (program_entity.key().id_or_name()), "Apply to become a Mentor", 'any_access')] deadline = 'accepted_students_announced_deadline' if timeline_helper.isAfterEvent(timeline_entity, deadline): items += [(redirects.getListProjectsRedirect(program_entity, {'url_name':'program'}), "List all student projects", 'any_access')] return items
def _getTimeDependentEntries(self, program_entity, params, id, user): """Returns a list with time dependent menu items. """ from soc.modules.gsoc.logic.models.org_app_survey import logic as \ org_app_logic items = [] timeline_entity = program_entity.timeline org_app_survey = org_app_logic.getForProgram(program_entity) if org_app_survey and \ timeline_helper.isActivePeriod(timeline_entity, 'org_signup'): # add the organization signup link items += [ (redirects.getTakeSurveyRedirect(org_app_survey, {'url_name': 'gsoc/org_app'}), "Apply to become an Organization", 'any_access') ] if user and org_app_survey and timeline_helper.isAfterEvent( timeline_entity, 'org_signup_start'): main_admin_fields = { 'main_admin': user, 'survey': org_app_survey, } backup_admin_fields = { 'backup_admin': user, 'survey': org_app_survey } org_app_record_logic = org_app_logic.getRecordLogic() if org_app_record_logic.getForFields(main_admin_fields, unique=True) or \ org_app_record_logic.getForFields(backup_admin_fields, unique=True): # add the 'List my Organization Applications' link items += [(redirects.getListSelfRedirect( org_app_survey, {'url_name': 'gsoc/org_app'}), "List My Organization Applications", 'any_access')] # get the student entity for this user and program filter = { 'user': user, 'scope': program_entity, 'status': ['active', 'inactive'] } student_entity = student_logic.getForFields(filter, unique=True) if student_entity: items += self._getStudentEntries(program_entity, student_entity, params, id, user, 'gsoc') # get mentor and org_admin entity for this user and program filter = { 'user': user, 'program': program_entity, 'status': ['active', 'inactive'] } mentor_entity = mentor_logic.getForFields(filter, unique=True) org_admin_entity = org_admin_logic.getForFields(filter, unique=True) if mentor_entity or org_admin_entity: items += self._getOrganizationEntries(program_entity, org_admin_entity, mentor_entity, params, id, user) if user and not (student_entity or mentor_entity or org_admin_entity): if timeline_helper.isActivePeriod(timeline_entity, 'student_signup'): # this user does not have a role yet for this program items += [('/gsoc/student/apply/%s' % (program_entity.key().id_or_name()), "Register as a Student", 'any_access')] deadline = 'accepted_organization_announced_deadline' if timeline_helper.isAfterEvent(timeline_entity, deadline): url = redirects.getAcceptedOrgsRedirect(program_entity, params) # add a link to list all the organizations items += [(url, "List participating Organizations", 'any_access')] if not student_entity and \ timeline_helper.isBeforeEvent(timeline_entity, 'program_end'): # add apply to become a mentor link items += [('/gsoc/org/apply_mentor/%s' % (program_entity.key().id_or_name()), "Apply to become a Mentor", 'any_access')] deadline = 'accepted_students_announced_deadline' if timeline_helper.isAfterEvent(timeline_entity, deadline): items += [(redirects.getListProjectsRedirect( program_entity, {'url_name': 'gsoc/program'}), "List all Student Projects", 'any_access')] return items
def _getTimeDependentEntries(self, program_entity, params, id, user): """Returns a list with time dependent menu items. """ items = [] timeline_entity = program_entity.timeline org_app_survey = org_app_logic.getForProgram(program_entity) if org_app_survey and \ timeline_helper.isActivePeriod(org_app_survey, 'survey'): # add the organization signup link items += [ (redirects.getTakeSurveyRedirect( org_app_survey, {'url_name': 'gsoc/org_app'}), "Apply to become an Organization", 'any_access')] if user and org_app_survey and timeline_helper.isAfterEvent( org_app_survey, 'survey_start'): main_admin_fields = { 'main_admin': user, 'survey': org_app_survey, } backup_admin_fields = { 'backup_admin': user, 'survey': org_app_survey } org_app_record_logic = org_app_logic.getRecordLogic() if org_app_record_logic.getForFields(main_admin_fields, unique=True) or \ org_app_record_logic.getForFields(backup_admin_fields, unique=True): # add the 'List my Organization Applications' link items += [ (redirects.getListSelfRedirect(org_app_survey, {'url_name' : 'gsoc/org_app'}), "List My Organization Applications", 'any_access')] # get the student entity for this user and program filter = { 'user': user, 'scope': program_entity, 'status': ['active', 'inactive'] } student_entity = student_logic.getForFields(filter, unique=True) if student_entity: items += self._getStudentEntries(program_entity, student_entity, params, id, user, 'gsoc') # get mentor and org_admin entity for this user and program filter = { 'user': user, 'program': program_entity, 'status': ['active', 'inactive'] } mentor_entity = mentor_logic.getForFields(filter, unique=True) org_admin_entity = org_admin_logic.getForFields(filter, unique=True) if mentor_entity or org_admin_entity: items += self._getOrganizationEntries(program_entity, org_admin_entity, mentor_entity, params, id, user) if not (student_entity or mentor_entity or org_admin_entity): if timeline_helper.isActivePeriod(timeline_entity, 'student_signup'): # this user does not have a role yet for this program items += [ ('/gsoc/student/apply/%s' % (program_entity.key().id_or_name()), "Register as a Student", 'any_access')] deadline = 'accepted_organization_announced_deadline' if timeline_helper.isAfterEvent(timeline_entity, deadline): url = redirects.getAcceptedOrgsRedirect(program_entity, params) # add a link to list all the organizations items += [(url, "List participating Organizations", 'any_access')] if not student_entity and \ timeline_helper.isBeforeEvent(timeline_entity, 'program_end'): # add apply to become a mentor link items += [ ('/gsoc/org/apply_mentor/%s' % (program_entity.key().id_or_name()), "Apply to become a Mentor", 'any_access')] deadline = 'accepted_students_announced_deadline' if timeline_helper.isAfterEvent(timeline_entity, deadline): items += [(redirects.getListProjectsRedirect(program_entity, {'url_name':'gsoc/program'}), "List all Student Projects", 'any_access')] return items