Changeset 755a70 in indico


Ignore:
Timestamp:
03/03/11 12:07:26 (2 years ago)
Author:
Pedro Ferreira <jose.pedro.ferreira@…>
Branches:
master, burotel, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 0da0c1403bae8e51d8229f460181c71b9e6dda72
Children:
20ac18
Parents:
5ce34c
git-author:
Pedro Ferreira <jose.pedro.ferreira@…> (03/02/11 18:19:08)
git-committer:
Pedro Ferreira <jose.pedro.ferreira@…> (03/03/11 12:07:26)
Message:

[FIX] Fixes in migration script

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • bin/migration/migrate_0.97_0.98.py

    r353585 r755a70  
    2525import traceback 
    2626from BTrees.OOBTree import OOTreeSet 
     27from dateutil import rrule 
    2728 
    2829from MaKaC.common.indexes import IndexesHolder, CategoryDayIndex 
     
    3738from indico.ext import livesync 
    3839from indico.util import console 
     40from indico.modules.scheduler.tasks import AlarmTask, FoundationSyncTask, \ 
     41     CategoryStatisticsUpdaterTask 
     42 
     43from indico.modules.scheduler import Client 
    3944 
    4045 
     
    4348    Migrating database tasks from the old format to the new one 
    4449    """ 
     50 
     51    c = Client() 
     52 
    4553    for t in HelperTaskList().getTaskListInstance().getTasks(): 
    46         print t 
    47         # TODO: finish this 
     54        for obj in t.getObjList(): 
     55            print console.colored("   * %s" % obj.__class__.__name__, 'blue') 
     56            if obj.__class__.__name__ == 'FoundationSync': 
     57                c.enqueue( 
     58                    FoundationSyncTask(rrule.DAILY, byhour=0, byminute=0)) 
     59            elif obj.__class__.__name__ == 'StatisticsUpdater': 
     60                c.enqueue(CategoryStatisticsUpdaterTask( 
     61                    CategoryManager().getById('0'), 
     62                    rrule.DAILY, 
     63                    byhour=0, byminute=0)) 
     64            elif obj.__class__.__name__ == 'sendMail': 
     65                # they have to be somewhere in the conference 
     66                alarm = t.conf.alarmList[t.id] 
     67                c.enqueue(alarm) 
     68            else: 
     69                raise Exception("Unknown task type!") 
    4870 
    4971    dbi.commit() 
     
    6486 
    6587 
     88def _convertAlarms(obj): 
     89    alarms = {} 
     90    obj._legacyAlarmList = obj.getAlarmList() 
     91 
     92    for alarm in obj.getAlarmList(): 
     93        sdate = alarm.getStartDate() 
     94        newTask = AlarmTask(obj, alarm.id, sdate) 
     95        newTask.setSubject(alarm.getSubject()) 
     96        newTask.setText(alarm.getText()) 
     97        newTask.setNote(alarm.getNote()) 
     98        newTask.setConfSummary(alarm.getConfSumary()) 
     99        newTask.setToAllParticipants(alarm.getToAllParticipants()) 
     100        alarms[alarm.id] = newTask 
     101 
     102        newTask.setFromAddr(alarm.getFromAddr()) 
     103        for addr in alarm.getToAddrList(): 
     104            newTask.addToAddr(addr) 
     105 
     106    obj.alarmList = alarms 
     107 
     108 
    66109def runConferenceMigration(dbi): 
    67110    """ 
     
    73116 
    74117    for (level, obj) in console.conferenceHolderIterator(ch, deepness='contrib'): 
    75  
    76         ## TODO: Fix and uncomment 
    77         ## 
    78         ## # only for conferences 
    79         ## if level == 'conf': 
    80         ##     if hasattr(obj, '__alarmCounter'): 
    81         ##         raise Exception("Conference Object %s (%s) seems to have been " 
    82         ##                         "already converted" % (obj, obj.id)) 
    83  
    84         ##     existingKeys = obj.alarmList.keys() 
    85         ##     existingKeys.sort() 
    86         ##     nstart = int(existingKeys[-1]) + 1 if existingKeys else 0 
    87         ##     obj._Conference__alarmCounter = Counter(nstart) 
    88  
    89         ##     # TODO: For each conference, take the existing tasks and 
    90         ##     # convert them to the new object classes. 
    91         ##     # It is important to save the state of the alarm (sent or not) 
    92  
     118        # only for conferences 
     119        if level == 'event': 
     120            if hasattr(obj, '_Conference__alarmCounter'): 
     121                raise Exception("Conference Object %s (%s) seems to have been " 
     122                                "already converted" % (obj, obj.id)) 
     123 
     124            existingKeys = obj.alarmList.keys() 
     125            existingKeys.sort() 
     126            nstart = int(existingKeys[-1]) + 1 if existingKeys else 0 
     127            obj._Conference__alarmCounter = Counter(nstart) 
     128 
     129            # TODO: For each conference, take the existing tasks and 
     130            # convert them to the new object classes. 
     131            # It is important to save the state of the alarm (sent or not) 
     132            _convertAlarms(obj) 
    93133        _fixAccessController(obj) 
    94134 
     
    100140        if isinstance(obj, Conference): 
    101141            for reg in obj.getRegistrants().values(): 
    102                 if reg._sessions and isinstance(reg._sessions[0], RegistrationSession): 
    103                     reg._sessions = [RegistrantSession(ses, reg) for ses in self._sessions] 
     142                if reg._sessions and \ 
     143                       isinstance(reg._sessions[0], RegistrationSession): 
     144                    reg._sessions = [RegistrantSession(ses, reg) \ 
     145                                     for ses in reg._sessions] 
    104146 
    105147    dbi.commit() 
     
    168210 
    169211    tasks = [runPluginMigration, 
     212             runConferenceMigration, 
    170213             runTaskMigration, 
    171              runConferenceMigration, 
    172214             runCategoryDateIndexMigration, 
    173215             runCategoryConfDictToTreeSet] 
  • indico/MaKaC/common/db.py

    r76defd r755a70  
    159159 
    160160    def commitZODBOld(self, sub=False): 
    161             transaction.commit(sub) 
     161        transaction.commit(sub) 
    162162 
    163163    def abort(self): 
     
    212212    elif int(zodbVersion[1]) < 7: 
    213213        commit = commitZODBOld 
    214  
    215  
  • indico/MaKaC/webinterface/pages/conferences.py

    r5ce34c r755a70  
    52055205            "saveAlarm": urlHandlers.UHConfSaveAlarm.getURL(), \ 
    52065206            "confId": self._conf.getId(), \ 
    5207             "alarmId": self._alarm.getId(), \ 
     5207            "alarmId": self._alarm.getConfRelativeId(), \ 
    52085208            "confTitle": self._conf.getTitle() } 
    52095209        vars["selec1"] = vars["selec2"] = vars["selec3"] = "" 
     
    52975297 
    52985298        vars["testSendAlarm"] = testSendAlarm 
    5299         if self._alarm.getConfSumary(): 
     5299        if self._alarm.getConfSummary(): 
    53005300            vars["includeConf"] = "checked" 
    53015301 
  • indico/MaKaC/webinterface/rh/conferenceModif.py

    ra3574e r755a70  
    32483248 
    32493249        if self._includeConf and self._includeConf == "1": 
    3250             al.setConfSumary(True) 
    3251         else: 
    3252             al.setConfSumary(False) 
     3250            al.setConfSummary(True) 
     3251        else: 
     3252            al.setConfSummary(False) 
    32533253 
    32543254        self._al = al 
     
    53815381 
    53825382 
    5383 class RHContributionList( RoomBookingDBMixin, RHContributionListBase ): 
     5383class RHContributionList202( RoomBookingDBMixin, RHContributionListBase ): 
    53845384    _uh = urlHandlers.UHConfModifContribList 
    53855385 
  • indico/modules/scheduler/tasks.py

    rd738f7 r755a70  
    281281    """ 
    282282    Singleton periodic tasks: no two or more PeriodicUniqueTask of this 
    283     class will be queued or running at the same time 
    284     """ 
     283    class will be queued or running at the same time (TODO) 
     284    """ 
     285    # TODO: implement this 
    285286 
    286287 
     
    317318        return self._task 
    318319 
     320 
    319321class CategoryStatisticsUpdaterTask(PeriodicUniqueTask): 
    320322    '''Updates statistics associated with categories 
    321323    ''' 
    322     def __init__(self, cat, **kwargs): 
    323         super(CategoryStatisticsUpdaterTask, self).__init__(**kwargs) 
     324    def __init__(self, cat, frequency, **kwargs): 
     325        super(CategoryStatisticsUpdaterTask, self).__init__(frequency, 
     326                                                            **kwargs) 
    324327        self._cat = cat 
    325328 
     
    329332 
    330333 
    331 # TODO CERN Specific 
     334# TODO: Isolate CERN Specific 
    332335class FoundationSyncTask(PeriodicUniqueTask): 
    333336    """ 
     
    339342    (This is object for a task class) 
    340343    """ 
    341     def __init__(self, **kwargs): 
    342         super(FoundationSyncTask, self).__init__(**kwargs) 
    343         obj.__init__(self) 
     344    def __init__(self, frequency, **kwargs): 
     345        super(FoundationSyncTask, self).__init__(frequency, **kwargs) 
    344346 
    345347    def run(self): 
     
    361363        self.smtpServer = Config.getInstance().getSmtpServer() 
    362364 
    363     def run(self, check = False): 
     365    def run(self, check=False): 
    364366        import smtplib 
    365367        from MaKaC.webinterface.mail import GenericMailer, GenericNotification 
    366368 
    367369        # prepare the mail 
    368         self._prepare(check = check); 
     370        self._prepare(check=check); 
    369371 
    370372        addrs = [smtplib.quoteaddr(x) for x in self.toAddr] 
     
    393395        if not addr in self.toAddr: 
    394396            self.toAddr.append(addr) 
    395             self._p_changed=1 
     397            self._p_changed = 1 
    396398 
    397399    def addCcAddr(self, addr): 
    398400        if not addr in self.ccAddr: 
    399401            self.ccAddr.append(addr) 
    400             self._p_changed=1 
     402            self._p_changed = 1 
    401403 
    402404    def removeToAddr(self, addr): 
    403405        if addr in self.toAddr: 
    404406            self.toAddr.remove(addr) 
    405             self._p_changed=1 
     407            self._p_changed = 1 
    406408 
    407409    def setToAddrList(self, addrList): 
    408410        """Params: addrList -- addresses of type : list of str.""" 
    409411        self.toAddr = addrList 
    410         self._p_changed=1 
     412        self._p_changed = 1 
    411413 
    412414    def getToAddrList(self): 
     
    416418        """Params: addrList -- addresses of type : list of str.""" 
    417419        self.ccAddr = addrList 
    418         self._p_changed=1 
     420        self._p_changed = 1 
    419421 
    420422    def getCcAddrList(self): 
     
    424426        if not user in self.toUser: 
    425427            self.toUser.append(user) 
    426             self._p_changed=1 
     428            self._p_changed = 1 
    427429 
    428430    def removeToUser(self, user): 
    429431        if user in self.toUser: 
    430432            self.toUser.remove(user) 
    431             self._p_changed=1 
     433            self._p_changed = 1 
    432434 
    433435    def getToUserList(self): 
     
    445447    def getText(self): 
    446448        return self.text 
    447  
    448449 
    449450 
     
    553554        return self.note 
    554555 
    555     def setConfSumary(self, val): 
     556    def setConfSummary(self, val): 
    556557        self.confSumary = val 
    557558        self._setMailText() 
    558559        self._p_changed=1 
    559560 
    560     def getConfSumary(self): 
     561    def getConfSummary(self): 
    561562        return self.confSumary 
    562563 
Note: See TracChangeset for help on using the changeset viewer.