def setUpYear():
    app = ISchoolToolApplication(None)
    syc = getSchoolYearContainer(app)
    syc['2010-2011'] = SchoolYear(u'2010-2011', datetime.date(2010, 9, 1),
                                  datetime.date(2011, 5, 30))
    syc['2010-2011'][u'fall'] = Term(u'Fall', datetime.date(2010, 9, 1),
                                     datetime.date(2010, 11, 30))
    syc['2010-2011'][u'winter'] = Term(u'Winter', datetime.date(2010, 12, 1),
                                       datetime.date(2011, 2, 28))
    syc['2010-2011'][u'spring'] = Term(u'Spring', datetime.date(2011, 3, 1),
                                       datetime.date(2011, 5, 30))
Esempio n. 2
0
    def test_getPeriodsForDayBetweenTerms(self):
        from schooltool.term.term import Term
        term3 = Term('Sample', date(2005, 6, 2), date(2005, 8, 1))
        ITermContainer(self.app)['2005-autumn'] = term3
        term3.schooldays = [('A', time(9, 0), timedelta(minutes=115))]
        self.term2.schooldays = [('B', time(10, 0), timedelta(minutes=115))]

        from schooltool.timetable.browser.cal import DailyTimetableCalendarRowsView

        view = DailyTimetableCalendarRowsView(None, TestRequest())
        # We need the start date and the end date different
        view.getPersonTimezone = lambda: timezone('America/Chicago')
        self.assertEquals(len(view.getPeriodsForDay(date(2005, 6, 1))), 1)
Esempio n. 3
0
    def test_getPeriodsForDayBetweenTerms(self):
        from schooltool.term.term import Term
        term3 = Term('Sample', date(2005, 6, 2), date(2005, 8, 1))
        ITermContainer(self.app)['2005-autumn'] = term3
        term3.schooldays = [('A', time(9,0), timedelta(minutes=115))]
        self.term2.schooldays = [('B', time(10,0), timedelta(minutes=115))]

        from schooltool.timetable.browser.cal import DailyTimetableCalendarRowsView

        view = DailyTimetableCalendarRowsView(None, TestRequest())
        # We need the start date and the end date different
        view.getPersonTimezone = lambda: timezone('America/Chicago')
        self.assertEquals(len(view.getPeriodsForDay(date(2005, 6, 1))), 1)
Esempio n. 4
0
    def setUp(self):
        layeredTestSetup()
        app = ISchoolToolApplication(None)
        self.person = app['persons']['person'] = Person('person')

        # set up schoolyear
        from schooltool.schoolyear.schoolyear import SchoolYear
        from schooltool.schoolyear.interfaces import ISchoolYearContainer
        ISchoolYearContainer(app)['2004'] = SchoolYear("2004",
                                                       date(2004, 9, 1),
                                                       date(2004, 12, 31))

        # set up the timetable schema
        days = ['A', 'B', 'C']
        schema = self.createSchema(days, ['1', '2', '3', '4'],
                                   ['1', '2', '3', '4'], ['1', '2', '3', '4'])
        schema.timezone = 'Europe/London'
        template = SchooldayTemplate()
        template.add(SchooldaySlot(time(8, 0), timedelta(hours=1)))
        template.add(SchooldaySlot(time(10, 15), timedelta(hours=1)))
        template.add(SchooldaySlot(time(11, 30), timedelta(hours=1)))
        template.add(SchooldaySlot(time(12, 30), timedelta(hours=2)))
        schema.model = SequentialDaysTimetableModel(days, {None: template})

        ITimetableSchemaContainer(app)['default'] = schema

        # set up terms
        from schooltool.term.term import Term
        terms = ITermContainer(app)
        terms['term'] = term = Term("Some term", date(2004, 9, 1),
                                    date(2004, 12, 31))
        term.add(date(2004, 11, 5))
Esempio n. 5
0
 def preview_term(self):
     data, errors = self.extractData()
     self.updateWidgets()
     if errors:
         return None
     term = Term(data['title'], data['first'], data['last'])
     self.setHolidays(term)
     return TermRenderer(term).calendar()
