Beispiel #1
0
  def grading_record(self, record):
    """Returns the redirector object with the arguments for grading record

    Args:
      record: the grading record entity
    """
    project = record.parent()

    self.program()
    self.id()
    self.kwargs['user'] = profile_model.getUserId(project.parent_key())
    self.kwargs['group'] = record.grading_survey_group.key().id_or_name()
    self.kwargs['record'] = record.key().id()

    return self
Beispiel #2
0
    def grading_record(self, record):
        """Returns the redirector object with the arguments for grading record

    Args:
      record: the grading record entity
    """
        project = record.parent()

        self.program()
        self.id()
        self.kwargs['user'] = profile_model.getUserId(project.parent_key())
        self.kwargs['group'] = record.grading_survey_group.key().id_or_name()
        self.kwargs['record'] = record.key().id()

        return self
def _getRequestData(profile, postdata=None):
  """Returns a new request data based on the specified profile and post data.

  Args:
    profile: Profile entity.
    postdata: A dict containing POST data.

  Returns:
    RequestData object.
  """
  profile_key = profile.key if isinstance(profile, ndb.Model) else profile.key()
  kwargs = {
      'sponsor': profile_model.getSponsorId(profile_key),
      'program': profile_model.getProgramId(profile_key),
      'user': profile_model.getUserId(profile_key),
      }
  data = request_data.RequestData(None, None, kwargs)
  data._POST = postdata
  return data
Beispiel #4
0
  def userId(self, profile_key, entity_id, url_name):
    """Returns the URL of a page whose address contains parts associated
    with the specified profile and numeric identifier of some other entity.

    Args:
      profile_key: Profile key.
      entity_id: Numeric ID of entity.
      url_name: The name with which a URL was registered with Django.

    Returns:
      The URL of the page matching the given names for the given profile
      and organization.
    """
    kwargs = {
        'sponsor': profile_model.getSponsorId(profile_key),
        'program': profile_model.getProgramId(profile_key),
        'user': profile_model.getUserId(profile_key),
        'id': entity_id,
        }
    return urlresolvers.reverse(url_name, kwargs=kwargs)
def _getRequestData(profile, postdata=None):
    """Returns a new request data based on the specified profile and post data.

  Args:
    profile: Profile entity.
    postdata: A dict containing POST data.

  Returns:
    RequestData object.
  """
    profile_key = profile.key if isinstance(profile,
                                            ndb.Model) else profile.key()
    kwargs = {
        'sponsor': profile_model.getSponsorId(profile_key),
        'program': profile_model.getProgramId(profile_key),
        'user': profile_model.getUserId(profile_key),
    }
    data = request_data.RequestData(None, None, kwargs)
    data._POST = postdata
    return data
Beispiel #6
0
    def userId(self, profile_key, entity_id, url_name):
        """Returns the URL of a page whose address contains parts associated
    with the specified profile and numeric identifier of some other entity.

    Args:
      profile_key: Profile key.
      entity_id: Numeric ID of entity.
      url_name: The name with which a URL was registered with Django.

    Returns:
      The URL of the page matching the given names for the given profile
      and organization.
    """
        kwargs = {
            'sponsor': profile_model.getSponsorId(profile_key),
            'program': profile_model.getProgramId(profile_key),
            'user': profile_model.getUserId(profile_key),
            'id': entity_id,
        }
        return urlresolvers.reverse(url_name, kwargs=kwargs)
Beispiel #7
0
  def profile(self, profile, url_name):
    """Returns the URL of a profile's named page.

    Args:
      profile: A profile entity.
      url_name: The name with which a URL was registered with Django.

    Returns:
      The URL of the page matching the given name for the given profile.
    """
    if isinstance(profile, ndb.Model):
      profile_key = profile.key
    else:
      profile_key = profile.key()

    kwargs = {
        'program': profile_model.getProgramId(profile_key),
        'sponsor': profile_model.getSponsorId(profile_key),
        'user': profile_model.getUserId(profile_key)
         }
    return urlresolvers.reverse(url_name, kwargs=kwargs)
