| # Copyright 2014 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 student forms related views for Code In.""" |
| |
| from google.appengine.ext.ndb import blobstore |
| |
| from codein.request import error |
| from codein.request import render |
| from codein.views.helper import urls as urls |
| |
| from melange.request import links |
| from melange.views import student_forms as student_forms_view |
| |
| from soc.modules.gci.views import base |
| from soc.modules.gci.views.helper import url_patterns as ci_url_patterns |
| from soc.views import template |
| |
| |
| class StudentFormsTemplate(template.Template): |
| """Template to provide links to student forms.""" |
| |
| template_path = 'modules/gci/profile_show/_student_forms.html' |
| |
| def __init__(self, data, profile): |
| super(StudentFormsTemplate, self).__init__(data) |
| self.profile = profile |
| |
| def context(self): |
| """See template.Template.context for specification.""" |
| download_form_url = links.LINKER.profile( |
| self.profile, urls.UrlNames.STUDENT_FORM_DOWNLOAD) |
| |
| consent_form_url = '%s?%s=%s' % ( |
| download_form_url, |
| student_forms_view.FORM_TYPE_GET_PARAM, |
| student_forms_view.CONSENT_FORM_TYPE) |
| enrollment_form_url = '%s?%s=%s' % ( |
| download_form_url, |
| student_forms_view.FORM_TYPE_GET_PARAM, |
| student_forms_view.ENROLLMENT_FORM_TYPE) |
| |
| student_data = self.profile.student_data |
| |
| consent_form = ( |
| blobstore.BlobInfo.get(student_data.consent_form) |
| if self.profile.student_data.consent_form |
| else None) |
| |
| enrollment_form = ( |
| blobstore.BlobInfo.get(student_data.enrollment_form) |
| if self.profile.student_data.enrollment_form |
| else None) |
| |
| return { |
| 'consent_form': consent_form, |
| 'is_consent_form_verified': student_data.is_consent_form_verified, |
| 'consent_form_url': consent_form_url, |
| 'enrollment_form': enrollment_form, |
| 'is_enrollment_form_verified': student_data.is_enrollment_form_verified, |
| 'enrollment_form_url': enrollment_form_url, |
| 'is_awaiting_forms': self.profile.flags.awaiting_forms, |
| } |
| |
| |
| STUDENT_FORM_DOWNLOAD = student_forms_view.StudentFormDownload( |
| base._GCI_INITIALIZER, links.LINKER, render.CI_RENDERER, |
| error.CI_ERROR_HANDLER, ci_url_patterns.CI_URL_PATTERN_CONSTRUCTOR, |
| urls.UrlNames) |
| |
| |
| STUDENT_FORM_VERIFY = student_forms_view.StudentFormVerify( |
| base._GCI_INITIALIZER, links.LINKER, render.CI_RENDERER, |
| error.CI_ERROR_HANDLER, ci_url_patterns.CI_URL_PATTERN_CONSTRUCTOR, |
| urls.UrlNames) |