Esempio n. 1
0
  def __init__(self, request, data):
    self.request = request
    self.data = data

    list_config = lists.ListConfiguration()

    list_config.addColumn('name', 'Name',
                          lambda e, *args: e.name().strip())
    list_config.addSimpleColumn('link_id', 'Link ID')
    list_config.addColumn('is_org_admin', 'Org Admin',
        lambda e, *args: 'Yes' if e.is_org_admin else 'No', hidden=True)
    list_config.addSimpleColumn('email', 'Email')
    list_config.addColumn(
        'org_admin_for', 'Org Admin For',
        lambda e, org_admin_for, *args: ', '.join(
            [org_admin_for[k].name for k in e.org_admin_for]))
    list_config.addColumn(
        'mentor_for', 'Mentor For',
        lambda e, mentor_for, *args: ', '.join(
            [mentor_for[k].name for k in e.mentor_for]))

    addresses.addAddressColumns(list_config)

    list_config.setDefaultPagination(False)
    list_config.setDefaultSort('name')

    self._list_config = list_config
Esempio n. 2
0
  def __init__(self, data):
    self.data = data

    list_config = lists.ListConfiguration()

    list_config.addPlainTextColumn(
        'name', 'Name', lambda e, *args: e.public_name.strip())
    list_config.addSimpleColumn('profile_id', 'Username')
    list_config.addPlainTextColumn('is_admin', 'Is Admin',
        lambda e, *args: 'Yes' if e.is_admin else 'No', hidden=True)
    list_config.addPlainTextColumn(
        'email', 'Email', lambda entity, *args: entity.contact.email)

    def getMentorFor(entity, *args):
      """Helper function to get value of mentor_for column."""
      org_keys = [org_key.to_old_key() for org_key in entity.admin_for]
      return ', '.join(
          org.name for org in org_model.GCIOrganization.get(org_keys)
              if org)

    def getAdminFor(entity, *args):
      """Helper function to get value of admin_for column."""
      org_keys = [org_key.to_old_key() for org_key in entity.mentor_for]
      return ', '.join(
          org.name for org in org_model.GCIOrganization.get(org_keys) if org)

    list_config.addPlainTextColumn('admin_for', 'Admin For', getAdminFor)
    list_config.addPlainTextColumn('mentor_for', 'Mentor For', getMentorFor)

    addresses.addAddressColumns(list_config)

    list_config.setDefaultPagination(False)
    list_config.setDefaultSort('name')

    self._list_config = list_config
Esempio n. 3
0
    def __init__(self, data):
        self.data = data

        list_config = lists.ListConfiguration()

        list_config.addPlainTextColumn('name', 'Name',
                                       lambda e, *args: e.public_name.strip())
        list_config.addSimpleColumn('profile_id', 'Username')
        list_config.addPlainTextColumn('is_admin',
                                       'Is Admin',
                                       lambda e, *args: 'Yes'
                                       if e.is_admin else 'No',
                                       hidden=True)
        list_config.addPlainTextColumn(
            'email', 'Email', lambda entity, *args: entity.contact.email)

        def getMentorFor(entity, *args):
            """Helper function to get value of mentor_for column."""
            org_keys = [org_key.to_old_key() for org_key in entity.admin_for]
            return ', '.join(org.name
                             for org in org_model.GCIOrganization.get(org_keys)
                             if org)

        def getAdminFor(entity, *args):
            """Helper function to get value of admin_for column."""
            org_keys = [org_key.to_old_key() for org_key in entity.mentor_for]
            return ', '.join(org.name
                             for org in org_model.GCIOrganization.get(org_keys)
                             if org)

        list_config.addPlainTextColumn('admin_for', 'Admin For', getAdminFor)
        list_config.addPlainTextColumn('mentor_for', 'Mentor For',
                                       getMentorFor)

        addresses.addAddressColumns(list_config)

        list_config.setDefaultPagination(False)
        list_config.setDefaultSort('name')

        self._list_config = list_config
