source: indico/indico/MaKaC/webinterface/pages/sessions.py @ 6f816f

hello-world-walkthroughipv6v0.98-seriesv0.98.2v0.98.3v0.99v1.0v1.1
Last change on this file since 6f816f was 6f816f, checked in by Alberto Resco Perez <alberto.resco.perez@…>, 16 months ago

[IMP] Small refactor of iCal export popup.

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