Exemplo n.º 1
0
 def read_units(cls):
     '''This method retrieves scholarship data from the CIT and CS databases
     and returns the union of the two lists, merging entries that share the
     same name. CS database entries are assumed to have name fields.
     '''
     cit_list = cls.get_cit_scholarships('CPSC')
     # Add a name entry to each CIT record based on the title-name mapping.
     for cit_entry in cit_list:
         if cit_entry[cls.CIT_TITLE_KEY] in cls.cit2cs_name_map:
             cit_entry['name'] = \
                 cls.cit2cs_name_map[cit_entry[cls.CIT_TITLE_KEY]]
     return Unit.merge_lists(cit_list,
                             list(g.mongo.db.scholarships.find().sort('ordinal')))
Exemplo n.º 2
0
 def read_unit(cls, name, scholarships=None):
     '''This method retrieves merges program data from the CIT
     and CS databases.
     '''
     result = Unit.merge_records(
         cls.get_cit_data(name),
         g.mongo.db.programs.find_one({'name': name})
     )
     if result:
         # Modify the course hyperlinks to link to our own pages.
         if 'majorCourses' in result:
             result['majorCourses'] = \
                 cls.fix_courses(result['majorCourses'])
         if 'minorCourses' in result:
             result['minorCourses'] = \
                 cls.fix_courses(result['minorCourses'])
         # Add scholarships regardless of where the program comes from.
         # Use the scholarships parameter if given, otherwise read them.
         if scholarships is None:
             scholarships = Scholarships.read_units()
         result['scholarships'] = \
             cls.get_scholarships(name, scholarships)
     return result
Exemplo n.º 3
0
 def read_unit(cls, name):
     '''This routine find an document with the given nameField.'''
     return Unit.merge_records(
         cls.get_cit_scholarship('CPSC', name),
         g.mongo.db.scholarships.find_one({'name': name})
         )