Changeset 7319f3 in indico


Ignore:
Timestamp:
09/29/11 16:56:28 (20 months ago)
Author:
Pedro Ferreira <jose.pedro.ferreira@…>
Branches:
master, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, d9941f8582b36b24821a11ea5ba16fda6a457fb1
Children:
ecda80
Parents:
0bebd5
git-author:
Pedro Ferreira <jose.pedro.ferreira@…> (09/27/11 16:21:38)
git-committer:
Pedro Ferreira <jose.pedro.ferreira@…> (09/29/11 16:56:28)
Message:

[FIX] DB writes

  • Also, sending mail on recording request modification was failing;
Location:
indico
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • indico/MaKaC/common/utils.py

    r4137b2 r7319f3  
    415415 
    416416 
    417 def formatDateTime(dateTime, showWeek=False, format=None): 
     417def formatDateTime(dateTime, showWeek=False, format=None, locale=None): 
    418418    week = "" 
    419     locale = str(currentLocale()) 
     419    locale = str(locale or currentLocale()) 
    420420    if showWeek: 
    421421        week = "EEEE " 
  • indico/MaKaC/plugins/Collaboration/CERNMCU/collaboration.py

    r9d8047 r7319f3  
    9191        self._creationTriesCounter = 0 
    9292 
     93    def canBeStarted(self): 
     94        if self.isHappeningNow(): 
     95            return self._numberOfDisconnectedParticipants > 0 
     96        else: 
     97            return False 
     98 
     99    def canBeStopped(self): 
     100        if self.isHappeningNow(): 
     101            return self._numberOfConnectedParticipants > 0 
     102        else: 
     103            return False 
     104 
    93105    def getMCUStartTime(self): 
    94106        return MCUTime(self.getAdjustedStartDate(getCERNMCUOptionValueByName("MCUTZ"))) 
     
    193205 
    194206    def updateNumberOfConnectedParticipants(self): 
    195         self._numberOfConnectedParticipants = 0 
    196         self._numberOfDisconnectedParticipants = 0 
     207        connected, disconnected = 0, 0 
    197208        for participant in self.getParticipantList(): 
    198209            if participant.getCallState() == "connected": 
    199                 self._numberOfConnectedParticipants = self._numberOfConnectedParticipants + 1 
     210                connected += 1 
    200211            else: 
    201                 self._numberOfDisconnectedParticipants = self._numberOfDisconnectedParticipants + 1 
     212                disconnected += 1 
     213 
     214        # we do these checks since we don't want to write in the DB 
     215        # unless we are sure the values changed 
     216        # (avoids DB writes in display pages) 
     217 
     218        if connected != self._numberOfConnectedParticipants: 
     219            self._numberOfConnectedParticipants = connected 
     220 
     221        if disconnected != self._numberOfDisconnectedParticipants: 
     222            self._numberOfDisconnectedParticipants = disconnected 
     223 
     224            if self._numberOfConnectedParticipants == 0: 
     225                if self._numberOfDisconnectedParticipants == 0: 
     226                    self._play_status = None 
     227                else: 
     228                    self._play_status = False 
     229            else: 
     230                self._play_status = True 
    202231 
    203232    ## overriding methods 
     
    306335                    return result 
    307336 
    308             self._statusMessage = "Booking created" 
    309             self._statusClass = "statusMessageOK" 
    310337            self._bookingParams["id"] = numericId 
    311338            self._oldName = self._bookingParams["name"] 
    312339            self._created = True 
    313             self.checkCanStart() 
     340 
     341            self.updateNumberOfConnectedParticipants() 
    314342 
    315343        except Fault, e: 
     
    421449 
    422450                self._created = True 
    423                 self.checkCanStart() 
     451                self.updateNumberOfConnectedParticipants() 
    424452 
    425453            except Fault, e: 
     
    433461            self._create() 
    434462 
    435  
    436463    def _start(self): 
    437464        self._checkStatus() 
    438         if self._canBeStarted: 
     465        if self.canBeStarted(): 
    439466            for p in self.getParticipantList(returnSorted = True): 
    440467                self._connectParticipant(p) 
    441468 
    442             self._statusMessage = "Conference started!" 
    443             self.checkCanStart(changeMessage = False) 
     469            # True = started 
     470        self.updateNumberOfConnectedParticipants() 
    444471 
    445472    def _connectParticipant(self, participant): 
     
    451478 
    452479        try: 
     480            self.updateNumberOfConnectedParticipants() 
    453481            mcu = MCU.getInstance() 
    454482            if (participant.getCallState() == "disconnected" or participant.getCallState() == "dormant") and participant.getParticipantType() != "ad_hoc": 
     
    462490 
    463491                participant.setCallState("connected") 
     492                self.updateNumberOfConnectedParticipants() 
    464493 
    465494        except Fault, e: 
     
    474503    def startSingleParticipant(self, participant): 
    475504        self._checkStatus() 
    476         if self._canBeStarted: 
     505        if self.canBeStarted(): 
    477506            result = self._connectParticipant(participant) 
    478             self.checkCanStart(changeMessage = False) 
    479507            return result 
     508        self.updateNumberOfConnectedParticipants() 
    480509 
    481510    def _stop(self): 
    482511        self._checkStatus() 
    483         if self._canBeStopped: 
     512        if self.canBeStopped(): 
    484513            for p in self.getParticipantList(returnSorted = True): 
    485514                self._disconnectParticipant(p) 
    486515 
    487             self.checkCanStart() 
    488             self._statusMessage = "Conference stopped" 
    489             self._statusClass = "statusMessageOther" 
     516            # False = stopped 
     517 
     518        self.updateNumberOfConnectedParticipants() 
    490519 
    491520    def _disconnectParticipant(self, participant): 
    492521        try: 
     522            self.updateNumberOfConnectedParticipants() 
    493523            mcu = MCU.getInstance() 
    494524 
     
    510540                del self._participants[participant.getId()] 
    511541 
     542            self.updateNumberOfConnectedParticipants() 
     543 
    512544        except Fault, e: 
    513545            Logger.get('CERNMCU').warning("""Evt:%s, booking:%s, calling participant.disconnect. Got error: %s""" % (self._conf.getId(), self.getId(), str(e))) 
     
    521553    def stopSingleParticipant(self, participant): 
    522554        self._checkStatus() 
    523         if self._canBeStopped: 
     555        if self.canBeStopped(): 
    524556            result = self._disconnectParticipant(participant) 
    525             self.checkCanStart(changeMessage = False) 
    526557            return result 
    527558 
    528559    def _notifyOnView(self): 
    529         self.checkCanStart() 
     560        pass 
    530561 
    531562    def _checkStatus(self): 
    532563        if self._created: 
     564            self.updateNumberOfConnectedParticipants() 
    533565            self.queryConference() 
    534566            self._cleanupAdHocParticipants() 
    535             self.checkCanStart() 
    536567 
    537568    def _delete(self): 
     
    578609 
    579610 
    580             self.checkCanStart() 
    581611            if self._numberOfConnectedParticipants > 0: 
    582612                #we have to connect the new participant 
    583613                self._connectParticipant(participant) 
    584                 self.checkCanStart(changeMessage = False) 
    585  
    586614 
    587615            return True 
     
    661689            Logger.get('CERNMCU').warning("""Evt:%s, calling participant.remove. Got error: %s""" % (self._conf.getId(), str(e))) 
    662690            return self.handleFault('remove', e) 
    663  
    664     def checkCanStart(self, changeMessage = True): 
    665         if self._created: 
    666             now = nowutc() 
    667             self._canBeNotifiedOfEventDateChanges = CSBooking._canBeNotifiedOfEventDateChanges 
    668             self.updateNumberOfConnectedParticipants() 
    669             if self.getStartDate() < now and self.getEndDate() > now: 
    670                 self._canBeStarted = self._numberOfDisconnectedParticipants > 0 
    671                 self._canBeStopped = self._numberOfConnectedParticipants > 0 
    672                 if changeMessage: 
    673                     self._statusMessage = "Ready to start!" 
    674                     self._statusClass = "statusMessageOK" 
    675             else: 
    676                 self._canBeStarted = False 
    677                 self._canBeStopped = False 
    678                 if now > self.getEndDate() and changeMessage: 
    679                     self._statusMessage = "Already took place" 
    680                     self._statusClass = "statusMessageOther" 
    681                     self._needsToBeNotifiedOfDateChanges = False 
    682                     self._canBeNotifiedOfEventDateChanges = False 
    683691 
    684692    def _cleanupAdHocParticipants(self): 
  • indico/MaKaC/plugins/Collaboration/EVO/collaboration.py

    rd25c08 r7319f3  
    195195 
    196196            self.bookingOK() 
    197             self.checkCanStart() 
    198  
    199197 
    200198#            if self._bookingParams["sendMailToManagers"]: 
     
    237235 
    238236                self.bookingOK() 
    239                 self.checkCanStart() 
    240237 
    241238#                if self._bookingParams["sendMailToManagers"]: 
     
    271268        """ 
    272269        self._checkStatus() 
    273         if self._canBeStarted: 
     270        if self.canBeStarted(): 
    274271            self._permissionToStart = True 
     272 
     273    def _canBeNotifiedOfEventDateChanges(self): 
     274        return not self.hasHappened() 
     275 
     276    def needsToBeNotifiedOfDateChanges(self): 
     277        """ Returns if this booking in particular needs to be notified 
     278            of their owner Event changing start date, end date or timezone. 
     279        """ 
     280        if self.hasHappened(): 
     281            return False 
     282        else: 
     283            return self._needsToBeNotifiedOfDateChanges 
    275284 
    276285    def _notifyOnView(self): 
     
    284293        remainingTime = self.getAdjustedStartDate('UTC') - nowutc() 
    285294 
    286         checkDone = False 
    287  
    288295        for index, check in enumerate(checksToDo): 
    289296            if remainingTime < check and not check in self._checksDone: 
    290297                self._checkStatus() 
    291298                self._checksDone.extend(checksToDo[index:]) 
    292                 checkDone = True 
    293299                break 
    294  
    295         if not checkDone: 
    296             self.checkCanStart() 
    297300 
    298301    def _checkStatus(self): 
     
    305308 
    306309                self.assignAttributes(returnedAttributes) 
    307                 self.checkCanStart() 
    308310 
    309311            except EVOControlledException, e: 
     
    406408        self._bookingParams["communityId"] = attributes["com"] 
    407409 
    408         self.checkCanStart() 
    409  
    410410        if changesFromEVO: 
    411411            return ChangesFromEVOError(changesFromEVO) 
    412412 
    413413    def bookingOK(self): 
    414         self._statusMessage = "Booking created" 
    415         self._statusClass = "statusMessageOK" 
    416414        self._created = True 
    417  
    418     def checkCanStart(self, changeMessage = True): 
    419         if self._created: 
    420             now = nowutc() 
    421             self._canBeDeleted = True 
    422             self._canBeNotifiedOfEventDateChanges = CSBooking._canBeNotifiedOfEventDateChanges 
    423             if self.getStartDate() < now and self.getEndDate() > now: 
    424                 self._canBeStarted = True 
    425                 self._canBeDeleted = False 
    426                 if changeMessage: 
    427                     self._statusMessage = "Ready to start!" 
    428                     self._statusClass = "statusMessageOK" 
    429             else: 
    430                 self._canBeStarted = False 
    431                 if now > self.getEndDate() and changeMessage: 
    432                     self._canBeDeleted = False 
    433                     self._statusMessage = "Already took place" 
    434                     self._statusClass = "statusMessageOther" 
    435                     self._needsToBeNotifiedOfDateChanges = False 
    436                     self._canBeNotifiedOfEventDateChanges = False 
    437                 elif changeMessage: 
    438                     self.bookingOK() 
    439415 
    440416    def _sendMail(self, operation): 
  • indico/MaKaC/plugins/Collaboration/EVO/pages.py

    rc87441 r7319f3  
    201201    @classmethod 
    202202    def getLaunchInfo(cls, booking, displayTz=None): 
    203         booking.checkCanStart() 
    204203        if (booking.canBeStarted()): 
    205204            return { 
  • indico/MaKaC/plugins/Collaboration/EVO/tpls/Main.js

    rc0de5a r7319f3  
    139139            return '<span class="collaborationWarning">' + booking.errorMessage + '<\/span>' 
    140140        } else { 
    141             return booking.bookingParams.startDate.substring(11) + " to " + booking.bookingParams.endDate.substring(11) + " for " + booking.bookingParams.communityName; 
     141            return booking.bookingParams.startDate.split(' ')[1] + " to " + booking.bookingParams.endDate.split(' ')[1] + " for " + booking.bookingParams.communityName; 
    142142        } 
    143143    }, 
  • indico/MaKaC/plugins/Collaboration/RecordingRequest/collaboration.py

    r800c21 r7319f3  
    5555    def __init__(self, type, conf): 
    5656        CSBookingBase.__init__(self, type, conf) 
     57 
     58    def getStatusMessage(self): 
     59        return self._statusMessage 
     60 
     61    def hasHappened(self): 
     62        return False 
     63 
     64    def isHappeningNow(self): 
     65        return False 
    5766 
    5867    def _checkBookingParams(self): 
  • indico/MaKaC/plugins/Collaboration/RecordingRequest/mail.py

    r800c21 r7319f3  
    9898    </tr> 
    9999    <tr> 
    100         <td style="vertical-align: top; white-space : nowrap;"> 
    101             <strong>Recording purpose(s):</strong> 
    102         </td> 
    103         <td style="vertical-align: top"> 
    104             %s 
    105         </td> 
    106     </tr> 
    107     <tr> 
    108         <td style="vertical-align: top; white-space : nowrap;"> 
    109             <strong>Intended audience(s):</strong> 
    110         </td> 
    111         <td style="vertical-align: top; white-space : nowrap;"> 
    112             %s 
    113         </td> 
    114     </tr> 
    115     <tr> 
    116         <td style="vertical-align: top; white-space : nowrap;"> 
    117             <strong>Subject matter(s):</strong> 
    118         </td> 
    119         <td style="vertical-align: top"> 
    120             %s 
    121         </td> 
    122     </tr> 
    123     <tr> 
    124100        <td colspan="2"> 
    125101            <strong>Additional comments:</strong><br /> 
     
    143119       str(bp['numRemoteViewers']), 
    144120       str(bp['numAttendees']), 
    145        self._getPurposes(), 
    146        self._getAudiences(), 
    147        self._getMatters(), 
    148121       self._getComments(), 
    149122       self._getTalks()) 
  • indico/MaKaC/plugins/Collaboration/Vidyo/collaboration.py

    r67688b r7319f3  
    8080    ## setters and getters for complex params and internal params ## 
    8181 
     82    def canBeStarted(self): 
     83        return self._created 
     84 
     85    def canBeStopped(self): 
     86        return False 
     87 
     88    def canBeDeleted(self): 
     89        return True 
     90 
    8291    def getPin(self): 
    8392        """ This method returns the PIN that will be displayed in the indico page 
     
    251260            or if there are no more checks to do. 
    252261        """ 
    253         if self._created: 
    254             checksToDo = [timedelta(hours = int(hours)) for hours in getVidyoOptionValue("checkTimes")] 
    255             checksToDo.sort() 
    256  
    257             minimumCheckDate = self.getConference().getAdjustedEndDate() + timedelta(days = int(getVidyoOptionValue("maxDaysBeforeClean"))) 
    258             for index, check in enumerate(checksToDo): 
    259                 if nowutc() > minimumCheckDate + check and not check in self.getChecksDone(): 
    260                     try: 
    261                         self._checkStatus() #will call self.setBookingNotPresent() if room has been removed 
    262                         self.getChecksDone().extend(checksToDo[index:]) 
    263                         self._p_changed = 1 
    264                     except Exception: 
    265                         Logger.get("Vidyo").exception("Calling _checkStatus() during _notifyOnView() for booking %s of conf %s" % (str(self.getId()), str(self.getConference().getId()))) 
    266                     break 
    267  
     262        pass 
    268263 
    269264 
     
    341336                'launchTooltip': _("Click here to join the Vidyo room!")} 
    342337 
     338    def getStatusMessage(self): 
     339        """ Returns the status message as a string. 
     340            This attribute will be available in Javascript with the "statusMessage" 
     341        """ 
     342        status = self.getPlayStatus() 
     343        if not self._created: 
     344            return _("Room no longer exists") 
     345        elif status == None: 
     346                return _("Public room created") 
     347        elif status: 
     348            return _("Conference started") 
     349        elif not status: 
     350            return _("Conference stopped") 
    343351 
    344352    ## end of overriding methods 
     
    348356        """ 
    349357        self._created = True 
    350         self._statusMessage = "Public room created" 
    351         self._statusClass = "statusMessageOK" 
    352         self._canBeStarted = True 
    353  
    354358 
    355359    def setBookingNotPresent(self): 
     
    358362        """ 
    359363        self._created = False 
    360         self._statusMessage = "Room no longer exists" 
    361         self._statusClass = "statusMessageOther" 
    362         self._canBeStarted = False 
    363364        #booking is not present remotely so no need to delete it later 
    364365        VidyoTools.getEventEndDateIndex().unindexBooking(self) 
    365  
    366366 
    367367    def _sendNotificationToOldNewOwner(self, oldOwner): 
     
    487487        cs.setStartDate(self.getStartDate()) 
    488488        cs.setEndDate(self.getEndDate()) 
    489         cs.setStatusMessage(self.getStatusMessage()) 
    490         cs.setStatusClass(self.getStatusClass()) 
    491489        cs.setCanBeDeleted(self.canBeDeleted()) 
    492490        cs.setHidden(self.isHidden()) 
  • indico/MaKaC/plugins/Collaboration/WebcastRequest/collaboration.py

    r800c21 r7319f3  
    5454 
    5555    def _checkBookingParams(self): 
     56        return False 
     57 
     58    def getStatusMessage(self): 
     59        return self._statusMessage 
     60 
     61    def hasHappened(self): 
     62        return False 
     63 
     64    def isHappeningNow(self): 
    5665        return False 
    5766 
  • indico/MaKaC/plugins/Collaboration/base.py

    rdc366d r7319f3  
    119119            or if it is a list of strings, those who have a type included in filterByType. 
    120120        """ 
     121 
    121122        if not hasattr(self, "_bookingsByType"): #TODO: remove when safe 
    122123            self._bookingsByType = {} 
     
    956957                              They will be used on the client for the local start action. 
    957958                              Needs to be defined by the implementing class, as keys with empty values. 
    958             -_statusMessage, _statusClass : they represent the status message (and its CSS class) that will be displayed. 
    959                  The status of a booking can be, for example: "Booking Accepted" (in green), "Booking refused" (in red) 
    960959            -_warning: A warning is a plugin-defined object, with information to show to the user when 
    961960                       the operation went well but we still have to show some info to the user. 
    962             -_canBeStarted: If its value is true, the "start" button for the booking will be able to be pushed. 
    963                             It can be false if, for example: 
    964                               + The plugin didn't like the booking parameters and doesn't give permission for the booking to be started, 
    965                               + The booking has already been started, so the "start" button has to be faded in order not to be pressed twice. 
    966             -_canBeStopped: If its value is true, the "stop" button for the booking will be able to be pushed. 
    967                             For example, before starting a booking the "stop" button for the booking will be faded. 
    968961            -_permissionToStart : Even if the "start" button for a booking is able to be pushed, there may be cases where the booking should 
    969962                            not start. For example, if it's not the correct time yet. 
     
    984977        self._startDateTimestamp = None 
    985978        self._endDateTimestamp = None 
    986         self._statusMessage = "" 
    987         self._statusClass = "" 
    988979        self._acceptRejectStatus = None #None = not yet accepted / rejected; True = accepted; False = rejected 
    989980        self._rejectReason = "" 
    990981        self._bookingParams = {} 
    991982        self._canBeDeleted = True 
    992         self._canBeStarted = self._hasStart 
    993         self._canBeStopped = False 
    994983        self._permissionToStart = False 
    995984        self._permissionToStop = False 
    996985        self._needsToBeNotifiedOfDateChanges = self._canBeNotifiedOfEventDateChanges 
    997986        self._hidden = False 
     987        self._play_status = None 
    998988 
    999989        setattr(self, "_" + bookingType + "Options", CollaborationTools.getPlugin(bookingType).getOptions()) 
     
    11511141            return "" 
    11521142        else: 
    1153             return formatDateTime(self.getAdjustedStartDate()) 
     1143            return formatDateTime(self.getAdjustedStartDate(), locale='en_US') 
    11541144 
    11551145    def setStartDate(self, startDate): 
     
    11781168        return self._endDate 
    11791169 
     1170    def isHappeningNow(self): 
     1171        now = nowutc() 
     1172        return self.getStartDate() < now and self.getEndDate() > now 
     1173 
     1174    def hasHappened(self): 
     1175        now = nowutc() 
     1176        return now > self.getEndDate() 
     1177 
    11801178    def getAdjustedEndDate(self, tz=None): 
    11811179        """ Returns the booking end date, adjusted to a given timezone. 
     
    11911189    def setEndDateTimestamp(self, endDateTimestamp): 
    11921190        self._endDateTimestamp = endDateTimestamp 
     1191 
    11931192    def getEndDateAsString(self): 
    11941193        """ Returns the start date as a string, expressed in the meeting's timezone 
     
    11971196            return "" 
    11981197        else: 
    1199             return formatDateTime(self.getAdjustedEndDate()) 
     1198            return formatDateTime(self.getAdjustedEndDate(), locale='en_US') 
    12001199 
    12011200    def setEndDate(self, endDate): 
     
    12231222            This attribute will be available in Javascript with the "statusMessage" 
    12241223        """ 
    1225         return _(self._statusMessage) 
    1226  
    1227     def setStatusMessage(self, statusMessage): 
    1228         """ Sets the status message as a string. 
    1229             This attribute will be available in Javascript with the "statusMessage" 
    1230         """ 
    1231         self._statusMessage = statusMessage 
     1224        status = self.getPlayStatus() 
     1225        if status == None: 
     1226            if self.isHappeningNow(): 
     1227                return _("Ready to start!") 
     1228            elif self.hasHappened(): 
     1229                return _("Already took place") 
     1230            else: 
     1231                return _("Booking created") 
     1232        elif status: 
     1233            return _("Conference started") 
     1234        elif not status: 
     1235            return _("Conference stopped") 
    12321236 
    12331237    def getStatusClass(self): 
     
    12351239            This attribute will be available in Javascript with the "statusClass" 
    12361240        """ 
    1237         if not hasattr(self, "_statusClass"): #TODO: remove when safe 
    1238             self._statusClass = "" 
    1239         return self._statusClass 
    1240  
    1241     def setStatusClass(self, statusClass): 
    1242         """ Sets the status message CSS class as a string. 
    1243             This attribute will be available in Javascript with the "statusClass" 
    1244         """ 
    1245         self._statusClass = statusClass 
     1241        if self.getPlayStatus() == None or self.hasHappened(): 
     1242            return "statusMessageOther" 
     1243        else: 
     1244            return "statusMessageOK" 
    12461245 
    12471246    def accept(self, user = None): 
     
    15401539        """ 
    15411540 
    1542         if not hasattr(self, '_canBeDeleted'): 
    1543             self._canBeDeleted = True 
    1544         return self._canBeDeleted 
     1541        if self.isHappeningNow() or self.hasHappened(): 
     1542            return False 
     1543        else: 
     1544            return True 
    15451545 
    15461546    def setCanBeDeleted(self, canBeDeleted): 
     
    15541554            This attribute will be available in Javascript with the "canBeStarted" attribute 
    15551555        """ 
    1556         return self._canBeStarted 
     1556        return self.isHappeningNow() 
    15571557 
    15581558    def canBeStopped(self): 
     
    15601560            This attribute will be available in Javascript with the "canBeStopped" attribute 
    15611561        """ 
    1562         return self._canBeStopped 
     1562        return self.isHappeningNow() 
    15631563 
    15641564    def isPermittedToStart(self): 
     
    15891589            of their owner Event changing start date, end date or timezone. 
    15901590        """ 
    1591         return self._canBeNotifiedOfEventDateChanges 
     1591        return False 
    15921592 
    15931593    def needsToBeNotifiedOfDateChanges(self): 
     
    17981798                raise 
    17991799 
     1800    def getPlayStatus(self): 
     1801        if not hasattr(self, '_play_status'): 
     1802            self._play_status = None 
     1803        return self._play_status 
     1804 
    18001805class WCSTemplateBase(wcomponents.WTemplated): 
    18011806    """ Base class for Collaboration templates. 
  • indico/MaKaC/webinterface/tpls/events/include/MeetingBody.tpl

    rc87441 r7319f3  
    1313    <div style="position: absolute; right: 50px; top: 3px;"><span class="fakeLink dropDownMenu" id="goToDayLink"><strong>Go to day</strong></span></div> 
    1414    <script type="text/javascript"> 
    15         var goToDayMenuItems = {}; 
     15        var goToDayMenuItems = $D(${dict((prettyDate(item.getAdjustedStartDate(timezone)), 
     16                                       '#%s' % getDate(item.getAdjustedStartDate(timezone))) for item in entries)| n,j}); 
    1617 
    17         <% addedDates = set() %> 
    18         % for item in entries: 
    19             % if item.getAdjustedStartDate(timezone): 
    20                 <% date = getDate(item.getAdjustedStartDate(timezone)) %> 
    21                 % if date not in addedDates: 
    22                     goToDayMenuItems['${prettyDate(item.getAdjustedStartDate(timezone))}'] = '#${date}'; 
    23                     <% addedDates.add(date) %> 
    24                 % endif 
    25             % endif 
    26         % endfor 
     18 
     19        goToDayMenuItems.sort(function(val1, val2){ 
     20           return SortCriteria.Default(goToDayMenuItems.get(val1), goToDayMenuItems.get(val2)); 
     21        }); 
    2722 
    2823        var goToDayLink = $E('goToDayLink'); 
     
    4742 
    4843    <ul class="dayList"> 
     44        <% previousDate = None %> 
    4945        % for index, item in enumerate(entries): 
    5046            <% 
    5147                date = getDate(item.getAdjustedStartDate(timezone)) 
    52                 previousItem = entries[index - 1] if index - 1 >= 0 else None 
    53                 nextItem = entries[index + 1] if index + 1 < len(entries) else None 
    5448            %> 
    55             % if not previousItem or date != getDate(previousItem.getAdjustedStartDate(timezone)): 
     49 
     50            % if previousDate and previousDate != date: 
     51                </ul> 
     52                </li> 
     53            % endif 
     54 
     55            % if not previousDate or date != previousDate: 
    5656                <li> 
    5757                <div style="width: 100%;"> 
     
    6464            <%include file="${getItemType(item)}.tpl" args="item=item, parent=conf, minutes=minutes"/> 
    6565 
    66             % if not nextItem or date != getDate(nextItem.getAdjustedStartDate(timezone)): 
    67                 </ul> 
    68                 </li> 
    69             % endif 
     66            <% previousDate = date %> 
    7067        % endfor 
     68        % if entries: 
     69            </ul> 
     70            </li> 
     71        % endif 
    7172    </ul> 
    7273</div> 
  • indico/htdocs/js/indico/Core/Presentation.js

    raaf49c r7319f3  
    257257 
    258258         this.each = function(iterator) { 
    259  
    260              // follow the order 
    261  
    262              var self = this; 
    263              each(this.order, 
    264                   function (key) { 
    265                       iterator(self.get(key), key); 
    266                   }); 
    267          }; 
     259             self.order.each(function(val, i){ 
     260                 return iterator(self.get(val), val); 
     261             }); 
     262             return iterator.result; 
     263         } 
    268264 
    269265         this.set = function(key, value) { 
Note: See TracChangeset for help on using the changeset viewer.