Example #1
0
    def __init__(self, data):
        """Initializes the dashboard.

    Args:
      data: The RequestData object
    """
        # TODO(nathaniel): Eliminate this state-setting call.
        data.redirect.program()

        subpages = [
            {
                'name': 'edit_evaluation_group',
                'description': ugettext('Create evaluation group'),
                'title': 'Create',
                'link': data.redirect.urlOf('gsoc_grading_group')
            },
        ]

        q = GSoCGradingSurveyGroup.all()
        q.filter('program', data.program)

        for group in q:
            data.redirect.id(group.key().id())
            subpages.append({
                'name':
                'view_evaluation_group_%s' % group.key().id(),
                'description':
                ugettext('View this group'),
                'title':
                'View %s' % group.name,
                'link':
                data.redirect.urlOf('gsoc_grading_record_overview')
            })

        super(EvaluationGroupDashboard, self).__init__(data, subpages)
Example #2
0
    def __init__(self, data):
        """Initializes the dashboard.

    Args:
      data: The RequestData object
    """
        # TODO(nathaniel): Eliminate this state-setting call.
        data.redirect.program()

        subpages = [
            {
                "name": "edit_evaluation_group",
                "description": ugettext("Create evaluation group"),
                "title": "Create",
                "link": data.redirect.urlOf("gsoc_grading_group"),
            }
        ]

        q = GSoCGradingSurveyGroup.all()
        q.filter("program", data.program)

        for group in q:
            data.redirect.id(group.key().id())
            subpages.append(
                {
                    "name": "view_evaluation_group_%s" % group.key().id(),
                    "description": ugettext("View this group"),
                    "title": "View %s" % group.name,
                    "link": data.redirect.urlOf("gsoc_grading_record_overview"),
                }
            )

        super(EvaluationGroupDashboard, self).__init__(data, subpages)
Example #3
0
  def __init__(self, data):
    """Initializes the dashboard.

    Args:
      data: The RequestData object
    """
    # TODO(nathaniel): Eliminate this state-setting call.
    data.redirect.program()

    subpages = [
        {
            'name': 'edit_evaluation_group',
            'description': ugettext('Create evaluation group'),
            'title': 'Create',
            'link': data.redirect.urlOf('gsoc_grading_group')
        },
    ]

    q = GSoCGradingSurveyGroup.all()
    q.filter('program', data.program)

    for group in q:
      data.redirect.id(group.key().id())
      subpages.append(
        {
            'name': 'view_evaluation_group_%s' % group.key().id(),
            'description': ugettext('View this group'),
            'title': 'View %s' % group.name,
            'link': data.redirect.urlOf('gsoc_grading_record_overview')
        }
      )

    super(EvaluationGroupDashboard, self).__init__(data, subpages)
    def post(self, data, check, mutator):
        """Handles the POST request when creating a Grading Group"""
        student_survey = None
        grading_survey = None
        survey_type = None

        if 'midterm' in data.POST:
            student_survey = survey.getMidtermProjectSurveyForProgram(
                data.program)
            grading_survey = survey.getMidtermGradingProjectSurveyForProgram(
                data.program)
            survey_type = 'Midterm'
        elif 'final' in data.POST:
            student_survey = survey.getFinalProjectSurveyForProgram(
                data.program)
            grading_survey = survey.getFinalGradingProjectSurveyForProgram(
                data.program)
            survey_type = 'Final'
        else:
            raise exception.BadRequest('No valid evaluation type present')

        if not student_survey or not grading_survey:
            data.redirect.program()
            return data.redirect.to('gsoc_grading_group', extra=['err=1'])

        q = GSoCGradingSurveyGroup.all()
        q.filter('student_survey', student_survey)
        q.filter('grading_survey', grading_survey)

        existing_group = q.get()

        if existing_group:
            data.redirect.id(existing_group.key().id())
        else:
            props = {
                'name':
                '%s - %s Evaluation' % (data.program.name, survey_type),
                'program': data.program,
                'grading_survey': grading_survey,
                'student_survey': student_survey,
            }
            new_group = GSoCGradingSurveyGroup(**props)
            new_group.put()
            data.redirect.id(new_group.key().id())

        return data.redirect.to('gsoc_grading_record_overview')
  def post(self, data, check, mutator):
    """Handles the POST request when creating a Grading Group"""
    student_survey = None
    grading_survey = None
    survey_type = None

    if 'midterm' in data.POST:
      student_survey = survey.getMidtermProjectSurveyForProgram(data.program)
      grading_survey = survey.getMidtermGradingProjectSurveyForProgram(
          data.program)
      survey_type = 'Midterm'
    elif 'final' in data.POST:
      student_survey = survey.getFinalProjectSurveyForProgram(data.program)
      grading_survey = survey.getFinalGradingProjectSurveyForProgram(
          data.program)
      survey_type = 'Final'
    else:
      raise exception.BadRequest('No valid evaluation type present')

    if not student_survey or not grading_survey:
      data.redirect.program()
      return data.redirect.to('gsoc_grading_group', extra=['err=1'])

    q = GSoCGradingSurveyGroup.all()
    q.filter('student_survey', student_survey)
    q.filter('grading_survey', grading_survey)

    existing_group = q.get()

    if existing_group:
      data.redirect.id(existing_group.key().id())
    else:
      props = {
          'name': '%s - %s Evaluation' %(data.program.name, survey_type),
          'program': data.program,
          'grading_survey': grading_survey,
          'student_survey': student_survey,
      }
      new_group = GSoCGradingSurveyGroup(**props)
      new_group.put()
      data.redirect.id(new_group.key().id())

    return data.redirect.to('gsoc_grading_record_overview')