Esempio n. 4
0
    def __init__(self, data):
        self.data = data

        def getMentorFor(entity, *args):
            """Helper function to get value of mentor_for column."""
            return ', '.join(org.name
                             for org in ndb.get_multi(entity.mentor_for)
                             if org)

        def getAdminFor(entity, *args):
            """Helper function to get value of admin_for column."""
            return ', '.join(org.name
                             for org in ndb.get_multi(entity.admin_for) if org)

        list_config = lists.ListConfiguration()

        list_config.addPlainTextColumn(
            'name', 'Name', lambda entity, *args: entity.public_name.strip())
        list_config.addSimpleColumn('profile_id', 'Username')
        list_config.addPlainTextColumn('is_admin',
                                       'Is Admin',
                                       lambda entity, *args: 'Yes'
                                       if entity.is_admin else 'No',
                                       hidden=True)
        list_config.addPlainTextColumn(
            'email', 'Email', lambda entity, *args: entity.contact.email)
        list_config.addPlainTextColumn('admin_for', 'Admin For', getAdminFor)
        list_config.addPlainTextColumn('mentor_for', 'Mentor For',
                                       getMentorFor)

        addresses.addAddressColumns(list_config)
        list_config.addPlainTextColumn('tee_style', 'T-Shirt Style',
                                       lambda entity, *args: entity.tee_style)
        list_config.addPlainTextColumn('tee_size', 'T-Shirt Size',
                                       lambda entity, *args: entity.tee_size)

        list_config.setDefaultPagination(False)
        list_config.setDefaultSort('name')

        self._list_config = list_config
Esempio n. 5
0
  def __init__(self, data):
    self.data = data

    def getMentorFor(entity, *args):
      """Helper function to get value of mentor_for column."""
      return ', '.join(
          org.name for org in ndb.get_multi(entity.mentor_for) if org)

    def getAdminFor(entity, *args):
      """Helper function to get value of admin_for column."""
      return ', '.join(
          org.name for org in ndb.get_multi(entity.admin_for) if org)


    list_config = lists.ListConfiguration()

    list_config.addPlainTextColumn(
        'name', 'Name', lambda entity, *args: entity.public_name.strip())
    list_config.addSimpleColumn('profile_id', 'Username')
    list_config.addPlainTextColumn('is_admin', 'Is Admin',
        lambda entity, *args: 'Yes' if entity.is_admin else 'No', hidden=True)
    list_config.addPlainTextColumn(
        'email', 'Email', lambda entity, *args: entity.contact.email)
    list_config.addPlainTextColumn(
        'admin_for', 'Admin For', getAdminFor)
    list_config.addPlainTextColumn('mentor_for', 'Mentor For', getMentorFor)

    addresses.addAddressColumns(list_config)
    list_config.addPlainTextColumn(
        'tee_style', 'T-Shirt Style', lambda entity, *args: entity.tee_style)
    list_config.addPlainTextColumn(
        'tee_size', 'T-Shirt Size', lambda entity, *args: entity.tee_size)

    list_config.setDefaultPagination(False)
    list_config.setDefaultSort('name')

    self._list_config = list_config
