Changeset e83ea5 in indico for indico/MaKaC/conference.py


Ignore:
Timestamp:
10/18/09 23:29:30 (4 years ago)
Author:
David Martín Clavo <david.martin.clavo@…>
Branches:
master, burotel, hello-world-walkthrough, ipv6, new-webex, prov-dual-interface, v0.97-series, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, b8c30da8ebdbdcbd675a873997cc3e95f567de49, 4287315ec967a3da168d83963c14001db8487d53
Children:
bca298
Parents:
0ff223
git-author:
David Martín Clavo <david.martin.clavo@…> (10/18/09 23:17:12)
git-committer:
David Martín Clavo <david.martin.clavo@…> (10/18/09 23:29:30)
Message:

[ADDED] Notification on booking sync pbs. Warning refactor. Squashed commit

# This is a combination of 14 commits.
# The first commit's message is:
[MINOR] new WarningPopup? and FieldChangeWarningPopup? JS classes

# This is the 2nd commit message:

[IMPROVEMENT] (temporary) added FieldModificationWarning? python class

# This is the 3rd commit message:

[IMPROVEMENT] (temporary) added FieldModificationWarning? python class

# This is the 4th commit message:

[IMPROVEMENT] Added warning dialog to event inline widgets

-Changed cachedRpcValue so that it detects if a result
is a warning and calls a dialog accordingly.

# This is the 5th commit message:

[IMPROVEMENT] Warning when changing event start/end dates has side problems

-Used mechanism: make the Conference.setDates, Conference.setStartDate,
etc. return values (to be changed)

# This is the 6th commit message:

[REFACTOR] event date change observer notifications changed to ContextManager?

-When an event date change triggered an observer error,
the user is notified by a dialog. For this we changed the
setDates, setStartDate, etc. methods to return values.
-Now we use ContextManager? to store the problem strings in
a context variable.
-Changed the observer mechanism so that there is a single method
for both start and end date changes, so that when both are
modified at the same time (future new start/end date widget)
there's only 1 notification.

# This is the 7th commit message:

[REFACTOR] Warning refactor

-Old Warning class->NoReportError? class.
-Changed ServiceAccessWarning? to ServiceAccessError?, that
inherits from new NoReportError?.
-Also created new Warning class, with info for Warning dialog,
and new ResultWithWarning? class.

# This is the 8th commit message:

[REFACTOR] Warning refactor

-Old Warning class->NoReportError? class.
-Changed ServiceAccessWarning? to ServiceAccessError?, that
inherits from new NoReportError?.
-Also created new Warning class, with info for Warning dialog,
and new ResultWithWarning? class.

# This is the 9th commit message:

[IMPROVEMENT] New WarningPopup?

# This is the 10th commit message:

[IMPROVEMENT] New WarningPopup?

# This is the 11th commit message:

[IMPROVEMENT] More info in event date change sync warning

# This is the 12th commit message:

[MINOR] Changed ErrorReportDialog? to use AlertPopup?

# This is the 13th commit message:

[MINOR] Centered title of AlertPopup? and WarningPopup?

# This is the 14th commit message:

