source: indico/indico/MaKaC/webinterface/rh/conferenceDisplay.py @ e782bc2

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

[FIXED] Several bug fixes

Squashed commit of the following:

commit 36e9f6c4866624961149f4c09d13fd6b06a4172c
Author: Jose Benito <jose.benito.gonzalez@…>
Date: Thu Jul 23 18:52:59 2009 +0200

[FIXED] Removed ConfSignIn? for meetings

commit f3ffa27402b04f94142e7603580c64d28a604092
Author: Jose Benito <jose.benito.gonzalez@…>
Date: Thu Jul 23 16:23:53 2009 +0200

[FIXED] Removed https from logo

commit 2fa58ca8b3a0fc329aea895805915db044fa8017
Author: Jose Benito <jose.benito.gonzalez@…>
Date: Thu Jul 23 09:53:50 2009 +0200

[FIXED] Error in cdsagenda style, managing materials

commit 7f90a2a442c5ed18e3ffef55833dad104c015955
Author: Jose Benito <jose.benito.gonzalez@…>
Date: Wed Jul 22 16:30:45 2009 +0200

[FIXED] PRE problems in meetings display

  • Property mode set to 100644
File size: 56.6 KB
Line 
1# -*- coding: utf-8 -*-
2##
3## $Id: conferenceDisplay.py,v 1.86 2009/05/15 11:51:10 eragners Exp $
4##
5## This file is part of CDS Indico.
6## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN.
7##
8## CDS Indico is free software; you can redistribute it and/or
9## modify it under the terms of the GNU General Public License as
10## published by the Free Software Foundation; either version 2 of the
11## License, or (at your option) any later version.
12##
13## CDS Indico is distributed in the hope that it will be useful, but
14## WITHOUT ANY WARRANTY; without even the implied warranty of
15## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16## General Public License for more details.
17##
18## You should have received a copy of the GNU General Public License
19## along with CDS Indico; if not, write to the Free Software Foundation, Inc.,
20## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
21
22from datetime import timedelta,datetime, time
23import os, sys
24import MaKaC.common.info as info
25import MaKaC.webinterface.rh.base as base
26import MaKaC.webinterface.rh.conferenceBase as conferenceBase
27import MaKaC.webinterface.pages.conferences as conferences
28import MaKaC.webinterface.pages.abstracts as abstracts
29import MaKaC.webinterface.pages.authors as authors
30import MaKaC.webinterface.urlHandlers as urlHandlers
31import MaKaC.webinterface.displayMgr as displayMgr
32import MaKaC.webinterface.internalPagesMgr as internalPagesMgr
33import MaKaC.user as user
34import MaKaC.webinterface.mail as mail
35from MaKaC.webinterface.pages.errors import WPAccessError
36import MaKaC.conference as conference
37from MaKaC.common import Config, DBMgr
38from MaKaC.common.utils import isStringHTML,sortContributionByDate
39from MaKaC.authentication import AuthenticatorMgr
40from MaKaC.webinterface.rh.base import RHDisplayBaseProtected
41from MaKaC.webinterface.rh.conferenceBase import RHConferenceBase, RHSubmitMaterialBase
42import MaKaC.common.filters as filters
43import MaKaC.webinterface.common.contribFilters as contribFilters
44from MaKaC.errors import MaKaCError, ModificationError, NoReportError, AccessError
45from MaKaC.PDFinterface.conference import ConfManagerContribsToPDF,TimeTablePlain,AbstractBook, SimplifiedTimeTablePlain, ProgrammeToPDF, TimetablePDFFormat
46from xml.sax.saxutils import escape
47from MaKaC.participant import Participant
48from MaKaC.ICALinterface.conference import ConferenceToiCal
49from MaKaC.common.contribPacker import ConferencePacker, ZIPFileHandler
50import StringIO, zipfile
51from MaKaC.i18n import _
52
53import MaKaC.common.timezoneUtils as timezoneUtils
54from reportlab.platypus.doctemplate import LayoutError
55from MaKaC.webinterface.rh.base import RH
56from MaKaC.webinterface.common.tools import cleanHTMLHeaderFilename
57
58class RHConfSignIn( conferenceBase.RHConferenceBase ):
59   
60    def _checkParams( self, params ):
61        conferenceBase.RHConferenceBase._checkParams( self, params )
62        self._login = params.get( "login", "" ).strip()
63        self._password = params.get( "password", "" ).strip()
64        self._returnURL = params.get( "returnURL", "").strip()
65        if self._returnURL == "":
66            self._returnURL = urlHandlers.UHConferenceDisplay.getURL( self._conf )
67        self._loginURL = params.get( "loginURL", "").strip()
68        self._signIn = params.get("signIn", "").strip()
69       
70   
71    def _process( self ):
72        self._tohttps = True
73        #Check for automatic login
74        auth = AuthenticatorMgr()
75        av = auth.autoLogin(self)
76        if av:
77            url = self._returnURL
78            self._getSession().setUser( av )
79            self._redirect( url )
80        if not self._signIn:
81            p = conferences.WPConfSignIn( self, self._conf )
82            return p.display( returnURL = self._returnURL )
83        else:
84            li = user.LoginInfo( self._login, self._password )   
85            av = auth.getAvatar(li)
86            if not av:
87                p = conferences.WPConfSignIn( self, self._conf, login = self._login, msg = "Wrong login or password" )
88                return p.display( returnURL = self._returnURL )
89            elif not av.isActivated():
90                if av.isDisabled():
91                    self._redirect(urlHandlers.UHConfDisabledAccount.getURL(self._conf, av))
92                else:
93                    self._redirect(urlHandlers.UHConfUnactivatedAccount.getURL( self._conf, av))
94                return "your account is not active\nPlease activate it and retry"
95            else:
96                url = self._returnURL
97                self._getSession().setUser( av )
98                tzUtil = timezoneUtils.SessionTZ(av)
99                tz = tzUtil.getSessionTZ()
100                self._getSession().setVar("ActiveTimezone",tz)
101            self._redirect( url )
102
103# REPLACED BY RHSignOut IN login.py
104#class RHConfSignOut( conferenceBase.RHConferenceBase ):
105#   
106#    def _process( self ):
107#        if self._getUser():
108#            self._getSession().setUser( None )
109#            self._setUser( None )
110#        self._redirect( urlHandlers.UHConferenceDisplay.getURL( self._conf ) )
111       
112
113
114class RHConferenceAccessKey( conferenceBase.RHConferenceBase ):
115   
116    def _checkParams( self, params ):
117        conferenceBase.RHConferenceBase._checkParams(self, params )
118        self._accesskey = params.get( "accessKey", "" ).strip()
119   
120    def _process( self ):
121        access_keys = self._getSession().getVar("accessKeys")
122        if access_keys == None:
123            access_keys = {}
124        access_keys[self._conf.getUniqueId()] = self._accesskey
125        self._getSession().setVar("accessKeys",access_keys)
126        url = urlHandlers.UHConferenceDisplay.getURL( self._conf )
127        self._redirect( url )
128
129
130class RHConferenceForceAccessKey( conferenceBase.RHConferenceBase ):
131   
132    def _checkParams( self, params ):
133        conferenceBase.RHConferenceBase._checkParams(self, params )
134   
135    def _process( self ):
136        wp = WPAccessError( self )
137        return wp.display()
138
139
140class RHConfDisabledAccount( conferenceBase.RHConferenceBase ):
141   
142    def _checkParams( self, params ):
143        conferenceBase.RHConferenceBase._checkParams(self, params )
144        self._userId = params.get( "userId", "" ).strip()
145   
146    def _process( self ):
147        av = user.AvatarHolder().getById( self._userId )
148        p = conferences.WPConfAccountDisabled( self, self._conf, av )
149        return p.display()
150
151
152class RHConfUnactivatedAccount( conferenceBase.RHConferenceBase ):
153   
154    def _checkParams( self, params ):
155        conferenceBase.RHConferenceBase._checkParams(self, params )
156        self._userId = params.get( "userId", "" ).strip()
157   
158    def _process( self ):
159        av = user.AvatarHolder().getById(self._userId)
160        p = conferences.WPConfUnactivatedAccount( self, self._conf, av )
161        return p.display()
162
163
164class RHConfSendActivation( conferenceBase.RHConferenceBase ):
165   
166    def _checkParams( self, params ):
167        conferenceBase.RHConferenceBase._checkParams(self, params )
168        self._userId = params.get( "userId", "" ).strip()
169   
170    def _process( self ):
171        av = user.AvatarHolder().getById(self._userId)
172        sm = mail.sendConfirmationRequest(av) 
173        sm.send()
174        self._redirect( urlHandlers.UHConfSignIn.getURL( self._conf ) )
175
176
177class _UserUtils:
178   
179    def setUserData( self, a, userData):
180        a.setName( userData["name"] )
181        a.setSurName( userData["surName"] )
182        a.setTitle( userData["title"] )
183        a.setOrganisation( userData["organisation"] )
184        a.setAddress( userData["address"] )
185        a.setEmail( userData["email"] )
186        a.setTelephone( userData["telephone"] )
187        a.setFax( userData["fax"] )
188        ##################################
189        # Fermi timezone awareness       #
190        ##################################
191        a.setTimezone(userData["timezone"])
192        a.setDisplayTZMode(userData["displayTZMode"])
193        ##################################
194        # Fermi timezone awareness(end)  #
195        ##################################
196    setUserData = classmethod( setUserData )
197
198
199class RHConfUserCreation( conferenceBase.RHConferenceBase ):
200    _uh = urlHandlers.UHConfUserCreation
201   
202    def _checkProtection( self ):
203        pass
204   
205    def _checkParams( self, params ):
206        self._params = params
207        conferenceBase.RHConferenceBase._checkParams( self, params )
208        self._save = params.get("Save", "")
209        self._returnURL = params.get( "returnURL", "").strip()
210   
211    def _process( self ):
212        save = False
213        ih = AuthenticatorMgr()
214        self._params["msg"] = ""
215        if self._save:
216            save = True
217            #check submited data
218            if not self._params.get("name",""):
219                self._params["msg"] += "You must enter a name.<br>"
220                save = False
221            if not self._params.get("surName",""):
222                self._params["msg"] += "You must enter a surname.<br>"
223                save = False
224            if not self._params.get("organisation",""):
225                self._params["msg"] += "You must enter the name of your organisation.<br>"
226                save = False
227            if not self._params.get("email",""):
228                self._params["msg"] += "You must enter an email address.<br>"
229                save = False
230            if not self._params.get("login",""):
231                self._params["msg"] += "You must enter a login.<br>"
232                save = False
233            if not self._params.get("password",""):
234                self._params["msg"] += "You must define a password.<br>"
235                save = False
236            if self._params.get("password","") != self._params.get("passwordBis",""):
237                self._params["msg"] += "You must enter the same password two time.<br>"
238                save = False
239            if not ih.isLoginFree(self._params.get("login","")):
240                self._params["msg"] += "Sorry, the login you requested is already in use. Please choose another one.<br>"
241                save = False
242           
243        if save:
244            #Data are OK, Now check if there is an existing user or create a new one
245            ah = user.AvatarHolder()
246            res =  ah.match({"email": self._params["email"]}, exact=1, forceWithoutExtAuth=True)
247            if res:
248                #we find a user with the same email
249                a = res[0]
250                #check if the user have an identity:
251                if a.getIdentityList():
252                    self._redirect( urlHandlers.UHConfUserExistWithIdentity.getURL( self._conf, a))
253                    return
254                else:
255                    #create the identity to the user and send the comfirmatio email
256                    li = user.LoginInfo( self._params["login"], self._params["password"] )   
257                    id = ih.createIdentity( li, a, "Local" )
258                    ih.add( id )
259                    DBMgr.getInstance().commit()
260                    notif = _AccountActivationNotification( a, self._conf, self._returnURL )
261                    mail.Mailer.send( notif )
262            else:
263                a = user.Avatar()
264                _UserUtils.setUserData( a, self._params )
265                ah.add(a)
266                li = user.LoginInfo( self._params["login"], self._params["password"] )   
267                id = ih.createIdentity( li, a, "Local" )
268                ih.add( id )
269                DBMgr.getInstance().commit()
270                notif = _AccountActivationNotification( a, self._conf, self._returnURL )
271                mail.Mailer.send( notif )
272            self._redirect( urlHandlers.UHConfUserCreated.getURL( self._conf, a ) )
273        else:
274            p = conferences.WPConfUserCreation( self, self._conf, self._params )
275            return p.display()
276
277
278class _AccountActivationNotification:
279
280    def __init__( self, dest, conf, returnURL=""):
281        self._destination = dest
282        self._conf = conf
283        self._returnURL=returnURL
284
285    def getSubject( self ):
286        return "User account activation (%s)"%self._conf.getTitle()
287
288    def getDestination( self ):
289        return self._destination
290
291    def getCCList(self):
292        return []
293
294    def getToList(self):
295        return []
296
297    def getMsg( self ):
298        url = urlHandlers.UHConfActiveAccount.getURL( self._conf, self._destination )
299        url.addParam( "key", self._destination.getKey() )
300        if self._returnURL.strip() != "":
301            url.addParam( "returnURL", self._returnURL )
302        return """Welcome to Indico,
303You have created a new account on the Indico conference management system.
304
305In order to activate your new account and being able to be authenticated by the system, please open on your web browser the following URL:
306
307%s 
308
309Once you've done it, your account will be fully operational so you can log in and start using the system normally.
310
311Good luck and thank you for using our system.
312                """%( url )
313
314
315class RHConfUserCreated( conferenceBase.RHConferenceBase ):
316   
317    def _checkParams( self, params ):
318        conferenceBase.RHConferenceBase._checkParams( self, params )
319        self._av = user.AvatarHolder().getById(params["userId"])
320   
321    def _process( self ):
322        p = conferences.WPConfUserCreated( self, self._conf, self._av )
323        return p.display()
324
325
326class RHConfActivate( conferenceBase.RHConferenceBase ):
327   
328    def _checkParams( self, params ):
329        conferenceBase.RHConferenceBase._checkParams(self, params )
330        self._userId = params.get( "userId", "" ).strip()
331        self._key = params.get( "key", "" ).strip()
332        self._returnURL = params.get( "returnURL", "").strip()
333       
334   
335    def _process( self ):
336        av = user.AvatarHolder().getById(self._userId)
337        if av.isActivated():
338            p = conferences.WPConfAccountAlreadyActivated( self, self._conf, av )
339            return p.display()
340            #return "your account is already activated"
341        if av.isDisabled():
342            p = conferences.WPConfAccountDisabled( self, self._conf, av )
343            return p.display()
344            #return "your account is disabled. please, ask to enable it"
345        elif self._key == av.getKey():
346            av.activateAccount()
347            p = conferences.WPConfAccountActivated( self, self._conf, av, self._returnURL )
348            return p.display()
349            #return "Your account is activate now"
350        else:
351            return "Wrong key. Please, ask for a new one"
352
353
354class RHConfUserExistWithIdentity( conferenceBase.RHConferenceBase ):
355   
356    def _checkParams( self, params ):
357        conferenceBase.RHConferenceBase._checkParams( self, params )
358        self._av = user.AvatarHolder().getById(params["userId"])
359   
360    def _process( self ):
361        p = conferences.WPConfUserExistWithIdentity( self, self._conf, self._av )
362        return p.display()
363
364
365class RHConfSendLogin( conferenceBase.RHConferenceBase ):
366   
367    def _checkParams( self, params ):
368        conferenceBase.RHConferenceBase._checkParams( self, params )
369        self._userId = params.get( "userId", "" ).strip()
370        self._email = params.get("email", "").strip()
371   
372    def _process( self ):
373        av = None
374        if self._userId != "":
375            av = user.AvatarHolder().getById(self._userId)
376        elif self._email != "":
377            try:
378                av = user.AvatarHolder().match({"email":self._email})[0]
379            except IndexError:
380                pass
381        if av:
382            sm = mail.sendLoginInfo(av) 
383            sm.send()
384        self._redirect(urlHandlers.UHConfSignIn.getURL( self._conf ))
385
386
387class RHConferenceBaseDisplay( RHConferenceBase, RHDisplayBaseProtected ):
388   
389    def _checkParams( self, params ):
390        RHConferenceBase._checkParams( self, params )
391
392    def _checkProtection( self ):
393        RHDisplayBaseProtected._checkProtection( self )
394
395
396class RHConferenceDisplay( RHConferenceBaseDisplay ):
397    _uh = urlHandlers.UHConferenceDisplay
398   
399    def _process( self ):
400        params = self._getRequestParams()
401       
402        #set default variables
403        if not self._reqParams.has_key("showDate"):
404            self._reqParams["showDate"] = "all"
405        if not self._reqParams.has_key("showSession"):
406            self._reqParams["showSession"] = "all"
407        if not self._reqParams.has_key("detailLevel"):
408            self._reqParams["detailLevel"] = "contribution"
409        #get default/selected view
410        view = "static"
411        wf = self.getWebFactory()
412        if wf != None:
413            type = self.getWebFactory().getId()
414        else:
415            type = "conference"
416        if self._reqParams.has_key("view"):
417            view = self._reqParams["view"]
418        else:
419            view = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._target).getDefaultStyle()
420            # if no default view was attributed, then get the configuration default
421            if view == "":
422                styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager()
423                view =styleMgr.getDefaultStylesheetForEventType( type )
424                displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._target).setDefaultStyle( view )
425        isLibxml = True
426        warningText = ""
427        try:
428            import libxml2
429            import libxslt
430        except:
431            isLibxml = False
432        # create the html factory
433        if type == "conference":
434            self._page = None
435            intPagesMgr=internalPagesMgr.InternalPagesMgrRegistery().getInternalPagesMgr(self._target)
436            for page in intPagesMgr.getPagesList():
437                if page.isHome():
438                    self._page = page
439            if not self._page: 
440                p = conferences.WPConferenceDisplay( self, self._target )
441            else:
442                p = conferences.WPInternalPageDisplay(self,self._target, self._page)
443        elif view != "static" and isLibxml:
444            p = conferences.WPXSLConferenceDisplay( self, self._target, view, type, self._reqParams )
445        else:   
446            if view != "static":
447                warningText = "libxml2 and libxslt python modules need to be installed if you want to use a stylesheet-driven display - switching to static display"
448            if wf != None:               
449                p = wf.getConferenceDisplayPage( self, self._target, self._reqParams )
450            else:               
451                p = conferences.WPConferenceDisplay( self, self._target )
452        # generate the html
453
454        return warningText + p.display(**params)
455
456
457class RHConferenceOtherViews( RHConferenceBaseDisplay ):
458    """this class is for the conference type objects only
459    it is an alternative to the standard TimeTable view"""
460    _uh = urlHandlers.UHConferenceOtherViews
461   
462    def _process( self ):
463        #set default variables
464        if not self._reqParams.has_key("showDate"):
465            self._reqParams["showDate"] = "all"
466        if not self._reqParams.has_key("showSession"):
467            self._reqParams["showSession"] = "all"
468        if not self._reqParams.has_key("detailLevel"):
469            self._reqParams["detailLevel"] = "contribution"
470        #get default/selected view
471        view = "standard"
472        type = "conference"
473        if self._reqParams.has_key("view"):
474            view = self._reqParams["view"]
475        else:
476            view = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._target).getDefaultStyle()
477            # if no default view was attributed, then get the configuration default
478            if view == "":
479                styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager()
480                view =styleMgr.getDefaultStylesheetForEventType( type )
481                displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._target).setDefaultStyle( view )
482        # create the html factory
483        if view != "static":
484            p = conferences.WPXSLConferenceDisplay( self, self._target, view, type, self._reqParams )
485        else:
486            p = conferences.WPMeetingTimeTable( self, self._target,"parallel","meeting",self._reqParams )
487        # generate the html
488        if view == "xml" and self._reqParams.get('fr') == 'no':
489            self._req.content_type = "text/xml" 
490        return p.display()
491
492
493class RHConferenceGetLogo(RHConferenceBaseDisplay):
494   
495    def _process(self):
496        logo=self._target.getLogo()
497        self._req.headers_out["Content-Length"]="%s"%logo.getSize()
498        cfg=Config.getInstance()
499        mimetype=cfg.getFileTypeMimeType(logo.getFileType())
500        self._req.content_type="""%s"""%(mimetype)
501        self._req.headers_out["Content-Disposition"]="""inline; filename="%s\""""%cleanHTMLHeaderFilename(logo.getFileName())
502        return self._target.getLogo().readBin()
503   
504
505class RHConferenceGetCSS(RHConferenceBaseDisplay):
506
507    """
508    CSS which is used just for a conference.
509    """
510   
511    def _process(self):
512        sm = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getStyleManager()
513        css=sm.getLocalCSS()
514        if css:
515            self._req.headers_out["Content-Length"]="%s"%css.getSize()
516            self._req.content_type="text/css"
517            self._req.headers_out["Content-Disposition"]="""inline; filename="%s\""""%css.getFileName()
518            return css.readBin()
519
520        return ""
521
522
523class RHConferenceGetPic(RHConferenceBaseDisplay):
524   
525    def _checkParams(self, params):
526        RHConferenceBaseDisplay._checkParams( self, params )
527        self._picId = params.get("picId","")
528   
529    def _process(self):
530        im = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getImagesManager()
531        pic=im.getPic(self._picId).getLocalFile()
532        self._req.headers_out["Content-Length"]="%s"%pic.getSize()
533        cfg=Config.getInstance()
534        mimetype=cfg.getFileTypeMimeType(pic.getFileType())
535        self._req.content_type="""%s"""%(mimetype)
536        self._req.headers_out["Content-Disposition"]="""inline; filename="%s\""""%pic.getFileName()
537        return pic.readBin()   
538
539 
540class RHConferenceEmail(RHConferenceBaseDisplay, base.RHProtected):
541    _uh = urlHandlers.UHConferenceEmail
542   
543    def _checkProtection(self):
544        base.RHProtected._checkProtection(self)
545
546    def _checkParams( self, params ):
547        RHConferenceBaseDisplay._checkParams( self, params )
548        self._auth = params.has_key("authId")
549        self._chair = params.has_key("chairId")
550        if params.has_key("contribId"):
551            contrib = self._conf.getContributionById(params.get("contribId",""))
552        if self._chair:
553            chairid=params.get("chairId","")
554            self._emailto =self._conf.getChairById(chairid).getEmail()
555        if self._auth:
556            authid=params.get("authId","")
557            self._emailto =contrib.getAuthorById(authid).getEmail()
558           
559    def _process(self):
560        p=conferences.WPEMail(self, self._target)
561        return p.display(emailto=self._emailto)
562
563class RHConferenceSendEmail (RHConferenceBaseDisplay):
564    _uh = urlHandlers.UHConferenceSendEmail
565
566    def _checkParams(self, params):
567        RHConferenceBaseDisplay._checkParams( self, params )
568        self._to = params.get("to","")
569        self._cc = params.get("cc","")
570        self._from=params.get("from","")
571        self._subject=params.get("subject","")
572        self._body = params.get("body","")
573        self._send = params.has_key("OK")
574
575    def _process(self):
576        if self._send:
577            mail.personMail.send(self._to, self._cc, self._from,self._subject,self._body)
578            p = conferences.WPSentEmail(self, self._target)
579            return p.display()
580        else:
581            self._redirect(urlHandlers.UHConferenceDisplay.getURL(self._conf))
582       
583
584       
585class RHConferenceProgram( RHConferenceBaseDisplay ):
586    _uh = urlHandlers.UHConferenceProgram
587   
588    def _checkParams( self, params ):
589        RHConferenceBaseDisplay._checkParams( self, params )
590        self._xs = self._normaliseListParam( params.get("xs", []) )
591   
592   
593    def _process( self ):
594        p = conferences.WPConferenceProgram( self, self._target )
595        return p.display( xs = self._xs )
596
597
598class RHConferenceProgramPDF( RHConferenceBaseDisplay ):
599   
600    def _process( self ):
601        tz = timezoneUtils.DisplayTZ(self._aw,self._target).getDisplayTZ()
602        filename = "%s - Programme.pdf"%cleanHTMLHeaderFilename(self._target.getTitle())
603        from MaKaC.PDFinterface.conference import ProgrammeToPDF
604        pdf = ProgrammeToPDF(self._target, tz=tz)
605        data = pdf.getPDFBin()
606        #self._req.headers_out["Accept-Ranges"] = "bytes"
607        self._req.headers_out["Content-Length"] = "%s"%len(data)
608        cfg = Config.getInstance()
609        mimetype = cfg.getFileTypeMimeType( "PDF" )
610        #self._req.content_type = """%s; name="%s\""""%(mimetype, filename )
611        self._req.content_type = """%s"""%(mimetype)
612        self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename
613        return data
614
615class RHConferenceTimeTable( RHConferenceBaseDisplay ):
616    _uh = urlHandlers.UHConferenceTimeTable
617   
618    def _process( self ):
619        defStyle = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._target).getDefaultStyle()
620        if defStyle in ["", "static", "parallel"]:
621            p = conferences.WPConferenceTimeTable( self, self._target )
622            return p.display( **self._getRequestParams() )
623        else:
624            url = urlHandlers.UHConferenceOtherViews.getURL( self._conf ) 
625            url.addParam("view", defStyle)
626            self._redirect(url)
627
628
629class RHTimeTablePDF(RHConferenceTimeTable):
630   
631    fontsizes = ['xxx-small', 'xx-small', 'x-small', 'smaller', 'small', 'normal', 'large', 'larger']
632
633    def _checkParams(self,params):
634        RHConferenceTimeTable._checkParams(self,params)
635        self._showSessions=self._normaliseListParam(params.get("showSessions",[]))
636        if "all" in self._showSessions:
637            self._showSessions.remove("all")
638        self._showDays=self._normaliseListParam(params.get("showDays",[]))
639        if "all" in self._showDays:
640            self._showDays.remove("all")
641        self._sortingCrit=None
642        if params.has_key("sortBy") and params["sortBy"].strip()!="":
643            self._sortingCrit=contribFilters.SortingCriteria([params.get( "sortBy", "number").strip()])
644        self._pagesize = params.get('pagesize','A4')
645        self._fontsize = params.get('fontsize','normal')
646        try:
647            self._firstPageNumber = int(params.get('firstPageNumber','1'))
648        except ValueError:
649            self._firstPageNumber = 1
650        self._showSpeakerAffiliation = False
651        if params.has_key("showSpeakerAffiliation"):
652            self._showSpeakerAffiliation = True
653   
654    def _reduceFontSize( self ):
655        index = self.fontsizes.index(self._fontsize)
656        if index > 0:
657            self._fontsize = self.fontsizes[index-1]
658            return True
659        return False
660
661    def _process(self):
662        tz = timezoneUtils.DisplayTZ(self._aw,self._target).getDisplayTZ()
663        params=self._getRequestParams()
664        ttPDFFormat=TimetablePDFFormat(params)
665
666        retry = True
667        while retry:
668            if params.get("typeTT","normalTT")=="normalTT":
669                filename = "timetable.pdf"
670                pdf = TimeTablePlain(self._target,self.getAW(),
671                        showSessions=self._showSessions,showDays=self._showDays,
672                        sortingCrit=self._sortingCrit, ttPDFFormat=ttPDFFormat,
673                        pagesize = self._pagesize, fontsize = self._fontsize, 
674                        firstPageNumber = self._firstPageNumber,
675                        showSpeakerAffiliation = self._showSpeakerAffiliation)
676            else:
677                filename = "SimplifiedTimetable.pdf"
678                pdf = SimplifiedTimeTablePlain(self._target,self.getAW(),
679                    showSessions=self._showSessions,showDays=self._showDays,
680                    sortingCrit=self._sortingCrit, ttPDFFormat=ttPDFFormat,
681                    pagesize = self._pagesize, fontsize = self._fontsize)
682            try:
683                data=pdf.getPDFBin()
684                retry = False
685            except LayoutError, e:
686                if not self._reduceFontSize():
687                    raise MaKaCError("Error in PDF generation - One of the paragraphs does not fit on a page")
688            except Exception, e:
689                raise e
690
691##        tries = 5
692##        while tries:
693##            if params.get("typeTT","normalTT")=="normalTT":
694##                filename = "timetable.pdf"
695##                pdf = TimeTablePlain(self._target,self.getAW(),
696##                        showSessions=self._showSessions,showDays=self._showDays,
697##                        sortingCrit=self._sortingCrit, ttPDFFormat=ttPDFFormat,
698##                        pagesize = self._pagesize, fontsize = self._fontsize, firstPageNumber = self._firstPageNumber, tz=tz)
699##            else:
700##                filename = "SimplifiedTimetable.pdf"
701##                pdf = SimplifiedTimeTablePlain(self._target,self.getAW(),
702##                    showSessions=self._showSessions,showDays=self._showDays,
703##                    sortingCrit=self._sortingCrit, ttPDFFormat=ttPDFFormat,
704##                    pagesize = self._pagesize, fontsize = self._fontsize, tz=tz)
705##            try:
706##                data=pdf.getPDFBin()
707##                tries = 0
708##            except LayoutError, e:
709##                if self._reduceFontSize():
710##                    tries -= 1
711##                else:
712##                    tries = 0
713##                    raise MaKaCError(str(e))
714
715        self._req.headers_out["Content-Length"] = "%s"%len(data)
716        cfg=Config.getInstance()
717        mimetype=cfg.getFileTypeMimeType("PDF")
718        self._req.content_type = """%s"""%(mimetype)
719        self._req.headers_out["Content-Disposition"]="""inline; filename="%s\""""%filename
720        return data
721
722class RHTimeTableCustomizePDF(RHConferenceTimeTable):
723   
724    def _checkParams(self,params):
725        RHConferenceTimeTable._checkParams(self,params)
726        self._cancel = params.has_key("cancel")
727   
728    def _process(self):
729        p=conferences.WPTimeTableCustomizePDF(self,self._target)
730        wf = self.getWebFactory()
731        if wf != None:
732            p=wf.getTimeTableCustomizePDF(self, self._target)
733        return p.display(**self._getRequestParams())
734
735
736class _HideWithdrawnFilterField(filters.FilterField):
737    """
738    """
739    _id = "hide_withdrawn"
740   
741    def __init__(self,conf,values):
742        pass
743
744    def satisfies(self,contribution):
745        """
746        """
747        return not isinstance(contribution.getCurrentStatus(),conference.ContribStatusWithdrawn)
748
749
750class ContributionsFilterCrit(filters.FilterCriteria):
751    _availableFields = { \
752        contribFilters.TypeFilterField.getId():contribFilters.TypeFilterField, \
753        contribFilters.TrackFilterField.getId():contribFilters.TrackFilterField, \
754        contribFilters.SessionFilterField.getId():contribFilters.SessionFilterField, \
755        _HideWithdrawnFilterField.getId(): _HideWithdrawnFilterField
756                }
757
758
759class RHContributionList( RHConferenceBaseDisplay ):
760    _uh = urlHandlers.UHContributionList
761
762    def _checkParams( self, params ):
763        RHConferenceBaseDisplay._checkParams( self, params )
764        # Sorting
765        self._sortingCrit=contribFilters.SortingCriteria( [params.get( "sortBy", "number").strip()] )
766        self._order = params.get("order","down") 
767        # Filtering
768        filterUsed = params.has_key( "OK" ) # this variable is true when the
769                                            # filter has been used
770        filter = {"hide_withdrawn": True}
771        ltypes = []
772        if not filterUsed:
773            for type in self._conf.getContribTypeList():
774                ltypes.append( type.getId() )
775        else:
776            for id in self._normaliseListParam( params.get("selTypes", []) ):
777                ltypes.append(id)
778        filter["type"] = ltypes
779       
780        ltracks = []
781        if not filterUsed:
782            for track in self._conf.getTrackList():
783                ltracks.append( track.getId() )
784        filter["track"] = self._normaliseListParam( params.get("selTracks", ltracks) )
785
786        lsessions = []
787        if not filterUsed:
788            for session in self._conf.getSessionList():
789                lsessions.append( session.getId() )
790        filter["session"] = self._normaliseListParam( params.get("selSessions", lsessions) )
791       
792        self._filterCrit=ContributionsFilterCrit(self._conf,filter)
793        typeShowNoValue, trackShowNoValue, sessionShowNoValue = True, True, True
794        if filterUsed:
795            if self._conf.getContribTypeList():
796                typeShowNoValue =  params.has_key("typeShowNoValue")
797            if self._conf.getTrackList():
798                trackShowNoValue =  params.has_key("trackShowNoValue")
799            if self._conf.getSessionList():
800                sessionShowNoValue =  params.has_key("sessionShowNoValue")
801        self._filterCrit.getField("type").setShowNoValue( typeShowNoValue )
802        self._filterCrit.getField("track").setShowNoValue( trackShowNoValue )
803        self._filterCrit.getField("session").setShowNoValue( sessionShowNoValue )
804        self._sc=params.get("sc",1)
805        self._nc=params.get("nc",20)
806       
807   
808    def _process( self ):
809        p = conferences.WPContributionList( self, self._target )
810        return p.display(sortingCrit = self._sortingCrit, filterCrit = self._filterCrit, sc=self._sc, nc=self._nc, order=self._order)
811
812
813class RHAuthorIndex(RHConferenceBaseDisplay):
814    _uh=urlHandlers.UHConfAuthorIndex
815   
816    def _checkParams( self, params ):
817        RHConferenceBaseDisplay._checkParams( self, params )
818        self._view=params.get("view","full")
819        self._letter=params.get("letter","a")
820
821    def _process(self):
822        p=conferences.WPAuthorIndex(self,self._target)
823        return p.display(viewMode=self._view,selLetter=self._letter)
824
825class RHSpeakerIndex(RHConferenceBaseDisplay):
826    _uh=urlHandlers.UHConfAuthorIndex
827   
828    def _checkParams( self, params ):
829        RHConferenceBaseDisplay._checkParams( self, params )
830        self._view=params.get("view","full")
831        self._letter=params.get("letter","a")
832
833    def _process(self):
834        p=conferences.WPSpeakerIndex(self,self._target)
835        return p.display(viewMode=self._view,selLetter=self._letter)
836
837class RHMyStuff(RHConferenceBaseDisplay,base.RHProtected):
838    _uh=urlHandlers.UHConfMyStuff
839   
840    def _checkProtection(self):
841        base.RHProtected._checkProtection(self)
842   
843    def _process(self):
844        p=conferences.WPMyStuff(self,self._target)
845        return p.display()
846
847       
848class RHContribsActions:
849    """
850    class to select the action to do with the selected abstracts
851    """
852    def __init__(self, req):
853        self._req = req
854   
855    def process(self, params):
856        if params.has_key("PDF"):
857            return RHContributionListToPDF(self._req).process(params)
858        return "no action to do"
859   
860class RHContributionListToPDF(RHConferenceBaseDisplay):
861   
862    def _checkParams( self, params ):
863        RHConferenceBaseDisplay._checkParams( self, params )
864        self._contribIds = self._normaliseListParam( params.get("contributions", []) )
865        self._contribs = []
866        for id in self._contribIds:
867            contrib = self._conf.getContributionById(id)
868            if contrib.canAccess(self.getAW()):
869                self._contribs.append(contrib)
870
871    def _process( self ):
872        tz = timezoneUtils.DisplayTZ(self._aw,self._conf).getDisplayTZ()
873        filename = "Contributions.pdf"
874        if not self._contribs:
875            return "No contributions to print"
876        from MaKaC.PDFinterface.conference import ConfManagerContribsToPDF
877        pdf = ConfManagerContribsToPDF(self._conf, self._contribs, tz=tz)
878        data = pdf.getPDFBin()
879        self._req.set_content_length(len(data))
880        cfg = Config.getInstance()
881        mimetype = cfg.getFileTypeMimeType( "PDF" )
882        self._req.content_type = """%s"""%(mimetype)
883        self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename
884        return data
885
886
887class RHConferenceMenuClose(RHConferenceBaseDisplay):
888   
889    def _checkParams( self, params ):
890        RHConferenceBaseDisplay._checkParams( self, params )
891        self._currentURL = params.get("currentURL","")
892
893    def _process( self ):
894        websession = self._getSession()
895        websession.setVar("menuStatus", "close")
896        self._redirect(self._currentURL)
897
898
899class RHConferenceMenuOpen(RHConferenceBaseDisplay):
900   
901    def _checkParams( self, params ):
902        RHConferenceBaseDisplay._checkParams( self, params )
903        self._currentURL = params.get("currentURL","")
904
905    def _process( self ):
906        websession = self._getSession()
907        websession.setVar("menuStatus", "open")
908        self._redirect(self._currentURL)
909
910
911class RHAbstractBook(RHConferenceBaseDisplay):
912    _uh=urlHandlers.UHConfAbstractBook
913
914    def _checkProtection( self ):
915        RHConferenceBaseDisplay._checkProtection(self)
916        if not self._conf.hasEnabledSection("cfa"):
917            raise MaKaCError( _("The Call For Abstracts was disabled by the conference managers"))
918   
919    def _process( self ):
920        p=conferences.WPAbstractBookCustomise(self,self._target)
921        return p.display()
922
923class RHAbstractBookPerform(RHConferenceBaseDisplay):
924    _uh=urlHandlers.UHConfAbstractBook
925   
926    def _checkParams( self, params ):
927        RHConferenceBaseDisplay._checkParams( self, params )
928        self._sortBy = params.get("sortBy","")
929       
930    def _process( self ):
931        tz = timezoneUtils.DisplayTZ(self._aw,self._target).getDisplayTZ()
932        filename = "%s - Book of abstracts.pdf"%cleanHTMLHeaderFilename(self._target.getTitle())
933        from MaKaC.PDFinterface.conference import AbstractBook
934        pdf = AbstractBook(self._target,self.getAW(), self._sortBy, tz=tz)
935        data = pdf.getPDFBin()
936        self._req.headers_out["Content-Length"] = "%s"%len(data)
937        cfg = Config.getInstance()
938        mimetype = cfg.getFileTypeMimeType( "PDF" )
939        self._req.content_type = """%s"""%(mimetype)
940        self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename
941        return data
942
943       
944class RHConfParticipantsNewPending(RHConferenceBaseDisplay):
945    _uh = urlHandlers.UHConfParticipantsNewPending
946
947    def _process( self ):       
948        params = self._getRequestParams()
949       
950        errorList = []
951        if self._conf.getStartDate() < timezoneUtils.nowutc() :
952            errorList.append("This event began on %s"%self._conf.getStartDate())
953            errorList.append("You cannot apply for participation after the event began")
954            url = urlHandlers.UHConferenceDisplay.getURL( self._conf ) 
955            url.addParam("errorMsg", errorList)
956            self._redirect(url)
957           
958        if not self._conf.getParticipation().isAllowedForApplying() :
959            errorList.append("Participation in this event is restricted to persons invited")
960            errorList.append("If you insist on taking part in this event, please contact the event manager")
961            url = urlHandlers.UHConferenceDisplay.getURL( self._conf ) 
962            url.addParam("errorMsg", errorList)
963            self._redirect(url)
964           
965           
966        params["formAction"] = str(urlHandlers.UHConfParticipantsAddPending.getURL(self._conf))
967        user = self._getUser()
968        if user is not None :
969            params["titleValue"] = user.getTitle()
970            params["surNameValue"] = user.getFamilyName()
971            params["nameValue"] = user.getName()
972            params["emailValue"] = user.getEmail()
973            params["addressValue"] = user.getAddress()
974            params["affiliationValue"] = user.getAffiliation()
975            params["phoneValue"] = user.getTelephone()
976            params["faxValue"] = user.getFax()
977       
978            params["disabledTitle"] = params["disabledSurName"] = True
979            params["disabledName"] = params["disabledEmail"] = True
980            params["disabledAddress"] = params["disabledPhone"] = True
981            params["disabledFax"] = params["disabledAffiliation"] = True
982       
983       
984        wf=self.getWebFactory()
985        if wf is not None:
986            p = wf.getConfModifParticipantsNewPending(self, self._conf)
987        else :
988            p = conferences.WPConfModifParticipantsNewPending( self, self._target )
989        return p.display(**params)
990
991
992class RHConfParticipantsAddPending(RHConferenceBaseDisplay):
993    _uh = urlHandlers.UHConfParticipantsAddPending
994
995    def _process( self ):       
996        params = self._getRequestParams()
997        errorList = []
998        infoList = []
999        if params.has_key("ok") :
1000            user = self._getUser()
1001            pending = Participant(self._conf, user)
1002            if user is None :
1003                pending.setTitle(params.get("title",""))
1004                pending.setFamilyName(params.get("surName",""))
1005                pending.setFirstName(params.get("name",""))
1006                pending.setEmail(params.get("email",""))
1007                pending.setAffiliation(params.get("affiliation",""))
1008                pending.setAddress(params.get("address",""))
1009                pending.setTelephone(params.get("phone",""))
1010                pending.setFax(params.get("fax",""))
1011            participation = self._conf.getParticipation()
1012            if participation.alreadyParticipating(pending) != 0:
1013                errorList.append("The participant identified by email '%s' is already in the participants' list"
1014                                 % pending.getEmail())
1015                errorList.append("Please check if you are not already added to the meeting.")
1016            else:
1017                if participation.addPendingParticipant(pending):
1018                    infoList.append("The participant identified by email '%s' has been added to the list of pending participants"
1019                                    % pending.getEmail())
1020                else:
1021                    errorList.append("The participant cannot be added.")
1022       
1023        url = urlHandlers.UHConferenceDisplay.getURL( self._conf ) 
1024        url.addParam("errorMsg", errorList)
1025        url.addParam("infoMsg", infoList)
1026        self._redirect(url)
1027
1028       
1029class RHConfParticipantsRefusal(RHConferenceBaseDisplay):
1030    _uh = urlHandlers.UHConfParticipantsRefusal
1031   
1032    def _checkParams( self, params ):
1033        RHConferenceBaseDisplay._checkParams(self, params )
1034        self._confirm = params.has_key( "confirm" )
1035        self._cancel = params.has_key( "cancel" )
1036           
1037    def _process( self ):
1038        params = self._getRequestParams()
1039        participantId = params["participantId"]
1040        if self._cancel:
1041            participant = self._conf.getParticipation().getParticipantById(participantId)
1042            url = urlHandlers.UHConferenceDisplay.getURL( self._conf )
1043            self._redirect( url )
1044        elif self._confirm:
1045            participant = self._conf.getParticipation().getParticipantById(participantId)
1046            participant.setStatusRefused()
1047            url = urlHandlers.UHConferenceDisplay.getURL( self._conf )
1048            self._redirect( url )
1049        else:
1050            return conferences.WPConfModifParticipantsRefuse( self, self._conf ).display(**params)
1051
1052
1053class RHConfParticipantsInvitation(RHConferenceBaseDisplay):
1054    _uh = urlHandlers.UHConfParticipantsInvitation
1055   
1056    def _checkParams( self, params ):
1057        RHConferenceBaseDisplay._checkParams(self, params )
1058        self._confirm = params.has_key( "confirm" )
1059        self._cancel = params.has_key( "cancel" )
1060           
1061    def _process( self ):
1062        params = self._getRequestParams()
1063        participantId = params["participantId"]
1064        if self._cancel:
1065            participant = self._conf.getParticipation().getParticipantById(participantId)
1066            if participant == None:
1067                raise NoReportError("It seems you have been withdrawn from the list of invited participants")
1068            participant.setStatusRejected()
1069            url = urlHandlers.UHConferenceDisplay.getURL( self._conf )
1070            self._redirect( url )
1071        elif self._confirm:
1072            participant = self._conf.getParticipation().getParticipantById(participantId)
1073            if participant == None:
1074                raise NoReportError("It seems you have been withdrawn from the list of invited participants")
1075            participant.setStatusAccepted()
1076            url = urlHandlers.UHConferenceDisplay.getURL( self._conf )
1077            self._redirect( url )
1078        else:
1079            return conferences.WPConfModifParticipantsInvite( self, self._conf ).display(**params)
1080
1081class RHConferenceToiCal(RHConferenceBaseDisplay):
1082   
1083    def _process( self ):
1084        filename = "%s - Event.ics"%cleanHTMLHeaderFilename(self._target.getTitle())
1085        ical = ConferenceToiCal(self._target.getConference())
1086        data = ical.getBody()
1087        self._req.headers_out["Content-Length"] = "%s"%len(data)
1088        cfg = Config.getInstance()
1089        mimetype = cfg.getFileTypeMimeType( "ICAL" )
1090        self._req.content_type = """%s"""%(mimetype)
1091        self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename
1092        return data
1093
1094class RHConferenceToXML(RHConferenceBaseDisplay):
1095
1096    def _checkParams( self, params ): 
1097        RHConferenceBaseDisplay._checkParams( self, params )
1098        self._xmltype = params.get("xmltype","standard")
1099       
1100    def _process( self ):
1101        filename = "%s - Event.xml"%cleanHTMLHeaderFilename(self._target.getTitle())
1102        from MaKaC.common.xmlGen import XMLGen
1103        from MaKaC.common.output import outputGenerator, XSLTransformer
1104        xmlgen = XMLGen()
1105        xmlgen.initXml()
1106        outgen = outputGenerator(self.getAW(), xmlgen)
1107        xmlgen.openTag("event")
1108        outgen.confToXML(self._target.getConference(),0,0,1)
1109        xmlgen.closeTag("event")
1110        basexml = xmlgen.getXml()
1111        path = Config.getInstance().getStylesheetsDir()
1112        stylepath = "%s/%s.xsl" % (path,self._xmltype)
1113        if self._xmltype != "standard" and os.path.exists(stylepath):
1114            try:
1115                parser = XSLTransformer(stylepath)
1116                data = parser.process(basexml)
1117            except:
1118                data = "Cannot parse stylesheet: %s" % sys.exc_info()[0]
1119        else:
1120            data = basexml
1121        self._req.headers_out["Content-Length"] = "%s"%len(data)
1122        cfg = Config.getInstance()
1123        mimetype = cfg.getFileTypeMimeType( "XML" )
1124        self._req.content_type = """%s"""%(mimetype)
1125        self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename
1126        return data
1127       
1128
1129class RHConferenceToMarcXML(RHConferenceBaseDisplay):
1130   
1131    def _process( self ):
1132        filename = "%s - Event.xml"%cleanHTMLHeaderFilename(self._target.getTitle())
1133        from MaKaC.common.xmlGen import XMLGen
1134        from MaKaC.common.output import outputGenerator
1135        xmlgen = XMLGen()
1136        xmlgen.initXml()
1137        outgen = outputGenerator(self.getAW(), xmlgen)
1138        xmlgen.openTag("marc:record", [["xmlns:marc","http://www.loc.gov/MARC21/slim"],["xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance"],["xsi:schemaLocation", "http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"]])
1139        outgen.confToXMLMarc21(self._target.getConference())
1140        xmlgen.closeTag("marc:record")
1141        data = xmlgen.getXml()
1142        self._req.headers_out["Content-Length"] = "%s"%len(data)
1143        cfg = Config.getInstance()
1144        mimetype = cfg.getFileTypeMimeType( "XML" )
1145        self._req.content_type = """%s"""%(mimetype)
1146        self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename
1147        return data
1148       
1149class RHWriteMinutes( RHConferenceBaseDisplay ):
1150
1151    def _checkProtection(self):
1152        if not self._target.canModify( self.getAW() ):
1153            if self._target.getModifKey() != "":
1154                raise ModificationError()
1155            if self._getUser() == None:
1156                self._preserveParams()
1157                self._checkSessionUser()
1158            else:
1159                raise ModificationError()
1160   
1161    def _preserveParams(self):
1162        preservedParams = self._getRequestParams().copy()
1163        self._websession.setVar("minutesPreservedParams",preservedParams)
1164
1165    def _getPreservedParams(self):
1166        params = self._websession.getVar("minutesPreservedParams")
1167        if params is None :
1168            return {}
1169        return params
1170
1171    def _removePreservedParams(self):
1172        self._websession.setVar("minutesPreservedParams",None)
1173
1174    def _checkParams( self, params ): 
1175        RHConferenceBaseDisplay._checkParams( self, params )
1176        preservedParams = self._getPreservedParams()
1177        if preservedParams != {}:
1178            params.update(preservedParams)
1179            self._removePreservedParams()
1180        self._cancel = params.has_key("cancel")
1181        self._save = params.has_key("OK")
1182        self._compile = params.has_key("compile")
1183        self._text = params.get("text", "")#.strip()
1184
1185    def _getCompiledMinutes( self ):
1186        minutes = []
1187        isHTML = False
1188        cList = self._target.getContributionList()
1189        cList.sort(sortContributionByDate)
1190        for c in cList:
1191            if c.getMinutes():
1192                minText = c.getMinutes().getText()
1193                minutes.append([c.getTitle(),minText])
1194                if isStringHTML(minText):
1195                    isHTML = True
1196        if isHTML:
1197            lb = "<br>"
1198        else:
1199            lb = "\n"
1200        text = "%s (%s)%s" % (self._target.getTitle(), self._target.getStartDate().strftime("%d %b %Y"), lb)
1201        part = self._target.getParticipation().getPresentParticipantListText()
1202        if part != "":
1203            text += "Present: %s%s" % (part,lb)
1204        uList = self._target.getChairList()
1205        chairs = ""
1206        for chair in uList:
1207            if chairs != "":
1208                chairs += "; "
1209            chairs += chair.getFullName()
1210        if len(uList) > 0:
1211            text += "Chaired by: %s%s%s" % (chairs, lb, lb)
1212        for min in minutes:
1213            text += "==================%s%s%s==================%s%s%s%s" % (lb,min[0],lb,lb,min[1],lb,lb)
1214        return text
1215       
1216    def _process( self ):
1217        wf=self.getWebFactory()
1218        if self._compile:
1219            minutes = self._target.getMinutes()
1220            if not minutes:
1221                minutes = self._target.createMinutes()
1222            text = self._getCompiledMinutes()
1223            minutes.setText( text )
1224        if self._save:
1225            minutes = self._target.getMinutes()
1226            if not minutes:
1227                minutes = self._target.createMinutes()
1228            minutes.setText( self._text )
1229        elif not self._cancel:
1230            if wf is None:
1231                wp = conferences.WPConfDisplayWriteMinutes(self, self._target)
1232            else:
1233                wp = wf.getConferenceDisplayWriteMinutes( self, self._conf)
1234            return wp.display()
1235        self._redirect( urlHandlers.UHConferenceDisplay.getURL( self._target ) )
1236
1237
1238class RHInternalPageDisplay(RHConferenceBaseDisplay):
1239    _uh=urlHandlers.UHInternalPageDisplay
1240
1241    def _checkParams(self,params):
1242        RHConferenceBaseDisplay._checkParams(self,params)
1243        if params.has_key("pageId"):
1244            pageId=params.get("pageId")
1245            intPagesMgr=internalPagesMgr.InternalPagesMgrRegistery().getInternalPagesMgr(self._conf)
1246            self._page=intPagesMgr.getPageById(pageId)
1247            self._target = self._page
1248            if self._page is None:
1249                raise MaKaCError( _("The webpage, you are trying to access, does not exist"))
1250        else:
1251            raise MaKaCError( _("The webpage, you are trying to access, does not exist"))
1252   
1253    def _checkProtection(self):
1254        if not self._conf.canView( self.getAW() ):
1255            from MaKaC.conference import Link,LocalFile
1256           
1257            if self._conf.getAccessKey() != "":
1258                raise AccessError()
1259            if self._getUser() == None:
1260                self._checkSessionUser()
1261            else:
1262                raise AccessError()
1263
1264    def _process( self ):
1265        p=conferences.WPInternalPageDisplay(self,self._conf, self._page)
1266        return p.display()
1267
1268class RHConferenceLatexPackage(RHConferenceBaseDisplay):
1269   
1270    def _process( self ):
1271        #return "nothing"
1272        filename = "%s-BookOfAbstracts.zip"%cleanHTMLHeaderFilename(self._target.getTitle())
1273        zipdata = StringIO.StringIO()
1274        zip = zipfile.ZipFile(zipdata, "w")
1275        for cont in self._target.getContributionList():
1276            f = []
1277            f.append("""\\section*{%s}"""%cont.getTitle())
1278            f.append(" ")
1279            l = []
1280            affil = {}
1281            i = 1
1282            for pa in cont.getPrimaryAuthorList():
1283                if pa.getAffiliation() in affil.keys():
1284                    num = affil[pa.getAffiliation()]
1285                else:
1286                    affil[pa.getAffiliation()] = i
1287                    num = i
1288                    i += 1
1289                   
1290                l.append("""\\noindent \\underline{%s}$^%d$"""%(pa.getFullName(), num))
1291           
1292            for ca in cont.getCoAuthorList():
1293                if ca.getAffiliation() in affil.keys():
1294                    num = affil[ca.getAffiliation()]
1295                else:
1296                    affil[ca.getAffiliation()] = i
1297                    num = i
1298                    i += 1
1299                l.append("""%s$^%d$"""%(ca.getFullName(), num))
1300           
1301            f.append(",\n".join(l))
1302            f.append("\n")
1303            l = []
1304            for key in affil.keys():
1305                l.append("""$^%d$%s"""%(affil[key], key))
1306            f.append("\\noindent " + ",\n".join(l))
1307            f.append("\n")
1308            f.append("""\\noindent %s"""%cont.getDescription())
1309            zip.writestr("contribution-%s"%cont.getId(), "\n".join(f))
1310        zip.close()
1311        data = zipdata.getvalue()
1312        zipdata.close()
1313       
1314        #self._req.headers_out["Accept-Ranges"] = "bytes"
1315        self._req.headers_out["Content-Length"] = "%s"%len(data)
1316        cfg = Config.getInstance()
1317        mimetype = cfg.getFileTypeMimeType( "ZIP" )
1318        #self._req.content_type = """%s; name="%s\""""%(mimetype, filename )
1319        self._req.content_type = """%s"""%(mimetype)
1320        self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename
1321        return data
1322   
1323
1324class RHFullMaterialPackage(RHConferenceBaseDisplay):
1325    _uh=urlHandlers.UHConferenceDisplayMaterialPackage
1326   
1327    def _checkParams( self, params ):
1328        RHConferenceBaseDisplay._checkParams( self, params )
1329        self._errors = params.get("errors","")
1330
1331    def _process( self ):
1332        p = conferences.WPDisplayFullMaterialPackage(self,self._target)
1333        return p.display(errors=self._errors)
1334       
1335
1336class RHFullMaterialPackagePerform(RHConferenceBaseDisplay):
1337    _uh=urlHandlers.UHConferenceDisplayMaterialPackagePerform
1338   
1339    def _checkParams( self, params ):
1340        RHConferenceBaseDisplay._checkParams( self, params )
1341        self._days=self._normaliseListParam(params.get("days",[]))
1342        self._mainResource = (params.get("mainResource","") != "")
1343        self._fromDate = ""
1344        fromDay = params.get("fromDay","")
1345        fromMonth = params.get("fromMonth","")
1346        fromYear = params.get("fromYear","")
1347        if fromDay != "" and fromMonth != "" and fromYear != "" and \
1348           fromDay != "dd" and fromMonth != "mm" and fromYear != "yyyy":
1349            self._fromDate = "%s %s %s"%(fromDay, fromMonth, fromYear)
1350        self._cancel = params.has_key("cancel")
1351        self._materialTypes=self._normaliseListParam(params.get("materialType",[]))
1352        self._sessionList = self._normaliseListParam(params.get("sessionList",[]))
1353
1354    def _process( self ):
1355        if not self._cancel:
1356            if self._materialTypes != []:
1357                p=ConferencePacker(self._conf, self._aw)
1358                path=p.pack(self._materialTypes, self._days, self._mainResource, self._fromDate, ZIPFileHandler(),self._sessionList)
1359                filename = "full-material.zip"
1360                cfg = Config.getInstance()
1361                mimetype = cfg.getFileTypeMimeType( "ZIP" )
1362                self._req.content_type = """%s"""%(mimetype)
1363                self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename
1364                self._req.sendfile(path)
1365            else:
1366                url = urlHandlers.UHConferenceDisplayMaterialPackage.getURL(self._conf)
1367                url.addParam("errors", "You have to select at least one material type")
1368                self._redirect( url )
1369        else:
1370            self._redirect( urlHandlers.UHConferenceDisplay.getURL( self._conf ) )
1371           
1372
1373class RHShortURLRedirect(RH):
1374   
1375    def _checkParams( self, params ):
1376        self._tag = params.get("tag", "").strip()
1377   
1378    def _process(self):
1379        from MaKaC.conference import ConferenceHolder
1380        ch = ConferenceHolder()
1381        from MaKaC.common.url import ShortURLMapper
1382        sum = ShortURLMapper()
1383        if ch.hasKey(self._tag):
1384            conf = ch.getById(self._tag)
1385            self._redirect(urlHandlers.UHConferenceDisplay.getURL(conf))
1386        elif sum.hasKey(self._tag):
1387            conf = sum.getById(self._tag)
1388            self._redirect(urlHandlers.UHConferenceDisplay.getURL(conf))
1389        else:
1390            raise MaKaCError("Bad event tag or Id : \"%s\""%self._tag)
1391           
Note: See TracBrowser for help on using the repository browser.