<commit_before>#!/usr/bin/env python2.5
#
# Copyright 2011 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 AccessChecker class that contains helper functions
for checking access.
"""

__authors__ = [
    '"<NAME>" <<EMAIL>>',
  ]


from google.appengine.ext import db

from django.utils.translation import ugettext

from soc.logic.exceptions import AccessViolation
from soc.views.helper import access_checker

from soc.modules.gsoc.models.student_proposal import StudentProposal


DEF_MAX_PROPOSALS_REACHED = ugettext(
    'You have reached the maximum number of proposals allowed '
    'for this program.')


class Mutator(access_checker.Mutator):
  pass


class DeveloperMutator(access_checker.DeveloperMutator):
  pass


class AccessChecker(access_checker.AccessChecker):
  """Helper classes for access checking in GSoC module.
  """

  def canStudentPropose(self):
    """Checks if the student is eligible to submit a proposal.
    """

    # check if the timeline allows submitting proposals
    self.studentSignupActive()
<commit_msg>Add a mutator to populate project survey in request data.<commit_after>#!/usr/bin/env python2.5
#
# Copyright 2011 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 AccessChecker class that contains helper functions
for checking access.
"""

__authors__ = [
    '"<NAME>" <<EMAIL>>',
  ]


from google.appengine.ext import db

from django.utils.translation import ugettext

from soc.logic.exceptions import AccessViolation
from soc.logic.exceptions import NotFound
from soc.views.helper import access_checker

from soc.modules.gsoc.models.project_survey import ProjectSurvey
from soc.modules.gsoc.models.student_proposal import StudentProposal


DEF_MAX_PROPOSALS_REACHED = ugettext(
    'You have reached the maximum number of proposals allowed '
    'for this program.')

DEF_NO_PROJECT_SURVEY_MSG = ugettext(
    'The project survey with the requested parameters does not exist')


class Mutator(access_checker.Mutator):

  def projectSurveyFromKwargs(self):
    """Sets the survey record in RequestData object.
    """
        # kwargs which defines an organization
    fields = ['prefix', 'sponsor', 'program', 'survey']

    key_name = '/'.join(self.data.kwargs[field] for field in fields)
    self.data.project_survey = ProjectSurvey.get_by_key_name(key_name)

    if not self.data.project_survey:
      raise NotFound(DEF_NO_PROJECT_SURVEY_MSG)


class DeveloperMutator(access_checker.DeveloperMutator):
  pass


class AccessChecker(access_checker.AccessChecker):
  """Helper classes for access checking in GSoC module.
  """

  def canStudentPropose(self):
    """Checks if the student is eligible to submit a proposal.
    """

    # check if the timeline allows submitting proposals
    self.studentSignupActive()

{'fraction_non_alphanumeric': 0.07872174590802807, 'fraction_numerical': 0.005196154845414394, 'mean_word_length': 4.437853107344632, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2762044', 'n_tokens_mistral': 1105, 'n_tokens_neox': 1065, 'n_words': 400}