[MINOR] Removed wrong comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • indico/MaKaC/conference.py

    r9a0611 re83ea5  
    26832683                try: 
    26842684                    Logger.get('Conference').error("Exception while notifying the observer %s of of a conference deletion for conference %s: %s"% 
    2685                                                    (observer.getName(), self.getId(), str(e))) 
     2685                                                   (observer.getObserverName(), self.getId(), str(e))) 
    26862686                except Exception, e2: 
    26872687                    Logger.get('Conference').error("Exception while notifying a conference deletion: %s (origin: %s)"%(str(e2), str(e))) 
     
    27332733            return 
    27342734        self.unindexConf() 
    2735         self.setStartDate(sDate, check=0, moveEntries=moveEntries,index=False) 
    2736         self.setEndDate(eDate, check=0, index=False) 
     2735         
     2736        self.setStartDate(sDate, check=0, moveEntries = moveEntries, index=False, notifyObservers = False) 
     2737        self.setEndDate(eDate, check=0, index=False, notifyObservers = False) 
     2738         
    27372739        self._checkInnerSchedule() 
    27382740        self.indexConf() 
    27392741        self.cleanCategoryCache() 
     2742         
     2743        for observer in self.getDateChangeObservers(): 
     2744            try: 
     2745                observer.notifyEventDateChanges(oldStartDate, self.getStartDate(), oldEndDate, self.getEndDate()) 
     2746            except Exception, e: 
     2747                try: 
     2748                    Logger.get('Conference').error("Exception while notifying the observer %s of a start and end date change from %s - %s to %s - %s for conference %s: %s"% 
     2749                                                   (observer.getObserverName(), formatDateTime(oldStartDate), formatDateTime(oldEndDate), 
     2750                                                    formatDateTime(self.getStartDate()), formatDateTime(self.getEndDate()), self.getId(), str(e))) 
     2751                except Exception, e2: 
     2752                    Logger.get('Conference').error("Exception while notifying a start and end date change: %s (origin: %s)"%(str(e2), str(e))) 
    27402753 
    27412754    def _checkInnerSchedule( self ): 
    27422755        self.getSchedule().checkSanity() 
    27432756 
    2744     def setStartDate(self,sDate,check=1,moveEntries=0,index=True): 
    2745         """changes the current conference starting date to the one specified by 
    2746             the parameters""" 
     2757    def setStartDate(self, sDate, check = 1, moveEntries = 0, index = True, notifyObservers = True): 
     2758        """ Changes the current conference starting date/time to the one specified by the parameters. 
     2759        """ 
    27472760        if not sDate.tzname(): 
    27482761            raise MaKaCError("date should be timezone aware") 
     
    27622775        oldSdate = self.getStartDate() 
    27632776        diff = sDate - oldSdate 
    2764         try: 
    2765            tz = str(sDate.tzinfo) 
    2766         except: 
    2767            tz = "Undef" 
     2777         
    27682778        if index: 
    27692779            self.unindexConf() 
     
    27862796 
    27872797        #if everything went well, we notify the observers that the start date has changed 
    2788         for observer in self.getDateChangeObservers(): 
    2789             try: 
    2790                 observer.notifyStartDateChange(oldSdate, sDate) 
    2791             except Exception, e: 
     2798        if notifyObservers: 
     2799            for observer in self.getDateChangeObservers(): 
    27922800                try: 
    2793                     Logger.get('Conference').error("Exception while notifying the observer %s of a start date change from %s to %s for conference %s: %s"% 
    2794                                                    (observer.getName(), formatDateTime(oldSdate), formatDateTime(sDate), self.getId(), str(e))) 
    2795                 except Exception, e2: 
    2796                     Logger.get('Conference').error("Exception while notifying a start date change: %s (origin: %s)"%(str(e2), str(e))) 
     2801                    observer.notifyEventDateChanges(oldSdate, sDate, None, None) 
     2802                except Exception, e: 
     2803                    try: 
     2804                        Logger.get('Conference').error("Exception while notifying the observer %s of a start date change from %s to %s for conference %s: %s"% 
     2805                                                       (observer.getObserverName(), formatDateTime(oldSdate), formatDateTime(sDate), self.getId(), str(e))) 
     2806                    except Exception, e2: 
     2807                        Logger.get('Conference').error("Exception while notifying a start date change: %s (origin: %s)"%(str(e2), str(e))) 
    27972808 
    27982809 
     
    28012812            raise MaKaCError( _("End date cannot be before the Start date"), _("Event")) 
    28022813 
    2803     def setStartTime(self, hours=0, minutes=0): 
     2814    def setStartTime(self, hours=0, minutes=0, notifyObservers = True): 
     2815        """ Changes the current conference starting time (not date) to the one specified by the parameters. 
     2816        """ 
     2817         
    28042818        sdate = self.getStartDate() 
    28052819        self.startDate = datetime( sdate.year, sdate.month, sdate.day, 
     
    28092823 
    28102824        #if everything went well, we notify the observers that the start date has changed 
    2811         for observer in self.getDateChangeObservers(): 
    2812             try: 
    2813                 observer.notifyStartDateChange(sdate, self.startDate) 
    2814             except Exception, e: 
     2825        if notifyObservers: 
     2826            for observer in self.getDateChangeObservers(): 
    28152827                try: 
    2816                     Logger.get('Conference').error("Exception while notifying the observer %s of a start date change from %s to %s for conference %s: "% 
    2817                                                    (observer.getName(), formatDateTime(sdate), formatDateTime(self.startDate), self.getId(), str(e))) 
    2818                 except Exception, e2: 
    2819                     Logger.get('Conference').error("Exception while notifying a start time change: %s (origin: %s)"%(str(e2), str(e))) 
     2828                    observer.notifyEventDateChanges(sdate, self.startDate, None, None) 
     2829                except Exception, e: 
     2830                    try: 
     2831                        Logger.get('Conference').error("Exception while notifying the observer %s of a start date change from %s to %s for conference %s: "% 
     2832                                                       (observer.getObserverName(), formatDateTime(sdate), formatDateTime(self.startDate), self.getId(), str(e))) 
     2833                    except Exception, e2: 
     2834                        Logger.get('Conference').error("Exception while notifying a start time change: %s (origin: %s)"%(str(e2), str(e))) 
    28202835 
    28212836    def getStartDate(self): 
     
    28732888            raise MaKaCError(_("Cannot change end date to %s: some entries in the timetable would be outside this date (%s)") % (edate,self.getSchedule().getEntries()[-1].getStartDate()), _("Event")) 
    28742889 
    2875     def setEndDate(self, eDate,check=1, index=True): 
    2876         """changes the current conference ending date to the one specified by 
    2877             the parameters""" 
     2890    def setEndDate(self, eDate, check = 1, index = True, notifyObservers = True): 
     2891        """ Changes the current conference end date/time to the one specified by the parameters. 
     2892        """ 
    28782893        if not eDate.tzname(): 
    28792894            raise MaKaCError("date should be timezone aware") 
     
    28962911 
    28972912        #if everything went well, we notify the observers that the start date has changed 
    2898         for observer in self.getDateChangeObservers(): 
    2899             try: 
    2900                 observer.notifyEndDateChange(oldEdate, eDate) 
    2901             except Exception, e: 
     2913        if notifyObservers: 
     2914            for observer in self.getDateChangeObservers(): 
    29022915                try: 
    2903                     Logger.get('Conference').error("Exception while notifying the observer %s of a end date change from %s to %s for conference %s: "% 
    2904                                                    (observer.getName(), formatDateTime(oldEdate), formatDateTime(eDate), self.getId(), str(e))) 
    2905                 except Exception, e2: 
    2906                     Logger.get('Conference').error("Exception while notifying a end date change: %s (origin: %s)"%(str(e2), str(e))) 
    2907  
    2908     def setEndTime(self, hours=0, minutes=0): 
     2916                    observer.notifyEventDateChanges(None, None, oldEdate, eDate) 
     2917                except Exception, e: 
     2918                    try: 
     2919                        Logger.get('Conference').error("Exception while notifying the observer %s of a end date change from %s to %s for conference %s: "% 
     2920                                                       (observer.getObserverName(), formatDateTime(oldEdate), formatDateTime(eDate), self.getId(), str(e))) 
     2921                    except Exception, e2: 
     2922                        Logger.get('Conference').error("Exception while notifying a end date change: %s (origin: %s)"%(str(e2), str(e))) 
     2923 
     2924    def setEndTime(self, hours = 0, minutes = 0, notifyObservers = True): 
     2925        """ Changes the current conference end time (not date) to the one specified by the parameters. 
     2926        """ 
    29092927        edate = self.getEndDate() 
    2910         self.endDate = datetime( edate.year, edate.month, edate.day, \ 
    2911                                                     int(hours), int(minutes) ) 
     2928        self.endDate = datetime( edate.year, edate.month, edate.day, int(hours), int(minutes) ) 
    29122929        self.verifyEndDate(self.endDate) 
    29132930        self.notifyModification() 
    29142931 
    29152932        #if everything went well, we notify the observers that the start date has changed 
    2916         for observer in self.getDateChangeObservers(): 
    2917             try: 
    2918                 observer.notifyEndDateChange(edate, self.endDate) 
    2919             except Exception, e: 
     2933        if notifyObservers: 
     2934            for observer in self.getDateChangeObservers(): 
    29202935                try: 
    2921                     Logger.get('Conference').error("Exception while notifying the observer %s of a end timet change from %s to %s for conference %s: "% 
    2922                                                    (observer.getName(), formatDateTime(edate), formatDateTime(self.endDate), self.getId(), str(e))) 
    2923                 except Exception, e2: 
    2924                     Logger.get('Conference').error("Exception while notifying a end time change: %s (origin: %s)"%(str(e2), str(e))) 
     2936                    observer.notifyEventDateChanges(None, None, edate, self.endDate) 
     2937                except Exception, e: 
     2938                    try: 
     2939                        Logger.get('Conference').error("Exception while notifying the observer %s of a end timet change from %s to %s for conference %s: "% 
     2940                                                       (observer.getObserverName(), formatDateTime(edate), formatDateTime(self.endDate), self.getId(), str(e))) 
     2941                    except Exception, e2: 
     2942                        Logger.get('Conference').error("Exception while notifying a end time change: %s (origin: %s)"%(str(e2), str(e))) 
    29252943 
    29262944    def getEndDate(self): 
     
    30433061                try: 
    30443062                    Logger.get('Conference').error("Exception while notifying the observer %s of of a conference title change for conference %s: %s"% 
    3045                                                    (observer.getName(), self.getId(), str(e))) 
     3063                                                   (observer.getObserverName(), self.getId(), str(e))) 
    30463064                except Exception, e2: 
    30473065                    Logger.get('Conference').error("Exception while notifying a conference title change: %s (origin: %s)"%(str(e2), str(e))) 
     
    49114929        return None 
    49124930 
    4913 class TitleChangeObserver(object): 
    4914     """ Base class for objects who want to be notified of a Conference object being deleted. 
    4915         Inheriting classes have to implement the notifyDeletion method, and probably the __init__ method too. 
     4931class Observer(object): 
     4932    """ Base class for Observer objects. 
     4933        Provides the getObserverName method (used when writing info to the Indico log) 
    49164934    """ 
    49174935    def getObserverName(self): 
    4918         name = "'title change observer of class" + self.__class__.__name__ 
    4919         try: 
    4920             conference = self.getConference() 
    4921             name = name + " of conference " + conference.getId() 
     4936        name = "'Observer of class" + self.__class__.__name__ 
     4937        try: 
     4938            conf = self.getOwner() 
     4939            name = name + " of event " + conf.getId() + "'" 
    49224940        except AttributeError: 
    49234941            pass 
    49244942        return name 
     4943 
     4944class TitleChangeObserver(Observer): 
     4945    """ Base class for objects who want to be notified of a Conference object being deleted. 
     4946        Inheriting classes have to implement the notifyTitleChange method, and probably the __init__ method too. 
     4947    """ 
    49254948 
    49264949    def notifyTitleChange(self, oldTitle, newTitle): 
     
    49304953        raise MaKaCError("Class " + str(self.__class__.__name__) + " did not implement method notifyTitleChange") 
    49314954 
    4932 class DateChangeObserver(object): 
     4955class DateChangeObserver(Observer): 
    49334956    """ Base class for objects who want to be notified of a change in the start date / end date 
    49344957        of an object (for example a Conference object). 
     
    49364959        and probably the __init__ method too. 
    49374960    """ 
    4938     def getObserverName(self): 
    4939         name = "'date observer of class" + self.__class__.__name__ 
    4940         try: 
    4941             conference = self.getConference() 
    4942             name = name + " of conference " + conference.getId() 
    4943         except AttributeError: 
    4944             pass 
    4945         return name 
    4946  
    4947     def notifyStartDateChange(self, oldStartDate, newStartDate): 
     4961 
     4962    def notifyEventDateChanges(self, oldStartDate = None, newStartDate = None, oldEndDate = None, newEndDate = None): 
    49484963        """ To be implemented by inheriting classes 
    4949             Notifies the observer that the start date of the object it is attached to has changed 
     4964            Notifies the observer that the start and / or end dates of the object it is attached to has changed. 
     4965            If the observer finds any problems during whatever he needs to do as a consequence of 
     4966            the event dates changing, he should write strings describing the problems 
     4967            in the 'dateChangeNotificationProblems' context variable (which is a list of strings). 
    49504968        """ 
    49514969        raise MaKaCError("Class " + str(self.__class__.__name__) + " did not implement method notifyStartDateChange") 
    49524970 
    4953     def notifyEndDateChange(self, oldEndDate, newEndDate): 
    4954         """ To be implemented by inheriting classes 
    4955             Notifies the observer that the end date of the object it is attached to has changed 
    4956         """ 
    4957         raise MaKaCError("Class " + str(self.__class__.__name__) + " did not implement method notifyStartDateChange") 
    4958  
    49594971    def notifyTimezoneChange(self, oldTimezone, newTimezone): 
    4960         """ To be implemented by inheriting classes 
    4961             Notifies the observer that the end date of the object it is attached to has changed 
     4972        """ To be implemented by inheriting classes. 
     4973            Notifies the observer that the end date of the object it is attached to has changed. 
     4974            This method has to return a list of strings describing problems encountered during 
     4975            whatever the DateChangeObserver object does as a consequence of the notification. 
     4976            If there are no problems, the DateChangeObserver should return an empty list. 
    49624977        """ 
    49634978        raise MaKaCError("Class " + str(self.__class__.__name__) + " did not implement method notifyTimezoneChange") 
    49644979 
    49654980 
    4966 class DeleteObserver(object): 
     4981class DeleteObserver(Observer): 
    49674982    """ Base class for objects who want to be notified of a Conference object being deleted. 
    49684983        Inheriting classes have to implement the notifyDeletion method, and probably the __init__ method too. 
    49694984    """ 
    4970     def getObserverName(self): 
    4971         name = "'delete observer of class" + self.__class__.__name__ 
    4972         try: 
    4973             conference = self.getConference() 
    4974             name = name + " of conference " + conference.getId() 
    4975         except AttributeError: 
    4976             pass 
    4977         return name 
    4978  
    49794985    def notifyDeletion(self): 
    49804986        """ To be implemented by inheriting classes 
Note: See TracChangeset for help on using the changeset viewer.