Esempio n. 6
0
  def __init__(self, data):
    self.data = data
    self.idx = 1

    list_config = lists.ListConfiguration()

    list_config.setRowAction(
        lambda entity, *args: data.redirect.profile(
            entity.profile_id).urlOf(url_names.GCI_STUDENT_TASKS))

    list_config.addSimpleColumn('public_name', 'Public Name')

    list_config.addSimpleColumn('profile_id', 'Username')
    list_config.addPlainTextColumn(
        'email', 'Email', lambda entity, *args: entity.contact.email)
    list_config.addSimpleColumn('first_name', 'First Name', hidden=True)
    list_config.addSimpleColumn('last_name', 'Last Name')
    list_config.addBirthDateColumn(
        'birth_date', 'Birth date', lambda entity, *args: entity.birth_date,
        hidden=True)
    list_config.addSimpleColumn('gender', 'Gender')

    addresses.addAddressColumns(list_config)

    list_config.addPlainTextColumn(
        'school_id', 'School name',
        lambda entity, *args: entity.student_data.education.school_id,
        hidden=True)
    list_config.addPlainTextColumn(
        'school_country', 'School Country',
        lambda entity, *args: entity.student_data.education.school_country,
        hidden=True)
    list_config.addPlainTextColumn(
        'grade', 'Grade',
        lambda entity, *args: entity.student_data.education.grade, hidden=True)
    list_config.addPlainTextColumn(
        'expected_graduation', 'Expected Graduation',
        lambda entity, *args: entity.student_data.education.expected_graduation,
        hidden=True)
    list_config.addPlainTextColumn(
        'number_of_completed_tasks', 'Completed tasks',
        lambda entity, *args: entity.student_data.number_of_completed_tasks)

    def formsSubmitted(entity, form_type):
      """Returns "Yes" if form has been submitted otherwise "No".

      form takes either 'consent' or 'student_id' as values which stand
      for parental consent form and student id form respectively.
      """
      if form_type == 'consent':
        return 'Yes' if entity.student_data.consent_form else 'No'
      elif form_type == 'enrollment':
        return 'Yes' if entity.student_data.enrollment_form else 'No'
      else:
        raise ValueError('Unsupported form type: %s' % form_type)

    list_config.addPlainTextColumn(
        'consent_form', 'Consent Form Submitted',
        lambda entity, *args: formsSubmitted(entity, 'consent'))
    list_config.addPlainTextColumn(
        'enrollment_form', 'Student ID Form Submitted',
        lambda entity, *args: formsSubmitted(entity, 'enrollment'))

    list_config.addPlainTextColumn(
        'home_page', 'Home Page',
        lambda entity, *args: entity.contact.web_page, hidden=True)
    list_config.addPlainTextColumn(
        'blog', 'Blog',
        lambda entity, *args: entity.contact.blog, hidden=True)
    list_config.addSimpleColumn('tee_style', 'T-Shirt Style')
    list_config.addSimpleColumn('tee_size', 'T-Shirt Size')

    list_config.addHtmlColumn(
        'photo_url', 'Photo URL',
        (lambda entity, *args: urlize(entity.photo_url)), hidden=True)
    list_config.addSimpleColumn(
        'program_knowledge', 'Program Knowledge', hidden=True)

    self._list_config = list_config
