Exemplo n.º 1
0
def programs_with_template(templates, suffix):
    matching_programs = []
    slugs = [t['slug'] for t in templates]
    for program in Program.get_all_configs():
        if get_slug(program['label'], suffix) in slugs:
            matching_programs.append(program)

    return matching_programs
Exemplo n.º 2
0
 def get(self):
     # Refresh the newest two cohorts of each program.
     tasks = []
     for program_config in Program.get_all_configs():
         cohorts = sorted(program_config['cohorts'].keys())
         for cohort_label in cohorts[-2:]:
             task = taskqueue.add(
                 url='/task/cache_dashboard',
                 headers={'Content-Type': 'application/json'},
                 payload=json.dumps({
                     'program_label': program_config['label'],
                     'cohort_label': cohort_label,
                 }),
             )
             tasks.append(task)
     self.write({
         'tasks': [{
             'name': t.name,
             'payload': json.loads(t.payload)
         } for t in tasks]
     })