Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Copyright 2013 the Melange authors.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- """Module containing the view for GSoC participants list page."""
- from django.utils import translation
- from google.appengine.ext import ndb
- from django.utils import translation
- from melange.logic import profile as profile_logic
- from melange.request import access
- from melange.request import exception
- from soc.views.helper import addresses
- from soc.views.helper import url_patterns
- from soc.views import template
- from soc.views import toggle_button
- from soc.views.helper import lists
- from soc.views.template import Template
- from soc.modules.gsoc.views.base import GSoCRequestHandler
- from soc.modules.gsoc.views.helper.url_patterns import url
- from summerofcode.logic import profile as soc_profile_logic
- from summerofcode.request import links
- from summerofcode.views.helper import urls
- from summerofcode.views.helper import urls as soc_urls
- from google.appengine.ext import ndb
- from django import forms as django_forms
- from django import http
- from django.utils import translation
- from melange.logic import profile as profile_logic
- from melange.request import access
- from melange.request import exception
- from soc.modules.gsoc.views import assign_mentor
- from soc.modules.gsoc.views import forms as gsoc_forms
- from soc.modules.gsoc.views import base as gsoc_base
- from soc.modules.gsoc.views.helper import url_patterns as soc_url_patterns
- from soc.views import base
- from soc.views import template
- from soc.views import toggle_button
- from soc.views.helper import url_patterns
- from summerofcode.logic import profile as soc_profile_logic
- from summerofcode.logic import proposal as proposal_logic
- from summerofcode.models import proposal as proposal_model
- from summerofcode.request import error
- from summerofcode.request import links
- from summerofcode.request import render
- from summerofcode.templates import top_message
- from summerofcode.views.helper import urls as soc_urls
- class MentorsList(Template):
- """Template for list of mentors for admins."""
- def __init__(self, data):
- self.data = data
- def getMentorFor(entity, *args):
- """Helper function to get value of mentor_for column."""
- return ', '.join(
- org.name for org in ndb.get_multi(entity.mentor_for) if org)
- def getAdminFor(entity, *args):
- """Helper function to get value of admin_for column."""
- return ', '.join(
- org.name for org in ndb.get_multi(entity.admin_for) if org)
- list_config = lists.ListConfiguration()
- list_config.addPlainTextColumn(
- 'name', 'Name', lambda entity, *args: entity.public_name.strip())
- list_config.addSimpleColumn('profile_id', 'Username')
- list_config.addPlainTextColumn('is_admin', 'Is Admin',
- lambda entity, *args: 'Yes' if entity.is_admin else 'No', hidden=True)
- list_config.addPlainTextColumn(
- 'email', 'Email', lambda entity, *args: entity.contact.email)
- list_config.addPlainTextColumn(
- 'admin_for', 'Admin For', getAdminFor)
- list_config.addPlainTextColumn('mentor_for', 'Mentor For', getMentorFor)
- addresses.addAddressColumns(list_config)
- list_config.addPlainTextColumn(
- 'tee_style', 'T-Shirt Style', lambda entity, *args: entity.tee_style)
- list_config.addPlainTextColumn(
- 'tee_size', 'T-Shirt Size', lambda entity, *args: entity.tee_size)
- list_config.setDefaultPagination(False)
- list_config.setDefaultSort('name')
- self._list_config = list_config
- def context(self):
- description = \
- 'List of organization admins and mentors participating in %s' % (
- self.data.program.name)
- return {
- 'lists': [lists.ListConfigurationResponse(
- self.data, self._list_config, 0, description)],
- }
- def getListData(self):
- if lists.getListIndex(self.data.request) != 0:
- return None
- query = profile_logic.queryAllMentorsForProgram(self.data.program.key())
- starter = lists.keyStarter
- # TODO(daniel): enable prefetching from ndb models
- # ('mentor_for', 'org_admin_for')
- prefetcher = None
- response_builder = lists.RawQueryContentResponseBuilder(
- self.data.request, self._list_config, query, starter,
- prefetcher=prefetcher)
- return response_builder.buildNDB()
- def templatePath(self):
- return 'modules/gsoc/participants/_mentors_list.html'
- class MentorsListAdminPage(GSoCRequestHandler):
- """View for the organization admin and mentors page for admin."""
- access_checker = access.PROGRAM_ADMINISTRATOR_ACCESS_CHECKER
- def templatePath(self):
- return 'modules/gsoc/participants/base.html'
- def djangoURLPatterns(self):
- return [
- url(r'admin/list/mentors/%s$' % url_patterns.PROGRAM, self,
- name='gsoc_list_mentors'),
- ]
- def jsonContext(self, data, check, mutator):
- list_content = MentorsList(data).getListData()
- if list_content:
- return list_content.content()
- else:
- raise exception.Forbidden(message='You do not have access to this data')
- def context(self, data, check, mutator):
- return {
- 'page_name': "List of organization admins and mentors for %s" % (
- data.program.name),
- 'mentors_list': MentorsList(data),
- }
- class ManageActions(template.Template):
- """Template to render the left side user actions."""
- def __init__(self, data, toggle_buttons):
- """Initializes a new instance of this class.
- Args:
- data: request_data.RequestData for the current request.
- toggle_buttons: List of toggle buttons to use for the actions.
- assign_mentor_field: Optional field to assign mentors for the proposal.
- """
- super(ManageActions, self).__init__(data)
- self.toggle_buttons = toggle_buttons
- def templatePath(self):
- """See template.Template.templatPath for specification"""
- return 'modules/gsoc/proposal/_user_action.html'
- def context(self):
- """See template.Template.context for specification."""
- return {
- 'toggle_buttons': self.toggle_buttons,
- }
- _BUTTON_ACCEPT_AS_PROJECT_HELP_TEXT = translation.ugettext(
- 'Choosing Yes will mark this proposal as accepted. The proposal is '
- 'accepted when Yes is displayed in bright orange.')
- _BUTTON_ACCEPT_AS_PROJECT_TITLE = translation.ugettext('Accept Project Student')
- _BUTTON_ACCEPT_AS_PROJECT_ID = 'accept-proposal'
- _MANAGE_ACTIONS_TITLE = translation.ugettext('List Actions')
- def _toggleButtonsForStudent(data, url_names):
- """Returns toggle buttons for proposal actions available for organization
- administrators and program administrators.
- Args:
- data: request_data.RequestData for the current request.
- url_names: Instance of url_names.UrlNames.
- Returns:
- A list of toggle_button.ToggleButtonTwoActionsTemplate instances.
- """
- toggle_buttons = []
- toggle_buttons.append(
- toggle_button.ToggleButtonTwoActionsTemplate(
- data, 'on_off', _BUTTON_ACCEPT_AS_PROJECT_TITLE,
- _BUTTON_ACCEPT_AS_PROJECT_ID,
- url_names.STUDENTS_ALL,
- url_names.STUDENTS_ALL,
- checked=None,
- labels={'checked': 'Yes', 'unchecked': 'No'},
- help_text=_BUTTON_ACCEPT_AS_PROJECT_HELP_TEXT))
- return toggle_buttons
- class StudentsList(Template):
- """List configuration for listing all the students involved with the program.
- """
- def __init__(self, request, data, linker, url_names):
- """Initializes this component."""
- self.data = data
- self.linker = linker
- self.url_names = url_names
- def taxFormSubmitted(entity, *args):
- """Helper function to get value of tax_form_submitted column."""
- if not soc_profile_logic.hasProject(entity):
- return 'N/A'
- elif entity.student_data.tax_form:
- return 'Yes'
- else:
- return 'No'
- def enrollmentFormSubmitted(entity, *args):
- """Helper function to get value of enrollment_form_submitted column."""
- if not soc_profile_logic.hasProject(entity):
- return 'N/A'
- elif entity.student_data.enrollment_form:
- return 'Yes'
- else:
- return 'No'
- def allFormsSubmitted(entity, *args):
- """Helper function to get value of all_forms_submitted column."""
- if not soc_profile_logic.hasProject(entity):
- return 'N/A'
- elif entity.student_data.enrollment_form and entity.student_data.tax_form:
- return 'Yes'
- else:
- return 'No'
- def projectsForOrgs(entity, *args):
- """Helper function to get value of projects_for_orgs column."""
- if not soc_profile_logic.hasProject(entity):
- return 'N/A'
- else:
- return ', '.join(
- org_key.get().name
- for org_key in entity.student_data.project_for_orgs)
- list_config = lists.ListConfiguration()
- list_config.addPlainTextColumn(
- 'name', 'Name', lambda entity, *args: entity.public_name.strip())
- list_config.addSimpleColumn('profile_id', 'Username')
- list_config.addPlainTextColumn(
- 'email', 'Email', lambda entity, *args: entity.contact.email)
- list_config.addSimpleColumn('gender', 'Gender', hidden=True)
- list_config.addSimpleColumn(
- 'birth_date', 'Birthdate', column_type=lists.BIRTHDATE, hidden=True)
- list_config.addPlainTextColumn(
- 'tax_form_submitted', 'Tax form submitted',
- taxFormSubmitted, hidden=True)
- list_config.addPlainTextColumn(
- 'enrollment_form_submitted', 'Enrollment form submitted',
- enrollmentFormSubmitted, hidden=True)
- list_config.addPlainTextColumn(
- 'all_forms_submitted', 'All Forms submitted', allFormsSubmitted)
- addresses.addAddressColumns(list_config)
- list_config.addPlainTextColumn(
- 'tee_style', 'T-Shirt Style', lambda entity, *args: entity.tee_style)
- list_config.addPlainTextColumn(
- 'tee_size', 'T-Shirt Size', lambda entity, *args: entity.tee_size)
- list_config.addPlainTextColumn(
- 'school_name', 'School Name',
- lambda entity, *args: entity.student_data.education.school_id,
- hidden=True)
- list_config.addPlainTextColumn(
- 'school_country', 'School Country',
- lambda entity, *args: entity.student_data.education.school_country,
- hidden=True)
- list_config.addPlainTextColumn(
- 'school_web_page', 'School Web Page',
- lambda entity, *args: entity.student_data.education.web_page,
- hidden=True)
- list_config.addPlainTextColumn(
- 'major', 'Major',
- lambda entity, *args: entity.student_data.education.major,
- hidden=True)
- list_config.addPlainTextColumn(
- 'degree', 'Degree',
- lambda entity, *args: entity.student_data.education.degree,
- hidden=True)
- list_config.addPlainTextColumn(
- 'expected_graduation', 'Expected Graduation',
- lambda entity, *args: entity.student_data.education.expected_graduation,
- hidden=True)
- list_config.addPlainTextColumn(
- 'number_of_proposals', 'Number Of Proposals',
- lambda entity, *args: entity.student_data.number_of_proposals,
- hidden=True)
- list_config.addNumericalColumn(
- 'number_of_projects', 'Number Of Projects',
- lambda entity, *args: entity.student_data.number_of_projects,
- hidden=True)
- list_config.addNumericalColumn(
- 'number_of_passed_evaluations', 'Passed Evaluations',
- lambda entity, *args: entity.student_data.number_of_passed_evaluations,
- hidden=True)
- list_config.addNumericalColumn(
- 'number_of_failed_evaluations', 'Failed Evaluations',
- lambda entity, *args: entity.student_data.number_of_failed_evaluations,
- hidden=True)
- list_config.addPlainTextColumn(
- 'project_for_orgs', 'Projects For Organizations', projectsForOrgs)
- list_config.setRowAction(
- lambda profile, *args: self.linker.profile(
- profile, self.url_names.PROFILE_ADMIN))
- self._list_config = list_config
- def templatePath(self):
- """See template.Template.templatePath for specification."""
- return 'modules/gsoc/dashboard/list_component.html'
- def getListData(self):
- idx = lists.getListIndex(self.data.request)
- if idx != 0:
- return None
- query = profile_logic.queryAllStudentsForProgram(self.data.program.key())
- starter = lists.keyStarter
- response_builder = lists.RawQueryContentResponseBuilder(
- self.data.request, self._list_config, query, starter)
- return response_builder.buildNDB()
- def context(self):
- """See template.Template.context for specification."""
- description = translation.ugettext('List of participating students')
- list_configuration_response = lists.ListConfigurationResponse(
- self.data, self._list_config, idx=0, description=description)
- return {
- 'name': 'students',
- 'title': 'Participating students',
- 'lists': [list_configuration_response],
- }
- class StudentsListWithProject(Template):
- """List configuration for listing all the students involved with the program.
- """
- def __init__(self, request, data, linker, url_names):
- """Initializes this component."""
- self.data = data
- self.linker = linker
- self.url_names = url_names
- def taxFormSubmitted(entity, *args):
- """Helper function to get value of tax_form_submitted column."""
- if not soc_profile_logic.hasProject(entity):
- return 'N/A'
- elif entity.student_data.tax_form:
- return 'Yes'
- else:
- return 'No'
- def enrollmentFormSubmitted(entity, *args):
- """Helper function to get value of enrollment_form_submitted column."""
- if not soc_profile_logic.hasProject(entity):
- return 'N/A'
- elif entity.student_data.enrollment_form:
- return 'Yes'
- else:
- return 'No'
- def allFormsSubmitted(entity, *args):
- """Helper function to get value of all_forms_submitted column."""
- if not soc_profile_logic.hasProject(entity):
- return 'N/A'
- elif entity.student_data.enrollment_form and entity.student_data.tax_form:
- return 'Yes'
- else:
- return 'No'
- def projectsForOrgs(entity, *args):
- """Helper function to get value of projects_for_orgs column."""
- if not soc_profile_logic.hasProject(entity):
- return 'N/A'
- else:
- return ', '.join(
- org_key.get().name
- for org_key in entity.student_data.project_for_orgs)
- list_config = lists.ListConfiguration()
- list_config.addPlainTextColumn(
- 'name', 'Name', lambda entity, *args: entity.public_name.strip())
- list_config.addSimpleColumn('profile_id', 'Username')
- list_config.addPlainTextColumn(
- 'email', 'Email', lambda entity, *args: entity.contact.email)
- list_config.addSimpleColumn('gender', 'Gender', hidden=True)
- list_config.addSimpleColumn(
- 'birth_date', 'Birthdate', column_type=lists.BIRTHDATE, hidden=True)
- list_config.addPlainTextColumn(
- 'tax_form_submitted', 'Tax form submitted',
- taxFormSubmitted, hidden=True)
- list_config.addPlainTextColumn(
- 'enrollment_form_submitted', 'Enrollment form submitted',
- enrollmentFormSubmitted, hidden=True)
- list_config.addPlainTextColumn(
- 'all_forms_submitted', 'All Forms submitted', allFormsSubmitted)
- addresses.addAddressColumns(list_config)
- list_config.addPlainTextColumn(
- 'tee_style', 'T-Shirt Style', lambda entity, *args: entity.tee_style)
- list_config.addPlainTextColumn(
- 'tee_size', 'T-Shirt Size', lambda entity, *args: entity.tee_size)
- list_config.addPlainTextColumn(
- 'school_name', 'School Name',
- lambda entity, *args: entity.student_data.education.school_id,
- hidden=True)
- list_config.addPlainTextColumn(
- 'school_country', 'School Country',
- lambda entity, *args: entity.student_data.education.school_country,
- hidden=True)
- list_config.addPlainTextColumn(
- 'school_web_page', 'School Web Page',
- lambda entity, *args: entity.student_data.education.web_page,
- hidden=True)
- list_config.addPlainTextColumn(
- 'major', 'Major',
- lambda entity, *args: entity.student_data.education.major,
- hidden=True)
- list_config.addPlainTextColumn(
- 'degree', 'Degree',
- lambda entity, *args: entity.student_data.education.degree,
- hidden=True)
- list_config.addPlainTextColumn(
- 'expected_graduation', 'Expected Graduation',
- lambda entity, *args: entity.student_data.education.expected_graduation,
- hidden=True)
- list_config.addPlainTextColumn(
- 'number_of_proposals', 'Number Of Proposals',
- lambda entity, *args: entity.student_data.number_of_proposals,
- hidden=True)
- list_config.addNumericalColumn(
- 'number_of_projects', 'Number Of Projects',
- lambda entity, *args: entity.student_data.number_of_projects,
- hidden=True)
- list_config.addNumericalColumn(
- 'number_of_passed_evaluations', 'Passed Evaluations',
- lambda entity, *args: entity.student_data.number_of_passed_evaluations,
- hidden=True)
- list_config.addNumericalColumn(
- 'number_of_failed_evaluations', 'Failed Evaluations',
- lambda entity, *args: entity.student_data.number_of_failed_evaluations,
- hidden=True)
- list_config.addPlainTextColumn(
- 'project_for_orgs', 'Projects For Organizations', projectsForOrgs)
- list_config.setRowAction(
- lambda profile, *args: self.linker.profile(
- profile, self.url_names.PROFILE_ADMIN))
- self._list_config = list_config
- def templatePath(self):
- """See template.Template.templatePath for specification."""
- return 'modules/gsoc/dashboard/list_component.html'
- def getListData(self):
- idx = lists.getListIndex(self.data.request)
- if idx != 0:
- return None
- query = profile_logic.queryAllStudentsWithProjectForProgram(self.data.program.key())
- starter = lists.keyStarter
- response_builder = lists.RawQueryContentResponseBuilder(
- self.data.request, self._list_config, query, starter)
- return response_builder.buildNDB()
- def context(self):
- """See template.Template.context for specification."""
- description = translation.ugettext('List of participating students')
- list_configuration_response = lists.ListConfigurationResponse(
- self.data, self._list_config, idx=0, description=description)
- return {
- 'name': 'students',
- 'title': 'Participating students',
- 'lists': [list_configuration_response],
- }
- class StudentsListPage(base.RequestHandler):
- """View that lists all the students associated with the program."""
- access_checker = access.PROGRAM_ADMINISTRATOR_ACCESS_CHECKER
- def __init__(self, initializer, linker, renderer, error_handler,
- url_pattern_constructor, url_names, template_path):
- """Initializes a new instance of the request handler for the specified
- parameters.
- Args:
- initializer: Implementation of initialize.Initializer interface.
- linker: Instance of links.Linker class.
- renderer: Implementation of render.Renderer interface.
- error_handler: Implementation of error.ErrorHandler interface.
- url_pattern_constructor:
- Implementation of url_patterns.UrlPatternConstructor.
- url_names: Instance of url_names.UrlNames.
- template_path: The path of the template to be used.
- """
- super(StudentsListPage, self).__init__(
- initializer, linker, renderer, error_handler)
- self.url_pattern_constructor = url_pattern_constructor
- self.url_names = url_names
- self.template_path = template_path
- def djangoURLPatterns(self):
- """See base.RequestHandler.djangoURLPatterns for specification."""
- return [
- self.url_pattern_constructor.construct(
- r'admin/students/%s$' % url_patterns.PROGRAM, self,
- name=self.url_names.STUDENTS_LIST),
- ]
- def templatePath(self):
- """See base.RequestHandler.template_path for specification."""
- return self.template_path
- def jsonContext(self, data, check, mutator):
- """See base.RequestHandler.jsonContext for specification."""
- list_content = StudentsList(
- data.request, data, links.SOC_LINKER, urls.UrlNames).getListData()
- if list_content:
- return list_content.content()
- else:
- raise exception.Forbidden(message='You do not have access to this data')
- def context(self, data, check, mutator):
- """See base.RequestHandler.context for specification."""
- toggle_buttons = _toggleButtonsForStudent(data,urls.UrlNames)
- manage_actions = ManageActions(data,toggle_buttons)
- return {
- 'page_name': 'Students list page',
- # TODO(nathaniel): Drop the first parameter of StudentsList.
- 'list': StudentsList(data.request, data, links.SOC_LINKER, urls.UrlNames),
- 'manage_actions': manage_actions,
- }
- STUDENTS_LIST = (
- StudentsListPage(
- gsoc_base._GSOC_INITIALIZER, links.SOC_LINKER, render.SOC_RENDERER,
- error.SOC_ERROR_HANDLER, soc_url_patterns.SOC_URL_PATTERN_CONSTRUCTOR,
- soc_urls.UrlNames, 'modules/gsoc/admin/student_list.html'))
- class StudentsAll(base.RequestHandler):
- """Handler to withdraw the proposal."""
- access_checker = access.IS_URL_USER_ACCESS_CHECKER
- def __init__(self, initializer, linker, renderer, error_handler,
- url_pattern_constructor, url_names):
- """Initializes a new instance of the request handler for the specified
- parameters.
- Args:
- initializer: Implementation of initialize.Initializer interface.
- linker: Instance of links.Linker class.
- renderer: Implementation of render.Renderer interface.
- error_handler: Implementation of error.ErrorHandler interface.
- url_pattern_constructor:
- Implementation of url_patterns.UrlPatternConstructor.
- url_names: Instance of url_names.UrlNames.
- """
- super(StudentsAll, self).__init__(
- initializer, linker, renderer, error_handler)
- self.url_pattern_constructor = url_pattern_constructor
- self.url_names = url_names
- def djangoURLPatterns(self):
- """See base.RequestHandler.djangoURLPatterns for specification."""
- return [
- self.url_pattern_constructor.construct(
- r'admin/students/%s$' % url_patterns.PROGRAM,
- self, name=self.url_names.STUDENTS_ALL),
- ]
- def post(self, data, check, mutator):
- """See base.RequestHandler.post for specification."""
- '''result = proposal_logic.withdrawProposal(data.url_ndb_proposal.key)
- if not result:
- raise exception.BadRequest(message=result.extra)
- else:
- return http.HttpResponse()'''
- return http.HttpResponseRedirect(STUDENTS_LIST_WITH_PROJECT)
- STUDENTS_ALL = StudentsAll(
- gsoc_base._GSOC_INITIALIZER, links.SOC_LINKER, render.SOC_RENDERER,
- error.SOC_ERROR_HANDLER, soc_url_patterns.SOC_URL_PATTERN_CONSTRUCTOR,
- soc_urls.UrlNames)
- class StudentsListPageWithProject(base.RequestHandler):
- """View that lists all the students associated with the program."""
- access_checker = access.PROGRAM_ADMINISTRATOR_ACCESS_CHECKER
- def __init__(self, initializer, linker, renderer, error_handler,
- url_pattern_constructor, url_names, template_path):
- """Initializes a new instance of the request handler for the specified
- parameters.
- Args:
- initializer: Implementation of initialize.Initializer interface.
- linker: Instance of links.Linker class.
- renderer: Implementation of render.Renderer interface.
- error_handler: Implementation of error.ErrorHandler interface.
- url_pattern_constructor:
- Implementation of url_patterns.UrlPatternConstructor.
- url_names: Instance of url_names.UrlNames.
- template_path: The path of the template to be used.
- """
- super(StudentsListPageWithProject, self).__init__(
- initializer, linker, renderer, error_handler)
- self.url_pattern_constructor = url_pattern_constructor
- self.url_names = url_names
- self.template_path = template_path
- def djangoURLPatterns(self):
- """See base.RequestHandler.djangoURLPatterns for specification."""
- return [
- self.url_pattern_constructor.construct(
- r'admin/students/%s$' % url_patterns.PROGRAM, self,
- name=self.url_names.STUDENTS_LIST_WITH_PROJECT),
- ]
- def templatePath(self):
- """See base.RequestHandler.template_path for specification."""
- return self.template_path
- def jsonContext(self, data, check, mutator):
- """See base.RequestHandler.jsonContext for specification."""
- list_content = StudentsListWithProject(
- data.request, data, links.SOC_LINKER, urls.UrlNames).getListData()
- if list_content:
- return list_content.content()
- else:
- raise exception.Forbidden(message='You do not have access to this data')
- def context(self, data, check, mutator):
- """See base.RequestHandler.context for specification."""
- toggle_buttons = _toggleButtonsForStudent(data,urls.UrlNames)
- manage_actions = ManageActions(data,toggle_buttons)
- return {
- 'page_name': 'Students list page',
- # TODO(nathaniel): Drop the first parameter of StudentsList.
- 'list': StudentsListWithProject(data.request, data, links.SOC_LINKER, urls.UrlNames),
- 'manage_actions': manage_actions,
- }
- STUDENTS_LIST_WITH_PROJECT = (
- StudentsListPageWithProject(
- gsoc_base._GSOC_INITIALIZER, links.SOC_LINKER, render.SOC_RENDERER,
- error.SOC_ERROR_HANDLER, soc_url_patterns.SOC_URL_PATTERN_CONSTRUCTOR,
- soc_urls.UrlNames, 'modules/gsoc/admin/student_list.html'))
- class StudentsWithProject(base.RequestHandler):
- """Handler to withdraw the proposal."""
- access_checker = access.IS_URL_USER_ACCESS_CHECKER
- def __init__(self, initializer, linker, renderer, error_handler,
- url_pattern_constructor, url_names):
- """Initializes a new instance of the request handler for the specified
- parameters.
- Args:
- initializer: Implementation of initialize.Initializer interface.
- linker: Instance of links.Linker class.
- renderer: Implementation of render.Renderer interface.
- error_handler: Implementation of error.ErrorHandler interface.
- url_pattern_constructor:
- Implementation of url_patterns.UrlPatternConstructor.
- url_names: Instance of url_names.UrlNames.
- """
- super(StudentsWithProject, self).__init__(
- initializer, linker, renderer, error_handler)
- self.url_pattern_constructor = url_pattern_constructor
- self.url_names = url_names
- def djangoURLPatterns(self):
- """See base.RequestHandler.djangoURLPatterns for specification."""
- return [
- self.url_pattern_constructor.construct(
- r'admin/students/%s$' % url_patterns.PROGRAM,
- self, name=self.url_names.STUDENTS_WITH_PROJECT),
- ]
- def post(self, data, check, mutator):
- """See base.RequestHandler.post for specification."""
- '''result = proposal_logic.withdrawProposal(data.url_ndb_proposal.key)
- if not result:
- raise exception.BadRequest(message=result.extra)
- else:
- return http.HttpResponse()'''
- return http.HttpResponseRedirect(self.url_names.STUDENTS_ALL)
- STUDENTS_WITH_PROJECT = StudentsWithProject(
- gsoc_base._GSOC_INITIALIZER, links.SOC_LINKER, render.SOC_RENDERER,
- error.SOC_ERROR_HANDLER, soc_url_patterns.SOC_URL_PATTERN_CONSTRUCTOR,
- soc_urls.UrlNames)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement