source: indico/indico/MaKaC/webinterface/rh/conferenceDisplay.py @ 0e0c28

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

[FIXED] Webcast admins access

fixes #78: Webcast admins should have access rights to every event
fixes #79: Webcast admins should see the "Video Services Overview"

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