source: indico/indico/MaKaC/webinterface/pages/sessions.py @ 07a40b

burotelhello-world-walkthroughipv6new-webexprov-dual-interfacev0.97-seriesv0.98-seriesv0.98.2v0.98.3v0.98b1v0.98b2v0.99v1.0v1.1
Last change on this file since 07a40b was 07a40b, checked in by Jose Benito <jose.benito.gonzalez@…>, 4 years ago

[REFACTOR] Timetable code refactoring

  • Property mode set to 100644
File size: 140.9 KB
Line 
1# -*- coding: utf-8 -*-
2##
3## $Id: sessions.py,v 1.121 2009/06/23 09:48:49 pferreir Exp $
4##
5## This file is part of CDS Indico.
6## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN.
7##
8## CDS Indico is free software; you can redistribute it and/or
9## modify it under the terms of the GNU General Public License as
10## published by the Free Software Foundation; either version 2 of the
11## License, or (at your option) any later version.
12##
13## CDS Indico is distributed in the hope that it will be useful, but
14## WITHOUT ANY WARRANTY; without even the implied warranty of
15## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16## General Public License for more details.
17##
18## You should have received a copy of the GNU General Public License
19## along with CDS Indico; if not, write to the Free Software Foundation, Inc.,
20## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
21
22from xml.sax.saxutils import quoteattr, escape
23from datetime import datetime,timedelta
24
25import MaKaC.webinterface.wcomponents as wcomponents
26import MaKaC.webinterface.urlHandlers as urlHandlers
27import MaKaC.webinterface.materialFactories as materialFactories
28import MaKaC.webinterface.navigation as navigation
29import MaKaC.schedule as schedule
30import MaKaC.conference as conference
31import MaKaC.webinterface.linking as linking
32from MaKaC.webinterface.pages.conferences import WScheduleContribution, WConfModifScheduleGraphicOverview, WPConferenceBase, WPConfModifScheduleGraphic, WPConferenceDefaultDisplayBase, WContribParticipantList, WContributionCreation, WContributionSchCreation, WPModScheduleNewContribBase, WPConferenceModifBase
33from MaKaC.common import Config, info
34from MaKaC.errors import MaKaCError
35import MaKaC.webinterface.timetable as timetable
36from MaKaC.webinterface.common.contribStatusWrapper import ContribStatusList
37import MaKaC.common.filters as filters
38import MaKaC.webinterface.common.contribFilters as contribFilters
39from MaKaC.webinterface.common.person_titles import TitlesRegistry
40from MaKaC.webinterface.pages import main
41from MaKaC.common.utils import isStringHTML
42from MaKaC import user
43from MaKaC.i18n import _
44
45from pytz import timezone
46import pytz
47import copy
48import MaKaC.webinterface.common.timezones as convertTime
49import MaKaC.common.timezoneUtils as timezoneUtils
50
51
52class WPSessionBase( WPConferenceBase ):
53   
54    def __init__( self, rh, session):
55        self._session = session
56        WPConferenceBase.__init__( self, rh, self._session.getConference() )
57
58
59class WPSessionDisplayBase( WPSessionBase ):
60    pass
61
62class WPSessionDefaultDisplayBase( WPConferenceDefaultDisplayBase, WPSessionDisplayBase ):
63   
64    def __init__( self, rh, session ):
65        WPSessionDisplayBase.__init__( self, rh, session )
66
67class WContributionDisplayItemBase(wcomponents.WTemplated):
68   
69    def __init__(self,aw,contrib):
70        self._contrib=contrib
71        self._aw=aw
72
73    def getVars( self ):
74        vars=wcomponents.WTemplated.getVars( self )
75        vars["id"]=self.htmlText(self._contrib.getId())
76        vars["title"]=self.htmlText(self._contrib.getTitle())
77        cType=""
78        if self._contrib.getType() is not None:
79            cType=self.htmlText(self._contrib.getType().getName())
80        vars["type"]=self.htmlText(cType)
81        vars["startDate"]="&nbsp;"
82        if self._contrib.isScheduled():
83            vars["startDate"]=self._contrib.getAdjustedStartDate().strftime("%Y-%b-%d %H:%M")
84        vars["duration"] = "&nbsp;"
85        if self._contrib.getDuration() is not None:
86            if (datetime(1900,1,1)+self._contrib.getDuration()).minute>0:
87                vars["duration"]="%s"%(datetime(1900,1,1)+self._contrib.getDuration()).strftime("%M'")
88            if (datetime(1900,1,1)+self._contrib.getDuration()).hour>0:
89                vars["duration"]="%s"%(datetime(1900,1,1)+self._contrib.getDuration()).strftime("%Hh%M'")
90        lspk = []
91        for speaker in self._contrib.getSpeakerList():
92            lspk.append(self.htmlText(speaker.getFullName()))
93        vars["speakers"] = "<br>".join( lspk )
94        if vars["speakers"]=="":
95            vars["speakers"]="&nbsp;"
96        vars["displayURL"]=quoteattr(str(urlHandlers.UHContributionDisplay.getURL(self._contrib)))
97        vars["boardNumber"]=self.htmlText(self._contrib.getBoardNumber())
98        return vars
99
100
101class WContributionDisplayItemFull(WContributionDisplayItemBase):
102    pass
103
104
105class WContributionDisplayItemMin(WContributionDisplayItemBase):
106    pass
107
108
109class WContributionDisplayItem:
110   
111    def __init__( self, aw, contrib ):
112        self._contribution = contrib
113        self._aw = aw
114
115    def getHTML( self, params={} ):
116        if self._contribution.canAccess( self._aw ):
117            c = WContributionDisplayItemFull( self._aw, self._contribution )
118            return c.getHTML( params )
119        if self._contribution.canView( self._aw ):
120            c = WContributionDisplayItemMin( self._aw, self._contribution )
121            return c.getHTML( params )
122        return ""
123
124
125class WContributionDisplayPosterItemFull(WContributionDisplayItemBase):
126    pass
127
128
129class WContributionDisplayPosterItemMin(WContributionDisplayItemBase):
130    pass
131
132
133class WContributionDisplayPosterItem:
134   
135    def __init__( self, aw, contrib ):
136        self._contribution = contrib
137        self._aw = aw
138
139    def getHTML( self, params={} ):
140        if self._contribution.canAccess( self._aw ):
141            c = WContributionDisplayPosterItemFull( self._aw, self._contribution )
142            return c.getHTML( params )
143        if self._contribution.canView( self._aw ):
144            c = WContributionDisplayPosterItemMin( self._aw, self._contribution )
145            return c.getHTML( params )
146        return ""
147
148
149class WSessionTabControl(wcomponents.WTabControl):
150    _unSelTabCls="display_unselectedhtab"
151    _selTabCls="display_selectedhtab"
152    _noTabCls="display_neutralhtab"
153
154
155class _NoWitdhdrawFF(filters.FilterField):
156    _id="no_withdrawn"
157
158    def __init__(self):
159        pass
160
161    def satisfies(self,contrib):
162        return not isinstance(contrib.getCurrentStatus(),conference.ContribStatusWithdrawn)
163
164
165class _NoWithdrawnFilterCriteria(filters.FilterCriteria):
166   
167    def __init__(self,conf):
168        self._fields={"no_withdrawn":_NoWitdhdrawFF()}
169
170
171class WSessionDisplayBase(wcomponents.WTemplated):
172   
173    def __init__(self,aw,session,activeTab="time_table",sortingCrit=None):
174        self._aw=aw
175        self._session=session
176        self._activeTab=activeTab
177        self._sortingCrit=sortingCrit
178        self._tz = timezoneUtils.DisplayTZ(self._aw,self._session.getConference()).getDisplayTZ()
179   
180    def _getHTMLRow(self,title,body):
181        str = """
182                <tr>
183                    <td nowrap class="displayField" valign="top"><b>%s:</b></td>
184                    <td>%s</td>
185                </tr>"""%(title,body)
186        if body.strip() == "":
187            return ""
188        return str
189
190    def _createTabCtrl( self ):
191        self._tabCtrl=wcomponents.TabControl()
192        url=urlHandlers.UHSessionDisplay.getURL(self._session)
193        url.addParam("tab","contribs")
194        self._tabContribs=self._tabCtrl.newTab("contribs", \
195                                                _("Contribution List"),str(url))
196        url.addParam("tab","time_table")
197        self._tabTimeTable=self._tabCtrl.newTab("time_table", \
198                                                _("Time Table"),str(url))
199        if self._session.getScheduleType()=="poster":
200            self._tabTimeTable.setEnabled(False)
201            self._tabCtrl.getTabById("contribs").setActive()
202        else:
203            self._tabTimeTable.setEnabled(True)
204            tab=self._tabCtrl.getTabById(self._activeTab)
205            if tab is None:
206                tab=self._tabCtrl.getTabById("time_table")
207            tab.setActive()
208           
209    def _getURL(self,sortByField):
210        url=urlHandlers.UHSessionDisplay.getURL(self._session)
211        url.addParam("tab",self._activeTab)
212        url.addParam("sortBy",sortByField)
213        return url
214       
215    def _getContribListHTML(self):
216        cl = []
217        if self._sortingCrit is None:
218            self._sortingCrit=contribFilters.SortingCriteria(["number"])
219        fc=_NoWithdrawnFilterCriteria(self._session.getConference())
220        f=filters.SimpleFilter(fc,self._sortingCrit)
221        for contrib in f.apply(self._session.getContributionList()):
222            wc=WContributionDisplayItem(self._aw,contrib)
223            html=wc.getHTML()
224            cl.append("""<tr><td valign="top">%s</td></tr>"""%html)
225        idHTML="""id <img src=%s border="0" alt="down">"""%quoteattr(str(Config.getInstance().getSystemIconURL("downArrow")))
226        if self._sortingCrit.getField().getId()!="number":
227            idHTML="""<a href=%s>id</a>"""%quoteattr(str(self._getURL("number")))
228        dateHTML="""date <img src=%s border="0" alt="down">"""%quoteattr(str(Config.getInstance().getSystemIconURL("downArrow")))
229        if self._sortingCrit.getField().getId()!="date":
230            dateHTML="""<a href=%s>date</a>"""%quoteattr(str(self._getURL("date")))
231        typeHTML="""type <img src=%s border="0" alt="down">"""%quoteattr(str(Config.getInstance().getSystemIconURL("downArrow")))
232        if self._sortingCrit.getField().getId()!="type":
233            typeHTML="""<a href=%s>type</a>"""%quoteattr(str(self._getURL("type")))
234        spkHTML="""presenters <img src=%s border="0" alt="down">"""%quoteattr(str(Config.getInstance().getSystemIconURL("downArrow")))
235        if self._sortingCrit.getField().getId()!="speaker":
236            spkHTML="""<a href=%s>presenters</a>"""%quoteattr(str(self._getURL("speaker")))
237        return """
238            <table cellspacing="0" cellpadding="5" width="100%%">
239                <tr>
240                    <td nowrap class="titleCellFormat" style="border-bottom: 1px solid #5294CC; padding-right:10px;border-right:5px solid #FFFFFF">%s</td>
241                    <td nowrap class="titleCellFormat" style="border-bottom: 1px solid #5294CC; padding-right:10px;border-right:5px solid #FFFFFF">%s</td>
242                    <td class="titleCellFormat" style="border-bottom: 1px solid #5294CC; padding-right:10px;border-right:5px solid #FFFFFF">dur.</td>
243                    <td nowrap class="titleCellFormat" style="border-bottom: 1px solid #5294CC; padding-right:10px;border-right:5px solid #FFFFFF">%s</td>
244                    <td nowrap class="titleCellFormat" style="border-bottom: 1px solid #5294CC; padding-right:10px;border-right:5px solid #FFFFFF">title</td>
245                    <td nowrap class="titleCellFormat" style="border-bottom: 1px solid #5294CC; padding-right:10px;border-right:5px solid #FFFFFF">%s</td>
246                </tr>
247                %s
248            </table>"""%(idHTML,dateHTML,typeHTML,spkHTML,"".join(cl))
249
250    def _getPosterContribListHTML(self):
251        cl = []
252        if self._sortingCrit is None:
253            self._sortingCrit=contribFilters.SortingCriteria(["number"])
254        fc=_NoWithdrawnFilterCriteria(self._session.getConference())
255        f=filters.SimpleFilter(fc,self._sortingCrit)
256        for contrib in f.apply(self._session.getContributionList()):
257            wc=WContributionDisplayPosterItem(self._aw,contrib)
258            html=wc.getHTML()
259            cl.append("""<tr><td valign="top">%s</td></tr>"""%html)
260        idHTML="""id <img src=%s border="0" alt="down">"""%quoteattr(str(Config.getInstance().getSystemIconURL("downArrow")))
261        if self._sortingCrit.getField().getId()!="number":
262            idHTML="""<a href=%s>id</a>"""%quoteattr(str(self._getURL("number")))
263        #dateHTML="""date <img src=%s border="0" alt="down">"""%quoteattr(str(Config.getInstance().getSystemIconURL("downArrow")))
264        #if self._sortingCrit.getField().getId()!="date":
265        #    dateHTML="""<a href=%s>date</a>"""%quoteattr(str(self._getURL("date")))
266        typeHTML="""type <img src=%s border="0" alt="down">"""%quoteattr(str(Config.getInstance().getSystemIconURL("downArrow")))
267        if self._sortingCrit.getField().getId()!="type":
268            typeHTML="""<a href=%s>type</a>"""%quoteattr(str(self._getURL("type")))
269        spkHTML="""presenters <img src=%s border="0" alt="down">"""%quoteattr(str(Config.getInstance().getSystemIconURL("downArrow")))
270        if self._sortingCrit.getField().getId()!="speaker":
271            spkHTML="""<a href=%s>presenters</a>"""%quoteattr(str(self._getURL("speaker")))
272        boardNumHTML="""board # <img src=%s border="0" alt="down">"""%quoteattr(str(Config.getInstance().getSystemIconURL("downArrow")))
273        if self._sortingCrit.getField().getId()!="board_number":
274            boardNumHTML="""<a href=%s>board #</a>"""%quoteattr(str(self._getURL("board_number")))
275        return """
276            <table cellspacing="0" cellpadding="5" width="100%%">
277                <tr>
278                    <td nowrap class="titleCellFormat" style="border-bottom: 1px solid #5294CC; padding-right:10px;border-right:5px solid #FFFFFF">%s</td>
279                    <td nowrap class="titleCellFormat" style="border-bottom: 1px solid #5294CC; padding-right:10px;border-right:5px solid #FFFFFF">%s</td>
280                    <td nowrap class="titleCellFormat" style="border-bottom: 1px solid #5294CC; padding-right:10px;border-right:5px solid #FFFFFF">title</td>
281                    <td nowrap class="titleCellFormat" style="border-bottom: 1px solid #5294CC; padding-right:10px;border-right:5px solid #FFFFFF">%s</td>
282                    <td nowrap class="titleCellFormat" style="border-bottom: 1px solid #5294CC; padding-right:10px;border-right:5px solid #FFFFFF">%s</td>
283                </tr>
284                %s
285            </table>"""%(idHTML,typeHTML,spkHTML,boardNumHTML,"".join(cl))
286
287    def _getColor(self,entry):
288        bgcolor = "white"
289        if isinstance(entry,schedule.LinkedTimeSchEntry):
290            if isinstance(entry.getOwner(),conference.Contribution):
291                bgcolor = entry.getOwner().getSession().getColor()
292        elif isinstance(entry,schedule.BreakTimeSchEntry):
293            bgcolor = entry.getColor()
294        return bgcolor
295
296    def _getMaterialHTML(self, contrib):
297        lm=[]
298        paper=contrib.getPaper()
299        if paper is not None:
300            lm.append("""<a href=%s><img src=%s border="0" alt="paper"><small> %s</small></a>"""%(
301                quoteattr(str(urlHandlers.UHMaterialDisplay.getURL(paper))),
302                quoteattr(str(Config.getInstance().getSystemIconURL( "smallPaper" ))),
303                self.htmlText("paper")))
304        slides=contrib.getSlides()
305        if slides is not None:
306            lm.append("""<a href=%s><img src=%s border="0" alt="slides"><small> %s</small></a>"""%(
307                quoteattr(str(urlHandlers.UHMaterialDisplay.getURL(slides))),
308                quoteattr(str(Config.getInstance().getSystemIconURL( "smallSlides" ))),
309                self.htmlText("slides")))
310        proceedings=None
311        for mat in contrib.getMaterialList():
312            if mat.getTitle().lower() == "proceedings":
313                proceedings=mat
314                break
315        if proceedings is not None:
316            lm.append("""<a href=%s><small> %s</small></a>"""%(
317                quoteattr(str(urlHandlers.UHMaterialDisplay.getURL(proceedings))),
318                self.htmlText("proceedings")))
319        video=contrib.getVideo()
320        if video is None:
321            for mat in contrib.getMaterialList():
322               if mat.getTitle().lower().find("video") != -1:
323                   video = mat
324        if video is not None:
325            lm.append("""<a href=%s><img src=%s border="0" alt="video"><small> %s</small></a>"""%(
326                quoteattr(str(urlHandlers.UHMaterialDisplay.getURL(video))),
327                quoteattr(str(Config.getInstance().getSystemIconURL( "smallVideo" ))),
328                self.htmlText("video")))
329        return ", ".join(lm)
330   
331    def _getContributionHTML(self,contrib):
332        URL=urlHandlers.UHContributionDisplay.getURL(contrib)
333        room = ""
334        if contrib.getRoom() != None:
335            room = "%s: "%contrib.getRoom().getName()
336        speakerList = []
337        for spk in contrib.getSpeakerList():
338            spkcapt=spk.getDirectFullName()
339            if spk.getAffiliation().strip() != "":
340                spkcapt="%s (%s)"%(spkcapt, spk.getAffiliation())
341            speakerList.append(spkcapt)
342        speakers =""
343        if speakerList != []:
344            speakers = _("""<br><small> _("by") %s</small>"%"; """).join(speakerList)
345        linkColor=""
346        if contrib.getSession().isTextColorToLinks():
347            linkColor="color:%s"%contrib.getSession().getTextColor()
348        return """<table width="100%%">
349                        <tr>
350                            <td width="100%%" align="center" style="color:%s">
351                                [%s] <a href="%s" style="%s">%s</a>%s<br><small>(%s%s - %s)</small>
352                            </td>
353                            <td align="right" valign="top" nowrap style="color:%s">
354                                %s
355                            </td>
356                        </tr>
357                    </table>"""%(
358                contrib.getSession().getTextColor(),contrib.getId(),URL,\
359                linkColor, contrib.getTitle(),speakers,room,
360                contrib.getAdjustedStartDate(self._tz).strftime("%H:%M"),
361                contrib.getAdjustedEndDate(self._tz).strftime("%H:%M"),
362                contrib.getSession().getTextColor(),
363                self._getMaterialHTML(contrib))
364
365    def _getBreakHTML(self,breakEntry):
366        return """
367                <font color="%s">%s<br><small>(%s - %s)</small></font>
368                """%(\
369                    breakEntry.getTextColor(),\
370                    self.htmlText(breakEntry.getTitle()),\
371                    self.htmlText(breakEntry.getAdjustedStartDate(self._tz).strftime("%H:%M")),\
372                    self.htmlText(breakEntry.getAdjustedEndDate(self._tz).strftime("%H:%M")))
373
374    def _getSchEntries(self):
375        res=[]
376        for slot in self._session.getSlotList():
377            for entry in slot.getSchedule().getEntries():
378                res.append(entry)
379        return res
380
381    def _getEntryHTML(self,entry):
382        if isinstance(entry,schedule.LinkedTimeSchEntry):
383            if isinstance(entry.getOwner(),conference.Contribution):
384                return self._getContributionHTML(entry.getOwner())
385        elif isinstance(entry,schedule.BreakTimeSchEntry):
386            return self._getBreakHTML(entry)
387
388    def _getTimeTableHTML(self):
389
390        timeTable=timetable.TimeTable(self._session.getSchedule(),self._tz) 
391        sDate,eDate=self._session.getAdjustedStartDate(self._tz),self._session.getAdjustedEndDate(self._tz) 
392        timeTable.setStartDate(sDate)
393        timeTable.setEndDate(eDate)
394        tz = self._session.getTimezone()
395        timeTable.mapEntryList(self._getSchEntries())
396        daySch = []
397        num_slots_in_hour=int(timedelta(hours=1).seconds/timeTable.getSlotLength().seconds)
398        hourSlots,hourNeedsDisplay=[],False
399        for day in timeTable.getDayList():
400            hourSlots = []
401            slotList=[]
402            lastEntries=[]
403            maxOverlap=day.getNumMaxOverlaping()
404            width="100"
405            if maxOverlap!=0:
406                width=100/maxOverlap
407            else:
408                maxOverlap=1
409            for slot in day.getSlotList():
410                if slot.getAdjustedStartDate().minute==0:
411                    if hourNeedsDisplay:
412                        slotList.append("".join(hourSlots))
413                    hourSlots,hourNeedsDisplay=[],False
414                remColSpan=maxOverlap
415                temp=[]               
416                for entry in slot.getEntryList():
417                    hourNeedsDisplay=True
418                    if len(slot.getEntryList()):
419                        remColSpan=0
420                    else:
421                        remColSpan-=1
422                    if entry in lastEntries:
423                        continue
424                    bgcolor=self._getColor(entry)
425                    colspan=""
426                    if not day.hasEntryOverlaps(entry):
427                        colspan=""" colspan="%s" """%maxOverlap
428                    temp.append("""<td valign="top" rowspan="%i" align="center" bgcolor="%s" width="%i%%"%s>%s</td>"""%(day.getNumSlots(entry),bgcolor,width,colspan,self._getEntryHTML(entry)))
429                    lastEntries.append(entry)
430                if remColSpan>0:
431                    temp.append("""<td width="100%%" colspan="%i"></td>"""%(remColSpan))
432                if slot.getAdjustedStartDate().minute==0:
433                    slotHTML="""
434                        <tr>
435                            <td valign="top" rowspan="%s" bgcolor="white" width="40"><font color="gray" size="-1">%s</font></td>
436                            %s
437                        </tr>
438                        """%(num_slots_in_hour,\
439                                slot.getAdjustedStartDate().strftime("%H:%M"),\
440                                "".join(temp))
441                else:
442                    if len(temp) == 0:
443                        temp = ["<td></td>"]
444                    slotHTML = """<tr>%s</tr>"""%"".join(temp)
445                hourSlots.append(slotHTML)
446               
447                if slot == day.getSlotList()[-1]:
448                    if hourNeedsDisplay:
449                        slotList.append("".join(hourSlots))
450
451            dayHTML="""
452                <a name="%s">
453                <table align="center" width="100%%">
454                    <tr>
455                        <td width="100%%">
456                            <table align="center" border="0" width="100%%"
457                                    celspacing="0" cellpadding="0" bgcolor="#E6E6E6">
458                                <tr>
459                                    <td colspan="%i" align="center" bgcolor="white"><b>%s</b></td>
460                                </tr>
461                                %s
462                            </table>
463                        </td>
464                    </tr>
465                </table>
466                """%(day.getDate().strftime("%Y-%m-%d"),maxOverlap+2,
467                        day.getDate().strftime("%A, %d %B %Y"),
468                        "".join(slotList) )
469            daySch.append(dayHTML)
470        dayHTML = "<br>".join( daySch )
471        return dayHTML
472
473    def _getContribsHTML(self):
474        self._createTabCtrl()
475        if self._tabContribs.isActive():
476            if self._session.getScheduleType()=="poster":
477                html=self._getPosterContribListHTML()
478            else:
479                html=self._getContribListHTML()
480        else:
481            html=self._getTimeTableHTML()
482        return WSessionTabControl(self._tabCtrl, self._aw).getHTML(html)
483
484    def getVars(self):
485        vars=wcomponents.WTemplated.getVars( self )
486       
487        vars["title"]=self.htmlText(self._session.getTitle())
488       
489        if self._session.getDescription():
490            desc = self._session.getDescription().strip()
491        else:
492            desc = ""
493       
494        if desc!="":
495            vars["description"]="""
496                <tr>
497                    <td colspan="2"><table width="100%%" cellpadding="0" cellspacing="0" class="tablepre"><tr><td><pre>%s</pre></td></tr></table></td>
498                </tr>
499                                """%desc
500        else:
501            vars["description"]=""
502                               
503        tzUtil = timezoneUtils.DisplayTZ(self._aw,self._session.getOwner())
504        tz = tzUtil.getDisplayTZ()
505        sDate=self._session.getAdjustedStartDate(tz)
506        eDate=self._session.getAdjustedEndDate(tz)
507        if sDate.strftime("%d%b%Y")==eDate.strftime("%d%b%Y"):
508            vars["dateInterval"]=sDate.strftime("%A %d %B %Y %H:%M")
509        else:
510            vars["dateInterval"]= _(""" _("from") %s  _("to") %s""")%(
511                sDate.strftime("%A %d %B %Y %H:%M"),
512                eDate.strftime("%A %d %B %Y %H:%M"))
513        vars["location"]=""
514        loc=self._session.getLocation()
515        if loc is not None and loc.getName().strip()!="":
516            vars["location"]="""<i>%s</i>"""%self.htmlText(loc.getName())
517            if loc.getAddress().strip()!="":
518                vars["location"]="""%s<pre>%s</pre>"""%(vars["location"],
519                                                        loc.getAddress())
520        room = self._session.getRoom()
521        if room is not None:
522            roomLink=linking.RoomLinker().getHTMLLink(room,loc)
523            vars["location"]= _("""%s<br><small> _("Room"):</small> %s""")%(vars["location"],
524                                                            roomLink)
525        vars["location"]=self._getHTMLRow( _("Place"), vars["location"])
526        sessionConvs=[]
527        for convener in self._session.getConvenerList():
528            sessionConvs.append("""<a href="mailto:%s">%s</a>"""%(convener.getEmail(),
529                                        self.htmlText(convener.getFullName())))
530        slotConvsHTML=""
531        for entry in self._session.getSchedule().getEntries():
532            slot=entry.getOwner()
533            l=[]
534            for convener in slot.getOwnConvenerList():
535                l.append("""<a href="mailto:%s">%s</a>"""%(convener.getEmail(),
536                                        self.htmlText(convener.getFullName())))
537            if len(l)>0:
538                slotConvsHTML+="""
539                    <tr>
540                        <td valign="top">%s (<small>%s-%s</small>):</td>
541                        <td>%s</td>
542                    </tr>
543                      """%(self.htmlText(slot.getTitle()),
544                      slot.getAdjustedStartDate().strftime("%d-%b-%y %H:%M"),
545                      slot.getAdjustedEndDate().strftime("%d-%b-%y %H:%M"),
546                      "; ".join(l))
547        convs=""
548        if len(sessionConvs)>0 or slotConvsHTML.strip()!="":
549            convs="""
550                <table>
551                    <tr>
552                        <td valign="top" colspan="2">%s</td>
553                    </tr>
554                    %s
555                </table>"""%("<br>".join(sessionConvs),slotConvsHTML)
556        vars["conveners"]=self._getHTMLRow( _("Conveners"),convs)
557        lm = []
558        for material in self._session.getAllMaterialList():
559            url=urlHandlers.UHMaterialDisplay.getURL(material)
560            lm.append(wcomponents.WMaterialDisplayItem().getHTML(self._aw,material,url))
561        vars["material"] = self._getHTMLRow( _("Material"), "<br>".join( lm ) )
562        vars["contribs"]= ""
563        if self._session.getContributionList() != []:
564            vars["contribs"]=self._getContribsHTML()
565        vars["PDFIcon"]=quoteattr(str(Config.getInstance().getSystemIconURL("print")))
566        url=urlHandlers.UHConfTimeTablePDF.getURL(self._session.getConference())
567        url.addParam("showSessions",self._session.getId())
568        if self._session.getScheduleType()=="poster":
569            if self._sortingCrit is not None and \
570                    self._sortingCrit.getField() is not None:
571                url.addParam("sortBy",self._sortingCrit.getField().getId())
572        vars["PDFURL"]=quoteattr(str(url))
573        return vars
574
575
576# TODO: These classes are actually the same, no?  (Pedro)
577
578class WSessionDisplayFull(WSessionDisplayBase):
579    pass
580
581
582class WSessionDisplayMin(WSessionDisplayBase):
583    pass
584
585
586class WSessionDisplay:
587
588    def __init__(self,aw,session):
589        self._aw = aw
590        self._session = session
591
592    def getHTML(self,params={}):
593        if self._session.canAccess( self._aw ):
594            c=WSessionDisplayFull(self._aw,self._session,params["activeTab"],
595                    params.get("sortingCrit",None))
596            return c.getHTML( params )
597        if self._session.canView( self._aw ):
598            c = WSessionDisplayMin(self._aw,self._session,params["activeTab"],
599                    params.get("sortingCrit",None))
600            return c.getHTML( params )
601        return ""
602
603
604class WPSessionDisplay( WPSessionDefaultDisplayBase ):
605    navigationEntry = navigation.NESessionDisplay
606   
607    def _getBody(self,params):
608        wc=WSessionDisplay(self._getAW(),self._session)
609        return wc.getHTML({"activeTab":params["activeTab"],
610                            "sortingCrit":params.get("sortingCrit",None)})
611
612    def _defineToolBar(self):
613        edit=wcomponents.WTBItem( _("manage this session"),
614            icon=Config.getInstance().getSystemIconURL("modify"),
615            actionURL=urlHandlers.UHSessionModification.getURL(self._session),
616            enabled=self._session.canModify(self._getAW()) or \
617                    self._session.canCoordinate(self._getAW()))
618        url=urlHandlers.UHConfTimeTablePDF.getURL(self._session.getConference())
619        url.addParam("showSessions",self._session.getId())
620        pdf=wcomponents.WTBItem( _("get PDF of this session"),
621            icon=Config.getInstance().getSystemIconURL("pdf"),
622            actionURL=url)
623        ical=wcomponents.WTBItem( _("get ICal of this session"),
624            icon=Config.getInstance().getSystemIconURL("ical"),
625            actionURL=urlHandlers.UHSessionToiCal.getURL(self._session))
626        self._toolBar.addItem(edit)
627        self._toolBar.addItem(pdf)
628        self._toolBar.addItem(ical)
629
630
631class WPSessionModifBase( WPConferenceModifBase ):
632   
633    def __init__(self, rh, session):
634        WPConferenceModifBase.__init__(self, rh, session.getConference())
635        self._session = session
636
637    def _setActiveSideMenuItem( self ):
638        self._timetableMenuItem.setActive()
639   
640    def _createTabCtrl( self ):
641        type = self._session.getConference().getType()
642        self._tabCtrl = wcomponents.TabControl()
643        self._tabMain = self._tabCtrl.newTab( "main", _("Main"), \
644                urlHandlers.UHSessionModification.getURL( self._session ) )
645        self._tabContribs=self._tabCtrl.newTab( "contribs", _("Contributions"), \
646                urlHandlers.UHSessionModContribList.getURL(self._session) )
647        self._tabTimetable=self._tabCtrl.newTab( "sessionTimetable", _("Session timetable"), \
648                urlHandlers.UHSessionModifSchedule.getURL(self._session) )
649        self._tabComm = self._tabCtrl.newTab( "comment", _("Comment"), \
650                urlHandlers.UHSessionModifComm.getURL( self._session ) )
651        self._tabMaterials = self._tabCtrl.newTab( "materials", _("Files"), \
652                urlHandlers.UHSessionModifMaterials.getURL( self._session ) )
653        self._tabAC = self._tabCtrl.newTab( "ac", _("Protection"), \
654                urlHandlers.UHSessionModifAC.getURL( self._session ) )
655        canCoord=self._session.canCoordinate(self._getAW())
656        canModify=self._session.canModify(self._getAW())
657        self._tabAC.setEnabled(canModify)
658        self._tabTools = self._tabCtrl.newTab( "tools", _("Tools"), \
659                urlHandlers.UHSessionModifTools.getURL( self._session ) )
660        self._tabTools.setEnabled(canModify)
661        self._setActiveTab()
662        self._setupTabCtrl()
663        if type != "conference":
664            self._tabContribs.disable()
665
666    def _setActiveTab( self ):       
667        pass
668
669    def _setupTabCtrl(self):
670        pass     
671
672    def _getNavigationDrawer(self):
673        pars = {"target": self._session, "isModif": True }
674        return wcomponents.WNavigationDrawer( pars, bgColor="white" )
675
676    def _getPageContent( self, params ):
677        self._createTabCtrl()
678       
679        banner = wcomponents.WTimetableBannerModif(self._session).getHTML()
680        body = wcomponents.WTabControl( self._tabCtrl, self._getAW() ).getHTML( self._getTabContent( params ) )
681        return banner + body
682
683
684class WSessionModifClosed(wcomponents.WTemplated):
685   
686    def __init__(self):
687        pass
688
689    def getVars(self):
690        vars = wcomponents.WTemplated.getVars(self)
691        vars["closedIconURL"] = Config.getInstance().getSystemIconURL("closed")
692        return vars
693       
694class WSessionModifMainType(wcomponents.WTemplated):
695   
696    def __init__(self):
697        pass
698       
699    def getVars( self ):
700        vars=wcomponents.WTemplated.getVars(self) 
701        l=[]
702        currentTTType=vars.get("tt_type",conference.SlotSchTypeFactory.getDefaultId())
703        for i in conference.SlotSchTypeFactory.getIdList():
704            sel=""
705            if i==currentTTType:
706                sel=" selected"
707            l.append("""<option value=%s%s>%s</option>"""%(quoteattr(str(i)),
708                        sel,self.htmlText(i)))
709        vars["tt_types"]="".join(l)
710        return vars
711       
712class WSessionModifMainCode(wcomponents.WTemplated):
713   
714    def __init__(self):
715        pass
716       
717    def getVars( self ):
718        vars=wcomponents.WTemplated.getVars(self) 
719        vars["code"]=str(vars.get("code",""))
720        return vars
721   
722class WSessionModifMainColors(wcomponents.WTemplated):
723   
724    def __init__(self):
725        pass
726
727    def getVars(self):
728        vars = wcomponents.WTemplated.getVars(self)
729        return vars
730   
731class WSessionModifMain(wcomponents.WTemplated):
732   
733    def __init__( self, session, mfRegistry ):
734        self._session = session
735        self._mfr = mfRegistry
736
737    def _getConvenersHTML(self):
738        res=[]
739        for conv in self._session.getConvenerList():
740            url=urlHandlers.UHSessionModConvenerEdit.getURL(conv)
741            res.append("""
742                <input type="checkbox" name="selConv" value=%s> <a href=%s>%s</a>
743                """%(quoteattr(str(conv.getId())),\
744                    quoteattr(str(url)), \
745                    self.htmlText(conv.getFullName())))
746        return "<br>".join(res)
747       
748    def getVars( self ):
749        vars = wcomponents.WTemplated.getVars( self )
750        vars["addMaterialURL"]=urlHandlers.UHSessionAddMaterial.getURL(self._session)
751        vars["removeMaterialsURL"]=urlHandlers.UHSessionRemoveMaterials.getURL()
752        modifyMaterialURLGen=urlHandlers.UHMaterialModification.getURL
753               
754        newConvenerURL = urlHandlers.UHSessionDataModificationNewConvenerCreate.getURL(self._session)
755        vars["newConvenerURL"] = newConvenerURL
756        searchConvenerURL = urlHandlers.UHSessionDataModificationNewConvenerSearch.getURL(self._session)
757        vars["searchConvenerURL"] = searchConvenerURL
758        vars["remConvenersURL"]=quoteattr(str(urlHandlers.UHSessionModConvenersRem.getURL(self._session)))
759        vars["dataModificationURL"]=quoteattr(str(urlHandlers.UHSessionDataModification.getURL(self._session)))
760        vars["code"]=self.htmlText(self._session.getCode())
761        vars["title"]=self._session.getTitle()
762        if isStringHTML(self._session.getDescription()):
763            vars["description"] = self._session.getDescription()
764        else:
765            vars["description"] = """<table class="tablepre"><tr><td><pre>%s</pre></td></tr></table>""" % self._session.getDescription()
766        vars["place"]=""
767        place=self._session.getLocation()
768        if place is not None:
769            vars["place"] = "%s<br><pre>%s</pre>"%(\
770                                            self.htmlText(place.getName()), 
771                                            self.htmlText(place.getAddress()))
772        room=self._session.getRoom()
773        if room is not None:
774            vars["place"]+="<i>Room:</i> %s"%self.htmlText(room.getName())
775        vars["startDate"],vars["endDate"],vars["duration"]="","","" 
776        if self._session.getAdjustedStartDate() is not None:
777            tz = self._session.getTimezone()
778            vars["startDate"]=self.htmlText(self._session.getAdjustedStartDate().strftime("%A %d %B %Y %H:%M"))
779            vars["endDate"]=self.htmlText(self._session.getAdjustedEndDate().strftime("%A %d %B %Y %H:%M"))
780        vars["conveners"]=self._getConvenersHTML()
781        vars["bgcolor"] = self._session.getColor()
782        vars["textcolor"] = self._session.getTextColor()
783        vars["entryDuration"]=self.htmlText((datetime(1900,1,1)+self._session.getContribDuration()).strftime("%Hh%M'"))
784        vars["tt_type"]=self.htmlText(self._session.getScheduleType())
785        type = self._session.getConference().getType()
786        if type == "conference":
787            vars["Type"]=WSessionModifMainType().getHTML(vars)
788            vars["Colors"]=WSessionModifMainColors().getHTML(vars)
789            vars["Code"]=WSessionModifMainCode().getHTML(vars)
790            vars["Rowspan"]=9
791        else:
792            vars["Type"]=""
793            vars["Colors"]=""
794            vars["Code"]=""
795            vars["Rowspan"]=6
796        return vars
797
798
799class WPSessionModification( WPSessionModifBase ):
800
801    def _getTabContent( self, params ):
802        comp=WSessionModifMain(self._session,materialFactories.SessionMFRegistry())
803        return comp.getHTML()
804
805class WPSessionModificationClosed( WPSessionModifBase ):
806
807    def _createTabCtrl( self ):
808        self._tabCtrl = wcomponents.TabControl()
809        self._tabMain = self._tabCtrl.newTab( "main",_("Main"), "")
810        self._setActiveTab()
811       
812    def _getTabContent( self, params ):
813        comp=WSessionModifClosed()
814        return comp.getHTML()
815
816#------------------------------------------------------------------------------------
817
818class WPSessionDataModification(WPSessionModification):
819   
820    def _getTabContent(self,params):
821        title="Edit session data"
822        p=wcomponents.WSessionModEditData(self._session.getConference(),self._getAW(),title)
823        params["postURL"]=urlHandlers.UHSessionDataModification.getURL(self._session)
824        params["colorChartIcon"]=Config.getInstance().getSystemIconURL("colorchart")
825        urlbg=urlHandlers.UHSimpleColorChart.getURL()
826        urlbg.addParam("colorCodeTarget", "backgroundColor")
827        urlbg.addParam("colorPreviewTarget", "backgroundColorpreview")
828        params["bgcolorChartURL"]=urlbg
829        params["bgcolor"] = self._session.getColor()
830        urltext=urlHandlers.UHSimpleColorChart.getURL()
831        urltext.addParam("colorCodeTarget", "textColor")
832        urltext.addParam("colorPreviewTarget", "textColorpreview")
833        params["textcolorChartURL"]=urltext
834        params["textcolor"] = self._session.getTextColor()
835        params["textColorToLinks"]=""
836        if self._session.isTextColorToLinks():
837            params["textColorToLinks"]="checked=\"checked\""
838       
839        #wconvener = wcomponents.WAddPersonModule("convener")
840        #params["convenerDefined"] = self._getDefinedDisplayList("convener")
841        #params["convenerOptions"] = ""
842        #params["convener"] = wconvener.getHTML(params)
843        params["convener"] = ""   
844        return p.getHTML(params)
845
846    def _getDefinedDisplayList(self, typeName):
847         list = self._session.getConvenerList()
848         if list is None :
849             return ""
850         html = []
851         counter = 0
852         for person in list :
853             text = """
854                 <tr>
855                     <td width="5%%"><input type="checkbox" name="%ss" value="%s"></td>
856                     <td>&nbsp;%s</td>
857                 </tr>"""%(typeName,counter,person.getFullName())
858             html.append(text)
859             counter = counter + 1
860         return """
861             """.join(html)
862   
863#---------------------------------------------------------------------------
864
865class WPSessionDataModificationConvenerSelect( WPSessionModifBase):
866   
867    #def _setActiveTab( self ):
868    #    self._tabContribList.setActive()
869       
870    def _getTabContent( self, params ):
871        searchAction = str(self._rh.getCurrentURL())       
872        newButtonAction = params["newButtonAction"]
873        searchExt = params.get("searchExt","")
874        if searchExt != "":
875            searchLocal = False
876        else:
877            searchLocal = True
878        p = wcomponents.WComplexSelection(self._conf,searchAction,forceWithoutExtAuth=searchLocal)
879        return p.getHTML(params)
880
881#---------------------------------------------------------------------------
882
883class WPSessionDataModificationConvenerNew(WPSessionModifBase):
884   
885    #def _setActiveTab( self ):
886    #    self._tabContribList.setActive()
887       
888    def _getTabContent( self, params ):
889        p = wcomponents.WNewPerson()
890       
891        if params.get("formTitle",None) is None :
892            params["formTitle"] =_("Define new convener")
893        if params.get("titleValue",None) is None :
894            params["titleValue"] = ""
895        if params.get("surNameValue",None) is None :
896            params["surNameValue"] = ""
897        if params.get("nameValue",None) is None :
898            params["nameValue"] = ""
899        if params.get("emailValue",None) is None :
900            params["emailValue"] = ""
901        if params.get("addressValue",None) is None :
902            params["addressValue"] = ""
903        if params.get("affiliationValue",None) is None :
904            params["affiliationValue"] = ""
905        if params.get("phoneValue",None) is None :
906            params["phoneValue"] = ""
907        if params.get("faxValue",None) is None :
908            params["faxValue"] = ""
909       
910       
911        params["disabledRole"] = False
912        params["roleDescription"] = _(""" _("Coordinator")<br> _("Manager")""")
913        if params.has_key("submissionControlValue") :
914            params["roleValue"] = _(""" <input type="checkbox" name="coordinatorControl" checked> _("Give coordinator rights to the convener").<br>
915                                      <input type="checkbox" name="managerControl" checked> _("Give management rights to the convener").""")
916        else:
917            params["roleValue"] = _(""" <input type="checkbox" name="coordinatorControl"> _("Give coordinator rights to the convener").<br>
918                                      <input type="checkbox" name="managerControl"> _("Give management rights to the convener").""")
919        params["disabledNotice"] = True
920        params["noticeValue"] = _("""<i><font color="black"><b> _("Note"): </b></font> _("If this person does not already have
921         an Indico account, he or she will be sent an email asking to create an account. After the account creation the
922         user will automatically be given coordinator rights").</i>""")
923       
924       
925        if params.get("formAction",None) is None :
926            formAction = urlHandlers.UHSessionDataModificationPersonAdd.getURL(self._conf)
927            formAction.addParam("sessionId",self._session.getId())
928            formAction.addParam("orgin","new")
929            formAction.addParam("typeName","convener")
930            params["formAction"] = formAction
931       
932        return p.getHTML(params)
933
934#---------------------------------------------------------------------------
935
936class WPModEditDataConfirmation(WPSessionModification):
937   
938    def _getTabContent(self,params):
939        wc=wcomponents.WConfirmation()
940        msg= _("""You have selected to CHANGE THIS SESSION SCHEDULE TYPE from %s to %s, if you continue any contribution scheduled within any slot of the current session will be unscheduled, are you sure you want to continue?""")%(self._session.getScheduleType(),params["tt_type"])
941        url=urlHandlers.UHSessionDataModification.getURL(self._session)
942        return wc.getHTML(msg,url,params)
943
944
945class WPModConvenerNew(WPSessionModification):
946   
947    def _getTabContent(self,params):
948        caption= _("Adding a new convener")
949        wc=wcomponents.WConfModParticipEdit(title=caption)
950        params["postURL"]=urlHandlers.UHSessionModConvenerNew.getURL(self._session)
951        params["addToManagersList"]= _("""
952                                    <tr>
953                                        <td nowrap class="titleCellTD">
954                                            <span class="titleCellFormat"> _("Specific rights")</span>
955                                        </td>
956                                        <td bgcolor="white" width="100%%" valign="top" class="blacktext">
957                                            <input type="radio" name="specialRights" value="none" checked> _("Do not give specific rights").<br>
958                                            <input type="radio" name="specialRights" value="manager"> _("Give session manager rights to the convener").<br>
959                                            <input type="radio" name="specialRights" value="coordinator"> _("Give session coordinator rights to the convener").<br><br><i><font color="black"><b> _("Note"): </b></font> _("If this person does not already have an Indico account, he or she will be sent an email asking to create an account. After the account creation the user will automatically be given the specific rights").</i>
960                                        </td>
961                                    </tr>
962                                    """)
963        return wc.getHTML( params )
964   
965
966
967class WPModConvenerEdit(WPSessionModification):
968   
969##    def _getTabContent(self,params):
970##        caption="Edit convener data"
971##        conv=params["convener"]
972##        wc=wcomponents.WConfModParticipEdit(part=conv,title=caption)
973##        params["postURL"]=urlHandlers.UHSessionModConvenerEdit.getURL(conv)
974##        params["addToManagersList"]=""
975##        return wc.getHTML(params)
976
977    def _getTabContent(self,params):
978        p = wcomponents.WNewPerson()
979        conv = params["convener"]
980        params["formTitle"] =  _("Define new convener")
981        params["titleValue"] = conv.getTitle()
982        params["surNameValue"] = conv.getFamilyName()
983        params["nameValue"] = conv.getFirstName()
984        params["emailValue"] = conv.getEmail()
985        params["addressValue"] = conv.getAddress()
986        params["affiliationValue"] = conv.getAffiliation()
987        params["phoneValue"] = conv.getPhone()
988        params["faxValue"] = conv.getFax()
989       
990        params["disabledRole"] = False
991        params["roleDescription"] =  _(""" _("Coordinator")<br> _("Manager")""")
992        session = conv.getSession()
993        av = user.AvatarHolder().match({"email":conv.getEmail()})
994        params["disabledNotice"] = True
995        coordValue =  _("""<input type="checkbox" name="coordinatorControl"> _("Give coordinator rights to the convener").""")
996        if (av and av[0] in session.getCoordinatorList()) or conv.getEmail() in session.getCoordinatorEmailList():
997            coordValue = _("""The convener is already a coordinator""")
998        else:
999            params["disabledNotice"] = False
1000       
1001        managerValue =  _("""<input type="checkbox" name="managerControl"> _("Give management rights to the convener").""")
1002        if (av and av[0] in session.getManagerList() ) or conv.getEmail() in session.getAccessController().getModificationEmail():
1003            managerValue = _("""The convener is already a manager""")
1004        else:
1005            params["disabledNotice"] = False
1006       
1007        params["roleValue"] = """ %s<br>
1008                                  %s"""%(coordValue, managerValue)
1009       
1010        params["noticeValue"] =  _("""<i><font color="black"><b> _("Note"): </b></font> _("If this person does not already have
1011         an Indico account, he or she will be sent an email asking to create an account. After the account creation the
1012         user will automatically be given coordinator/manager rights").</i>""")
1013       
1014        formAction = urlHandlers.UHSessionModConvenerEdit.getURL(conv)
1015        formAction.addParam("orgin","new")
1016        formAction.addParam("typeName","convener")
1017        params["formAction"] = formAction
1018       
1019        return p.getHTML(params)
1020
1021
1022
1023class WPSessionAddMaterial( WPSessionModification ):
1024   
1025    def __init__( self, rh, session, mf ):
1026        WPSessionModification.__init__( self, rh, session )
1027        self._mf = mf
1028   
1029    def _getTabContent( self, params ):
1030        if self._mf:
1031            comp = self._mf.getCreationWC( self._session )
1032        else:
1033            comp = wcomponents.WMaterialCreation( self._session )
1034        pars = { "postURL": urlHandlers.UHSessionPerformAddMaterial.getURL() }
1035        return comp.getHTML( pars )
1036
1037
1038class WSessionModPlainTTDay(wcomponents.WTemplated):
1039   
1040    def __init__(self,aw,day,session):
1041        self._aw=aw
1042        self._day=day
1043        self._session=session
1044
1045    def _getContribHTML(self,contrib):
1046        duration=(datetime(1900,1,1)+contrib.getDuration()).strftime("%Hh%M'")
1047        speakers=[]
1048        for spk in contrib.getSpeakerList():
1049            speakers.append(self.htmlText("%s"%spk.getFullName()))
1050        url=urlHandlers.UHContributionModification.getURL(contrib)
1051        urlEdit=urlHandlers.UHSessionModSchEditContrib.getURL(contrib)
1052        editIconURL=Config.getInstance().getSystemIconURL("modify")
1053        return """
1054            <tr>
1055                <td valign="top" nowrap><input type="checkbox" name="schEntryId" value=%s></td>
1056                <td valign="top" nowrap>%s</td>
1057                <td valign="top" nowrap>(%s)</td>
1058                <td valign="top" nowrap><a href=%s><img src=%s border="0" alt=""></a></td>
1059                <td width="100%%" valign="top">
1060                    <table width="100%%" cellpadding="0" cellspacing="0">
1061                        <tr>
1062                            <td width="100%%" valign="top">
1063                                [%s] <a href=%s>%s</a>
1064                            </td>
1065                            <td nowrap align="right" valign="top">
1066                                %s
1067                            </td>
1068                        </tr cellpadding="0" cellspacing="0">
1069                    </table>
1070                </td>
1071            </tr>
1072            <tr>
1073                <td colspan="5" nowrap valign="top" style="border-top: 1px solid">&nbsp;</td>
1074            </tr>
1075                """%( contrib.getSchEntry().getId(),
1076                        contrib.getAdjustedStartDate().strftime("%H:%M"),
1077                        duration,quoteattr(str(urlEdit)),
1078                        quoteattr(str(editIconURL)),
1079                        self.htmlText(contrib.getId()),
1080                        quoteattr(str(url)),
1081                        self.htmlText(contrib.getTitle()),
1082                        "<br>".join(speakers))
1083
1084    def _getBreakHTML(self,breakEntry):
1085        duration=(datetime(1900,1,1)+breakEntry.getDuration()).strftime("%Hh%M")
1086        url=urlHandlers.UHSessionModifyBreak.getURL(breakEntry)
1087        urlEdit=urlHandlers.UHSessionModifyBreak.getURL(breakEntry)
1088        editIconURL=Config.getInstance().getSystemIconURL("modify")
1089        return """
1090            <tr>
1091                <td valign="top" nowrap><input type="checkbox" name="schEntryId" value=%s></td>
1092                <td valign="top" nowrap>%s</td>
1093                <td valign="top" nowrap>(%s)</td>
1094                <td valign="top" nowrap><a href=%s><img src=%s border="0" alt=""></a></td>
1095                <td width="100%%" valign="top" align="center">
1096                    <a href=%s>%s</a>
1097                </td>
1098            </tr>
1099            <tr>
1100                <td colspan="5" nowrap valign="top" style="border-top: 1px solid">&nbsp;</td>
1101            </tr>
1102                """%(breakEntry.getId(),
1103                        breakEntry.getAdjustedStartDate().strftime("%H:%M"),
1104                        duration,quoteattr(str(urlEdit)),
1105                        quoteattr(str(editIconURL)),
1106                        quoteattr(str(url)),
1107                        self.htmlText(breakEntry.getTitle()))
1108
1109    def _getSlotHTML(self,slot):
1110        caption = ""
1111        if slot.getRoom() is not None:
1112            caption=slot.getRoom().getName()
1113        if slot.getTitle().strip() != "":
1114            caption = "%s (%s)"%(self.htmlText(slot.getTitle()),self.htmlText(caption))
1115        duration=""
1116        if (datetime(1900,1,1)+slot.getDuration()).minute>0:
1117            duration="%s'"%(datetime(1900,1,1)+slot.getDuration()).minute
1118        if (datetime(1900,1,1)+slot.getDuration()).hour>0:
1119            duration="%sh%s"%((datetime(1900,1,1)+slot.getDuration()).hour,duration)
1120        if duration!="":
1121            duration="(%s)"%duration
1122        entries=[]
1123        at=timedelta(0,0,0)
1124        for entry in slot.getSchedule().getEntries():
1125            if isinstance(entry,schedule.LinkedTimeSchEntry) and \
1126                    isinstance(entry.getOwner(),conference.Contribution):
1127                entries.append(self._getContribHTML(entry.getOwner()))
1128            elif isinstance(entry,schedule.BreakTimeSchEntry):
1129                entries.append(self._getBreakHTML(entry))
1130            at+=entry.getDuration()
1131        addContribURL=urlHandlers.UHSessionModScheduleAddContrib.getURL(slot)       
1132       
1133        orginURL = urlHandlers.UHSessionModifSchedule.getURL(self._session.getOwner())
1134        orginURL.addParam("sessionId", self._session.getId())
1135        newContribURL = urlHandlers.UHConfModScheduleNewContrib.getURL(self._session.getOwner())
1136        newContribURL.addParam("sessionId", self._session.getId())
1137        newContribURL.addParam("slotId", slot.getId())
1138        newContribURL.addParam("orginURL",orginURL)       
1139       
1140        addBreakURL=urlHandlers.UHSessionAddBreak.getURL(slot)
1141        delSlotURL=urlHandlers.UHSessionModSlotRem.getURL(slot)
1142        editSlotURL=urlHandlers.UHSessionModSlotEdit.getURL(slot)
1143        delContribsURL=urlHandlers.UHSessionDelSchItems.getURL(slot)
1144        urlCompSlot = urlHandlers.UHSessionModSlotCalc.getURL(slot)
1145        if slot.getContribDuration() is None or slot.getContribDuration()==timedelta(0):
1146            ded=slot.getSession().getContribDuration()
1147        else:
1148            ded=slot.getContribDuration()
1149        nat=slot.getDuration()-at
1150        numEntries=len(entries)
1151        ree=0
1152        if ded!=0 and ded.seconds != 0:
1153            ree=int(nat.seconds/ded.seconds)
1154        linkColor=""
1155        if self._session.isTextColorToLinks():
1156            linkColor="color:%s"%self._session.getTextColor()
1157        editSlotLink,delSlotLink="",""
1158        if self._session.canModify(self._aw) or self._session.canCoordinate(self._aw, "unrestrictedSessionTT"):
1159            editSlotLink="""<input type="submit" value="delete" onClick="self.location.href='%s';return false;" class="smallbtn">"""%str(delSlotURL)
1160            delSlotLink="""<input type="submit" value="edit" onClick="self.location.href='%s';return false;" class="smallbtn">"""%str(editSlotURL)
1161
1162        convs=""
1163        l=[]
1164        if slot.getConvenerList() == []:
1165            for conv in self._session.getConvenerList():
1166                l.append("""%s"""%(self.htmlText(conv.getFullName())))
1167        else:
1168            for conv in slot.getConvenerList():
1169                l.append("""%s"""%(self.htmlText(conv.getFullName())))
1170        if len(l)>0:
1171            convs="Conveners: %s"%"; ".join(l)
1172        return  _("""
1173            <a name="slot%s"/>
1174            <table width="90%%" align="center" border="0"
1175                                        style="border-left: 1px solid #777777">
1176                <tr>
1177                    <td class="groupTitle" style="background: %s">
1178                        <table>
1179                            <tr>
1180                                <td nowrap class="groupTitle" style="background:%s;color: %s">
1181                                    %s-%s %s
1182                                </td>
1183                                <td width="100%%" align="center" class="groupTitle" style="background:%s;color: %s">
1184                                    %s
1185                                </td>
1186                                <td align="right" nowrap style="letter-spacing: 0px">
1187                                    <input type="submit" value="_("add contribution")" onClick="self.location.href='%s';return false;" class="smallbtn">
1188                                    <input type="submit" value="_("new contribution")" onClick="self.location.href='%s';return false;" class="smallbtn">
1189                                    <input type="submit" value="_("new break")" onClick="self.location.href='%s';return false;" class="smallbtn">
1190                                    %s %s
1191                                    <input type="submit" value="_("reschedule")" onClick="self.location.href='%s';return false;" class="smallbtn">
1192                                </td>
1193                            </tr>
1194                            <tr>
1195                                <td colspan="3" style="letter-spacing: 0px;background:%s;color:%s">
1196                                    <small>%s</small>
1197                                </td>
1198                            </tr>
1199                            <tr>
1200                                <td colspan="3" style="letter-spacing: 0px; color:%s">
1201                                    <small>NAT:%s - AT:%s - #E:%s - DED:%s - #REE:%s</small>
1202                                </td>
1203                            </tr>
1204                        </table>
1205                    </td>
1206                </tr>
1207                <form action=%s method="POST">
1208                <tr>
1209                    <td>
1210                        <table width="100%%" align="center">
1211                            %s
1212                        </table>
1213                    </td>
1214                </tr>
1215                <tr>
1216                    <td>
1217                        <table>
1218                            <tr>
1219                                <td><input type="submit" class="btn" value="_("remove selected")"></td>
1220                            </tr>
1221                        </table>
1222                    </td>
1223                </tr>
1224                </form>
1225            </table>
1226                """)%( slot.getId(),self._session.getColor(), self._session.getColor(), self._session.getTextColor(), \
1227                        slot.getAdjustedStartDate().strftime("%H:%M"), \
1228                        slot.getAdjustedEndDate().strftime("%H:%M"), \
1229                        duration,self._session.getColor(),self._session.getTextColor(),caption, \
1230                        str(addContribURL), \
1231                        str(newContribURL), \
1232                        str(addBreakURL), \
1233                        editSlotLink,delSlotLink, \
1234                        quoteattr(str(urlCompSlot)), linkColor, \
1235                        self._session.getTextColor(), convs,self._session.getTextColor(), \
1236                        (datetime(1900,1,1)+nat).strftime("%Hh%M'"),(datetime(1900,1,1)+at).strftime("%Hh%M'"), \
1237                        numEntries,(datetime(1900,1,1)+ded).strftime("%Hh%M'"), \
1238                        ree, \
1239                        quoteattr(str(delContribsURL)), \
1240                        "".join(entries))
1241
1242    def getVars(self):
1243        vars=wcomponents.WTemplated.getVars(self)
1244        vars["day"]=self._day.strftime("%A, %d %B %Y")
1245        tz = self._session.getTimezone()
1246        sDate=timezone(tz).localize(datetime(self._day.year,self._day.month,self._day.day,0,0))
1247        eDate=timezone(tz).localize(datetime(self._day.year,self._day.month,self._day.day,23,59))
1248        res=[]
1249        for slotEntry in self._session.getSchedule().getEntries():
1250            if slotEntry.getAdjustedStartDate()>eDate:
1251                break
1252            if slotEntry.getAdjustedEndDate()>=sDate and \
1253                                slotEntry.getAdjustedStartDate()<=eDate:
1254                res.append(self._getSlotHTML(slotEntry.getOwner()))
1255        vars["slots"]="<br>".join(res)
1256        urlNewSlot=urlHandlers.UHSessionModSlotNew.getURL(self._session)
1257        urlNewSlot.addParam("slotDate",self._day.strftime("%d-%m-%Y"))
1258        vars["newSlotURL"]=quoteattr(str(urlNewSlot))
1259        vars["newSlotBtn"]="&nbsp;"
1260        if self._session.canModify(self._aw) or self._session.canCoordinate(self._aw, "unrestrictedSessionTT"):
1261            if self._session.getConference().getEnableSessionSlots() :
1262                vars["newSlotBtn"]= _("""<input type="submit" class="btn" value="_("new slot")">""")
1263        vars["fitToInnerSlots"] = "&nbsp;"
1264        if self._session.getConference().getEnableSessionSlots() :
1265            vars["fitToInnerSlots"] = _("""<input type="submit" class="btn" value="_("fit to inner slots")">""")
1266        vars["start_date"] = self._session.getAdjustedStartDate().strftime("%a %d %b %Y %H:%M")
1267        vars["end_date"] = self._session.getAdjustedEndDate().strftime("%a %d %b %Y %H:%M")
1268        vars["editURL"] = quoteattr(str(urlHandlers.UHSessionModFit.getURL(self._session)))
1269        return vars
1270
1271
1272class WSessionModPosterTTDay(wcomponents.WTemplated):
1273   
1274    def __init__(self,aw,day,session):
1275        self._aw=aw
1276        self._day=day
1277        self._session=session
1278
1279    def _getContribHTML(self,contrib):
1280        #duration=(datetime(1900,1,1)+contrib.getDuration()).strftime("%Hh%M'")
1281        speakers=[]
1282        for spk in contrib.getSpeakerList():
1283            speakers.append(self.htmlText("%s"%spk.getFullName()))
1284        url=urlHandlers.UHContributionModification.getURL(contrib)
1285        urlEdit=urlHandlers.UHSessionModSchEditContrib.getURL(contrib)
1286        editIconURL=Config.getInstance().getSystemIconURL("modify")
1287        return """
1288            <tr>
1289                <td valign="top" nowrap><input type="checkbox" name="schEntryId" value=%s></td>
1290                <td valign="top" nowrap>%s</td>
1291                <td valign="top" nowrap><a href=%s><img src=%s border="0" alt=""></a></td>
1292                <td width="100%%" valign="top">
1293                    <table width="100%%" cellpadding="0" cellspacing="0">
1294                        <tr>
1295                            <td width="100%%" valign="top">
1296                                [%s] <a href=%s>%s</a>
1297                            </td>
1298                            <td nowrap align="right" valign="top">
1299                                %s
1300                            </td>
1301                        </tr cellpadding="0" cellspacing="0">
1302                    </table>
1303                </td>
1304            </tr>
1305            <tr>
1306                <td colspan="5" nowrap valign="top" style="border-top: 1px solid">&nbsp;</td>
1307            </tr>
1308                """%( contrib.getSchEntry().getId(),
1309                        self.htmlText(contrib.getBoardNumber()),
1310                        quoteattr(str(urlEdit)),
1311                        quoteattr(str(editIconURL)),
1312                        self.htmlText(contrib.getId()),
1313                        quoteattr(str(url)),
1314                        self.htmlText(contrib.getTitle()),
1315                        "<br>".join(speakers))
1316
1317    def _getSlotHTML(self,slot):
1318        caption = ""
1319        if slot.getRoom() is not None:
1320            caption=slot.getRoom().getName()
1321        if slot.getTitle().strip() != "":
1322            caption = "%s (%s)"%(self.htmlText(slot.getTitle()),self.htmlText(caption))
1323        duration=""
1324        if (datetime(1900,1,1)+slot.getDuration()).minute>0:
1325            duration="%s'"%(datetime(1900,1,1)+slot.getDuration()).minute
1326        if (datetime(1900,1,1)+slot.getDuration()).hour>0:
1327            duration="%sh%s"%((datetime(1900,1,1)+slot.getDuration()).hour,duration)
1328        if duration!="":
1329            duration="(%s)"%duration
1330        entries=[]
1331        for entry in slot.getSchedule().getEntries():
1332            if isinstance(entry,schedule.LinkedTimeSchEntry) and \
1333                    isinstance(entry.getOwner(),conference.Contribution):
1334                entries.append(self._getContribHTML(entry.getOwner()))
1335        addContribURL=urlHandlers.UHSessionModScheduleAddContrib.getURL(slot)
1336       
1337        orginURL = urlHandlers.UHSessionModifSchedule.getURL(self._session.getOwner())
1338        orginURL.addParam("sessionId", self._session.getId())
1339        newContribURL = urlHandlers.UHConfModScheduleNewContrib.getURL(self._session.getOwner())
1340        newContribURL.addParam("sessionId", self._session.getId())
1341        newContribURL.addParam("slotId", slot.getId())
1342        newContribURL.addParam("orginURL",orginURL)
1343       
1344        delSlotURL=urlHandlers.UHSessionModSlotRem.getURL(slot)
1345        editSlotURL=urlHandlers.UHSessionModSlotEdit.getURL(slot)
1346        delContribsURL=urlHandlers.UHSessionDelSchItems.getURL(slot)
1347        numEntries=len(entries)
1348        linkColor=""
1349        if self._session.isTextColorToLinks():
1350            linkColor="color:%s"%self._session.getTextColor()
1351        editSlotLink,delSlotLink="",""
1352        if self._session.canModify(self._aw) or self._session.canCoordinate(self._aw, "unrestrictedSessionTT"):
1353            editSlotLink="""<input type="submit" value="delete" onClick="self.location.href='%s';return false;" class="smallbtn">"""%str(delSlotURL)
1354            delSlotLink="""<input type="submit" value="edit" onClick="self.location.href='%s';return false;" class="smallbtn">"""%str(editSlotURL)
1355        convs=""
1356        l=[]
1357        if slot.getConvenerList() == []:
1358            for conv in slot.getSession().getConvenerList():
1359                l.append("""%s"""%(self.htmlText(conv.getFullName())))
1360        else:
1361            for conv in slot.getConvenerList():
1362                l.append("""%s"""%(self.htmlText(conv.getFullName())))
1363        if len(l)>0:
1364            convs="""<span style="letter-spacing: 0px">Conveners: %s</span>"""%"; ".join(l)
1365        return  _("""
1366            <a name="slot%s"/>
1367            <table width="90%%" align="center" border="0"
1368                                        style="border-left: 1px solid #777777">
1369                <tr>
1370                    <td class="groupTitle" style="background-color: %s">
1371                        <table>
1372                            <tr>
1373                                <td nowrap class="groupTitle" style="background-color: %s; color: %s">
1374                                    %s-%s %s
1375                                </td>
1376                                <td width="100%%" align="center" class="groupTitle" style="background-color: %s; color: %s">
1377                                    %s
1378                                </td>
1379                                <td align="right" nowrap style="letter-spacing: 0px">
1380                                    <input type="submit" value="_("add contribution")" onClick="self.location.href='%s';return false;" class="smallbtn">
1381                                    <input type="submit" value="_("new contribution")" onClick="self.location.href='%s';return false;" class="smallbtn">
1382                                    %s %s
1383                                </td>
1384                            </tr>
1385                            <tr>
1386                                <td colspan="3" style="color:%s">%s</td>
1387                            </tr>
1388                            <tr>
1389                                <td colspan="3" style="color:%s">%s  _("entries")</td>
1390                            </tr>
1391                        </table>
1392                    </td>
1393                </tr>
1394                <form action=%s method="POST">
1395                <tr>
1396                    <td>
1397                        <table width="100%%" align="center">
1398                            %s
1399                        </table>
1400                    </td>
1401                </tr>
1402                <tr>
1403                    <td>
1404                        <table>
1405                            <tr>
1406                                <td><input type="submit" class="btn" value="_("remove selected")"></td>
1407                            </tr>
1408                        </table>
1409                    </td>
1410                </tr>
1411                </form>
1412            </table>
1413                """)%( slot.getId(),slot.getSession().getColor(), slot.getSession().getColor(),slot.getSession().getTextColor(), slot.getAdjustedStartDate().strftime("%H:%M"),
1414                        slot.getAdjustedEndDate().strftime("%H:%M"),
1415                        duration,slot.getSession().getColor(),slot.getSession().getTextColor(),caption,
1416                        str(addContribURL),
1417                       str(newContribURL),
1418                        editSlotLink,delSlotLink,slot.getSession().getTextColor(),convs,slot.getSession().getTextColor(),numEntries,
1419                        quoteattr(str(delContribsURL)),   
1420                        "".join(entries))
1421
1422    def getVars(self):
1423        vars=wcomponents.WTemplated.getVars(self)
1424        vars["day"]=self._day.strftime("%A, %d %B %Y")
1425        tz = self._session.getTimezone()
1426        sDate=timezone(tz).localize(datetime(self._day.year,self._day.month,self._day.day,0,0))
1427        eDate=timezone(tz).localize(datetime(self._day.year,self._day.month,self._day.day,23,59))
1428        res=[]
1429        for slotEntry in self._session.getSchedule().getEntries():
1430            if slotEntry.getAdjustedStartDate()>eDate:
1431                break
1432            if slotEntry.getAdjustedEndDate()>=sDate and \
1433                                slotEntry.getAdjustedStartDate()<=eDate:
1434                res.append(self._getSlotHTML(slotEntry.getOwner()))
1435        vars["slots"]="<br>".join(res)
1436        urlNewSlot=urlHandlers.UHSessionModSlotNew.getURL(self._session)
1437        urlNewSlot.addParam("slotDate",self._day.strftime("%d-%m-%Y"))
1438        vars["newSlotURL"]=quoteattr(str(urlNewSlot))
1439        vars["newSlotBtn"]=""
1440        if self._session.canModify(self._aw) or self._session.canCoordinate(self._aw, "unrestrictedSessionTT"):
1441            vars["newSlotBtn"]= _("""<input type="submit" class="btn" value="_("new slot")">""")
1442        return vars
1443
1444
1445class WPSessionModifSchedule( WPConfModifScheduleGraphic ):
1446   
1447    def __init__( self, rh, session):
1448        WPConfModifScheduleGraphic.__init__( self, rh, session.getConference() )       
1449        self._session = session       
1450   
1451    def _setActiveTab(self):
1452        self._tabTimetable.setActive()
1453   
1454    def _generateSessionTimetable(self):
1455       
1456        tz = self._conf.getTimezone()
1457        timeTable = timetable.TimeTable(self._session.getSchedule(), tz)
1458        sDate,eDate=self._session.getAdjustedStartDate(tz),self._session.getAdjustedEndDate(tz) 
1459        timeTable.setStartDate(sDate)
1460        timeTable.setEndDate(eDate)
1461#        timeTable.setStartDayTime(7,0)
1462#        timeTable.setEndDayTime(21,59)
1463       
1464        timeTable.mapEntryList(self._session.getSchedule().getEntries()) 
1465        return timeTable
1466   
1467    def _getScheduleContent(self,params):
1468
1469        sessionTimetable = self._generateSessionTimetable();
1470        sessionDays = sessionTimetable.getDayList()
1471       
1472        wc = WSessionModifSchedule(self._getAW(), self._session, sessionDays, sessionTimetable)
1473        return wc.getHTML(params)
1474
1475class WScheduleBreak(wcomponents.WTemplated):
1476
1477    def __init__(self, breakEntry):
1478        self._breakEntry = breakEntry
1479
1480    def getHTML(self, params=None):
1481        params['modifyAction'] = urlHandlers.UHSessionModifyBreak.getURL
1482        params['deleteAction'] = urlHandlers.UHSessionDelSchItems.getURL
1483        params['relocateAction'] = urlHandlers.UHConfModifScheduleRelocate.getURL
1484        params['moveUpAction'] = urlHandlers.UHSessionModSlotMoveUpEntry.getURL
1485        params['moveDownAction'] = urlHandlers.UHSessionModSlotMoveDownEntry.getURL
1486       
1487        return wcomponents.WTemplated.getHTML( self, params )
1488   
1489class WSessionModifSchedule(WConfModifScheduleGraphicOverview):
1490   
1491    def __init__(self,aw,session,days,timetable):
1492        self._aw=aw
1493        self._session = session
1494        self._days=days
1495        self._timetable = timetable
1496             
1497    def _getContributionHTML(self,contrib,days,params):
1498        if days:
1499            params['days'] = days
1500        return WScheduleContribution(contrib, insideSession=True).getHTML(params) 
1501   
1502    def _getBreakHTML(self,breakEntry, header="", footer="", params={}):       
1503        return WScheduleBreak(breakEntry).getHTML(params)
1504
1505    def _getEntryHTML(self,entry, days, room = "", header = "", footer="", params={}):
1506       
1507        if isinstance(entry,schedule.LinkedTimeSchEntry):
1508            if isinstance(entry.getOwner(),conference.Contribution):
1509                params.update({room: room, header: header, footer: footer})
1510                return self._getContributionHTML(entry.getOwner(), days, params)
1511        elif isinstance(entry,schedule.BreakTimeSchEntry):
1512            return self._getBreakHTML(entry, header, footer, params=params)
1513
1514    def _getFitSlotLink( self, container ):
1515        """
1516        returns a link to the "fit slot" action if and only if
1517        the time slot has a son and its limits are larger than its sons'
1518        """
1519        fitSlotLink = ""
1520        entries = container.getSessionSlot().getSchedule().getEntries()
1521        if len(entries) > 0:
1522            if container.getAdjustedStartDate()<entries[0].getAdjustedStartDate() or container.getAdjustedEndDate()>entries[-1].getAdjustedEndDate():
1523                fitSlotLink = _("""
1524                                        <a href=%s><small>[_("fit slot")]</small></a>""")% quoteattr(str(urlHandlers.UHSessionFitSlot.getURL(container.getSessionSlot())))
1525        return fitSlotLink
1526
1527    def _getEntries(self, schedule):
1528        l = []
1529        for sessionEntry in schedule.getEntries():
1530            sesSlot = sessionEntry.getOwner()
1531            l.append(sesSlot)
1532        return l
1533
1534    def _initTempList(self, max, defaultValue=None):
1535        t = []
1536        for i in range(0, max):
1537            t.append(defaultValue)
1538        return t
1539   
1540    def _getScheduleHTML(self, days, eventType="conference"):                       
1541        confTZ = self._session.getTimezone()
1542        if self._slot:
1543            target = self._slot
1544        else:
1545            target = self._session
1546       
1547        timeTable=timetable.TimeTable(target.getSchedule(), confTZ) 
1548        sDate,eDate=target.getAdjustedStartDate(), target.getAdjustedEndDate() 
1549        timeTable.setStartDate(sDate)
1550        timeTable.setEndDate(eDate)
1551       
1552        if self._slot:
1553            timeTable.mapContainerList([self._slot])
1554        else:
1555            timeTable.mapContainerList(self._getEntries(self._session.getSchedule()))
1556                       
1557        timeTable.compactDays()
1558        containerIndex = ContainerIndex()
1559        daySch = [] 
1560       
1561        for day in timeTable.getDayList():       
1562            slotList=[]
1563            lastEntries=[]
1564            maxoverlaping= day.getContainerMaxOverlap()
1565            if not day.hasContainerOverlaps():
1566                maxoverlaping = day.getNumMaxOverlaping() or 1
1567            width="100"           
1568            if maxoverlaping!=0:
1569                width=100/maxoverlaping
1570            containerIndex.initialization(day, day.hasContainerOverlaps())
1571            lastSlot = self._initTempList(maxoverlaping, None)
1572           
1573            for slot in day.getSlotList():               
1574                tempList = self._initTempList(maxoverlaping, """<td></td>""")
1575                containerHeader = self._initTempList(maxoverlaping, """<td></td>""")
1576                containerFooter = self._initTempList(maxoverlaping, """<td></td>""")
1577                thisSlot = self._initTempList(maxoverlaping, None)
1578
1579                for container in slot.getContainerList():
1580                    containerIndex.addContainer(container)
1581                    bgcolorSlot = self._getColor(container)
1582                    # --- Getting header and footer for the container
1583                    ind = containerIndex.getStartPosition(container)
1584                   
1585                    # ---.
1586                    entryList = slot.getContainerEntries(container)
1587                    containerIndex.setContainerEntries(container, entryList)
1588                    for i in range(0, containerIndex.getMaxOverlap(container)):
1589                        entry = containerIndex.getEntryByPosition(container, i)
1590                        entryIndex = containerIndex.getEntryIndex(container, i)
1591                        thisSlot[entryIndex] = entry
1592                        # --- if an entry has already added, it is not added again because it was done a rowspan
1593                        if entry and (entry in lastEntries):
1594                            tempList[entryIndex] = ""
1595                            continue
1596                        # ---.
1597                        bgcolorContrib=self._getColor(entry)
1598                        # ---.
1599                        # --- Getting the HTML for an entry:
1600                        rowspan = day.getNumContainerSlots(entry)
1601                        if entry:
1602                            if slot.hasHeaders() and slot.isFirstSlotEntry(entry):
1603                                rowspan -= 1
1604                            if container.isFinalEntry(entry, day.getLastContainerSlot(container), confTZ):
1605                                rowspan -= 1
1606                            room = ""
1607                            if container.getRoom() != None and container.getRoom().getName().strip() != "":
1608                                room = container.getRoom().getName()
1609                               
1610                            entryParams = {}
1611                            entryParams['bgcolor'] = bgcolorContrib;
1612                            entryParams['rowspan'] = rowspan;
1613                            entryParams['colspan'] = '';
1614                            entryParams['width'] = width;
1615                               
1616                            temp = self._getEntryHTML(entry, days, room, params=entryParams)
1617                        else:
1618                            # --- Getting header for the broken slots among days and for starting of slots
1619                            temp = """<td valign="top" align="center" width="%s%%">&nbsp;
1620                                      </td>"""%width
1621                        # ---.
1622                        tempList[entryIndex] = temp
1623                        lastEntries.append(entry)
1624
1625                # ---.
1626                if slot.getAdjustedStartDate().minute==0:
1627                    timecol = """<td style="border-top:2px solid #E6E6E6;border-left:2px solid #E6E6E6" valign="top" bgcolor="white" width="40">
1628                                    <font color="gray" size="-1">%s</font>
1629                                 </td>"""%slot.getAdjustedStartDate().strftime("%H:%M")
1630                else:
1631                    timecol = """<td style="border-left:2px solid #E6E6E6" bgcolor="white" width="40">&nbsp;</td>"""
1632                stri = """
1633                            <tr>
1634                                %s
1635                                %s
1636                            </tr>"""%( timecol, \
1637                                    "".join(tempList))
1638                slotList.append(stri)
1639                lastSlot = thisSlot[:]
1640           
1641            urlNewSlot = urlHandlers.UHSessionModSlotNew.getURL(self._session)
1642            urlNewSlot.addParam("slotDate", day.getDate().strftime("%d-%m-%Y"))
1643            newSlotBtn=""
1644            if self._session.canModify(self._aw) or self._session.canCoordinate(self._aw, "unrestrictedSessionTT"):
1645                if self._session.getConference().getEnableSessionSlots() :
1646                    newSlotBtn=_("""<input type="submit" class="btn" value="_("new slot")">""")
1647            stri="""
1648                <table>
1649                    <tr>
1650
1651                    </tr>
1652                    %s
1653                </table>"""%("".join(slotList))
1654            daySch.append(stri)
1655        return "<br>".join(daySch)
1656
1657           
1658    def getVars( self ):
1659        vars=wcomponents.WTemplated.getVars(self)
1660       
1661        self._conf = self._session.getConference()
1662       
1663        sessions = {}
1664       
1665        #self._days = vars["days"]
1666       
1667        sList = self._conf.getSessionList()
1668   
1669        for d in self._days:           
1670            for s in sList:                       
1671                if  s.getAdjustedStartDate().date() <= d.getDate().date() and \
1672                    s.getAdjustedEndDate().date() >= d.getDate().date():
1673                    sessions[s.getId()] = s
1674               
1675        vars["daysParam"] = vars.get('days')
1676        vars["sessionList"] = sessions               
1677        vars["session"]=self._session.getId()
1678       
1679        vars["slotList"] = self._session.slots
1680        slot = vars.get("slot",None)
1681       
1682        if slot:           
1683            self._slot = self._session.getSlotById(slot)
1684        else:
1685            # by default, present the user with the first slot
1686            self._slot = self._session.getSlotList()[0]
1687       
1688        vars["slot"] = self._slot       
1689       
1690        vars["slots"]=self._getScheduleHTML(vars["daysParam"])
1691       
1692        sDate,eDate=self._session.getAdjustedStartDate(),self._session.getAdjustedEndDate()
1693        if sDate.strftime("%Y%b%d")==eDate.strftime("%Y%b%d"):
1694            vars["dateInterval"]=self.htmlText("%s-%s"%(sDate.strftime("%Y-%b-%d %H:%M"),eDate.strftime("%H:%M")))
1695        else:
1696            vars["dateInterval"]=self.htmlText("%s/%s"%(sDate.strftime("%Y-%b-%d %H:%M"),eDate.strftime("%Y-%b-%d %H:%M")))
1697        vars["start_date"] = self._session.getAdjustedStartDate().strftime("%a %d %b %Y %H:%M")
1698        vars["end_date"] = self._session.getAdjustedEndDate().strftime("%a %d %b %Y %H:%M")
1699        vars["place"]=""
1700        if self._session.getLocation() is not None:
1701            vars["place"]=self.htmlText(self._session.getLocation().getName())
1702        vars["start_date"] = self._session.getAdjustedStartDate().strftime("%a %d %b %Y %H:%M")
1703        vars["end_date"] = self._session.getAdjustedEndDate().strftime("%a %d %b %Y %H:%M")
1704        vars["editURL"] = str(urlHandlers.UHSessionModFit.getURL(self._session))
1705        vars["dayDate"]=self._days[0].getDate()
1706       
1707        if self._session.getConference().getEnableSessionSlots() :
1708            vars["fitToInnerSlots"] = """<input type="submit" class="btn" value="fit inner timetable">"""
1709        else :
1710            editURL = urlHandlers.UHSessionDatesModification.getURL(self._session)
1711            vars["fitToInnerSlots"] = """<input type="submit" class="btn" value="fit inner timetable"><input type="submit" class="btn" value="modify dates" onClick="this.form.action='%s';">""" % editURL
1712
1713        vars['rbActive'] = info.HelperMaKaCInfo.getMaKaCInfoInstance().getRoomBookingModuleActive()
1714
1715        return vars
1716
1717
1718       
1719
1720class ContainerIndexItem:
1721
1722    def __init__(self, container, day):
1723        self._overlap = container.getMaxOverlap(day)
1724        self._startPosition = -1
1725        self._entryList = []
1726        for i in range(0,self._overlap):
1727            self._entryList.append(None)
1728   
1729    def setStartPosition(self, counter):
1730        self._startPosition = counter
1731
1732    def getStartPosition(self):
1733        return self._startPosition
1734
1735    def setEntryList(self, newEntryList):
1736        # -- Remove the ones which are not in the new entry list
1737        i = 0
1738        for entry in self._entryList:
1739            if entry not in newEntryList:
1740                self._entryList[i] = None
1741            i += 1
1742        # -- Add the new ones to the new entry list
1743        for newEntry in newEntryList:
1744            if newEntry not in self._entryList:
1745                i = 0
1746                for entry in self._entryList:
1747                    if entry == None:
1748                        self._entryList[i] = newEntry
1749                        break
1750                    i += 1
1751
1752    def getEntryIndex(self, i):
1753        return self._startPosition + i
1754
1755    def getEntryByPosition(self, i):
1756        if i >= 0 and i < len(self._entryList):
1757            return self._entryList[i]
1758        return 0
1759
1760    def getOverlap(self):
1761        return self._overlap
1762
1763class ContainerIndex:
1764
1765    def __init__(self, containerIndex = {}, day = None, hasOverlap = False):
1766        self._containerIndex = containerIndex
1767        self._day = day
1768        self._rowsCounter = 0
1769        self._hasOverlap = hasOverlap
1770
1771    def initialization(self, day, hasOverlap = False):
1772        self._containerIndex={}
1773        self._day = day
1774        self._rowsCounter = 0
1775        self._hasOverlap = hasOverlap
1776
1777    def hasOverlap(self):
1778        return self._hasOverlap
1779
1780    def setHasOverlap(self, hasOverlap):
1781        self._hasOverlap = hasOverlap
1782
1783    def addContainer(self, container):
1784        if not self._containerIndex.has_key(container):
1785            item = ContainerIndexItem(container, self._day)
1786            item.setStartPosition(self._rowsCounter)
1787            if self.hasOverlap():
1788                self._rowsCounter += item.getOverlap()
1789            self._containerIndex[container] = item
1790
1791    def setContainerEntries(self, container, entryList):
1792        if self._containerIndex.has_key(container):
1793            self._containerIndex[container].setEntryList(entryList)
1794
1795    def getEntryIndex(self, container, i):
1796        if self._containerIndex.has_key(container):
1797            contItem = self._containerIndex[container]
1798            return contItem.getEntryIndex(i)
1799        return 0
1800   
1801    def getEntryByPosition(self, container, i):
1802        if self._containerIndex.has_key(container):
1803            contItem = self._containerIndex[container]
1804            return contItem.getEntryByPosition(i)
1805        return 0
1806
1807    def getMaxOverlap(self, container):
1808        if self._containerIndex.has_key(container):
1809            contItem = self._containerIndex[container]
1810            return contItem.getOverlap()
1811        return 0
1812
1813    def getStartPosition(self, container):
1814        if self._containerIndex.has_key(container):
1815            contItem = self._containerIndex[container]
1816            return contItem.getStartPosition()
1817        return 0
1818           
1819
1820class WPSessionModifyBreak( WPSessionModifSchedule ):
1821   
1822    def __init__(self,rh,conf,schBreak):
1823        WPSessionModifSchedule.__init__(self,rh,conf)
1824        self._break=schBreak
1825   
1826    def _getScheduleContent(self,params):
1827        sch=self._conf.getSchedule()
1828        wc=wcomponents.WBreakDataModification(sch,self._break,conf=self._conf)
1829        pars = { "postURL": urlHandlers.UHSessionPerformModifyBreak.getURL(self._break) }
1830        params["body"] = wc.getHTML( pars )
1831        return wcomponents.WBreakModifHeader( self._break, self._getAW() ).getHTML( params )
1832
1833   
1834
1835class WPModSchEditContrib(WPSessionModifSchedule):
1836   
1837    def __init__(self,rh,contrib):
1838        WPSessionModifSchedule.__init__(self,rh,contrib.getSession())
1839        self._contrib=contrib
1840   
1841    def _getTabContent(self,params):
1842        if self._contrib.getSession().getScheduleType() == "poster":
1843            wc=WSessionModContribListEditContrib(self._contrib)
1844        else:
1845            wc=wcomponents.WSchEditContrib(self._contrib)
1846        pars={"postURL":urlHandlers.UHSessionModSchEditContrib.getURL(self._contrib)}
1847        return wc.getHTML(pars)
1848
1849class WSessionAddSlot(wcomponents.WTemplated):
1850   
1851    def __init__(self, slotData , conf, errors=[]):
1852        self._session = slotData.getSession()
1853        self._slotData = slotData
1854        self._errors=errors
1855        self._conf = conf
1856
1857    def _getConvenersHTML(self):
1858        res=[]
1859        for conv in self._slotData.getConvenerList():
1860            tmp= _("""
1861                    <tr>
1862                        <td style="border-top:1px solid #777777;border-left:1px solid #777777;" width="100%%">
1863                            <input type="checkbox" name="sel_conv" value=%s>
1864                            <input type="hidden" name="conv_id" value=%s>
1865                        </td>
1866                        <td style="border-top:1px solid #777777;padding-top:2px" width="100%%">
1867                            <table border="0" width="95%%" cellpadding="0" cellspacing="0">
1868                                <tr>
1869                                    <td>&nbsp;</td>
1870                                </tr>
1871                                <tr>
1872                                    <td nowrap>
1873                                         _("Title") <select name="conv_title">%s</select>
1874                                    </td>
1875                                </tr>
1876                                <tr>
1877                                    <td nowrap>
1878                                         _("Family name") <input type="text" size="40" name="conv_family_name" value=%s>
1879                                         _("First name") <input type="text" size="30" name="conv_first_name" value=%s>
1880                                    </td>
1881                                </tr>
1882                                <tr>
1883                                    <td nowrap>
1884                                         _("Affiliation") <input type="text" size="40" name="conv_affiliation" value=%s>
1885                                        _("Email") <input type="text" size="39" name="conv_email" value=%s>
1886                                    </td>
1887                                </tr>
1888                            </table>
1889                        </td>
1890                    </tr>
1891                    <tr><td colspan="3">&nbsp;</td></tr>
1892                """)%(quoteattr(str(conv.getId())),\
1893                    quoteattr(str(conv.getId())),\
1894                    TitlesRegistry.getSelectItemsHTML(conv.getTitle()), \
1895                    quoteattr(conv.getFamilyName()),\
1896                    quoteattr(conv.getFirstName()), \
1897                    quoteattr(conv.getAffiliation()), \
1898                    quoteattr(conv.getEmail()) )
1899            res.append(tmp)
1900        return "".join(res)
1901
1902    def _getErrorHTML( self, msgList ):
1903        if not msgList:
1904            return ""
1905        return """
1906            <table align="center" cellspacing="0" cellpadding="0">
1907                <tr>
1908                    <td>
1909                        <table align="center" valign="middle" style="padding:10px; border:1px solid #5294CC; background:#F6F6F6">
1910                            <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
1911                            <tr>
1912                                <td>&nbsp;</td>
1913                                <td><font color="red">%s</font></td>
1914                                <td>&nbsp;</td>
1915                            </tr>
1916                            <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
1917                        </table>
1918                    </td>
1919                </tr>
1920            </table>
1921                """%"<br>".join( msgList )
1922   
1923   
1924    def getVars(self):
1925        vars = wcomponents.WTemplated.getVars(self)
1926        vars["calendarIconURL"]=Config.getInstance().getSystemIconURL( "calendar" )
1927        vars["calendarSelectURL"]=urlHandlers.UHSimpleCalendar.getURL()
1928        defaultDefinePlace = defaultDefineRoom = ""
1929        defaultInheritPlace = defaultInheritRoom = "checked"
1930        locationName, locationAddress, roomName,defaultExistRoom = "", "", "",""
1931        slotSd = self._slotData.getStartDate()
1932        slotEd = self._slotData.getEndDate()
1933        vars["title"]=self._slotData.getTitle()
1934        vars["sDay"] = slotSd.day
1935        vars["sMonth"] = slotSd.month
1936        vars["sYear"] = slotSd.year
1937        vars["sHour"] = slotSd.hour
1938        vars["sMinute"] = slotSd.minute
1939        vars["eDay"] = slotEd.day
1940        vars["eMonth"] = slotEd.month
1941        vars["eYear"] = slotEd.year
1942        vars["eHour"] = slotEd.hour
1943        vars["eMinute"] = slotEd.minute
1944        vars["contribDurHours"] = ""
1945        vars["contribDurMins"] = ""
1946        if self._slotData.getContribDuration() != None:
1947            vars["contribDurHours"] = (datetime(1900,1,1)+self._slotData.getContribDuration()).hour
1948            vars["contribDurMins"] = (datetime(1900,1,1)+self._slotData.getContribDuration()).minute
1949        if self._slotData.getLocationName() !="":
1950            defaultDefinePlace = "checked"
1951            defaultInheritPlace = ""
1952            locationName = self._slotData.getLocationName()
1953            locationAddress = self._slotData.getLocationAddress()
1954        if self._slotData.getRoomName() != "":
1955            defaultDefineRoom= "checked"
1956            defaultInheritRoom = ""
1957            defaultExistRoom = ""
1958            roomName = self._slotData.getRoomName()
1959        vars["defaultInheritPlace"] = defaultInheritPlace
1960        vars["defaultDefinePlace"] = defaultDefinePlace
1961        vars["sesPlace"] = ""
1962        sesLocation = self._slotData.getSession().getLocation()
1963        if sesLocation:
1964            vars["sesPlace"] = sesLocation.getName()
1965        vars["locationName"] = locationName
1966        vars["locationAddress"] = locationAddress
1967        vars["defaultInheritRoom"] = defaultInheritRoom
1968        vars["defaultDefineRoom"] = defaultDefineRoom
1969        vars["defaultExistRoom"]= defaultExistRoom
1970        vars["sesRoom"] = ""
1971        sesRoom = self._slotData.getSession().getRoom()
1972        if sesRoom:
1973            vars["sesRoom"] = sesRoom.getName()
1974        vars["roomName"] = roomName
1975        vars["conveners"]=self._getConvenersHTML()
1976        vars["postURL"]=quoteattr(str(urlHandlers.UHSessionModSlotNew.getURL(self._session)))
1977        vars["errors"]=self._getErrorHTML(self._errors)
1978        rx=[]
1979        roomsexist = self._conf.getRoomList()
1980        roomsexist.sort()
1981        for room in roomsexist:
1982            sel=""
1983            rx.append("""<option value=%s%s>%s</option>"""%(quoteattr(str(room)),
1984                        sel,self.htmlText(room)))
1985        vars ["roomsexist"] = "".join(rx)
1986        if not self._conf.getAutoSolveConflict():
1987            vars["autoUpdate"]= _("""<input type="checkbox" name="check" value="2"> _("Update parents dates")""")
1988        else:
1989            vars["autoUpdate"]=""
1990        return vars
1991
1992
1993class WPModSlotNew(WPSessionModifSchedule):
1994
1995    def __init__(self, rh, slotData, errors=[] ):
1996        WPSessionModifSchedule.__init__(self, rh, slotData.getSession())
1997        self._slotData = slotData
1998        self._errors=errors
1999       
2000   
2001    def _getTabContent( self, params ):
2002        wc=WSessionAddSlot(self._slotData, self._conf, self._errors)
2003        return wc.getHTML()
2004
2005class WSlotModifMainData(wcomponents.WTemplated):
2006   
2007    def __init__(self, slot, conf, errors=[]):
2008        self._slotData = slot
2009        self._errors=errors
2010        self._conf = conf
2011
2012    def _getConvenersHTML(self):
2013        res=[]
2014        for conv in self._slotData.getConvenerList():
2015            tmp= _("""
2016                    <tr>
2017                        <td style="border-top:1px solid #777777;border-left:1px solid #777777;" width="100%%">
2018                            <input type="checkbox" name="sel_conv" value=%s>
2019                            <input type="hidden" name="conv_id" value=%s>
2020                        </td>
2021                        <td style="border-top:1px solid #777777;padding-top:2px" width="100%%">
2022                            <table border="0" width="95%%" cellpadding="0" cellspacing="0">
2023                                <tr>
2024                                    <td>&nbsp;</td>
2025                                </tr>
2026                                <tr>
2027                                    <td nowrap>
2028                                         _("Title") <select name="conv_title">%s</select>
2029                                    </td>
2030                                </tr>
2031                                <tr>
2032                                    <td nowrap>
2033                                         _("Family name") <input type="text" size="40" name="conv_family_name" value=%s>
2034                                         _("First name") <input type="text" size="30" name="conv_first_name" value=%s>
2035                                    </td>
2036                                </tr>
2037                                <tr>
2038                                    <td nowrap>
2039                                         _("Affiliation") <input type="text" size="40" name="conv_affiliation" value=%s>
2040                                         _("Email") <input type="text" size="39" name="conv_email" value=%s>
2041                                    </td>
2042                                </tr>
2043                            </table>
2044                        </td>
2045                    </tr>
2046                    <tr><td colspan="3">&nbsp;</td></tr>
2047                """)%(quoteattr(str(conv.getId())),\
2048                    quoteattr(str(conv.getId())),\
2049                    TitlesRegistry.getSelectItemsHTML(conv.getTitle()), \
2050                    quoteattr(conv.getFamilyName()),\
2051                    quoteattr(conv.getFirstName()), \
2052                    quoteattr(conv.getAffiliation()), \
2053                    quoteattr(conv.getEmail()) )
2054            res.append(tmp)
2055        return "".join(res)
2056
2057    def _getErrorHTML( self, msgList ):
2058        if not msgList:
2059            return ""
2060        return """
2061            <table align="center" cellspacing="0" cellpadding="0">
2062                <tr>
2063                    <td>
2064                        <table align="center" valign="middle" style="padding:10px; border:1px solid #5294CC; background:#F6F6F6">
2065                            <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
2066                            <tr>
2067                                <td>&nbsp;</td>
2068                                <td><font color="red">%s</font></td>
2069                                <td>&nbsp;</td>
2070                            </tr>
2071                            <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
2072                        </table>
2073                    </td>
2074                </tr>
2075            </table>
2076                """%"<br>".join( msgList )
2077   
2078    def getVars(self):
2079        vars = wcomponents.WTemplated.getVars(self)
2080        vars["calendarIconURL"]=Config.getInstance().getSystemIconURL( "calendar" )
2081        vars["calendarSelectURL"]=urlHandlers.UHSimpleCalendar.getURL()
2082        defaultDefinePlace = defaultDefineRoom = ""
2083        defaultInheritPlace = defaultInheritRoom = "checked"
2084        locationName, locationAddress, roomName, defaultExistRoom = "", "", "",""
2085        vars["conference"] = self._conf
2086        vars["session"] = self._slotData.getSession()
2087        minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
2088        vars["useRoomBookingModule"] = minfo.getRoomBookingModuleActive()
2089        vars["title"]=self._slotData.getTitle()
2090        sd = self._slotData.getAdjustedStartDate()
2091        ed = self._slotData.getAdjustedEndDate()
2092        vars["sDay"] = sd.day
2093        vars["sMonth"] = sd.month
2094        vars["sYear"] = sd.year
2095        vars["sHour"] = sd.hour
2096        vars["sMinute"] = sd.minute
2097        vars["eDay"] = ed.day
2098        vars["eMonth"] = ed.month
2099        vars["eYear"] = ed.year
2100        vars["eHour"] = ed.hour
2101        vars["eMinute"] = ed.minute
2102        vars["contribDurHours"] = ""
2103        vars["contribDurMins"] = ""
2104        if self._slotData.getContribDuration() != None:
2105            vars["contribDurHours"] = (datetime(1900,1,1)+self._slotData.getContribDuration()).hour
2106            vars["contribDurMins"] = (datetime(1900,1,1)+self._slotData.getContribDuration()).minute
2107        if self._slotData.getLocationName() !="":
2108            defaultDefinePlace = "checked"
2109            defaultInheritPlace = ""
2110            locationName = self._slotData.getLocationName()
2111            locationAddress = self._slotData.getLocationAddress()
2112        if self._slotData.getRoomName() != "":
2113            defaultDefineRoom= "checked"
2114            defaultInheritRoom = ""
2115            defaultExistRoom = ""
2116            roomName = self._slotData.getRoomName()
2117        vars["defaultInheritPlace"] = defaultInheritPlace
2118        vars["defaultDefinePlace"] = defaultDefinePlace
2119        vars["sesPlace"] = ""
2120        sesLocation = self._slotData.getSession().getLocation()
2121        if sesLocation:
2122            vars["sesPlace"] = sesLocation.getName()
2123        vars["locationName"] = locationName
2124        vars["locationAddress"] = locationAddress
2125        vars["defaultInheritRoom"] = defaultInheritRoom
2126        vars["defaultDefineRoom"] = defaultDefineRoom
2127        vars["defaultExistRoom"] = defaultExistRoom
2128        vars["sesRoom"] = ""
2129        sesRoom = self._slotData.getSession().getRoom()
2130        if sesRoom:
2131            vars["sesRoom"] = sesRoom.getName()
2132        vars["roomName"] = roomName
2133        rx=[]
2134        roomsexist = self._conf.getRoomList()
2135        roomsexist.sort()
2136        for room in roomsexist:
2137            rx.append("""<option value=%s>%s</option>"""%(quoteattr(str(room)),
2138                        self.htmlText(room)))
2139        vars ["roomsexist"] = "".join(rx)
2140        vars["conveners"]=self._getConvenersHTML()
2141        vars["errors"]=self._getErrorHTML(self._errors)
2142        vars["locator"] = ""   
2143        slot = self._slotData.getSession().getSlotById(self._slotData.getId())
2144        vars["locator"] = slot.getLocator().getWebForm()
2145        vars["postURL"]=quoteattr(str(urlHandlers.UHSessionModSlotEdit.getURL(slot)))
2146        if not self._conf.getAutoSolveConflict():
2147            vars["autoUpdate"]= _("""<input type="checkbox" name="check" value="2"> _("Update parents dates")""")
2148        else:
2149            vars["autoUpdate"]=""
2150        return vars
2151
2152
2153class WPModSlotEdit(WPConferenceModifBase):
2154   
2155    def __init__(self,rh, slot, errors=[]):
2156        WPConferenceModifBase.__init__(self,rh,slot.getSession().getConference())
2157        self._slotData=slot
2158        self._errors=errors
2159
2160    def _setActiveSideMenuItem(self):
2161        self._timetableMenuItem.setActive()
2162
2163    def _getPageContent( self, params ):
2164        wc=WSlotModifMainData(self._slotData,self._conf,self._errors)
2165        return wc.getHTML() 
2166
2167class WSchModifRecalculate(wcomponents.WTemplated):
2168   
2169    def __init__(self, entry):
2170        self._entry = entry
2171
2172    def getVars(self):
2173        vars = wcomponents.WTemplated.getVars(self)
2174        vars["entryType"]="slot" 
2175        vars["title"]=""
2176        if self._entry.getTitle().strip() != "":
2177            vars["title"]= _("""
2178                            <tr>
2179                                <td nowrap class="titleCellTD"><span class="titleCellFormat"> _("Title")</span></td>
2180                                <td bgcolor="white" width="100%%">&nbsp;%s</td>
2181                            </tr>
2182                            """)%self._entry.getTitle()
2183        return vars
2184
2185class WPModSlotCalc(WPConferenceModifBase):
2186   
2187    def __init__(self,rh, slot):
2188        WPConferenceModifBase.__init__(self,rh,slot.getSession().getConference())
2189        self._slot=slot
2190
2191    def _setActiveSideMenuItem(self):
2192        self._timetableMenuItem.setActive()
2193
2194    def _getPageContent( self, params ):
2195        wc=WSchModifRecalculate(self._slot)
2196        p={"postURL":quoteattr(str(urlHandlers.UHSessionModSlotCalc.getURL(self._slot)))}
2197        return wc.getHTML(p) 
2198
2199class WPModSlotRemConfirmation(WPSessionModifSchedule):
2200   
2201    def __init__(self,rh,slot):
2202        WPSessionModifSchedule.__init__(self,rh,slot.getSession())
2203        self._slot=slot
2204
2205    def _getTabContent(self,params):
2206        wc=wcomponents.WConfirmation()
2207        slotCaption="on %s %s-%s"%(
2208            self._slot.getAdjustedStartDate().strftime("%A %d %B %Y"),
2209            self._slot.getAdjustedStartDate().strftime("%H:%M"),
2210            self._slot.getAdjustedEndDate().strftime("%H:%M"))
2211        if self._slot.getTitle()!="":
2212            slotCaption=""" "%s" (%s) """%(self._slot.getTitle(),slotCaption)
2213       
2214        msg= _("""Are you sure you want to delete the slot %s 
2215        (note that any contribution scheduled
2216        inside will be unscheduled)?""")%(slotCaption)
2217        url=urlHandlers.UHSessionModSlotRem.getURL(self._slot)
2218        return wc.getHTML(msg,url,{})
2219
2220
2221class WPModScheduleAddContrib(WPSessionModifSchedule):
2222   
2223    def _getTabContent( self, params ):
2224        target=self._session
2225        if params.get("slot",None) is not None:
2226            target=params["slot"]
2227        l=[]
2228        for contrib in self._session.getContributionList():
2229            if contrib.isScheduled() or isinstance(contrib.getCurrentStatus(),conference.ContribStatusWithdrawn):
2230                continue
2231            l.append(contrib)
2232        p=wcomponents.WScheduleAddContributions(l)
2233        pars={"postURL":urlHandlers.UHSessionModScheduleAddContrib.getURL(target)}
2234        return p.getHTML(pars)
2235
2236class WPModScheduleNewContrib(WPModScheduleNewContribBase, WPSessionModifSchedule):
2237   
2238    def __init__(self, rh, ses, targetDay):
2239        WPSessionModifSchedule.__init__(self, rh, ses)
2240        WPModScheduleNewContribBase.__init__(self, targetDay)
2241   
2242class WSessionModifSchContribCreation(WContributionCreation):
2243
2244    def __init__(self, slot):
2245        WContributionCreation.__init__(self, slot.getConference())
2246        self._slot = slot
2247
2248    def getVars(self):
2249        vars=WContributionCreation.getVars(self)
2250        if self._slot is not None:
2251            d=self._slot.getSchedule().calculateDayEndDate(self._slot.getAdjustedStartDate())
2252            vars["day"]=d.day
2253            vars["month"]=d.month
2254            vars["year"]=d.year
2255            vars["sHour"]=d.hour
2256            vars["sMinute"]=d.minute
2257            vars["durationHours"],vars["durationMinutes"]="0","20"
2258            vars["poster"]=""
2259            if self._slot.getSession().getScheduleType() == "poster":
2260                vars["poster"]="disabled"
2261        return vars
2262
2263
2264class WPSessionAddBreak(WPSessionModifSchedule):
2265   
2266    def __init__(self,rh,slot):
2267        WPSessionModifSchedule.__init__(self,rh,slot.getSession())
2268        self._slot=slot
2269   
2270    def _getTabContent( self, params ):
2271        s = self._slot.getSchedule()
2272        day = self._slot.getAdjustedStartDate()
2273        p=wcomponents.WBreakDataModification(self._slot.getSchedule(),conf=self._slot.getConference(),targetDay=day)
2274        pars = {"postURL":urlHandlers.UHSessionAddBreak.getURL(self._slot)}
2275        return p.getHTML(pars)
2276
2277
2278
2279class WSessionModifAC(wcomponents.WTemplated):
2280   
2281    def __init__(self,session):
2282        self._session=session
2283   
2284    def _getCoordinatorsHTML(self):
2285        res = wcomponents.WPrincipalTable().getHTML( list(self._session.getCoordinatorList()), self._session, str(urlHandlers.UHSessionModCoordinatorsSel.getURL()), str(urlHandlers.UHSessionModCoordinatorsRem.getURL()), pendings=self._session.getCoordinatorEmailList(), selectable=False )
2286        return res
2287   
2288    def getVars(self):
2289        vars=wcomponents.WTemplated.getVars(self)
2290        wc=wcomponents.WAccessControlFrame()
2291        vars["accessControlFrame"]=wc.getHTML(self._session,\
2292                                urlHandlers.UHSessionSetVisibility.getURL(),\
2293                                urlHandlers.UHSessionSelectAllowed.getURL(),\
2294                                urlHandlers.UHSessionRemoveAllowed.getURL())
2295        if not self._session.isProtected():
2296            df=wcomponents.WDomainControlFrame(self._session)
2297            vars["accessControlFrame"] += "<br>%s"%df.getHTML( \
2298                                    urlHandlers.UHSessionAddDomains.getURL(),\
2299                                    urlHandlers.UHSessionRemoveDomains.getURL())
2300        wc=wcomponents.WModificationControlFrame()
2301        vars["modifyControlFrame"]=wc.getHTML(self._session,\
2302                                urlHandlers.UHSessionSelectManagers.getURL(),\
2303                                urlHandlers.UHSessionRemoveManagers.getURL() )
2304        vars["coordinators"]=self._getCoordinatorsHTML()
2305        return vars
2306
2307
2308class WPSessionModifAC( WPSessionModifBase ):
2309   
2310    def _setActiveTab( self ):
2311        self._tabAC.setActive()
2312   
2313    def _getTabContent( self, params ):
2314        comp=WSessionModifAC(self._session)
2315        return comp.getHTML()
2316
2317
2318class WPSessionSelectAllowed( WPSessionModifAC ):
2319   
2320    def _getTabContent( self, params ):
2321        searchExt = params.get("searchExt","")
2322        if searchExt != "":
2323            searchLocal = False
2324        else:
2325            searchLocal = True
2326        wc = wcomponents.WPrincipalSelection( urlHandlers.UHSessionSelectAllowed.getURL(),forceWithoutExtAuth=searchLocal )
2327        params["addURL"] = urlHandlers.UHSessionAddAllowed.getURL()
2328        return wc.getHTML( params )
2329
2330
2331class WPSessionSelectManagers( WPSessionModifAC ):
2332   
2333    def _getTabContent( self, params ):
2334        searchExt = params.get("searchExt","")
2335        if searchExt != "":
2336            searchLocal = False
2337        else:
2338            searchLocal = True
2339        wc = wcomponents.WPrincipalSelection( urlHandlers.UHSessionSelectManagers.getURL(), addTo=3,forceWithoutExtAuth=searchLocal)
2340        params["addURL"] = urlHandlers.UHSessionAddManagers.getURL()
2341        return wc.getHTML( params )
2342
2343
2344class WPModCoordinatorsSel(WPSessionModifAC):
2345   
2346    def _getTabContent(self,params):
2347        searchExt = params.get("searchExt","")
2348        if searchExt != "":
2349            searchLocal = False
2350        else:
2351            searchLocal = True
2352        url=urlHandlers.UHSessionModCoordinatorsSel.getURL()
2353        wc =wcomponents.WPrincipalSelection(url, addTo=3,forceWithoutExtAuth=searchLocal)
2354        wc.setTitle( _("Selecting session coordinators") )
2355        params["addURL"]=urlHandlers.UHSessionModCoordinatorsAdd.getURL()
2356        return wc.getHTML( params )
2357
2358
2359class WSessionModifTools(wcomponents.WTemplated):
2360   
2361    def __init__( self, session ):
2362        self.__session = session
2363   
2364    def getVars( self ):
2365        vars = wcomponents.WTemplated.getVars( self )
2366        vars["deleteIconURL"] = Config.getInstance().getSystemIconURL("delete")
2367        vars["writeIconURL"] = Config.getInstance().getSystemIconURL("write_minutes")
2368        vars["closeIconURL"] = Config.getInstance().getSystemIconURL("closeIcon")
2369        vars["closeURL"] = urlHandlers.UHSessionClose.getURL(self.__session)
2370        return vars
2371
2372
2373class WPSessionModifComm( WPSessionModifBase ):
2374   
2375    def _setActiveTab( self ): 
2376        self._tabComm.setActive()
2377   
2378    def _getTabContent( self, params ):
2379        wc = wcomponents.WSessionModifComm( self._getAW(),self._session )
2380        pars = { 
2381                "editCommentsURLGen":urlHandlers.UHSessionModifCommEdit.getURL
2382               }
2383        return wc.getHTML( pars )
2384
2385
2386class WPSessionCommEdit( WPSessionModifBase ):
2387       
2388    def _setActiveTab( self ): 
2389        self._tabComm.setActive()
2390
2391    def _getTabContent(self,params):
2392        self._comment = self._session.getComments()
2393        wc = wcomponents.WSessionModifCommEdit(self._comment)
2394        p={"postURL":urlHandlers.UHSessionModifCommEdit.getURL(self._session)}
2395        return wc.getHTML(p)
2396
2397
2398
2399class WPSessionModifTools( WPSessionModifBase ):
2400   
2401    def _setActiveTab( self ):
2402        self._tabTools.setActive()
2403   
2404    def _getTabContent( self, params ):
2405        comp = WSessionModifTools( self._session )
2406        pars = { 
2407"deleteSessionURL": urlHandlers.UHSessionDeletion.getURL( self._session ), \
2408"writeMinutesURL": urlHandlers.UHSessionWriteMinutes.getURL( self._session ) \
2409               }
2410        return comp.getHTML( pars )
2411
2412
2413class WPSessionDeletion( WPSessionModifTools ):
2414   
2415    def _getTabContent( self, params ):
2416        msg = _("""
2417        <font size="+2">_("Are you sure that you want to DELETE the session '%s'")?</font><br>(_("Note that if you delete the
2418session, all the items below it will also be deleted"))
2419              """)%(self._session.getTitle())
2420        wc = wcomponents.WConfirmation()
2421        return wc.getHTML( msg, \
2422                        urlHandlers.UHSessionDeletion.getURL( self._session ), \
2423                        {}, \
2424                        confirmButtonCaption= _("Yes"), cancelButtonCaption= _("No") )
2425
2426
2427class WPSessionWriteMinutes( WPSessionModifTools ):
2428   
2429    def _getTabContent( self, params ):
2430        wc = wcomponents.WWriteMinutes( self._session )
2431        pars = {"postURL": urlHandlers.UHSessionWriteMinutes.getURL(self._session) }
2432        return wc.getHTML( pars )
2433
2434
2435class WSessionModContribList(wcomponents.WTemplated):
2436
2437    def __init__(self,session,filter,sorting,order, aw):
2438        self._session=session
2439        self._conf=self._session.getConference()
2440        self._filterCrit=filter
2441        self._sortingCrit=sorting
2442        self._order = order
2443        self._totaldur =timedelta(0)
2444        self._aw=aw
2445
2446    def _getURL( self ):
2447        #builds the URL to the contribution list page
2448        #   preserving the current filter and sorting status
2449        url = urlHandlers.UHSessionModContribList.getURL(self._session)
2450        if self._filterCrit.getField("type"):
2451            l=[]
2452            for t in self._filterCrit.getField("type").getValues():
2453                if t!="":
2454                    l.append(t)
2455            url.addParam("types",l)
2456            if self._filterCrit.getField("type").getShowNoValue():
2457                url.addParam("typeShowNoValue","1")
2458
2459        if self._filterCrit.getField("track"):
2460            url.addParam("tracks",self._filterCrit.getField("track").getValues())
2461            if self._filterCrit.getField("track").getShowNoValue():
2462                url.addParam("trackShowNoValue","1")
2463
2464        if self._filterCrit.getField("status"):
2465            url.addParam("status",self._filterCrit.getField("status").getValues())
2466
2467        if self._filterCrit.getField("material"):
2468            url.addParam("material",self._filterCrit.getField("material").getValues())
2469
2470        if self._sortingCrit.getField():
2471            url.addParam("sortBy",self._sortingCrit.getField().getId())
2472            url.addParam("order","down")
2473        url.addParam("OK","1")
2474        return url
2475
2476    def _getMaterialsHTML(self, contrib, matUrlHandler):
2477        materials=[]
2478        if contrib.getPaper() is not None:
2479            url=matUrlHandler.getURL(contrib.getPaper())
2480            iconHTML="""<img border="0" src=%s alt="paper">"""%quoteattr(str(materialFactories.PaperFactory.getIconURL()))
2481            if len(contrib.getPaper().getResourceList())>0:
2482                r=contrib.getPaper().getResourceList()[0]
2483                if isinstance(r,conference.Link):
2484                    iconHTML="""<a href=%s>%s</a>"""%(quoteattr(str(r.getURL())),iconHTML)
2485                elif isinstance(r,conference.LocalFile):
2486                    iconHTML="""<a href=%s>%s</a>"""%(quoteattr(str(urlHandlers.UHFileAccess.getURL(r))),iconHTML)
2487            materials.append("""%s<a href=%s>%s</a>"""%(iconHTML,quoteattr(str(url)),self.htmlText(materialFactories.PaperFactory.getTitle().lower())))
2488        if contrib.getSlides() is not None:
2489            url=matUrlHandler.getURL(contrib.getSlides())
2490            iconHTML="""<img border="0" src=%s alt="slides">"""%quoteattr(str(materialFactories.SlidesFactory.getIconURL()))
2491            if len(contrib.getSlides().getResourceList())>0:
2492                r=contrib.getSlides().getResourceList()[0]
2493                if isinstance(r,conference.Link):
2494                    iconHTML="""<a href=%s>%s</a>"""%(quoteattr(str(r.getURL())),iconHTML)
2495                elif isinstance(r,conference.LocalFile):
2496                    iconHTML="""<a href=%s>%s</a>"""%(quoteattr(str(urlHandlers.UHFileAccess.getURL(r))),iconHTML)
2497            materials.append("""%s<a href=%s>%s</a>"""%(iconHTML,quoteattr(str(url)),self.htmlText(materialFactories.SlidesFactory.getTitle().lower())))
2498        if contrib.getPoster() is not None:
2499            url=matUrlHandler.getURL(contrib.getPoster())
2500            iconHTML="""<img border="0" src=%s alt="slides">"""%quoteattr(str(materialFactories.PosterFactory.getIconURL()))
2501            if len(contrib.getPoster().getResourceList())>0:
2502                r=contrib.getPoster().getResourceList()[0]
2503                if isinstance(r,conference.Link):
2504                    iconHTML="""<a href=%s>%s</a>"""%(quoteattr(str(r.getURL())),iconHTML)
2505                elif isinstance(r,conference.LocalFile):
2506                    iconHTML="""<a href=%s>%s</a>"""%(quoteattr(str(urlHandlers.UHFileAccess.getURL(r))),iconHTML)
2507            materials.append("""%s<a href=%s>%s</a>"""%(iconHTML,quoteattr(str(url)),self.htmlText(materialFactories.PosterFactory.getTitle().lower())))
2508        video=contrib.getVideo()
2509        if video is not None:
2510            materials.append("""<a href=%s><img src=%s border="0" alt="video"> %s</a>"""%(
2511                quoteattr(str(matUrlHandler.getURL(video))),
2512                quoteattr(str(materialFactories.VideoFactory.getIconURL())),
2513                self.htmlText(materialFactories.VideoFactory.getTitle())))
2514        minutes=contrib.getMinutes()
2515        if minutes is not None:
2516            materials.append("""<a href=%s><img src=%s border="0" alt="minutes"> %s</a>"""%(
2517                quoteattr(str(matUrlHandler.getURL(minutes))),
2518                quoteattr(str(materialFactories.MinutesFactory.getIconURL())),
2519                self.htmlText(materialFactories.MinutesFactory.getTitle())))
2520        iconURL=quoteattr(str(Config.getInstance().getSystemIconURL("material")))
2521        for material in contrib.getMaterialList():
2522            url=matUrlHandler.getURL(material)
2523            materials.append("""<a href=%s><img src=%s border="0" alt=""> %s</a>"""%(
2524                quoteattr(str(url)),iconURL,self.htmlText(material.getTitle())))
2525        return "<br>".join(materials)
2526
2527    def _getContribHTML(self,contrib):
2528        sdate = ""
2529        if contrib.getAdjustedStartDate() is not None:
2530            sdate=contrib.getAdjustedStartDate().strftime("%Y-%b-%d %H:%M" )
2531        title = """<a href=%s>%s</a>"""%( quoteattr( str( urlHandlers.UHContributionModification.getURL( contrib ) ) ), self.htmlText( contrib.getTitle() ))
2532        strdur = ""
2533        if contrib.getDuration() is not None and contrib.getDuration().seconds != 0:
2534            strdur = (datetime(1900,1,1)+ contrib.getDuration()).strftime("%Hh%M'")
2535            dur = contrib.getDuration()
2536            self._totaldur = self._totaldur + dur
2537        l = []
2538        for spk in contrib.getSpeakerList():
2539            l.append( self.htmlText( spk.getFullName() ) )
2540        speaker = "<br>".join( l )
2541        track = ""
2542        if contrib.getTrack():
2543            track = self.htmlText( contrib.getTrack().getCode() )
2544        cType=""
2545        if contrib.getType() is not None:
2546            cType=contrib.getType().getName()
2547        status=ContribStatusList().getCode(contrib.getCurrentStatus().__class__)
2548        if self._session.canCoordinate(self._aw,"modifContribs") or self._session.canModify(self._aw):
2549            matUrlHandler=urlHandlers.UHMaterialModification
2550        else:
2551            matUrlHandler=urlHandlers.UHMaterialDisplay
2552        html = """
2553            <tr>
2554                <td><input type="checkbox" name="contributions" value=%s></td>
2555                <td valign="top" class="abstractLeftDataCell" nowrap>%s</td>
2556                <td valign="top" nowrap class="abstractDataCell">%s</td>
2557                <td valign="top" class="abstractDataCell">%s</td>
2558                <td valign="top" class="abstractDataCell">%s</td>
2559                <td valign="top" class="abstractDataCell">%s</td>
2560                <td valign="top" class="abstractDataCell">%s</td>
2561                <td valign="top" class="abstractDataCell">%s</td>
2562                <td valign="top" class="abstractDataCell">%s</td>
2563                <td valign="top" class="abstractDataCell">%s</td>
2564            </tr>
2565                """%(quoteattr(str(contrib.getId())),\
2566                    self.htmlText(contrib.getId()),sdate or "&nbsp;",\
2567                    strdur or "&nbsp;",cType or "&nbsp;",title or "&nbsp;", speaker or "&nbsp;",\
2568                    track or "&nbsp;",status or "&nbsp;", self._getMaterialsHTML(contrib,matUrlHandler) or "&nbsp;")
2569        return html
2570
2571    def _getTypeItemsHTML(self):
2572        checked=""
2573        if self._filterCrit.getField("type").getShowNoValue():
2574            checked=" checked"
2575        res=[ _("""<input type="checkbox" name="typeShowNoValue" value="--none--"%s>--_("not specified")--""")%checked]
2576        for t in self._conf.getContribTypeList():
2577            checked=""
2578            if t.getId() in self._filterCrit.getField("type").getValues():
2579                checked=" checked"
2580            res.append("""<input type="checkbox" name="types" value=%s%s> %s"""%(quoteattr(str(t.getId())),checked,self.htmlText(t.getName())))
2581        return "<br>".join(res)
2582
2583    def _getTrackItemsHTML(self):
2584        checked=""
2585        if self._filterCrit.getField("track").getShowNoValue():
2586            checked=" checked"
2587        res=[ _("""<input type="checkbox" name="trackShowNoValue" value="--none--"%s>--_("not specified")--""")%checked]
2588        for t in self._conf.getTrackList():
2589            checked=""
2590            if t.getId() in self._filterCrit.getField("track").getValues():
2591                checked=" checked"
2592            res.append("""<input type="checkbox" name="tracks" value=%s%s> (%s) %s"""%(quoteattr(str(t.getId())),checked,self.htmlText(t.getCode()),self.htmlText(t.getTitle())))
2593        return "<br>".join(res)
2594
2595    def _getStatusItemsHTML(self):
2596        res=[]
2597        for st in ContribStatusList().getList():
2598            id=ContribStatusList().getId(st)
2599            checked=""
2600            if id in self._filterCrit.getField("status").getValues():
2601                checked=" checked"
2602            code=ContribStatusList().getCode(st)
2603            caption=ContribStatusList().getCaption(st)
2604            res.append("""<input type="checkbox" name="status" value=%s%s> (%s) %s"""%(quoteattr(str(id)),checked,self.htmlText(code),self.htmlText(caption)))
2605        return "<br>".join(res)
2606
2607    def _getMaterialItemsHTML(self):
2608        res=[]
2609        pf,sf=materialFactories.PaperFactory(),materialFactories.SlidesFactory()
2610        for (id,caption) in [(pf.getId(),pf.getTitle()),\
2611                        (sf.getId(),sf.getTitle()),\
2612                        ("--other--", _("other")),("--none--", _("""--_("no material")--"""))]:
2613            checked=""
2614            if id in self._filterCrit.getField("material").getValues():
2615                checked=" checked"
2616            res.append("""<input type="checkbox" name="material" value=%s%s> %s"""%(quoteattr(str(id)),checked,self.htmlText(caption)))
2617        return "<br>".join(res)
2618           
2619    def getVars( self ):
2620        vars = wcomponents.WTemplated.getVars( self )
2621        vars["quickAccessURL"]=quoteattr(str(urlHandlers.UHSessionModContribQuickAccess.getURL(self._session)))
2622        vars["filterPostURL"]=quoteattr(str(urlHandlers.UHSessionModContribList.getURL(self._session)))
2623        vars["types"]=self._getTypeItemsHTML()
2624        vars["tracks"]=self._getTrackItemsHTML()
2625        vars["status"]=self._getStatusItemsHTML()
2626        vars["materials"]=self._getMaterialItemsHTML()
2627        vars["authSearch"]=""
2628        authField=self._filterCrit.getField("author")
2629        if authField is not None:
2630            vars["authSearch"]=quoteattr(str(authField.getValues()))
2631        sortingField = self._sortingCrit.getField()
2632        self._currentSorting=""
2633        if sortingField is not None:
2634            self._currentSorting=sortingField.getId()
2635        vars["currentSorting"]=""
2636        url=self._getURL()
2637        url.addParam("sortBy","number")
2638        vars["numberImg"]=""
2639        if self._currentSorting == "number":
2640            vars["currentSorting"] = """<input type="hidden" name="sortBy" value="number">"""
2641            if self._order == "down":
2642                vars["numberImg"] = """<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
2643                url.addParam("order","up")
2644            elif self._order == "up":
2645                vars["numberImg"] = """<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow")))
2646                url.addParam("order","down")
2647        vars["numberSortingURL"]=quoteattr(str(url))
2648           
2649        url = self._getURL()
2650        url.addParam("sortBy", "date")
2651        vars["dateImg"] = ""
2652        if self._currentSorting == "date":
2653            vars["currentSorting"]="""<input type="hidden" name="sortBy" value="date">"""
2654            if self._order == "down":
2655                vars["dateImg"]="""<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
2656                url.addParam("order","up")
2657            elif self._order == "up":
2658                vars["dateImg"]="""<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow")))
2659                url.addParam("order","down")
2660        vars["dateSortingURL"]=quoteattr(str(url))
2661
2662        url = self._getURL()
2663        url.addParam("sortBy", "board_number")       
2664        vars["boardNumImg"]=""
2665        if self._currentSorting == "board_number":
2666            vars["currentSorting"]="""<input type="hidden" name="sortBy" value="board_number">"""
2667            if self._order == "down":
2668                vars["boardNumImg"] = """<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
2669                url.addParam("order","up")
2670            elif self._order == "up":
2671                vars["boardNumImg"] = """<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow")))
2672                url.addParam("order","down")
2673        vars["boardNumSortingURL"]=quoteattr(str(url))
2674           
2675        url = self._getURL()
2676        url.addParam("sortBy", "type")
2677        vars["typeImg"] = ""
2678        if self._currentSorting == "type":
2679            vars["currentSorting"]="""<input type="hidden" name="sortBy" value="type">"""
2680            if self._order == "down":
2681                vars["typeImg"]="""<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
2682                url.addParam("order","up")
2683            elif self._order == "up":
2684                vars["typeImg"]="""<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow"))) 
2685                url.addParam("order","down")
2686        vars["typeSortingURL"] = quoteattr( str( url ) )
2687
2688        url = self._getURL()
2689        url.addParam("sortBy", "name")
2690        vars["titleImg"] = ""
2691        if self._currentSorting == "name":
2692            vars["currentSorting"]="""<input type="hidden" name="sortBy" value="name">"""
2693            if self._order == "down":
2694                vars["titleImg"]="""<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
2695                url.addParam("order","up")
2696            elif self._order == "up":
2697                vars["titleImg"]="""<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow")))
2698                url.addParam("order","down")
2699        vars["titleSortingURL"]=quoteattr(str(url))
2700
2701        url = self._getURL()
2702        url.addParam("sortBy", "speaker")
2703        vars["speakerImg"]=""
2704        if self._currentSorting=="speaker":
2705            vars["currentSorting"] = """<input type="hidden" name="sortBy" value="speaker">"""
2706            if self._order == "down":
2707                vars["speakerImg"] = """<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
2708                url.addParam("order","up")
2709            elif self._order == "up":
2710                vars["speakerImg"] = """<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow")))
2711                url.addParam("order","down")
2712        vars["speakerSortingURL"]=quoteattr( str( url ) )
2713           
2714        url = self._getURL()
2715        url.addParam("sortBy","track")
2716        vars["trackImg"] = ""
2717        if self._currentSorting == "track":
2718            vars["currentSorting"] = """<input type="hidden" name="sortBy" value="track">"""
2719            if self._order == "down":
2720                vars["trackImg"] = """<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
2721                url.addParam("order","up")
2722            elif self._order == "up":
2723                vars["trackImg"] = """<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow")))
2724                url.addParam("order","down")
2725        vars["trackSortingURL"] = quoteattr( str( url ) )
2726        l = []
2727        numContribs=0
2728        f=filters.SimpleFilter(self._filterCrit,self._sortingCrit)
2729        contribsToPrint = []
2730        for contrib in f.apply(self._session.getContributionList()):
2731            l.append( self._getContribHTML( contrib ) )
2732            numContribs+=1
2733            contribsToPrint.append("""<input type="hidden" name="contributions" value="%s">"""%contrib.getId())
2734        if self._order =="up":
2735            l.reverse()
2736        vars["contributions"]="".join(l)
2737        vars["contribsToPrint"] = "".join(contribsToPrint)
2738        vars["contributionActionURL"]=quoteattr(str(urlHandlers.UHSessionModContributionAction.getURL(self._session)))
2739        vars["contributionsPDFURL"]=quoteattr(str(urlHandlers.UHSessionModToPDF.getURL(self._session)))
2740        vars["participantListURL"]=quoteattr(str(urlHandlers.UHSessionModParticipantList.getURL(self._session)))
2741        vars["addContribURL"]=quoteattr(str(urlHandlers.UHSessionModAddContribs.getURL(self._session)))
2742        vars["numContribs"]=str(numContribs)
2743        totaldur = self._totaldur
2744        days = totaldur.days       
2745        hours = (totaldur.seconds)/3600
2746        dayhours = (days * 24)+hours
2747        mins = ((totaldur.seconds)/60)-(hours*60)
2748        vars["totaldur" ]="""%sh%sm"""%(dayhours,mins) 
2749        return vars
2750
2751
2752class WSessionModPosterContribList(WSessionModContribList):
2753   
2754    def _getContribHTML(self,contrib):
2755        sdate = ""
2756        if contrib.getAdjustedStartDate() is not None:
2757            sdate=contrib.getAdjustedStartDate().strftime("%Y-%b-%d %H:%M" )
2758        strdur = ""
2759        if contrib.getDuration() is not None and contrib.getDuration().seconds != 0:
2760            strdur = (datetime(1900,1,1)+ contrib.getDuration()).strftime("%Hh%M'")
2761            dur = contrib.getDuration()
2762            self._totaldur = self._totaldur + dur
2763        title = """<a href=%s>%s</a>"""%( quoteattr( str( urlHandlers.UHContributionModification.getURL( contrib ) ) ), self.htmlText( contrib.getTitle() ))
2764        l = []
2765        for spk in contrib.getSpeakerList():
2766            l.append( self.htmlText( spk.getFullName() ) )
2767        speaker = "<br>".join( l )
2768        track = ""
2769        if contrib.getTrack():
2770            track = self.htmlText( contrib.getTrack().getCode() )
2771        cType=""
2772        if contrib.getType() is not None:
2773            cType=contrib.getType().getName()
2774        status=ContribStatusList().getCode(contrib.getCurrentStatus().__class__)
2775        materials=""
2776        if contrib.getPaper() is not None:
2777            url=urlHandlers.UHMaterialModification.getURL(contrib.getPaper())
2778            materials+="""<a href=%s><img border="0" src=%s alt="paper"></a>"""%(
2779                    quoteattr(str(url)),
2780                    quoteattr(str(materialFactories.PaperFactory().getIconURL())))
2781        if contrib.getSlides() is not None:
2782            url=urlHandlers.UHMaterialModification.getURL(contrib.getSlides())
2783            materials+="""<a href=%s><img border="0" src=%s alt="slides"></a>"""%(
2784                    quoteattr(str(url)),
2785                    quoteattr(str(materialFactories.SlidesFactory().getIconURL())))
2786        editURL=urlHandlers.UHSessionModContribListEditContrib.getURL(contrib)
2787        if self._currentSorting!="":
2788            editURL.addParam("sortBy",self._currentSorting)
2789        editIconURL=Config.getInstance().getSystemIconURL("modify")
2790        html = """
2791            <tr>
2792                <td><input type="checkbox" name="contributions" value=%s></td>
2793                <td valign="top" class="abstractLeftDataCell" nowrap>%s</td>
2794                <td valign="top" nowrap class="abstractDataCell">%s</td>
2795                <td valign="top" class="abstractDataCell">%s</td>
2796                <td valign="top" class="abstractDataCell">%s</td>
2797                <td valign="top" class="abstractDataCell"><a href=%s><img src=%s border="0" alt=""></a>%s</td>
2798                <td valign="top" class="abstractDataCell">%s</td>
2799                <td valign="top" class="abstractDataCell">%s</td>
2800                <td valign="top" class="abstractDataCell">%s</td>
2801                <td valign="top" class="abstractDataCell">%s</td>
2802                <td valign="top" class="abstractDataCell">%s</td>
2803            </tr>
2804                """%(quoteattr(str(contrib.getId())),
2805                    self.htmlText(contrib.getId()),
2806                    sdate or "&nbsp;",
2807                    strdur or "&nbsp;",
2808                    cType or "&nbsp;",
2809                    quoteattr(str(editURL)),
2810                    quoteattr(str(editIconURL)),title or "&nbsp;", 
2811                    speaker or "&nbsp;",
2812                    track or "&nbsp;",
2813                    status or "&nbsp;", 
2814                    materials or "&nbsp;",
2815                    self.htmlText(contrib.getBoardNumber()) or "&nbsp;")
2816        return html
2817
2818
2819class WPModContribList(WPSessionModifBase):
2820
2821    def _setActiveTab(self):
2822        self._tabContribs.setActive()
2823       
2824    def _getTabContent( self, params ):
2825        filterCrit=params.get("filterCrit",None)
2826        sortingCrit=params.get("sortingCrit",None)
2827        order = params.get("order","down")
2828        if self._session.getScheduleType()=="poster":
2829            wc=WSessionModPosterContribList(self._session,filterCrit,sortingCrit, order, self._getAW())
2830        else:
2831            wc=WSessionModContribList(self._session,filterCrit,sortingCrit, order, self._getAW())
2832        return wc.getHTML()
2833
2834
2835class WSessionModContribListEditContrib(wcomponents.WTemplated):
2836   
2837    def __init__(self,contrib):
2838        self._contrib=contrib
2839
2840    def getVars(self):
2841        vars=wcomponents.WTemplated.getVars(self)
2842        url=vars["postURL"]
2843        if vars.get("sortBy","").strip()!="":
2844            url.addParam("sortBy",vars["sortBy"])
2845        vars["postURL"]=quoteattr(str(url))
2846        vars["title"]=self.htmlText(self._contrib.getTitle())
2847        defaultDefinePlace=defaultDefineRoom=""
2848        defaultInheritPlace=defaultInheritRoom="checked"
2849        locationName,locationAddress,roomName="","",""
2850        if self._contrib.getOwnLocation():
2851            defaultDefinePlace,defaultInheritPlace="checked",""
2852            locationName=self._contrib.getLocation().getName()
2853            locationAddress=self._contrib.getLocation().getAddress()
2854        if self._contrib.getOwnRoom():
2855            defaultDefineRoom,defaultInheritRoom="checked",""
2856            roomName=self._contrib.getRoom().getName()
2857        vars["defaultInheritPlace"]=defaultInheritPlace
2858        vars["defaultDefinePlace"]=defaultDefinePlace
2859        vars["confPlace"]=""
2860        confLocation=self._contrib.getOwner().getLocation()
2861        if self._contrib.isScheduled():
2862            confLocation=self._contrib.getSchEntry().getSchedule().getOwner().getLocation()
2863            sDate=self._contrib.getAdjustedStartDate()
2864            vars["sYear"]=quoteattr(str(sDate.year))
2865            vars["sMonth"]=quoteattr(str(sDate.month))
2866            vars["sDay"]=quoteattr(str(sDate.day))
2867            vars["sHour"]=quoteattr(str(sDate.hour))
2868            vars["sMinute"]=quoteattr(str(sDate.minute))
2869            vars["startDate"]=self._contrib.getAdjustedStartDate().strftime("%Y-%b-%d %H:%M")
2870        else:
2871            vars["sYear"]=quoteattr(str(""))
2872            vars["sMonth"]=quoteattr(str(""))
2873            vars["sDay"]=quoteattr(str(""))
2874            vars["sHour"]=quoteattr(str(""))
2875            vars["sMinute"]=quoteattr(str(""))
2876            vars["startDate"]= _("""--_("not scheduled")--""")
2877        vars["durHours"]=quoteattr(str((datetime(1900,1,1)+self._contrib.getDuration()).hour))
2878        vars["durMins"]=quoteattr(str((datetime(1900,1,1)+self._contrib.getDuration()).minute))
2879        if confLocation:
2880            vars["confPlace"]=confLocation.getName()
2881        vars["locationName"]=locationName
2882        vars["locationAddress"]=locationAddress
2883        vars["defaultInheritRoom"]=defaultInheritRoom
2884        vars["defaultDefineRoom"]=defaultDefineRoom
2885        vars["confRoom"]=""
2886        confRoom=self._contrib.getOwner().getRoom()
2887        if self._contrib.isScheduled():
2888            confRoom=self._contrib.getSchEntry().getSchedule().getOwner().getRoom()
2889        if confRoom:
2890            vars["confRoom"]=confRoom.getName()
2891        vars["roomName"]=roomName
2892        vars["parentType"]="conference"
2893        if self._contrib.getSession() is not None:
2894            vars["parentType"]="session"
2895            if self._contrib.isScheduled():
2896                vars["parentType"]="session slot"
2897        vars["boardNumber"]=quoteattr(str(self._contrib.getBoardNumber()))
2898        return vars
2899
2900
2901class WPModContribListEditContrib(WPModContribList):
2902
2903    def __init__(self,rh,contrib):
2904        WPModContribList.__init__(self,rh,contrib.getSession())
2905        self._contrib=contrib
2906
2907    def _getTabContent( self, params ):
2908        wc=WSessionModContribListEditContrib(self._contrib)
2909        return wc.getHTML({"sortBy":params.get("sortBy",""),
2910                            "postURL":urlHandlers.UHSessionModContribListEditContrib.getURL(self._contrib)})
2911
2912
2913class WSessionModAddContribs(wcomponents.WTemplated):
2914   
2915    def __init__(self,session):
2916        self._session=session
2917
2918    def _getTrackItems(self):
2919        res=[ _("""<option value="--none--">--_("none")--</option>""")]
2920        for track in self._session.getConference().getTrackList():
2921            res.append("""<option value=%s>(%s) %s</option>"""%(quoteattr(str(track.getId())),self.htmlText(track.getCode()),self.htmlText(track.getTitle())))
2922        return "".join(res)
2923
2924    def _getContribItems(self):
2925        res=[]
2926        #available contributions to a session are those contributions which:
2927        #   1) are not included in any session
2928        #   2) are not withdrawn
2929        #   3) are not scheduled
2930        sc=contribFilters.SortingCriteria(["number"])
2931        contribList=filters.SimpleFilter(None,sc).apply(self._session.getConference().getContributionList())
2932        for contrib in contribList:
2933            if contrib.getSession() is not None or isinstance(contrib.getCurrentStatus(),conference.ContribStatusWithdrawn) or contrib.isScheduled():
2934                continue
2935            cType=""
2936            if contrib.getType() is not None:
2937                cType="%s"%contrib.getType().getName()
2938            spks=[self.htmlText(spk.getFullName()) for spk in contrib.getSpeakerList()]
2939            res.append("""
2940                <tr>
2941                    <td valgin="top"><input type="checkbox" name="manSelContribs" value=%s></td>
2942                    <td valgin="top">%s</td>
2943                    <td valgin="top">[%s]</td>
2944                    <td valgin="top"><i>%s</i></td>
2945                    <td valgin="top">%s</td>
2946                </tr>
2947                        """%(quoteattr(str(contrib.getId())), \
2948                        self.htmlText(contrib.getId()),\
2949                        self.htmlText(cType), \
2950                        self.htmlText(contrib.getTitle()),\
2951                        "<br>".join(spks)))
2952        return "".join(res)
2953
2954    def getVars(self):
2955        vars=wcomponents.WTemplated.getVars(self)
2956        vars["postURL"]=quoteattr(str(urlHandlers.UHSessionModAddContribs.getURL(self._session)))
2957        vars["tracks"]=self._getTrackItems()
2958        vars["availContribs"]=self._getContribItems()
2959        return vars
2960       
2961
2962class WPModAddContribs(WPModContribList):
2963
2964    def _getTabContent( self, params ):
2965        wc=WSessionModAddContribs(self._session)
2966        return wc.getHTML()
2967
2968
2969class WPModImportContribsConfirmation(WPModContribList):
2970
2971    def _getTabContent( self, params ):
2972        wc=wcomponents.WConfModMoveContribsToSessionConfirmation(self._conf,params.get("contribIds",[]),self._session)
2973        p={"postURL":urlHandlers.UHSessionModAddContribs.getURL(self._session)}
2974        return wc.getHTML(p)
2975
2976
2977class WPModParticipantList( WPSessionModifBase ):
2978   
2979    def __init__(self, rh, conf, emailList, displayedGroups, contribs):
2980        WPSessionModifBase.__init__(self, rh, conf)
2981        self._emailList = emailList
2982        self._displayedGroups = displayedGroups
2983        self._contribs = contribs
2984   
2985    def _getBody( self, params ):
2986        WPSessionModifBase._getBody(self, params)
2987        wc = WContribParticipantList(self._conf, self._emailList, self._displayedGroups, self._contribs)
2988        params = {"urlDisplayGroup":urlHandlers.UHSessionModParticipantList.getURL(self._session)}
2989        return wc.getHTML(params)
2990
2991class WPSessionDisplayRemoveMaterialsConfirm( WPSessionDefaultDisplayBase ):
2992   
2993    def __init__(self,rh, conf, mat):
2994        WPSessionDefaultDisplayBase.__init__(self,rh,conf)
2995        self._mat=mat
2996   
2997    def _getBody(self,params):
2998        wc=wcomponents.WDisplayConfirmation()
2999        msg="""Are you sure you want to delete the following material?<br>
3000        <b><i>%s</i></b>
3001        <br>"""%self._mat.getTitle()
3002        url=urlHandlers.UHSessionDisplayRemoveMaterial.getURL(self._mat.getOwner())
3003        return wc.getHTML(msg,url,{"deleteMaterial":self._mat.getId()})
3004
3005class WPSessionDisplayWriteMinutes( WPSessionDefaultDisplayBase ):
3006   
3007    def _getBody( self, params ):
3008        wc = wcomponents.WWriteMinutes( self._session )
3009        pars = {"postURL": urlHandlers.UHSessionDisplayWriteMinutes.getURL(self._session) }
3010        return wc.getHTML( pars )
3011
3012class WPSessionModifRelocate(WPSessionModifBase):
3013
3014    def __init__(self, rh, session, entry, targetDay):
3015        WPSessionModifBase.__init__(self, rh, session)
3016        self._targetDay=targetDay
3017        self._entry=entry
3018
3019    def _getPageContent( self, params):
3020        wc=wcomponents.WSchRelocate(self._entry)
3021        p={"postURL":quoteattr(str(urlHandlers.UHSessionModifScheduleRelocate.getURL(self._entry))), \
3022                "targetDay":quoteattr(str(self._targetDay))}
3023        return wc.getHTML(p)
3024
3025
3026class WPSessionModifMaterials( WPSessionModifBase ):
3027
3028    def __init__(self, rh, session):
3029        self._target = session
3030        WPSessionModifBase.__init__(self, rh, session)
3031   
3032    def _setActiveTab( self ):
3033        self._tabMaterials.setActive()
3034
3035    ## def _getContent( self, pars ):
3036    ##     wc=wcomponents.WShowExistingMaterial(self._target)
3037    ##     return wc.getHTML( pars )
3038
3039    def _getTabContent( self, pars ):
3040        wc=wcomponents.WShowExistingMaterial(self._target)
3041        return wc.getHTML( pars )
3042
3043class WPSessionDatesModification(WPSessionModifSchedule):
3044   
3045    def _getTabContent(self,params):
3046        p=WSessionModEditDates(self._session.getConference())
3047        params["postURL"]=urlHandlers.UHSessionDatesModification.getURL(self._session)
3048        return p.getHTML(params)
3049       
3050class WSessionModEditDates(wcomponents.WTemplated):
3051   
3052    def __init__(self,targetConf,targetDay=None):
3053        self._conf=targetConf
3054        self._targetDay=targetDay
3055
3056    def _getErrorHTML(self,l):
3057        if len(l)>0:
3058            return """
3059                <tr>
3060                    <td colspan="2" align="center">
3061                        <br>
3062                        <table bgcolor="red" cellpadding="6">
3063                            <tr>
3064                                <td bgcolor="white" style="color: red">%s</td>
3065                            </tr>
3066                        </table>
3067                        <br>
3068                    </td>
3069                </tr>
3070                    """%"<br>".join(l)
3071        else:
3072            return ""
3073   
3074    def getVars( self ):
3075        vars=wcomponents.WTemplated.getVars(self)
3076        vars["errors"]=self._getErrorHTML(vars.get("errors",[]))
3077        vars["postURL"]=quoteattr(str(vars["postURL"]))
3078        vars["calendarIconURL"]=Config.getInstance().getSystemIconURL( "calendar" )
3079        vars["calendarSelectURL"]=urlHandlers.UHSimpleCalendar.getURL()
3080        refDate=self._conf.getSchedule().calculateDayEndDate(self._targetDay, self._conf.getTimezone())
3081        endDate = None
3082        if refDate.hour == 23:
3083            refDate = refDate - timedelta(minutes=refDate.minute)
3084            endDate = refDate + timedelta(minutes=59)
3085        vars["sDay"]=quoteattr(str(vars.get("sDay",refDate.day)))
3086        vars["sMonth"]=quoteattr(str(vars.get("sMonth",refDate.month)))
3087        vars["sYear"]=quoteattr(str(vars.get("sYear",refDate.year)))
3088        vars["sHour"]=quoteattr(str(vars.get("sHour",refDate.hour)))
3089        vars["sMinute"]=quoteattr(str(vars.get("sMinute",refDate.minute)))
3090        if not endDate:
3091            endDate=refDate+timedelta(hours=1)
3092        vars["eDay"]=quoteattr(str(vars.get("eDay",endDate.day)))
3093        vars["eMonth"]=quoteattr(str(vars.get("eMonth",endDate.month)))
3094        vars["eYear"]=quoteattr(str(vars.get("eYear",endDate.year)))
3095        vars["eHour"]=quoteattr(str(vars.get("eHour",endDate.hour)))
3096        vars["eMinute"]=quoteattr(str(vars.get("eMinute",endDate.minute)))
3097        if not self._conf.getAutoSolveConflict():
3098            vars["autoUpdate"]= _("""<input type="checkbox" name="check" value="2"> _("Update parents dates")""")
3099        else:
3100            vars["autoUpdate"]=""
3101        if not self._conf.getEnableSessionSlots():
3102            vars["disabled"] = "disabled"
3103        else:
3104            vars["disabled"] = ""
3105        vars["adjustSlots"]=""
3106        return vars
3107   
Note: See TracBrowser for help on using the repository browser.