def evolve(context):
    """Evolve the ZODB.

    - Remove sessionLanguage from INegotiator utilities

    - Convert _offeredLangauges attribute to offeredLangauges property

    """
    root = getRootFolder(context)

    for site in findObjectsProviding(root, ISite):

        # check if we got the right object
        obj = zope.component.queryUtility(INegotiator, context=site)
        if interfaces.INegotiatorManager.providedBy(obj):

            # remove old unused ``sessionLanguages`` attr from all objects
            delattr(obj, '_sessionLanguages')

            # migrate ``_serverLanguage`` to ``serverLanguage``
            serverLanguage = getattr(obj, '_serverLanguage')
            if not serverLanguage:
                serverLanguage = u'en'
            setattr(obj, 'serverLanguage', serverLanguage)
            delattr(obj, '_serverLanguage')

            # migrate ``_offeredLanguages`` to ``offeredLanguages``
            offeredLanguages = getattr(obj, '_offeredLanguages')
            setattr(obj, 'offeredLanguages', offeredLanguages)
            delattr(obj, '_offeredLanguages')
Exemple #2
0
def evolve(context):
    root = getRootFolder(context)
    old_site = getSite()

    assert ISchoolToolApplication.providedBy(root)
    setSite(root)

    requireURICache(root)

    connection = context.connection

    link_oids, linkset_oids = collectOIDs(connection)

    evolveLinks(connection, link_oids)
    transaction.savepoint(optimistic=True)

    evolveLinkSets(connection, linkset_oids)
    transaction.savepoint(optimistic=True)

    addLinkCatalog(root)
    transaction.savepoint(optimistic=True)

    evolveGroupRelationships(root)
    evolveCourseRelationships(root)
    evolveResourceRelationships(root)
    evolveAdvisorRelationships(root)
    evolveSectionsRelationships(root)

    transaction.savepoint(optimistic=True)

    evolveContactRelationships(root)

    setSite(old_site)
def evolve(context):
    root = getRootFolder(context)
    old_site = getSite()

    assert ISchoolToolApplication.providedBy(root)
    setSite(root)

    requireURICache(root)

    connection = context.connection

    link_oids, linkset_oids = collectOIDs(connection)

    evolveLinks(connection, link_oids)
    transaction.savepoint(optimistic=True)

    evolveLinkSets(connection, linkset_oids)
    transaction.savepoint(optimistic=True)

    addLinkCatalog(root)
    transaction.savepoint(optimistic=True)

    evolveGroupRelationships(root)
    evolveCourseRelationships(root)
    evolveResourceRelationships(root)
    evolveAdvisorRelationships(root)
    evolveSectionsRelationships(root)

    transaction.savepoint(optimistic=True)

    evolveContactRelationships(root)

    setSite(old_site)
def evolve(context):
    root = getRootFolder(context)
    old_site = getSite()
    app = root
    setSite(app)
    setUpLeaveSchoolDemographics(app)
    setSite(old_site)
Exemple #5
0
def ensureEvolved(context):
    root = getRootFolder(context)
    assert ISchoolToolApplication.providedBy(root)
    catalogs = root['schooltool.app.catalog:Catalogs']
    if LinkCatalog.key() in catalogs:
        return
    evolve(context)
    transaction.commit()
def ensureEvolved(context):
    root = getRootFolder(context)
    assert ISchoolToolApplication.providedBy(root)
    catalogs = root["schooltool.app.catalog:Catalogs"]
    if LinkCatalog.key() in catalogs:
        return
    evolve(context)
    transaction.commit()
def evolve(context):
    """Add tzinfo to timestamp of ratings"""
    for ratable in findObjectsProviding(getRootFolder(context), IRatable):
        manager = IRatingsManager(ratable)
        for d in manager._storage.values():
            for rating in d.values():
                if rating._timestamp.tzinfo is None:
                    rating._timestamp = rating._timestamp.replace(tzinfo=UTC)
Exemple #8
0
def evolve(context):
    linkcatalogs.ensureEvolved(context)
    root = getRootFolder(context)

    old_site = getSite()
    apps = findObjectsProviding(root, ISchoolToolApplication)
    for app in apps:
        setSite(app)
        for person in app['persons'].values():
            evolvePerson(person)

    setSite(old_site)
Exemple #9
0
def evolve(context):
    linkcatalogs.ensureEvolved(context)
    root = getRootFolder(context)

    old_site = getSite()

    app = root
    setSite(app)
    evolveScheduleContainers(app)
    evolveTimetableContainers(app)

    setSite(old_site)
Exemple #10
0
def evolve(context):
    """Adds abbreviation column to all custom score systems"""

    app = getRootFolder(context)
    sm = app.getSiteManager()
    for name, util in sorted(sm.getUtilitiesFor(ICustomScoreSystem)):
        util = removeSecurityProxy(util)
        if not util.scores or len(util.scores[0]) != 3:
            continue
        new_scores = []
        for score, value, percent in util.scores:
            new_scores.append([score, '', value, percent])
        util.scores = new_scores
Exemple #11
0
def evolveToSimpleScoreSystem(context):
    """This is a help to migrate existing rating definitions.

    It only works if you use a score system which is compatible with
    SimpleScoreSystem.
    It is meant to be used from your application evolve script.
    """
    for definition in findObjectsProviding(
            getRootFolder(context), IRatingDefinition):
        old = definition.scoreSystem
        new = SimpleScoreSystem(
                old.__name__, old.title, old.description, old.scores)
        definition.scoreSystem = new
def evolve(context):
    """Migrates hard-coded discrete values score systems found in
       schooltool.requirement.scoresystem to the app site manager"""

    app = getRootFolder(context)
    setUpGradebookRoot(app)
    for ss in [PassFail, AmericanLetterScoreSystem, 
               ExtendedAmericanLetterScoreSystem]:
        custom_ss = CustomScoreSystem(ss.title, ss.description, ss.scores,
            ss._bestScore, ss._minPassingScore)
        app.getSiteManager().registerUtility(custom_ss, ICustomScoreSystem,
            name=custom_ss.title)
        updateEvaluations(app, ss, custom_ss)
        updateAllActivities(app, ss, custom_ss)
Exemple #13
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)
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)
Exemple #15
0
def evolve(context):
    root = getRootFolder(context)

    old_site = getSite()
    apps = findObjectsProviding(root, ISchoolToolApplication)
    for app in apps:
        setSite(app)
        site_manager = app.getSiteManager()

        if SCORESYSTEM_CONTAINER_KEY not in app:
            app[SCORESYSTEM_CONTAINER_KEY] = ScoreSystemContainer()
            scoresystems = app[SCORESYSTEM_CONTAINER_KEY]
            chooser = INameChooser(scoresystems)
            utilities = list(site_manager.getUtilitiesFor(ICustomScoreSystem))
            for key, util in utilities:
                name = chooser.chooseName('', util)
                scoresystems[name] = util

        removeUtils(site_manager, ICustomScoreSystem)

    setSite(old_site)
def evolve(context):
    getRootFolder(context).getSiteManager()._evolve_to_generation_4()