Beispiel #8
0
    def profile(self, profile, url_name):
        """Returns the URL of a profile's named page.

    Args:
      profile: A profile entity.
      url_name: The name with which a URL was registered with Django.

    Returns:
      The URL of the page matching the given name for the given profile.
    """
        if isinstance(profile, ndb.Model):
            profile_key = profile.key
        else:
            profile_key = profile.key()

        kwargs = {
            'program': profile_model.getProgramId(profile_key),
            'sponsor': profile_model.getSponsorId(profile_key),
            'user': profile_model.getUserId(profile_key)
        }
        return urlresolvers.reverse(url_name, kwargs=kwargs)
Beispiel #9
0
  def userOrg(self, profile_key, org_key, url_name):
    """Returns the URL of a page whose address contains parts associated
    with the specified profile and organization.

    The specified profile and organization must come from the same program.

    Args:
      profile_key: Profile key.
      org: organization entity.
      url_name: the name with which a URL was registered with Django.

    Returns:
      The URL of the page matching the given names for the given profile
      and organization.
    """
    kwargs = {
        'sponsor': profile_model.getSponsorId(profile_key),
        'program': profile_model.getProgramId(profile_key),
        'user': profile_model.getUserId(profile_key),
        'organization': org_model.getOrgId(org_key),
        }
    return urlresolvers.reverse(url_name, kwargs=kwargs)