Esempio n. 7
0
  def __init__(self, request, data, linker, url_names):
    """Initializes this component."""
    self.data = data
    self.linker = linker
    self.url_names = url_names

    def taxFormSubmitted(entity, *args):
      """Helper function to get value of tax_form_submitted column."""
      if not soc_profile_logic.hasProject(entity):
        return 'N/A'
      elif entity.student_data.tax_form:
        return 'Yes'
      else:
        return 'No'

    def enrollmentFormSubmitted(entity, *args):
      """Helper function to get value of enrollment_form_submitted column."""
      if not soc_profile_logic.hasProject(entity):
        return 'N/A'
      elif entity.student_data.enrollment_form:
        return 'Yes'
      else:
        return 'No'

    def allFormsSubmitted(entity, *args):
      """Helper function to get value of all_forms_submitted column."""
      if not soc_profile_logic.hasProject(entity):
        return 'N/A'
      elif entity.student_data.enrollment_form and entity.student_data.tax_form:
        return 'Yes'
      else:
        return 'No'

    def projectsForOrgs(entity, *args):
      """Helper function to get value of projects_for_orgs column."""
      if not soc_profile_logic.hasProject(entity):
        return 'N/A'
      else:
        return ', '.join(
            org_key.get().name
            for org_key in entity.student_data.project_for_orgs)

    list_config = lists.ListConfiguration()
    list_config.addPlainTextColumn(
        'name', 'Name', lambda entity, *args: entity.public_name.strip())
    list_config.addSimpleColumn('profile_id', 'Username')
    list_config.addPlainTextColumn(
        'email', 'Email', lambda entity, *args: entity.contact.email)
    list_config.addSimpleColumn('gender', 'Gender', hidden=True)
    list_config.addSimpleColumn(
        'birth_date', 'Birthdate', column_type=lists.BIRTHDATE, hidden=True)
    list_config.addPlainTextColumn(
        'tax_form_submitted', 'Tax form submitted',
        taxFormSubmitted, hidden=True)
    list_config.addPlainTextColumn(
        'enrollment_form_submitted', 'Enrollment form submitted',
        enrollmentFormSubmitted, hidden=True)
    list_config.addPlainTextColumn(
        'all_forms_submitted', 'All Forms submitted', allFormsSubmitted)

    addresses.addAddressColumns(list_config)
    list_config.addPlainTextColumn(
        'tee_style', 'T-Shirt Style', lambda entity, *args: entity.tee_style)
    list_config.addPlainTextColumn(
        'tee_size', 'T-Shirt Size', lambda entity, *args: entity.tee_size)

    list_config.addPlainTextColumn(
        'school_name', 'School Name',
        lambda entity, *args: entity.student_data.education.school_id,
        hidden=True)
    list_config.addPlainTextColumn(
        'school_country', 'School Country',
        lambda entity, *args: entity.student_data.education.school_country,
        hidden=True)
    list_config.addPlainTextColumn(
        'school_web_page', 'School Web Page',
        lambda entity, *args: entity.student_data.education.web_page,
        hidden=True)
    list_config.addPlainTextColumn(
        'major', 'Major',
        lambda entity, *args: entity.student_data.education.major,
        hidden=True)
    list_config.addPlainTextColumn(
        'degree', 'Degree',
        lambda entity, *args: entity.student_data.education.degree,
        hidden=True)
    list_config.addPlainTextColumn(
        'expected_graduation', 'Expected Graduation',
        lambda entity, *args: entity.student_data.education.expected_graduation,
        hidden=True)
    list_config.addPlainTextColumn(
        'number_of_proposals', 'Number Of Proposals',
        lambda entity, *args: entity.student_data.number_of_proposals,
        hidden=True)
    list_config.addNumericalColumn(
        'number_of_projects', 'Number Of Projects',
        lambda entity, *args: entity.student_data.number_of_projects,
        hidden=True)
    list_config.addNumericalColumn(
        'number_of_passed_evaluations', 'Passed Evaluations',
        lambda entity, *args: entity.student_data.number_of_passed_evaluations,
        hidden=True)
    list_config.addNumericalColumn(
        'number_of_failed_evaluations', 'Failed Evaluations',
        lambda entity, *args: entity.student_data.number_of_failed_evaluations,
        hidden=True)
    list_config.addPlainTextColumn(
        'project_for_orgs', 'Projects For Organizations', projectsForOrgs)

    list_config.setRowAction(
        lambda profile, *args: self.linker.profile(
            profile, self.url_names.PROFILE_ADMIN))

    self._list_config = list_config
