| # 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. |
| |
| from django.utils import translation |
| |
| from melange.logic import timeline as timeline_logic |
| from melange.request import links |
| from melange.templates import top_message |
| |
| from summerofcode.logic import proposal as proposal_logic |
| from summerofcode.views.helper import urls |
| |
| |
| TEMPLATE_PATH = 'summerofcode/_top_message.html' |
| |
| _ORG_MEMBER_REGISTER_MESSAGE_ACTIVE_STUDENT_SIGN_UP = translation.ugettext( |
| 'Use the form below only to register as an organization member. ' |
| 'If you want to participate as a student, please go to <a href="%s">' |
| 'the student registration page</a>. Keep in mind that if you have ' |
| 'created an organization member profile, you <strong>will not</strong> ' |
| 'be able to sign up as a student anymore.') |
| |
| _ORG_MEMBER_REGISTER_MESSAGE_BEFORE_STUDENT_SIGN_UP = translation.ugettext( |
| 'Use the form below only to register as an organization member. ' |
| 'If you want to participate as a student, please wait until the ' |
| 'registration open on %s. Keep in mind that if you have created an ' |
| 'organization member profile, you <strong>will not</strong> be able to ' |
| 'sign up as a student anymore.') |
| |
| _START_CONNECTION_AS_USER = translation.ugettext( |
| 'You are about to start a connection with %s. This indicates that you ' |
| 'are willing to accept a role for this organization. Having reviewed your ' |
| 'application, organization administrators may designate you as a mentor or ' |
| 'another organization administrator.') |
| |
| _PROPOSAL_UNEDITABLE = translation.ugettext( |
| 'Content of this proposal is not editable at this moment, because student ' |
| 'application period is over. If you still need to make some changes, ' |
| 'please send a comment to the organization. They can enable modifications ' |
| 'for this proposal.') |
| |
| _SURVEY_RESPONSE_MESSAGE_NOT_SUBMITTED = translation.ugettext( |
| 'Your application will be completed only if you submit this questionnaire.') |
| |
| _SURVEY_RESPONSE_MESSAGE_SUBMITTED = translation.ugettext( |
| 'Your questionnaire has already been submitted and registration process ' |
| 'for your organization is now complete. You can still modify and update ' |
| 'the answers below before %s.') |
| |
| |
| def orgMemberRegistrationTopMessage(data): |
| """Returns a top message to be displayed on the top of the page to register |
| as an organization member. |
| |
| Args: |
| data: request_data.RequestData for the current request. |
| |
| Returns: |
| top_message.TopMessage to be displayed on the top of the page. |
| """ |
| if data.timeline.beforeStudentSignupStart(): |
| return top_message.TopMessage( |
| data, TEMPLATE_PATH, |
| _ORG_MEMBER_REGISTER_MESSAGE_BEFORE_STUDENT_SIGN_UP % |
| data.timeline.studentSignupStart()) |
| elif not data.timeline.afterStudentSignupEnd(): |
| return top_message.TopMessage( |
| data, TEMPLATE_PATH, |
| _ORG_MEMBER_REGISTER_MESSAGE_ACTIVE_STUDENT_SIGN_UP % |
| links.ABSOLUTE_LINKER.program( |
| data.program, urls.UrlNames.PROFILE_REGISTER_AS_STUDENT, |
| secure=True)) |
| else: |
| return None |
| |
| |
| def startConnectionAsUserTopMessage(data): |
| """Returns a top message to be displayed on the top of the page to start |
| connection as user. |
| |
| Args: |
| data: request_data.RequestData for the current request. |
| |
| """ |
| return top_message.TopMessage( |
| data, TEMPLATE_PATH, _START_CONNECTION_AS_USER % data.url_ndb_org.name) |
| |
| |
| def surveyResponseTopMessage(data, is_survey_response_submitted): |
| """Returns a top message to be displayed on the top of the page to submit |
| or update a survey response for an organization. |
| |
| Args: |
| data: request_data.RequestData for the current request. |
| is_survey_response_submitted: A bool telling whether the survey response |
| has already been submitted for the organization or not. |
| |
| Returns: |
| top_message.TopMessage to be displayed on the top of the page. |
| """ |
| if is_survey_response_submitted: |
| return top_message.TopMessage( |
| data, TEMPLATE_PATH, |
| _SURVEY_RESPONSE_MESSAGE_SUBMITTED % |
| data.timeline.orgsAnnouncedOn()) |
| else: |
| return top_message.TopMessage( |
| data, TEMPLATE_PATH, |
| _SURVEY_RESPONSE_MESSAGE_NOT_SUBMITTED) |
| |
| |
| def proposalReviewAsStudentTopMessage(data): |
| """Returns a top message to be displayed on the top of the page to review |
| proposal as a student. |
| |
| Args: |
| data: request_data.RequestData for the current request. |
| |
| Returns: |
| top_message.TopMessage to be displayed on the top of the page. |
| """ |
| return ( |
| top_message.TopMessage(data, TEMPLATE_PATH, _PROPOSAL_UNEDITABLE) |
| if (not proposal_logic.canStudentUpdateProposal( |
| data.url_ndb_proposal, data.program.timeline) |
| and timeline_logic.isAfterStudentSignup(data.program.timeline)) |
| else None) |