Beispiel #10
0
    def userOrg(self, profile_key, org_key, url_name):
        """Returns the URL of a page whose address contains parts associated
    with the specified profile and organization.

    The specified profile and organization must come from the same program.

    Args:
      profile_key: Profile key.
      org: organization entity.
      url_name: the name with which a URL was registered with Django.

    Returns:
      The URL of the page matching the given names for the given profile
      and organization.
    """
        kwargs = {
            'sponsor': profile_model.getSponsorId(profile_key),
            'program': profile_model.getProgramId(profile_key),
            'user': profile_model.getUserId(profile_key),
            'organization': org_model.getOrgId(org_key),
        }
        return urlresolvers.reverse(url_name, kwargs=kwargs)
    def __init__(self, data):
        """Initializes the template.

    Args:
      data: The RequestData object
    """
        self.data = data

        list_config = lists.ListConfiguration()

        title_func = lambda rec, *args: rec.parent().title
        list_config.addPlainTextColumn('project_title', 'Project Title',
                                       title_func)

        def getOrganization(entity, *args):
            """Helper function to get value of organization column."""
            org_key = ndb.Key.from_old_key(
                (project_model.GSoCProject.org.get_value_for_datastore(
                    entity.parent())))
            return org_key.get().name

        list_config.addPlainTextColumn('org_name', 'Organization',
                                       getOrganization)

        stud_rec_func = lambda rec, *args: \
            'Present' if rec.student_record else 'Missing'
        list_config.addPlainTextColumn('student_record',
                                       'Evaluation by Student', stud_rec_func)

        stud_id_func = lambda rec, *args: (profile_model.getUserId(
            rec.parent_key().parent()))
        list_config.addPlainTextColumn('student_id',
                                       'Student username',
                                       stud_id_func,
                                       hidden=True)

        stud_email_func = lambda rec, *args: args[1][rec.key()].contact.email
        list_config.addPlainTextColumn('student_email',
                                       'Student Email Address',
                                       stud_email_func,
                                       hidden=True)

        stud_fn_func = lambda rec, *args: args[1][rec.key()].first_name
        list_config.addPlainTextColumn('student_fn',
                                       'Student First Name',
                                       stud_fn_func,
                                       hidden=True)

        stud_ln_func = lambda rec, *args: args[1][rec.key()].last_name
        list_config.addPlainTextColumn('student_ln',
                                       'Student Last Name',
                                       stud_ln_func,
                                       hidden=True)

        mentor_email_func = lambda rec, *args: args[0][rec.key()].contact.email

        list_config.addPlainTextColumn('mentor_email',
                                       'Mentor Email Address',
                                       mentor_email_func,
                                       hidden=True)

        mentor_fn_func = lambda rec, *args: args[0][rec.key()].first_name
        list_config.addPlainTextColumn('mentor_fn',
                                       'Mentor First Name',
                                       mentor_fn_func,
                                       hidden=True)

        mentor_ln_func = lambda rec, *args: args[0][rec.key()].last_name
        list_config.addPlainTextColumn('mentor_ln',
                                       'Mentor Last Name',
                                       mentor_ln_func,
                                       hidden=True)

        list_config.addPostButton('update_records', 'Update Records', '',
                                  [0, 'all'], [])
        list_config.addPostButton('update_projects', 'Update Projects', '',
                                  [0, 'all'], [])

        def mentorRecordInfo(rec, *args):
            """Displays information about a GradingRecord's mentor_record property.
      """
            if not rec.mentor_record:
                return 'Missing'

            if rec.mentor_record.grade:
                return 'Passing Grade'
            else:
                return 'Fail Grade'

        list_config.addPlainTextColumn('mentor_record', 'Evaluation by Mentor',
                                       mentorRecordInfo)

        list_config.addSimpleColumn('grade_decision', 'Decision')
        list_config.setRowAction(lambda e, *args: data.redirect.grading_record(
            e).urlOf('gsoc_grading_record_detail'))

        self._list_config = list_config
  def __init__(self, data):
    """Initializes the template.

    Args:
      data: The RequestData object
    """
    self.data = data

    list_config = lists.ListConfiguration()

    title_func = lambda rec, *args: rec.parent().title
    list_config.addPlainTextColumn(
        'project_title', 'Project Title', title_func)

    def getOrganization(entity, *args):
      """Helper function to get value of organization column."""
      org_key = ndb.Key.from_old_key((
          project_model.GSoCProject.org
              .get_value_for_datastore(entity.parent())))
      return org_key.get().name
    list_config.addPlainTextColumn('org_name', 'Organization', getOrganization)

    stud_rec_func = lambda rec, *args: \
        'Present' if rec.student_record else 'Missing'
    list_config.addPlainTextColumn(
        'student_record', 'Evaluation by Student', stud_rec_func)

    stud_id_func = lambda rec, *args: (
        profile_model.getUserId(rec.parent_key().parent()))
    list_config.addPlainTextColumn(
        'student_id', 'Student username', stud_id_func, hidden=True)

    stud_email_func = lambda rec, *args: args[1][rec.key()].contact.email
    list_config.addPlainTextColumn('student_email', 'Student Email Address',
        stud_email_func, hidden=True)

    stud_fn_func = lambda rec, *args: args[1][rec.key()].first_name
    list_config.addPlainTextColumn('student_fn', 'Student First Name',
        stud_fn_func, hidden=True)

    stud_ln_func = lambda rec, *args: args[1][rec.key()].last_name
    list_config.addPlainTextColumn('student_ln', 'Student Last Name',
        stud_ln_func, hidden=True)

    mentor_email_func = lambda rec, *args: args[0][rec.key()].contact.email

    list_config.addPlainTextColumn('mentor_email', 'Mentor Email Address',
        mentor_email_func, hidden=True)

    mentor_fn_func = lambda rec, *args: args[0][rec.key()].first_name
    list_config.addPlainTextColumn('mentor_fn', 'Mentor First Name',
        mentor_fn_func, hidden=True)

    mentor_ln_func = lambda rec, *args: args[0][rec.key()].last_name
    list_config.addPlainTextColumn('mentor_ln', 'Mentor Last Name',
        mentor_ln_func, hidden=True)


    list_config.addPostButton(
        'update_records', 'Update Records', '', [0, 'all'], [])
    list_config.addPostButton(
        'update_projects', 'Update Projects', '', [0, 'all'], [])

    def mentorRecordInfo(rec, *args):
      """Displays information about a GradingRecord's mentor_record property.
      """
      if not rec.mentor_record:
        return 'Missing'

      if rec.mentor_record.grade:
        return 'Passing Grade'
      else:
        return 'Fail Grade'

    list_config.addPlainTextColumn(
        'mentor_record', 'Evaluation by Mentor', mentorRecordInfo)

    list_config.addSimpleColumn('grade_decision', 'Decision')
    list_config.setRowAction(lambda e, *args:
        data.redirect.grading_record(e).urlOf('gsoc_grading_record_detail'))

    self._list_config = list_config