Esempio n. 8
0
    def __init__(self, request, data, linker, url_names):
        """Initializes this component."""
        self.data = data
        self.linker = linker
        self.url_names = url_names

        def taxFormSubmitted(entity, *args):
            """Helper function to get value of tax_form_submitted column."""
            if not soc_profile_logic.hasProject(entity):
                return 'N/A'
            elif entity.student_data.tax_form:
                return 'Yes'
            else:
                return 'No'

        def enrollmentFormSubmitted(entity, *args):
            """Helper function to get value of enrollment_form_submitted column."""
            if not soc_profile_logic.hasProject(entity):
                return 'N/A'
            elif entity.student_data.enrollment_form:
                return 'Yes'
            else:
                return 'No'

        def allFormsSubmitted(entity, *args):
            """Helper function to get value of all_forms_submitted column."""
            if not soc_profile_logic.hasProject(entity):
                return 'N/A'
            elif entity.student_data.enrollment_form and entity.student_data.tax_form:
                return 'Yes'
            else:
                return 'No'

        def projectsForOrgs(entity, *args):
            """Helper function to get value of projects_for_orgs column."""
            if not soc_profile_logic.hasProject(entity):
                return 'N/A'
            else:
                return ', '.join(
                    org_key.get().name
                    for org_key in entity.student_data.project_for_orgs)

        list_config = lists.ListConfiguration()
        list_config.addPlainTextColumn(
            'name', 'Name', lambda entity, *args: entity.public_name.strip())
        list_config.addSimpleColumn('profile_id', 'Username')
        list_config.addPlainTextColumn(
            'email', 'Email', lambda entity, *args: entity.contact.email)
        list_config.addSimpleColumn('gender', 'Gender', hidden=True)
        list_config.addSimpleColumn('birth_date',
                                    'Birthdate',
                                    column_type=lists.BIRTHDATE,
                                    hidden=True)
        list_config.addPlainTextColumn('tax_form_submitted',
                                       'Tax form submitted',
                                       taxFormSubmitted,
                                       hidden=True)
        list_config.addPlainTextColumn('enrollment_form_submitted',
                                       'Enrollment form submitted',
                                       enrollmentFormSubmitted,
                                       hidden=True)
        list_config.addPlainTextColumn('all_forms_submitted',
                                       'All Forms submitted',
                                       allFormsSubmitted)

        addresses.addAddressColumns(list_config)
        list_config.addPlainTextColumn('tee_style', 'T-Shirt Style',
                                       lambda entity, *args: entity.tee_style)
        list_config.addPlainTextColumn('tee_size', 'T-Shirt Size',
                                       lambda entity, *args: entity.tee_size)

        list_config.addPlainTextColumn(
            'school_name',
            'School Name',
            lambda entity, *args: entity.student_data.education.school_id,
            hidden=True)
        list_config.addPlainTextColumn(
            'school_country',
            'School Country',
            lambda entity, *args: entity.student_data.education.school_country,
            hidden=True)
        list_config.addPlainTextColumn(
            'school_web_page',
            'School Web Page',
            lambda entity, *args: entity.student_data.education.web_page,
            hidden=True)
        list_config.addPlainTextColumn(
            'major',
            'Major',
            lambda entity, *args: entity.student_data.education.major,
            hidden=True)
        list_config.addPlainTextColumn(
            'degree',
            'Degree',
            lambda entity, *args: entity.student_data.education.degree,
            hidden=True)
        list_config.addPlainTextColumn(
            'expected_graduation',
            'Expected Graduation',
            lambda entity, *args: entity.student_data.education.
            expected_graduation,
            hidden=True)
        list_config.addPlainTextColumn(
            'number_of_proposals',
            'Number Of Proposals',
            lambda entity, *args: entity.student_data.number_of_proposals,
            hidden=True)
        list_config.addNumericalColumn(
            'number_of_projects',
            'Number Of Projects',
            lambda entity, *args: entity.student_data.number_of_projects,
            hidden=True)
        list_config.addNumericalColumn(
            'number_of_passed_evaluations',
            'Passed Evaluations',
            lambda entity, *args: entity.student_data.
            number_of_passed_evaluations,
            hidden=True)
        list_config.addNumericalColumn(
            'number_of_failed_evaluations',
            'Failed Evaluations',
            lambda entity, *args: entity.student_data.
            number_of_failed_evaluations,
            hidden=True)
        list_config.addPlainTextColumn('project_for_orgs',
                                       'Projects For Organizations',
                                       projectsForOrgs)

        list_config.setRowAction(lambda profile, *args: self.linker.profile(
            profile, self.url_names.PROFILE_ADMIN))

        self._list_config = list_config