Пример #1
0
def setUpTimetables():
    app = ISchoolToolApplication(None)
    TimetableStartUp(app)()
    syc = ISchoolYearContainer(app)
    sy = syc.getActiveSchoolYear()
    timetables = ITimetableContainer(sy)
    timetables[u'rotating'] = tt_rot = Timetable(
        sy.first, sy.last, title=u"Rotating")

    tt_rot.periods = CalendarDayTemplates()
    tt_rot.periods.initTemplates()
    tt_rot.time_slots = CalendarDayTemplates()
    tt_rot.time_slots.initTemplates()
    addTimetableDays(
        tt_rot,
        [('1', 'Day 1'), ('2', 'Day 2'), ('3', 'Day 3')],
        ['A', 'B', 'C'])

    timetables[u'weekly'] = tt_week = Timetable(
        sy.first, sy.last, title=u"Weekly")

    tt_week.periods = WeekDayTemplates()
    tt_week.periods.initTemplates()
    tt_week.time_slots = WeekDayTemplates()
    tt_week.time_slots.initTemplates()

    dows = ['Monday', 'Tuesday', 'Wednesday', 'Thursday',
            'Friday', 'Saturday', 'Sunday']
    week_days = [(unicode(n), title)
                 for n, title in enumerate(dows)]

    addTimetableDays(
        tt_week,
        week_days,
        ['A', 'B', 'C'])
Пример #2
0
    def export_sections_enrollment(self, wb):
        self.task_progress.force('export_sections_enrollment', active=True)
        ws = wb.add_sheet("SectionEnrollment")

        row = 0
        years = ISchoolYearContainer(self.context)
        total_years = len(years)
        for ny, year in enumerate(sorted(years.values(), key=lambda year: year.first)):
            total_terms = len(year)
            for nt, term in enumerate(sorted(year.values(), key=lambda term: term.first)):
                sections = ISectionContainer(term)
                total_sections = len(sections)
                for ns, section in enumerate(sorted(sections.values(),
                                                    key=lambda section: section.__name__)):
                    row = self.export_section_enrollment(
                        ws, year, term, section, row=row)
                    self.progress(
                        'export_sections_enrollment',
                        normalized_progress(
                            ny, total_years,
                            nt, total_terms,
                            ns, total_sections,
                            ))

        self.finish('export_sections_enrollment')
Пример #3
0
 def __call__(self):
     app = ISchoolToolApplication(None)
     syc = ISchoolYearContainer(app)
     activeSchoolyear = syc.getActiveSchoolYear()
     if activeSchoolyear is not None:
         self.importDefaultGroups(activeSchoolyear)
     else:
         self.initializeGroupContainer()
Пример #4
0
def evolve(context):
    linkcatalogs.ensureEvolved(context)
    root = getRootFolder(context)

    old_site = getSite()
    app = root
    setSite(app)
    persons = ISchoolToolApplication(None)['persons']
    manager = persons.super_user
    if manager is not None:
        syc = ISchoolYearContainer(app)
        for sy in syc.values():
            makeManager(app, sy, manager)

    setSite(old_site)
Пример #5
0
 def getTargets(self, keys):
     if not keys:
         return []
     result = []
     sy_groups = {}
     app = ISchoolToolApplication(None)
     schoolyears = ISchoolYearContainer(app)
     for key in keys:
         for sy_name, schoolyear in schoolyears.items():
             if not key.startswith(sy_name+'.'):
                 continue
             if sy_name not in sy_groups:
                 sy_groups[sy_name] = IGroupContainer(schoolyear)
             group = sy_groups[sy_name].get(key[len(sy_name)+1:])
             if group is not None:
                 result.append(group)
     return result
Пример #6
0
def evolve(context):
    linkcatalogs.ensureEvolved(context)
    root = getRootFolder(context)
    old_site = getSite()

    app = root
    setSite(app)
    syc = ISchoolYearContainer(app)
    if not syc.values():
        setSite(old_site)
        return

    sy = syc.getActiveSchoolYear()
    if sy is None:
        sy = syc.values()[-1]
    for person in app['persons'].values():
        evolvePerson(app, sy, person)

    setSite(old_site)
Пример #7
0
def guessMostRecentLevels(app):
    container = app.get(LEVELS_APP_KEY)
    if (container is None or
        not isinstance(container, LevelContainerContainer)):
        return None
    levels = None
    syc = ISchoolYearContainer(app, None)
    int_ids = getUtility(IIntIds)

    years = list(reversed(syc.sorted_schoolyears))
    active_year = syc.getActiveSchoolYear()
    if active_year is not None:
        years = [active_year] + years
    for year in years:
        sy_id = str(int_ids.getId(year))
        levels = container.get(sy_id, None)
        if levels is not None:
            return levels
    return None
Пример #8
0
def getGroupContainerForApp(app):
    syc = ISchoolYearContainer(app)
    sy = syc.getActiveSchoolYear()
    if sy is None:
        return None
    return IGroupContainer(sy)
Пример #9
0
 def nextSchoolYear(self):
     """Return the next school year."""
     syc = ISchoolYearContainer(ISchoolToolApplication(None))
     if checkPermission("schooltool.edit", syc):
         return syc.getNextSchoolYear()
Пример #10
0
 def schoolyears(self):
     app = ISchoolToolApplication(None)
     schoolyears = ISchoolYearContainer(app)
     active_schoolyear = schoolyears.getActiveSchoolYear()
     return [schoolyear for schoolyear in schoolyears.values()
             if schoolyear.first >= active_schoolyear.first]
Пример #11
0
def get_active_year():
    schoolyears = ISchoolYearContainer(ISchoolToolApplication(None))
    return schoolyears.getActiveSchoolYear()
Пример #12
0
def getCourseContainerForApp(app):
    syc = ISchoolYearContainer(app)
    sy = syc.getActiveSchoolYear()
    if sy is not None:
        return ICourseContainer(sy)
Пример #13
0
def getTermContainer(context):
    app = ISchoolToolApplication(None)
    syc = ISchoolYearContainer(app)
    return syc.getActiveSchoolYear()
Пример #14
0
def getTermContainerForDate(date):
    app = ISchoolToolApplication(None)
    syc = ISchoolYearContainer(app)
    year = syc.getLastSchoolYearForDate(date)
    term_container = ITermContainer(year, None)
    return term_container