Esempio n. 6
0
def setUpTerms(schoolyear, term_count=3):
    term_delta = timedelta(
        ((schoolyear.last - schoolyear.first) / term_count).days)
    start_date = schoolyear.first
    for n in range(term_count):
        finish_date = start_date + term_delta - timedelta(1)
        schoolyear['Term%d' % (n+1)] = Term(
            'Term %d' % (n+1), start_date, finish_date)
        start_date = finish_date + timedelta(1)
Esempio n. 7
0
    def setUp(self):
        layeredTestSetup()
        app = ISchoolToolApplication(None)

        from schooltool.schoolyear.schoolyear import SchoolYear
        from schooltool.schoolyear.interfaces import ISchoolYearContainer
        ISchoolYearContainer(app)['2004-2005'] = SchoolYear(
            "2004-2005", date(2004, 9, 1), date(2005, 8, 1))

        from schooltool.term.term import Term
        self.term1 = Term('Sample', date(2004, 9, 1), date(2004, 12, 20))
        self.term1.schooldays = [
            ('A', time(9, 0), timedelta(minutes=115)),
            ('B', time(11, 0), timedelta(minutes=115)),
            ('C', time(13, 0), timedelta(minutes=115)),
            ('D', time(15, 0), timedelta(minutes=115)),
        ]
        self.term2 = Term('Sample', date(2005, 1, 1), date(2005, 6, 1))
        self.term2.schooldays = []
        terms = ITermContainer(app)
        terms['2004-fall'] = self.term1
        terms['2005-spring'] = self.term2

        class TimetableModelStub:
            def periodsInDay(this, schooldays, ttschema, date):
                if date not in schooldays:
                    raise "This date is not in the current term!"
                if ttschema == self.tt:
                    return schooldays.schooldays
                else:
                    return []

        tt = TimetableSchema([])
        tt.model = TimetableModelStub()
        tt.timezone = 'Europe/London'
        self.tt = tt
        ttschemas = ITimetableSchemaContainer(app)
        ttschemas['default'] = tt
        self.app = app
Esempio n. 8
0
def setUpSchool(app):
    sy = ISchoolYearContainer(app)['2005'] = SchoolYear(
        '2005', date(2005, 1, 1), date(2005, 1, 30))

    term = sy['spring'] = Term('Spring', date(2005, 1, 1), date(2005, 1, 30))
    term.addWeekdays(0, 1, 2, 3, 4)

    pc = app['persons']
    teacher = pc['teacher'] = BasicPerson("teacher", "Mister", "T")
    s1 = pc['john'] = BasicPerson("john", "John", "Peterson")
    s2 = pc['pete'] = BasicPerson("pete", "Pete", "Johnson")

    contacts = IContactContainer(app)
    contact = Contact()
    contact.__name__ = 'pete_parent'
    contact.prefix = 'Ms.'
    contact.first_name = 'Susan'
    contact.middle_name = 'T.'
    contact.last_name = 'Johnson'
    contact.suffix = 'Jr.'
    contact.address_line_1 = '1 First St.'
    contact.address_line_2 = 'Apt. 1'
    contact.city = 'NY'
    contact.state = 'NY'
    contact.country = 'USA'
    contact.postal_code = '00000'
    contact.email = '*****@*****.**'
    contact.home_phone = '000-0000'
    contact.work_phone = '111-1111'
    contact.mobile_phone = '222-2222'
    contact.language = 'English'
    contacts['pete_parent'] = contact

    IContactable(s2).contacts.relate(contact, ACTIVE + PARENT, 'p')
    IContactable(s2).contacts.relate(IContact(teacher), ACTIVE + PARENT, 'p')

    d1 = IDemographics(s1)
    d1['ID'] = "112323"
    d1['ethnicity'] = u'Asian'
    d1['language'] = "English"
    d1['placeofbirth'] = "Humptington"
    d1['citizenship'] = "US"
    d2 = IDemographics(s2)
    d2['ID'] = "333655"
    d2['ethnicity'] = u'White'
    d2['language'] = "Brittish"
    d2['placeofbirth'] = "Providence"
    d2['citizenship'] = "UK"

    course = ICourseContainer(sy)['c1'] = Course("History")
Esempio n. 9
0
 def create(self, data):
     term = Term(data['title'], data['first'], data['last'])
     form.applyChanges(self, term, data)
     self.setHolidays(term)
     self._term = term
     return term