Changeset 9b342a in indico


Ignore:
Timestamp:
06/09/11 11:11:38 (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, d9941f8582b36b24821a11ea5ba16fda6a457fb1
Children:
880a3e, 2810d8
Parents:
699502
git-author:
Pedro Ferreira <jose.pedro.ferreira@…> (06/09/11 10:48:56)
git-committer:
Pedro Ferreira <jose.pedro.ferreira@…> (06/09/11 11:11:38)
Message:

[FIX] Make evaluation alarms work

Location:
indico
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • indico/MaKaC/evaluation.py

    rb7b536 r9b342a  
    2828from MaKaC.common.info import HelperMaKaCInfo 
    2929from MaKaC.common.Counter       import Counter 
    30 from MaKaC.common.timerExec     import Alarm 
    3130from MaKaC.i18n import _ 
    3231from pytz import timezone 
    3332from MaKaC.common.timezoneUtils import nowutc 
     33 
     34from indico.modules.scheduler import Client 
     35from indico.modules.scheduler.tasks import AlarmTask 
    3436 
    3537 
     
    8688    def removeReferences(self): 
    8789        """remove all pointers to other objects.""" 
    88         self._conf = None 
    8990        self.removeAllAlarms() 
    9091        self.removeAllNotifications() 
    9192        self.removeAllQuestions() 
    9293        self.removeAllSubmissions() 
     94        self._conf = None 
    9395 
    9496    def clone(self, conference): 
     
    224226    def setStartDate( self, sd ): 
    225227        self.startDate = datetime(sd.year,sd.month,sd.day,0,0,0) 
     228        for nid, notif in self.getNotifications().iteritems(): 
     229            if isinstance(notif, EvaluationAlarm): 
     230                if notif.getStartOn() != sd: 
     231                    notif.move(sd) 
     232 
    226233    def getStartDate( self ): 
    227234        if not hasattr(self, "startDate") or self.startDate==datetime(1,1,1,0,0,0): 
     
    412419        elif notificationKey == self._EVALUATION_START : 
    413420            notification = self.getNotification(notificationKey) 
    414             if notification != None : 
     421            if notification != None: 
    415422                from MaKaC.webinterface import urlHandlers 
    416423                alarm = self.getAlarm(notificationKey) 
     
    419426                    self.getConference().addAlarm(alarm) 
    420427                    self.getAlarms()[notificationKey] = alarm 
     428 
    421429                    self.notifyModification() 
    422                     alarm.initialiseToAddr() 
     430                else: 
     431                    if self.getStartDate() != alarm.getStartOn(): 
     432                        alarm.move(self.getStartDate()) 
     433 
    423434                alarm.setFromAddr( HelperMaKaCInfo.getMaKaCInfoInstance().getSupportEmail() ) 
    424                 alarm.setStartDate(self.getStartDate()) 
    425435                alarm.setToAddrList(notification.getToList()) 
    426436                alarm.setCcAddrList(notification.getCCList()) 
     
    432442        """Remove given Alarm.""" 
    433443        if alarm != None : 
    434             if self.getConference().getAlarmById(alarm.getId())!=None : 
     444            if self.getConference().getAlarmById(alarm.getConfRelativeId()) != None : 
    435445                self.getConference().removeAlarm(alarm) 
    436446            else : 
     
    441451        """remove all alarms.""" 
    442452        alarms = self.getAlarms() 
     453 
    443454        for alarm in alarms.values() : 
    444455            self.getConference().removeAlarm(alarm) 
     
    462473 
    463474 
    464 class EvaluationAlarm(Alarm): 
     475class EvaluationAlarm(AlarmTask): 
    465476    """Suited alarm for an evaluation.""" 
    466477 
    467478    def __init__(self, evaluation, notificationKey): 
    468479        self._evaluation = evaluation 
    469         self.notificationKey = notificationKey #cf Evaluation._ALL_NOTIFICATIONS 
    470         Alarm.__init__(self, evaluation.getConference()) 
     480        self.notificationKey = notificationKey  #cf Evaluation._ALL_NOTIFICATIONS 
     481        super(EvaluationAlarm, self).__init__(evaluation.getConference(), 
     482                                              'Eval_%s' % notificationKey, 
     483                                              evaluation.getStartDate()) 
    471484 
    472485    def setEvaluation(self, evaluation): 
     
    478491        return self._evaluation 
    479492 
    480     def setNotificationKey(self, notificationKey): #cf Evaluation._ALL_NOTIFICATIONS 
     493    def setNotificationKey(self, notificationKey): 
    481494        self.notificationKey = notificationKey 
    482495 
    483     def getNotificationKey(self): #cf Evaluation._ALL_NOTIFICATIONS 
     496    def getNotificationKey(self): 
    484497        if not hasattr(self, "notificationKey"): 
    485498            self.notificationKey = None 
    486499        return self.notificationKey 
    487500 
     501    def move(self, newDate): 
     502        c = Client() 
     503        c.moveTask(self, newDate) 
     504 
    488505    def delete(self): 
    489506        evaluation = self.getEvaluation() 
    490         if evaluation != None : 
     507        if evaluation != None: 
    491508            evaluation.removeAlarm(self) 
    492509        self.setEvaluation(None) 
    493510        Alarm.delete(self) 
    494511 
    495     def prerun(self): 
    496         """returns True if aborted, False otherwise.""" 
    497         #date checking... 
     512    def _prepare(self, check=True): 
     513 
     514        # date checking... 
    498515        from MaKaC.conference import ConferenceHolder 
    499516        evaluation = self.getEvaluation() 
     
    502519        today = nowutc().date() 
    503520        if not ConferenceHolder().hasKey(self.conf.getId()) or \ 
    504                 evaluation.getNbOfQuestions()<1 or \ 
     521                evaluation.getNbOfQuestions() < 1 or \ 
    505522                not evaluation.isVisible() or \ 
    506                 notificationKey==Evaluation._EVALUATION_START and evalEndDate<today : 
     523                (notificationKey == Evaluation._EVALUATION_START and \ 
     524                evalEndDate < today and check): 
    507525            self.conf.removeAlarm(self) 
    508             return True #email aborted 
    509         return False #email ok 
     526            self.suicide() 
     527            return False  # email aborted 
     528        return True  # email ok 
    510529 
    511530 
  • indico/modules/scheduler/module.py

    rd71e61 r9b342a  
    147147            self._p_changed = True 
    148148        except ValueError: 
    149             logging.getLogger('scheduler').exception() 
     149            logging.getLogger('scheduler').exception("Problem removing running task: %s" % self._runningList) 
    150150 
    151151    def moveTask(self, task, moveFrom, status, occurrence=None, nocheck=False): 
  • indico/modules/scheduler/tasks.py

    r339487 r9b342a  
    7777 
    7878    def __cmp__(self, obj): 
    79         if self.id == obj.id and self.id == None: 
     79        if obj == None: 
     80            return 1 
     81        elif (not isinstance(obj, BaseTask) or \ 
     82              self.id == obj.id and self.id == None): 
    8083            return cmp(hash(self), hash(obj)) 
    8184        else: 
Note: See TracChangeset for help on using the changeset viewer.