source: indico/indico/MaKaC/webinterface/rh/CFADisplay.py @ 9033fd

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 9033fd was 9033fd, checked in by Pedro Ferreira <jose.pedro.ferreira@…>, 4 years ago

Import from CVS (2009-06-29).

  • Marked all the files' author as 'Indico Team';
  • Restructured directory tree;
  • Modified setup.py;
  • Property mode set to 100644
File size: 36.4 KB
Line 
1# -*- coding: utf-8 -*-
2##
3## $Id: CFADisplay.py,v 1.46 2009/05/14 18:06:01 jose 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
22import os
23from textwrap import TextWrapper
24
25from BTrees.IOBTree import IOBTree
26from datetime import datetime
27
28import MaKaC.webinterface.urlHandlers as urlHandlers
29import MaKaC.webinterface.mail as mail
30import MaKaC.webinterface.pages.abstracts as abstracts
31import MaKaC.webinterface.materialFactories as materialFactories
32import MaKaC.review as review
33from MaKaC.webinterface.rh.conferenceDisplay import RHConferenceBaseDisplay
34from MaKaC.webinterface.rh.base import RHModificationBaseProtected
35from MaKaC.common import DBMgr,Config
36from MaKaC.review import AbstractStatusSubmitted
37from MaKaC.PDFinterface.conference import AbstractToPDF, AbstractsToPDF
38from MaKaC.webinterface.general import normaliseListParam
39from MaKaC.errors import MaKaCError
40import MaKaC.common.timezoneUtils as timezoneUtils
41import MaKaC.conference as conference
42from MaKaC.common.info import HelperMaKaCInfo
43from MaKaC.i18n import _
44
45
46class RHBaseCFA( RHConferenceBaseDisplay ):
47   
48    def _processIfActive( self ):
49        """only override this method if the CFA must be activated for
50            carrying on the handler execution"""
51        return "cfa"
52
53    def _process( self ):
54        #if the CFA is not activated we show up a form informing about that.
55        #   This must be done at RH level because there can be some RH not
56        #   displaying pages.
57        cfaMgr = self._conf.getAbstractMgr()
58        if not cfaMgr.isActive() or not self._conf.hasEnabledSection("cfa"):
59            p = abstracts.WPCFAInactive( self, self._conf )
60            return p.display()
61        else:
62            return self._processIfActive()
63
64
65class RHConferenceCFA( RHBaseCFA ):
66    _uh = urlHandlers.UHConferenceCFA
67   
68    def _processIfActive( self ):
69        p = abstracts.WPConferenceCFA( self, self._target )
70        return p.display()
71
72
73class RHAbstractSubmissionBase( RHBaseCFA ):
74   
75    def _checkProtection( self ):
76        self._checkSessionUser()
77        RHBaseCFA._checkProtection( self )
78   
79    def _processIfOpened( self ):
80        """only override this method if the submission period must be opened
81            for the request handling"""
82        return "cfa opened"
83
84    def _processIfActive( self ):
85        cfaMgr = self._conf.getAbstractMgr()
86        #if the user is in the autorized list, don't check period
87        if self._getUser() in cfaMgr.getAuthorizedSubmitterList():
88            return self._processIfOpened()
89        #if the submission period is not yet opened we show up a form informing
90        #   about that.
91        if timezoneUtils.nowutc() < cfaMgr.getStartSubmissionDate():
92        #if the submission period is already closed we show up a form informing
93        #   about that.
94            p = abstracts.WPCFANotYetOpened( self, self._conf )
95            return p.display()
96        elif timezoneUtils.nowutc() > cfaMgr.getEndSubmissionDate() :
97            p = abstracts.WPCFAClosed( self, self._conf )
98            return p.display()
99        else:
100            return self._processIfOpened()
101
102
103class _AbstractAuthorList:
104   
105    def __init__( self, params ):
106        self._mapFromParams( params )
107
108    def _getAuthorFromParams( self, idx, params ):
109        author = {  "auth_id": int( params["auth_id"][idx].strip() ), \
110                "auth_title": params["auth_title"][idx].strip(), \
111                "auth_firstName": params["auth_firstName"][idx].strip(), \
112                "auth_surName": params["auth_surName"][idx].strip(), \
113                "auth_affiliation": params["auth_affiliation"][idx].strip(), \
114                "auth_email": params["auth_email"][idx].strip(), \
115                "auth_phone": params["auth_phone"][idx].strip(), \
116                "auth_address": params["auth_address"][idx].strip(), \
117                "auth_primary": params["auth_primary"][idx], \
118                "auth_speaker": params["auth_speaker"][idx], \
119                "auth_focus": False }
120        return author
121
122    def _normaliseAuthorParams( self, params ):
123        params["auth_id"]  = normaliseListParam( params.get("auth_id", []) )
124        params["auth_title"]  = normaliseListParam( params.get("auth_title", []) )
125        params["auth_firstName"]  = normaliseListParam( params.get("auth_firstName", []) )
126        params["auth_surName"]  = normaliseListParam( params.get("auth_surName", []) )
127        params["auth_affiliation"]       = normaliseListParam( params.get("auth_affiliation", []) )
128        params["auth_email"]  = normaliseListParam( params.get("auth_email", []) )
129        params["auth_phone"]  = normaliseListParam( params.get("auth_phone", []) )
130        params["auth_address"]  = normaliseListParam( params.get("auth_address", []) )
131        primaries  = normaliseListParam( params.get("auth_primary", []) )
132        #params["auth_primary"] = normaliseListParam( params.get("auth_primary", []) )
133        speakers = normaliseListParam( params.get("auth_speaker", []) )
134        params["auth_primary"] = []
135        params["auth_speaker"] = []
136        for id in params["auth_id"]:
137            params["auth_primary"].append( str(id) in primaries )
138            params["auth_speaker"].append( str(id) in speakers)
139
140    def _mapFromParams( self, params ):
141        self._normaliseAuthorParams( params )
142        self._primaryAuthors = IOBTree()
143        self._secondaryAuthors = IOBTree()
144        maxId = -1
145        for idx in range( len( params["auth_id"] ) ):
146            id = int( params["auth_id"][idx] )
147            if id>maxId:
148                maxId = id
149            author = self._getAuthorFromParams( idx, params )
150            if author["auth_primary"]:
151                self._primaryAuthors[ id ] = author
152            else:
153                self._secondaryAuthors[ id ] = author
154        self._nextId = maxId+1
155
156    def getList( self ):
157        res = []
158        for a in self._primaryAuthors.values():
159            res.append( a )
160        for a in self._secondaryAuthors.values():
161            res.append( a )
162        return res
163
164    def getPrimaryList( self ):
165        return self._primaryAuthors.values()
166
167    def getSecondaryList( self ):
168        return self._secondaryAuthors.values()
169
170    def _getNewAuthor( self, **data ):
171        author = { "auth_id": int( self._nextId ), \
172                "auth_title": data.get("title", ""), \
173                "auth_firstName": data.get("firstName", ""), \
174                "auth_surName": data.get("surName", ""), \
175                "auth_affiliation": data.get("affiliation", ""), \
176                "auth_email": data.get("email", ""), \
177                "auth_phone": data.get("phone", ""), \
178                "auth_address": data.get("address", ""), \
179                "auth_primary": data.get("primary", False), \
180                "auth_speaker": data.get("speaker", False), \
181                "auth_focus": data.get("focus", False) }
182        #self._authors[ self._nextId ] = author
183        self._nextId += 1
184        return author
185
186    def addPrimaryAuthor( self, **data ):
187        data["primary"] = True
188        author = self._getNewAuthor( **data )
189        self._primaryAuthors[ author["auth_id"] ] = author
190   
191    def addSecondaryAuthor( self, **data ):
192        data["primary"] = False
193        author = self._getNewAuthor( **data )
194        self._secondaryAuthors[ author["auth_id"] ] = author
195   
196    def removePrimaryAuthor( self, id ):
197        try:
198            del self._primaryAuthors[ int(id) ]
199        except KeyError:
200            pass
201   
202    def removeSecondaryAuthor( self, id ):
203        try:
204            del self._secondaryAuthors[ int(id) ]
205        except KeyError:
206            pass
207
208
209class AbstractData:
210   
211    def __init__( self, absMgr, params ):
212        self._absMgr = absMgr
213        self._afm = absMgr.getAbstractFieldsMgr()
214        cparams = params.copy()
215        self._mapFromParams( cparams )
216
217    def _mapFromParams( self, params ):
218        self.title = params.get("title",  "").strip()
219        self._otherFields = {}
220        for f in self._afm.getFields():
221            id = f.getId()
222            self._otherFields[id] = params.get("f_%s"%id,"").strip()
223        self.type = params.get("type", None)
224        self.tracks = normaliseListParam( params.get("tracks", []) )
225        self.authors = _AbstractAuthorList( params )
226        self.comments = params.get("comments","")
227
228    def getFieldValue( self, id ):
229        return self._otherFields.get(id, "")
230
231    def setFieldValue( self, id, value ):
232        self._otherFields[id] = value
233   
234    def check( self ):
235        errors = []
236        if self.title.strip() == "":
237            errors.append( _("Abstract TITLE cannot be empty") )
238        for f in self._afm.getFields():
239            id = f.getId()
240            caption = f.getCaption()
241            ml = f.getMaxLength()
242            if f.isMandatory() and self._otherFields.get(id,"") == "":
243                errors.append(_("The field <b>%s</b> is mandatory") % caption)
244            if ml != 0 and len(self._otherFields.get(id,"")) > ml:
245                errors.append(_("The field <b>%s</b> cannot be more than %s characters") % (caption,ml))
246        if len( self.authors.getPrimaryList() ) == 0:
247            errors.append( _("No PRIMARY AUTHOR has been specified. You must define at least one primary author") )
248        speakerCount = 0
249        idx = 1
250        for author in self.authors.getPrimaryList():
251            if author["auth_firstName"].strip() == "":
252                errors.append( _("FIRST NAME has not been specified for PRIMARY AUTHOR #%s")%idx )
253            if author["auth_surName"].strip() == "":
254                errors.append( _("SURNAME has not been specified for PRIMARY AUTHOR #%s")%idx )
255            if author["auth_affiliation"].strip() == "":
256                errors.append( _("AFFILIATION has not been specified for PRIMARY AUTHOR #%s")%idx )
257            if author["auth_email"].strip() == "":
258                errors.append( _("EMAIL has not been specified for PRIMARY AUTHOR #%s")%idx )
259            if author["auth_speaker"]:
260                speakerCount += 1
261            idx += 1
262        idx = 1
263        for author in self.authors.getSecondaryList():
264            if author["auth_firstName"].strip() == "":
265                errors.append( _("FIRST NAME has not been specified for CO-AUTHOR #%s")%idx )
266            if author["auth_surName"].strip() == "":
267                errors.append( _("SURNAME has not been specified for CO-AUTHOR #%s")%idx )
268            if author["auth_affiliation"].strip() == "":
269                errors.append( _("AFFILIATION has not been specified for CO-AUTHOR #%s")%idx )
270            if author["auth_speaker"]:
271                speakerCount += 1
272            idx += 1
273        if speakerCount == 0:
274            errors.append( _("At least ONE PRESENTER must be specified") )
275        if not self.tracks and self._absMgr.areTracksMandatory():
276            errors.append( _("At least ONE TRACK must be seleted") )
277        return errors
278
279    def toDict( self ):
280        d = { "title": self.title, \
281              "type": self.type, \
282              "tracks": self.tracks, \
283              "authors": self.authors, \
284              "comments": self.comments }
285        for f in self._afm.getFields():
286            id = f.getId()
287            d[id] = self._otherFields.get(id,"")
288        return d
289
290
291class _AbstractSubmissionNotification:
292
293    def __init__( self, abstract ):
294        self._abstract = abstract
295        self._conf = self._abstract.getConference()
296        self._subject=_("Abstract submission confirmation (%s)")%self._conf.getTitle()
297
298    def getSubject( self ):
299        return self._subject
300
301    def setSubject(self,s):
302        self._subject=s
303
304    def getDestination( self ):
305        return self._abstract.getSubmitter()
306
307    def getFromAddr(self):
308        if self._conf.getSupportEmail().strip()!="":
309            return self._conf.getSupportEmail()
310        else:
311            return HelperMaKaCInfo.getMaKaCInfoInstance().getSupportEmail()
312           
313    def getCCList(self):
314        return self._abstract.getOwner().getSubmissionNotification().getCCList()
315
316    def getToList(self):
317        return self._abstract.getOwner().getSubmissionNotification().getToList()
318
319    def getMsg( self ):
320        primary_authors = []
321        for auth in self._abstract.getPrimaryAuthorList():
322            primary_authors.append("""%s (%s) <%s>"""%(auth.getFullName(), auth.getAffiliation(), auth.getEmail())  )
323        co_authors = []
324        for auth in self._abstract.getCoAuthorList():
325            email = ""
326            if auth.getEmail() != "":
327                email = " <%s>"%auth.getEmail()
328            co_authors.append( """%s (%s)%s"""%(auth.getFullName(), auth.getAffiliation(), email) )
329        speakers = []
330        for spk in self._abstract.getSpeakerList():
331            speakers.append( spk.getFullName() )
332        tracks = []
333        for track in self._abstract.getTrackListSorted():
334            tracks.append( """%s"""%track.getTitle() )
335        tw = TextWrapper()
336        msg = [ _("""_("Dear") %s,""")%self._abstract.getSubmitter().getFullName() ]
337        msg.append( "" )
338        msg.append( tw.fill(_("The submission of your abstract has been successfully processed.")) )
339        msg.append( "" )
340        tw.break_long_words = False
341        msg.append( tw.fill( _("""_("Abstract submitted"):\n<%s>.""")%urlHandlers.UHUserAbstracts.getURL( self._conf ) ) )
342        msg.append( "" )
343        msg.append( tw.fill( _("""_("Status of your abstract"):\n<%s>.""")%urlHandlers.UHAbstractDisplay.getURL( self._abstract ) ) )
344        msg.append( "" )
345        tw.subsequent_indent = ""
346        msg.append( tw.fill( _("""_("See below a detailed summary of your submitted abstract"):""") ) )
347        msg.append( "" )
348        tw.subsequent_indent = " "*3
349        msg.append( tw.fill( _("""_("Conference"): %s""")%self._conf.getTitle() ) )
350        msg.append( "" )
351        msg.append( tw.fill( _("""_("Submitted by"): %s""")%self._abstract.getSubmitter().getFullName() ) )
352        msg.append( "" )
353        msg.append( tw.fill( _("""_("Submitted on"): %s""")%self._abstract.getSubmissionDate().strftime( "%d %B %Y %H:%M" ) ) )
354        msg.append( "" )
355        msg.append( tw.fill( _("""_("Title"): %s""")%self._abstract.getTitle() ) )
356        msg.append( "" )
357        for f in self._conf.getAbstractMgr().getAbstractFieldsMgr().getFields():
358            msg.append( tw.fill(f.getCaption()) )
359            msg.append( self._abstract.getField(f.getId()) )
360            msg.append( "" )
361        msg.append( tw.fill( _("""_("Primary Authors"):""") ) )
362        msg += primary_authors
363        msg.append( "" )
364        msg.append( tw.fill( _("""_("Co-authors"):""") ) )
365        msg += co_authors
366        msg.append( "" )
367        msg.append( tw.fill( _("""_("Abstract presenters"):""") ) )
368        msg += speakers
369        msg.append( "" )
370        msg.append( tw.fill( _("""_("Track classification"):""") ) )
371        msg += tracks
372        msg.append( "" )
373        ctype= _("""--_("not specified")--""")
374        if self._abstract.getContribType() is not None:
375            ctype=self._abstract.getContribType().getName()
376        msg.append( tw.fill( _("""_("Presentation type"): %s""")%ctype) )
377        msg.append( "" )
378        msg.append( tw.fill( _("""_("Comments"): %s""")%self._abstract.getComments() ) )
379        msg.append( "" )
380        return "\n".join( msg )
381   
382    def getBody(self):
383        msg=self.getMsg()
384        return _("""
385_("The following email has been sent to %s"):
386
387===
388               
389%s""")%(self.getDestination().getFullName(), msg)
390
391
392class RHAbstractSubmission( RHAbstractSubmissionBase ):
393    _uh = urlHandlers.UHAbstractSubmission
394
395    def _checkParams( self, params ):
396        RHAbstractSubmissionBase._checkParams( self, params )
397        #if the user is not logged in we return inmediately as this form needs
398        #   the user to be logged in and therefore all the checking below is not
399        #   necessary
400        if self._getUser() == None:
401            return
402        self._action = ""
403        if "cancel" in params:
404            self._action = "CANCEL"
405            return
406        id = params.get("type", "")
407        params["type"] = self._conf.getContribTypeById(id)
408        self._abstractData = AbstractData( self._target.getAbstractMgr(), params )
409        if "add_primary_author" in params:
410            #self._action = "NEW_AUTHOR"
411            self._abstractData.authors.addPrimaryAuthor( focus=True )
412        elif "add_secondary_author" in params:
413            #self._action = "NEW_AUTHOR"
414            self._abstractData.authors.addSecondaryAuthor( focus=True )
415        elif "remove_primary_authors" in params:
416            tmp = self._normaliseListParam( params.get("selected_primary_authors", []) )
417            for id in tmp:
418                self._abstractData.authors.removePrimaryAuthor( id )
419        elif "remove_secondary_authors" in params:
420            tmp = self._normaliseListParam( params.get("selected_secondary_authors", []) )
421            for id in tmp:
422                self._abstractData.authors.removeSecondaryAuthor( id )
423        elif "validate" in params:
424            self._action = "VALIDATE"
425        else:
426            #First call
427            av = self._getUser()
428            self._abstractData.authors.addPrimaryAuthor( \
429                                        title = av.getTitle(), \
430                                        firstName = av.getName(), \
431                                        surName = av.getSurName(), \
432                                        affiliation = av.getOrganisation(), \
433                                        email = av.getEmail(), \
434                                        phone = av.getTelephone(), \
435                                        address = av.getAddress(), \
436                                        speaker = True )
437
438    def _doValidate( self ):
439        #First, one must validate that the information is fine
440        errors = self._abstractData.check()
441        if errors:
442            p = abstracts.WPAbstractSubmission( self, self._target )
443            pars = self._abstractData.toDict()
444            pars["errors"] = errors
445            pars["action"] = self._action
446            return p.display( **pars )
447        #Then, we create the abstract object and set its data to the one
448        #   received
449        cfaMgr = self._target.getAbstractMgr()
450        afm = cfaMgr.getAbstractFieldsMgr()
451        a = cfaMgr.newAbstract( self._getUser() )
452        a.setTitle( self._abstractData.title )
453        for f in afm.getFields():
454            id = f.getId()
455            a.setField(id, self._abstractData.getFieldValue(id))
456        for authData in self._abstractData.authors.getPrimaryList():
457            auth=a.newPrimaryAuthor(title = authData["auth_title"], \
458                                firstName = authData["auth_firstName"], \
459                                surName = authData["auth_surName"], \
460                                email = authData["auth_email"], \
461                                affiliation = authData["auth_affiliation"], \
462                                address = authData["auth_address"], \
463                                telephone = authData["auth_phone"] )
464            if authData["auth_speaker"]:
465                a.addSpeaker( auth )
466        for authData in self._abstractData.authors.getSecondaryList():
467            auth=a.newCoAuthor(title = authData["auth_title"], \
468                                firstName = authData["auth_firstName"], \
469                                surName = authData["auth_surName"], \
470                                email = authData["auth_email"], \
471                                affiliation = authData["auth_affiliation"], \
472                                address = authData["auth_address"], \
473                                telephone = authData["auth_phone"] )
474            if authData["auth_speaker"]:
475                a.addSpeaker( auth )
476        a.setContribType( self._abstractData.type )
477        for trackId in self._abstractData.tracks:
478            track = self._conf.getTrackById( trackId )
479            a.addTrack( track )
480        a.setComments(self._abstractData.comments)
481        #The commit must be forced before sending the confirmation
482        DBMgr.getInstance().commit()
483        #Email confirmation about the submission
484        mail.Mailer.send( _AbstractSubmissionNotification( a ) )
485        #Email confirmation about the submission to coordinators
486        if cfaMgr.getSubmissionNotification().hasDestination():
487            asn=_AbstractSubmissionNotification( a )
488            asn.setSubject(_("[Indico] New abstract submission: %s")%asn.getDestination().getFullName())
489            mail.GenericMailer.send( asn )
490        #We must perform some actions: email warning to the authors
491        #Finally, we display a confirmation form
492        self._redirect( urlHandlers.UHAbstractSubmissionConfirmation.getURL( a ) )
493
494    def _processIfOpened( self ):
495        if self._action == "CANCEL":
496            self._redirect( urlHandlers.UHConferenceCFA.getURL( self._conf ) )
497        elif self._action == "VALIDATE":
498            return self._doValidate()
499        else:
500            p = abstracts.WPAbstractSubmission( self, self._target )
501            pars = self._abstractData.toDict()
502            return p.display( **pars )
503
504
505           
506class RHUserAbstracts( RHAbstractSubmissionBase ):
507    _uh = urlHandlers.UHUserAbstracts
508
509    def _processIfActive( self ):
510        p = abstracts.WPUserAbstracts( self, self._conf )
511        return p.display()
512
513       
514class RHAbstractDisplayBase( RHAbstractSubmissionBase ):
515   
516    def _checkParams( self, params ):
517        RHAbstractSubmissionBase._checkParams( self, params )
518        cfaMgr = self._conf.getAbstractMgr()
519        if not params.has_key("abstractId") and params.has_key("contribId"):
520            params["abstractId"] = params["contribId"]
521        self._abstract = self._target = cfaMgr.getAbstractById( params["abstractId"] )
522
523
524class RHAbstractSubmissionConfirmation( RHAbstractDisplayBase ):
525    _uh = urlHandlers.UHAbstractSubmissionConfirmation
526
527    def _processIfOpened( self ):
528        p = abstracts.WPAbstractSubmissionConfirmation( self, self._target )
529        return p.display()
530
531
532class RHAbstractDisplay( RHAbstractDisplayBase ):
533    _uh = urlHandlers.UHAbstractDisplay
534   
535    def _processIfActive( self ):
536        p = abstracts.WPAbstractDisplay( self, self._target )
537        return p.display()
538
539
540class RHAbstractDisplayPDF( RHAbstractDisplayBase ):
541
542    def _checkProtection( self ):
543        RHConferenceBaseDisplay._checkProtection(self)
544        if not self._conf.hasEnabledSection("cfa"):
545            raise MaKaCError( _("The Call For Abstracts was disabled by the conference managers"))
546   
547    def _process( self ):
548        tz = timezoneUtils.DisplayTZ(self._aw,self._conf).getDisplayTZ()
549        filename = "%s - Abstract.pdf"%self._target.getTitle()
550        pdf = AbstractToPDF(self._conf, self._target,tz=tz)
551        data = pdf.getPDFBin()
552        #self._req.headers_out["Accept-Ranges"] = "bytes"
553        self._req.headers_out["Content-Length"] = "%s"%len(data)
554        cfg = Config.getInstance()
555        mimetype = cfg.getFileTypeMimeType( "PDF" )
556        self._req.content_type = """%s"""%(mimetype)
557        self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename
558        return data
559
560
561class RHAbstractsDisplayPDF(RHConferenceBaseDisplay):
562
563    def _checkProtection( self ):
564        RHConferenceBaseDisplay._checkProtection(self)
565        if not self._conf.hasEnabledSection("cfa"):
566            raise MaKaCError( _("The Call For Abstracts was disabled by the conference managers"))
567   
568    def _checkParams( self, params ):
569        RHConferenceBaseDisplay._checkParams( self, params )
570        self._abstractIds = normaliseListParam( params.get("abstracts", []) )
571        self._abstracts = []
572        abMgr = self._conf.getAbstractMgr()
573        for id in self._abstractIds:
574            if abMgr.getAbstractById(id).canView(self._aw):
575                self._abstracts.append(abMgr.getAbstractById(id))
576   
577    def _process( self ): 
578        tz = timezoneUtils.DisplayTZ(self._aw,self._conf).getDisplayTZ()     
579        filename = "Abstracts.pdf"
580        if not self._abstracts:
581            return _("No abstract to print")
582        pdf = AbstractsToPDF(self._conf, self._abstracts,tz=tz)
583        data = pdf.getPDFBin()
584        self._req.set_content_length(len(data))
585        cfg = Config.getInstance()
586        mimetype = cfg.getFileTypeMimeType( "PDF" )
587        self._req.content_type = """%s"""%(mimetype)
588        self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename
589        return data
590
591
592class RHAbstractModificationBase( RHAbstractDisplayBase, RHModificationBaseProtected ):
593   
594    def _checkProtection( self ):
595        RHModificationBaseProtected._checkProtection( self )
596   
597   
598    def _processIfActive( self ):
599        #We overload this method to alow modification after the CFA is closed if the modification deadline is after the submission deadline
600        cfaMgr = self._conf.getAbstractMgr()
601        modifDeadLine = cfaMgr.getModificationDeadline()
602        if not modifDeadLine:
603            modifDeadLine = cfaMgr.getEndSubmissionDate()
604        #if the user is in the autorized list, don't check period
605        if self._getUser() in cfaMgr.getAuthorizedSubmitterList():
606            return self._processIfOpened()
607        #if the submission period is not yet opened we show up a form informing
608        #   about that.
609        if timezoneUtils.nowutc() < cfaMgr.getStartSubmissionDate():
610        #if the submission period is already closed we show up a form informing
611        #   about that.
612            p = abstracts.WPCFANotYetOpened( self, self._conf )
613            return p.display()
614        #elif timezoneUtils.nowutc() > cfaMgr.getEndSubmissionDate() :
615        elif timezoneUtils.nowutc() > cfaMgr.getEndSubmissionDate() and timezoneUtils.nowutc() > modifDeadLine:
616            p = abstracts.WPCFAClosed( self, self._conf )
617            return p.display()
618        else:
619            return self._processIfOpened()
620
621
622class RHAbstractModify( RHAbstractModificationBase ):
623    _uh = urlHandlers.UHAbstractModify
624
625    def _checkParams( self, params ):
626        RHAbstractModificationBase._checkParams( self, params )
627        #if the user is not logged in we return inmediately as this form needs
628        #   the user to be logged in and therefore all the checking below is not
629        #   necessary
630        if self._getUser() == None:
631            return
632        self._action = ""
633        if "cancel" in params:
634            self._action = "CANCEL"
635            return
636        params["type"]=self._conf.getContribTypeById(params.get("type", ""))
637        self._abstractData = AbstractData( self._conf.getAbstractMgr(), params )
638        if "add_primary_author" in params:
639            self._abstractData.authors.addPrimaryAuthor( focus=True )
640        elif "add_secondary_author" in params:
641            self._abstractData.authors.addSecondaryAuthor( focus=True )
642        elif "remove_primary_authors" in params:
643            tmp = self._normaliseListParam( params.get("selected_primary_authors", []) )
644            for id in tmp:
645                self._abstractData.authors.removePrimaryAuthor( id )
646        elif "remove_secondary_authors" in params:
647            tmp = self._normaliseListParam( params.get("selected_secondary_authors", []) )
648            for id in tmp:
649                self._abstractData.authors.removeSecondaryAuthor( id )
650        elif "validate" in params:
651            self._action = "VALIDATE"
652        else:
653            #First call
654            afm = self._conf.getAbstractMgr().getAbstractFieldsMgr()
655            self._abstractData.title = self._abstract.getTitle()
656            for f in afm.getFields():
657                id = f.getId()
658                self._abstractData.setFieldValue(id, self._abstract.getField(id))
659            for author in self._abstract.getPrimaryAuthorList():
660                data = { "title": author.getTitle(), \
661                        "firstName": author.getFirstName(), \
662                        "surName": author.getSurName(), \
663                        "affiliation": author.getAffiliation(), \
664                        "email": author.getEmail(), \
665                        "phone": author.getTelephone(), \
666                        "address": author.getAddress(), \
667                        "primary": self._abstract.isPrimaryAuthor( author ), \
668                        "speaker": self._abstract.isSpeaker( author ) }
669                self._abstractData.authors.addPrimaryAuthor( **data )
670            for author in self._abstract.getCoAuthorList():
671                data = { "title": author.getTitle(), \
672                        "firstName": author.getFirstName(), \
673                        "surName": author.getSurName(), \
674                        "affiliation": author.getAffiliation(), \
675                        "email": author.getEmail(), \
676                        "phone": author.getTelephone(), \
677                        "address": author.getAddress(), \
678                        "primary": self._abstract.isPrimaryAuthor( author ), \
679                        "speaker": self._abstract.isSpeaker( author ) }
680                self._abstractData.authors.addSecondaryAuthor( **data )
681            self._abstractData.type=self._abstract.getContribType()
682            trackIds = []
683            for track in self._abstract.getTrackListSorted():
684                trackIds.append( track.getId() )
685            self._abstractData.tracks = trackIds
686            self._abstractData.comments = self._abstract.getComments()
687   
688    def _doValidate( self ):
689        #First, one must validate that the information is fine
690        errors = self._abstractData.check()
691        if errors:
692            p = abstracts.WPAbstractModify( self, self._target )
693            pars = self._abstractData.toDict()
694            pars["errors"] = errors
695            pars["action"] = self._action
696            return p.display( **pars )
697        #Then, we create the abstract object and set its data to the one
698        #   received
699        self._abstract.setTitle( self._abstractData.title )
700        afm = self._conf.getAbstractMgr().getAbstractFieldsMgr()
701        for f in afm.getFields():
702            id = f.getId()
703            self._abstract.setField( id, self._abstractData.getFieldValue(id))
704        self._abstract.clearAuthors()
705        #for authData in self._abstractData.authors.getList():
706        #    auth = self._abstract.newAuthor( title = authData["auth_title"], \
707        #                        firstName = authData["auth_firstName"], \
708        #                        surName = authData["auth_surName"], \
709        #                        email = authData["auth_email"], \
710        #                        affiliation = authData["auth_affiliation"], \
711        #                        address = authData["auth_address"], \
712        #                        telephone = authData["auth_phone"] )
713        #    if authData["auth_speaker"]:
714        #        self._abstract.addSpeaker( auth )
715        #    if authData["auth_primary"]:
716        #        self._abstract.addPrimaryAuthor( auth )
717        for authData in self._abstractData.authors.getPrimaryList():
718            auth=self._abstract.newPrimaryAuthor(title=authData["auth_title"], \
719                                firstName = authData["auth_firstName"], \
720                                surName = authData["auth_surName"], \
721                                email = authData["auth_email"], \
722                                affiliation = authData["auth_affiliation"], \
723                                address = authData["auth_address"], \
724                                telephone = authData["auth_phone"] )
725            if authData["auth_speaker"]:
726                self._abstract.addSpeaker( auth )
727        for authData in self._abstractData.authors.getSecondaryList():
728            auth=self._abstract.newCoAuthor(title=authData["auth_title"], \
729                                firstName = authData["auth_firstName"], \
730                                surName = authData["auth_surName"], \
731                                email = authData["auth_email"], \
732                                affiliation = authData["auth_affiliation"], \
733                                address = authData["auth_address"], \
734                                telephone = authData["auth_phone"] )
735            if authData["auth_speaker"]:
736                self._abstract.addSpeaker( auth )
737        self._abstract.setContribType( self._abstractData.type )
738        #self._abstract.clearTracks()
739        tracks = []
740        for trackId in self._abstractData.tracks:
741            tracks.append( self._conf.getTrackById( trackId ) )
742        self._abstract.setTracks( tracks )
743        self._abstract.setComments(self._abstractData.comments)
744        #We must perform some actions: email warning to the authors
745        #Finally, we display a confirmation form
746        self._redirect( urlHandlers.UHAbstractDisplay.getURL( self._abstract ) )
747
748    def _processIfOpened( self ):
749        #check if the modification period is not over or if the abstract
750        #   is in a different status than Submitted
751        if not self._conf.getAbstractMgr().inModificationPeriod() or \
752                not isinstance( self._abstract.getCurrentStatus(), \
753                                                AbstractStatusSubmitted ):
754            wp = abstracts.WPAbstractCannotBeModified( self, self._abstract )
755            return wp.display()
756        if self._action == "CANCEL":
757            self._redirect( urlHandlers.UHAbstractDisplay.getURL( self._abstract ) )
758        elif self._action == "VALIDATE":
759            return self._doValidate()
760        else:
761            p = abstracts.WPAbstractModify( self, self._target )
762            pars = self._abstractData.toDict()
763            pars["action"] = self._action
764            return p.display( **pars )
765
766
767class RHAbstractWithdraw( RHAbstractModificationBase ):
768    _uh = urlHandlers.UHAbstractWithdraw
769   
770    def _checkParams( self, params ):
771        RHAbstractModificationBase._checkParams( self, params )
772        self._action = ""
773        self._comments = params.get( "comment", "" )
774        if params.has_key("OK"):
775            self._action = "WITHDRAW"
776        elif params.has_key("cancel"):
777            self._action = "CANCEL"
778       
779    def _processIfOpened( self ):
780        if self._action == "CANCEL":
781            self._redirect( urlHandlers.UHAbstractDisplay.getURL( self._abstract ) )
782        elif self._action == "WITHDRAW":
783            if self._abstract.getCurrentStatus().__class__ not in \
784                    [review.AbstractStatusSubmitted, 
785                    review.AbstractStatusUnderReview,
786                    review.AbstractStatusInConflict,
787                    review.AbstractStatusProposedToAccept,
788                    review.AbstractStatusProposedToReject]:
789                raise MaKaCError( _("this abstract cannot be withdrawn, please contact the conference organisers in order to do so"))
790            self._abstract.withdraw(self._getUser(),self._comments) 
791            self._redirect( urlHandlers.UHAbstractDisplay.getURL( self._abstract ) )
792        else:
793            wp = abstracts.WPAbstractWithdraw( self, self._abstract )
794            return wp.display()
795
796
797class RHAbstractRecovery( RHAbstractModificationBase ):
798    _uh = urlHandlers.UHAbstractWithdraw
799
800    def _checkParams( self, params ):
801        RHAbstractModificationBase._checkParams( self, params )
802        self._action = ""
803        if params.has_key("OK"):
804            self._action = "RECOVER"
805        elif params.has_key("cancel"):
806            self._action = "CANCEL"
807
808    def _processIfOpened( self ):
809        if self._action == "CANCEL":
810            self._redirect( urlHandlers.UHAbstractDisplay.getURL( self._abstract ) )
811        elif self._action == "RECOVER":
812            status=self._abstract.getCurrentStatus()
813            if isinstance(status,review.AbstractStatusWithdrawn):
814                if status.getResponsible()!=self._getUser():
815                    raise MaKaCError( _("you are not allowed to recover this abstract"))
816                self._abstract.recover() 
817            self._redirect( urlHandlers.UHAbstractDisplay.getURL( self._abstract ) )
818        else:
819            wp = abstracts.WPAbstractRecovery( self, self._abstract )
820            return wp.display()
Note: See TracBrowser for help on using the repository browser.