Ignore:
Timestamp:
08/29/11 17:19:55 (21 months ago)
Author:
Jose Benito <jose.benito.gonzalez@…>
Branches:
master, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 0da0c1403bae8e51d8229f460181c71b9e6dda72
Children:
a8c3b2
Parents:
83c12a
git-author:
Alexis Castilla Hernandez <alexis.castilla.hernandez@…> (07/28/11 12:00:23)
git-committer:
Jose Benito <jose.benito.gonzalez@…> (08/29/11 17:19:55)
Message:

[IMP] Abstract submission form

  • Many changes done to improve the abstract submission part:
  • Same classes for the abstract wrapper for both, display and management (before 2 differents ways to do this)
  • Added new class AbstractParam? to use inheritance.
  • Common template (AbstractDataModification?.tpl) for the submit/modify functionality everywhere and for the abstract preview.
  • Taken out all html code from python files for this functionality -> A lot of new code within the AbstractDataModification? template.
  • Allow to add existing authors.
  • Drag and drop to move authors and co-authors using jquery. New JS classes to manage the authors list.
  • Added more checks on submit the form.
  • New way to give feedback to the user for the limited fields.
  • Deleted some templates not used anymore.
  • New file Dragndrop.js with some standard code for drag and drop.
  • New fossil of the Author class (abstractDataWrapper) to keep the author values if the server gets an error.
  • Added functionality to add attached files in abstract submission form.
  • Included new LocalFile? fossil to set a new url for the files.
  • Added new path for the abstract attachments in the repository.
  • New attribute in class Abstract for the attachments.
  • Implemented functionlity in class Abstract to store new materials, delete materials, clone materials, check materials size...
  • Files size checked in the server side.
  • New param "attachments" to show the attached files in the abstract display/modify pages.
  • New UH and RH classes to get an attached file.
  • Included new attachments and files that are already attached (if modifying abstract) in the .tpl.
  • File/s size checked in the client size.
  • Implemented functionality in the interface to add/delete new attachments and to delete files already attached (if modifying)

Other things included in this ticket:

  • Fixed a bug in Default.css (extra " causing errors in IE7)
  • Added some internationalization to the parameter manager error messages.
  • Fixed bug within jquery-ui.js file in line -8262,7: Extra ',' at the end causing error in IE7.
  • New var in indico.conf.sample to limit he maximum size per file.
  • Renamed the var used in indico.conf.sample to limit the maximum size per request.
  • Sticky footer modifying some CSS properties.
  • Fixed some bugs in abstract display protection.
  • New class KeyAccessError?.
  • Fixed bug in AccessControler? class when the owner hasn't owner (highest level).
  • Replaced deprecated indico project url (<http://cern.ch/indico>) by the current one (<http://indico-software.org/>).
  • Fixed bug in AbstractMgr? to check if the author belongs to any abstract.
  • Removed internationalization of menu entries in displayMgr.py
  • closes #89
File:
1 edited

Legend:

Unmodified
Added
Removed
  • indico/MaKaC/webinterface/rh/CFADisplay.py

    r39b7d0 rd8fbd8  
    4242from MaKaC.i18n import _ 
    4343from indico.util.i18n import i18nformat 
    44 import util.text as textUtils 
     44from MaKaC.webinterface.common.abstractDataWrapper import AbstractParam 
    4545 
    4646 
     
    100100        else: 
    101101            return self._processIfOpened() 
    102  
    103  
    104 class _AbstractAuthorList: 
    105  
    106     def __init__( self, params ): 
    107         self._mapFromParams( params ) 
    108  
    109     def _getAuthorFromParams( self, idx, params ): 
    110         author = {  "auth_id": int( params["auth_id"][idx].strip() ), \ 
    111                 "auth_title": params["auth_title"][idx].strip(), \ 
    112                 "auth_firstName": params["auth_firstName"][idx].strip(), \ 
    113                 "auth_surName": params["auth_surName"][idx].strip(), \ 
    114                 "auth_affiliation": params["auth_affiliation"][idx].strip(), \ 
    115                 "auth_email": params["auth_email"][idx].strip(), \ 
    116                 "auth_phone": params["auth_phone"][idx].strip(), \ 
    117                 "auth_address": params["auth_address"][idx].strip(), \ 
    118                 "auth_primary": params["auth_primary"][idx], \ 
    119                 "auth_speaker": params["auth_speaker"][idx], \ 
    120                 "auth_focus": False } 
    121         return author 
    122  
    123     def _normaliseAuthorParams( self, params ): 
    124         params["auth_id"]  = normaliseListParam( params.get("auth_id", []) ) 
    125         params["auth_title"]  = normaliseListParam( params.get("auth_title", []) ) 
    126         params["auth_firstName"]  = normaliseListParam( params.get("auth_firstName", []) ) 
    127         params["auth_surName"]  = normaliseListParam( params.get("auth_surName", []) ) 
    128         params["auth_affiliation"]       = normaliseListParam( params.get("auth_affiliation", []) ) 
    129         params["auth_email"]  = normaliseListParam( params.get("auth_email", []) ) 
    130         params["auth_phone"]  = normaliseListParam( params.get("auth_phone", []) ) 
    131         params["auth_address"]  = normaliseListParam( params.get("auth_address", []) ) 
    132         primaries  = normaliseListParam( params.get("auth_primary", []) ) 
    133         #params["auth_primary"] = normaliseListParam( params.get("auth_primary", []) ) 
    134         speakers = normaliseListParam( params.get("auth_speaker", []) ) 
    135         params["auth_primary"] = [] 
    136         params["auth_speaker"] = [] 
    137         for id in params["auth_id"]: 
    138             params["auth_primary"].append( str(id) in primaries ) 
    139             params["auth_speaker"].append( str(id) in speakers) 
    140  
    141     def _mapFromParams( self, params ): 
    142         self._normaliseAuthorParams( params ) 
    143         self._primaryAuthors = IOBTree() 
    144         self._secondaryAuthors = IOBTree() 
    145         maxId = -1 
    146         for idx in range( len( params["auth_id"] ) ): 
    147             id = int( params["auth_id"][idx] ) 
    148             if id>maxId: 
    149                 maxId = id 
    150             author = self._getAuthorFromParams( idx, params ) 
    151             if author["auth_primary"]: 
    152                 self._primaryAuthors[ id ] = author 
    153             else: 
    154                 self._secondaryAuthors[ id ] = author 
    155         self._nextId = maxId+1 
    156  
    157     def getList( self ): 
    158         res = [] 
    159         for a in self._primaryAuthors.values(): 
    160             res.append( a ) 
    161         for a in self._secondaryAuthors.values(): 
    162             res.append( a ) 
    163         return res 
    164  
    165     def getPrimaryList( self ): 
    166         return self._primaryAuthors.values() 
    167  
    168     def getSecondaryList( self ): 
    169         return self._secondaryAuthors.values() 
    170  
    171     def _getNewAuthor( self, **data ): 
    172         author = { "auth_id": int( self._nextId ), \ 
    173                 "auth_title": data.get("title", ""), \ 
    174                 "auth_firstName": data.get("firstName", ""), \ 
    175                 "auth_surName": data.get("surName", ""), \ 
    176                 "auth_affiliation": data.get("affiliation", ""), \ 
    177                 "auth_email": data.get("email", ""), \ 
    178                 "auth_phone": data.get("phone", ""), \ 
    179                 "auth_address": data.get("address", ""), \ 
    180                 "auth_primary": data.get("primary", False), \ 
    181                 "auth_speaker": data.get("speaker", False), \ 
    182                 "auth_focus": data.get("focus", False) } 
    183         #self._authors[ self._nextId ] = author 
    184         self._nextId += 1 
    185         return author 
    186  
    187     def addPrimaryAuthor( self, **data ): 
    188         data["primary"] = True 
    189         author = self._getNewAuthor( **data ) 
    190         self._primaryAuthors[ author["auth_id"] ] = author 
    191  
    192     def addSecondaryAuthor( self, **data ): 
    193         data["primary"] = False 
    194         author = self._getNewAuthor( **data ) 
    195         self._secondaryAuthors[ author["auth_id"] ] = author 
    196  
    197     def removePrimaryAuthor( self, id ): 
    198         try: 
    199             del self._primaryAuthors[ int(id) ] 
    200         except KeyError: 
    201             pass 
    202  
    203     def removeSecondaryAuthor( self, id ): 
    204         try: 
    205             del self._secondaryAuthors[ int(id) ] 
    206         except KeyError: 
    207             pass 
    208  
    209  
    210 class AbstractData: 
    211  
    212     def __init__( self, absMgr, params ): 
    213         self._absMgr = absMgr 
    214         self._afm = absMgr.getAbstractFieldsMgr() 
    215         cparams = params.copy() 
    216         self._mapFromParams( cparams ) 
    217  
    218     def _mapFromParams( self, params ): 
    219         self.title = params.get("title",  "").strip() 
    220         self._otherFields = {} 
    221         for f in self._afm.getFields(): 
    222             id = f.getId() 
    223             self._otherFields[id] = params.get("f_%s"%id,"").strip() 
    224         self.type = params.get("type", None) 
    225         self.tracks = normaliseListParam( params.get("tracks", []) ) 
    226         self.authors = _AbstractAuthorList( params ) 
    227         self.comments = params.get("comments","") 
    228  
    229     def getFieldNames( self ): 
    230         return ['f_%s' % id for id in self._otherFields.keys()] 
    231  
    232     def getFieldValue( self, id ): 
    233         return self._otherFields.get(id, "") 
    234  
    235     def setFieldValue( self, id, value ): 
    236         self._otherFields[id] = value 
    237  
    238     def check( self ): 
    239         errors = [] 
    240         if self.title.strip() == "": 
    241             errors.append( _("Abstract TITLE cannot be empty") ) 
    242         for f in self._afm.getFields(): 
    243             id = f.getId() 
    244             caption = f.getCaption() 
    245             ml = f.getMaxLength() 
    246             limitation = f.getLimitation() 
    247             if f.isMandatory() and self._otherFields.get(id,"") == "": 
    248                 errors.append(_("The field <b>%s</b> is mandatory") % caption) 
    249             if ml != 0: 
    250                 if limitation == "words" and textUtils.wordsCounter(self._otherFields.get(id,"")) > ml: 
    251                     errors.append(_("The field <b>%s</b> cannot be more than %s words") % (caption,ml)) 
    252                 elif limitation == "chars" and len(self._otherFields.get(id,"")) > ml: 
    253                     errors.append(_("The field <b>%s</b> cannot be more than %s characters") % (caption,ml)) 
    254         if len( self.authors.getPrimaryList() ) == 0: 
    255             errors.append( _("No PRIMARY AUTHOR has been specified. You must define at least one primary author") ) 
    256         speakerCount = 0 
    257         idx = 1 
    258         for author in self.authors.getPrimaryList(): 
    259             if author["auth_firstName"].strip() == "": 
    260                 errors.append( _("FIRST NAME has not been specified for PRIMARY AUTHOR #%s")%idx ) 
    261             if author["auth_surName"].strip() == "": 
    262                 errors.append( _("SURNAME has not been specified for PRIMARY AUTHOR #%s")%idx ) 
    263             if author["auth_affiliation"].strip() == "": 
    264                 errors.append( _("AFFILIATION has not been specified for PRIMARY AUTHOR #%s")%idx ) 
    265             if author["auth_email"].strip() == "": 
    266                 errors.append( _("EMAIL has not been specified for PRIMARY AUTHOR #%s")%idx ) 
    267             if author["auth_speaker"]: 
    268                 speakerCount += 1 
    269             idx += 1 
    270         idx = 1 
    271         for author in self.authors.getSecondaryList(): 
    272             if author["auth_firstName"].strip() == "": 
    273                 errors.append( _("FIRST NAME has not been specified for CO-AUTHOR #%s")%idx ) 
    274             if author["auth_surName"].strip() == "": 
    275                 errors.append( _("SURNAME has not been specified for CO-AUTHOR #%s")%idx ) 
    276             if author["auth_affiliation"].strip() == "": 
    277                 errors.append( _("AFFILIATION has not been specified for CO-AUTHOR #%s")%idx ) 
    278             if author["auth_speaker"]: 
    279                 speakerCount += 1 
    280             idx += 1 
    281         if speakerCount == 0: 
    282             errors.append( _("At least ONE PRESENTER must be specified") ) 
    283         if not self.tracks and self._absMgr.areTracksMandatory(): 
    284             # check if there are tracks, otherwise the user cannot select at least one 
    285             if len(self._absMgr.getConference().getTrackList()) != 0: 
    286                 errors.append( _("At least ONE TRACK must be seleted") ) 
    287         return errors 
    288  
    289     def toDict( self ): 
    290         d = { "title": self.title, \ 
    291               "type": self.type, \ 
    292               "tracks": self.tracks, \ 
    293               "authors": self.authors, \ 
    294               "comments": self.comments } 
    295         for f in self._afm.getFields(): 
    296             id = f.getId() 
    297             d[id] = self._otherFields.get(id,"") 
    298         return d 
    299102 
    300103 
     
    397200 
    398201 
    399 class RHAbstractSubmission( RHAbstractSubmissionBase ): 
    400     _uh = urlHandlers.UHAbstractSubmission 
     202class RHAbstractModificationAction(RHAbstractSubmissionBase, AbstractParam): 
    401203 
    402204    def _checkParams( self, params ): 
    403         RHAbstractSubmissionBase._checkParams( self, params ) 
     205        RHAbstractSubmissionBase._checkParams(self, params) 
    404206        #if the user is not logged in we return inmediately as this form needs 
    405207        #   the user to be logged in and therefore all the checking below is not 
    406208        #   necessary 
    407  
    408209        if self._getUser() == None: 
    409210            return 
    410         self._action = "" 
    411         if "cancel" in params: 
    412             self._action = "CANCEL" 
    413             return 
    414         id = params.get("type", "") 
    415         params["type"] = self._conf.getContribTypeById(id) 
    416         self._abstractData = AbstractData( self._target.getAbstractMgr(), params ) 
    417         self._doNotSanitizeFields = self._abstractData.getFieldNames() 
    418         self._doNotSanitizeFields.append('title') 
    419         if "add_primary_author" in params: 
    420             #self._action = "NEW_AUTHOR" 
    421             self._abstractData.authors.addPrimaryAuthor( focus=True ) 
    422         elif "add_secondary_author" in params: 
    423             #self._action = "NEW_AUTHOR" 
    424             self._abstractData.authors.addSecondaryAuthor( focus=True ) 
    425         elif "remove_primary_authors" in params: 
    426             tmp = self._normaliseListParam( params.get("selected_primary_authors", []) ) 
    427             for id in tmp: 
    428                 self._abstractData.authors.removePrimaryAuthor( id ) 
    429         elif "remove_secondary_authors" in params: 
    430             tmp = self._normaliseListParam( params.get("selected_secondary_authors", []) ) 
    431             for id in tmp: 
    432                 self._abstractData.authors.removeSecondaryAuthor( id ) 
    433         elif "validate" in params: 
    434             self._action = "VALIDATE" 
    435         else: 
    436             #First call 
    437             av = self._getUser() 
    438             self._abstractData.authors.addPrimaryAuthor( \ 
    439                                         title = av.getTitle(), \ 
    440                                         firstName = av.getName(), \ 
    441                                         surName = av.getSurName(), \ 
    442                                         affiliation = av.getOrganisation(), \ 
    443                                         email = av.getEmail(), \ 
    444                                         phone = av.getTelephone(), \ 
    445                                         address = av.getAddress(), \ 
    446                                         speaker = True ) 
     211        headerSize = self._req.headers_in["content-length"] 
     212        AbstractParam._checkParams(self, params, self._conf, headerSize) 
     213 
     214 
     215class RHAbstractSubmission( RHAbstractModificationAction ): 
     216    _uh = urlHandlers.UHAbstractSubmission 
    447217 
    448218    def _doValidate( self ): 
     
    458228        #   received 
    459229        cfaMgr = self._target.getAbstractMgr() 
    460         afm = cfaMgr.getAbstractFieldsMgr() 
    461         a = cfaMgr.newAbstract( self._getUser() ) 
    462         a.setTitle( self._abstractData.title ) 
    463         for f in afm.getFields(): 
    464             id = f.getId() 
    465             a.setField(id, self._abstractData.getFieldValue(id)) 
    466         for authData in self._abstractData.authors.getPrimaryList(): 
    467             auth=a.newPrimaryAuthor(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         for authData in self._abstractData.authors.getSecondaryList(): 
    477             auth=a.newCoAuthor(title = authData["auth_title"], \ 
    478                                 firstName = authData["auth_firstName"], \ 
    479                                 surName = authData["auth_surName"], \ 
    480                                 email = authData["auth_email"], \ 
    481                                 affiliation = authData["auth_affiliation"], \ 
    482                                 address = authData["auth_address"], \ 
    483                                 telephone = authData["auth_phone"] ) 
    484             if authData["auth_speaker"]: 
    485                 a.addSpeaker( auth ) 
    486         a.setContribType( self._abstractData.type ) 
    487         for trackId in self._abstractData.tracks: 
    488             track = self._conf.getTrackById( trackId ) 
    489             a.addTrack( track ) 
    490         a.setComments(self._abstractData.comments) 
    491  
    492  
     230        abstract = cfaMgr.newAbstract( self._getUser() ) 
     231        #self._setAbstractData(abstract) 
     232        self._abstractData.setAbstractData(abstract) 
    493233        #The commit must be forced before sending the confirmation 
    494234        DBMgr.getInstance().commit() 
    495235        #Email confirmation about the submission 
    496         mail.Mailer.send( _AbstractSubmissionNotification( a ), self._conf.getSupportEmail(returnNoReply=True) ) 
     236        mail.Mailer.send( _AbstractSubmissionNotification( abstract ), self._conf.getSupportEmail(returnNoReply=True) ) 
    497237        #Email confirmation about the submission to coordinators 
    498238        if cfaMgr.getSubmissionNotification().hasDestination(): 
    499             asn=_AbstractSubmissionNotification( a ) 
     239            asn=_AbstractSubmissionNotification( abstract ) 
    500240            asn.setSubject(_("[Indico] New abstract submission: %s")%asn.getDestination().getFullName()) 
    501241            mail.GenericMailer.send( asn ) 
    502242        #We must perform some actions: email warning to the authors 
    503243        #Finally, we display a confirmation form 
    504         self._redirect( urlHandlers.UHAbstractSubmissionConfirmation.getURL( a ) ) 
     244        self._redirect( urlHandlers.UHAbstractSubmissionConfirmation.getURL( abstract ) ) 
    505245 
    506246    def _processIfOpened( self ): 
     
    514254            return p.display( **pars ) 
    515255 
     256 
     257 
     258class RHAbstractModify(RHAbstractModificationAction, RHModificationBaseProtected): 
     259    _uh = urlHandlers.UHAbstractModify 
     260 
     261    def _checkProtection( self ): 
     262        RHModificationBaseProtected._checkProtection( self ) 
     263 
     264 
     265    def _checkParams( self, params ): 
     266        RHAbstractModificationAction._checkParams(self, params) 
     267        if self._getUser() == None: 
     268            return 
     269        if self._action == "": 
     270            #First call 
     271            afm = self._conf.getAbstractMgr().getAbstractFieldsMgr() 
     272            self._abstractData.title = self._abstract.getTitle() 
     273            for f in afm.getFields(): 
     274                id = f.getId() 
     275                self._abstractData.setFieldValue(id, self._abstract.getField(id)) 
     276            self._abstractData.type = self._abstract.getContribType() 
     277            trackIds = [] 
     278            for track in self._abstract.getTrackListSorted(): 
     279                trackIds.append(track.getId()) 
     280            self._abstractData.tracks = trackIds 
     281            self._abstractData.comments = self._abstract.getComments() 
     282 
     283 
     284    def _processIfActive( self ): 
     285        #We overload this method to allow modification after the CFA is closed if the modification deadline is after the submission deadline 
     286        cfaMgr = self._conf.getAbstractMgr() 
     287        modifDeadLine = cfaMgr.getModificationDeadline() 
     288        if not modifDeadLine: 
     289            modifDeadLine = cfaMgr.getEndSubmissionDate() 
     290        #if the user is in the autorized list, don't check period 
     291        if self._getUser() in cfaMgr.getAuthorizedSubmitterList(): 
     292            return self._processIfOpened() 
     293        #if the submission period is not yet opened we show up a form informing 
     294        #   about that. 
     295        if timezoneUtils.nowutc() < cfaMgr.getStartSubmissionDate(): 
     296        #if the submission period is already closed we show up a form informing 
     297        #   about that. 
     298            p = abstracts.WPCFANotYetOpened( self, self._conf ) 
     299            return p.display() 
     300        #elif timezoneUtils.nowutc() > cfaMgr.getEndSubmissionDate() : 
     301        elif timezoneUtils.nowutc() > cfaMgr.getEndSubmissionDate() and timezoneUtils.nowutc() > modifDeadLine: 
     302            p = abstracts.WPCFAClosed( self, self._conf ) 
     303            return p.display() 
     304        else: 
     305            return self._processIfOpened() 
     306 
     307    def _doValidate( self ): 
     308        #First, one must validate that the information is fine 
     309        errors = self._abstractData.check() 
     310        if errors: 
     311            p = abstracts.WPAbstractModify( self, self._target ) 
     312            pars = self._abstractData.toDict() 
     313            pars["errors"] = errors 
     314            pars["action"] = self._action 
     315            # restart the current value of the param attachments to show the existing files 
     316            pars["attachments"] = self._abstract.getAttachments().values() 
     317            return p.display( **pars ) 
     318        self._abstract.clearAuthors() 
     319        self._abstractData.setAbstractData(self._abstract) 
     320        self._redirect( urlHandlers.UHAbstractDisplay.getURL( self._abstract ) ) 
     321 
     322    def _processIfOpened( self ): 
     323        #check if the modification period is not over or if the abstract 
     324        #   is in a different status than Submitted 
     325        if not self._conf.getAbstractMgr().inModificationPeriod() or \ 
     326                not isinstance( self._abstract.getCurrentStatus(), \ 
     327                                                AbstractStatusSubmitted ): 
     328            wp = abstracts.WPAbstractCannotBeModified( self, self._abstract ) 
     329            return wp.display() 
     330        if self._action == "CANCEL": 
     331            self._redirect( urlHandlers.UHAbstractDisplay.getURL( self._abstract ) ) 
     332        elif self._action == "VALIDATE": 
     333            return self._doValidate() 
     334        else: 
     335            p = abstracts.WPAbstractModify( self, self._target ) 
     336            pars = self._abstractData.toDict() 
     337            pars["action"] = self._action 
     338            return p.display( **pars ) 
    516339 
    517340 
     
    557380        p = abstracts.WPAbstractDisplay( self, self._target ) 
    558381        return p.display() 
     382 
     383 
     384class RHGetAttachedFile(RHAbstractDisplay): 
     385 
     386    def _checkParams(self, params): 
     387        RHAbstractDisplay._checkParams(self, params) 
     388        self._fileId = params.get("resId", None) 
     389        if (self._fileId == None): 
     390            raise MaKaCError( _("Invalid resource Id.")) 
     391 
     392    def _process(self): 
     393        try: 
     394            file = self._abstract.getAttachments()[self._fileId] 
     395        except AttributeError: 
     396            raise MaKaCError( _("The file does not exist.")) 
     397        self._req.headers_out["Content-Length"] = "%s" % file.getSize() 
     398        cfg = Config.getInstance() 
     399        mimetype = cfg.getFileTypeMimeType(file.getFileType()) 
     400        self._req.content_type = """%s""" % (mimetype) 
     401        self._req.headers_out["Content-Disposition"] = """inline; filename="%s\"""" % file.getFileName() 
     402        return file.readBin() 
    559403 
    560404 
     
    636480 
    637481 
    638 class RHAbstractModify( RHAbstractModificationBase ): 
    639     _uh = urlHandlers.UHAbstractModify 
    640  
    641     def _checkParams( self, params ): 
    642         RHAbstractModificationBase._checkParams( self, params ) 
    643         #if the user is not logged in we return inmediately as this form needs 
    644         #   the user to be logged in and therefore all the checking below is not 
    645         #   necessary 
    646         if self._getUser() == None: 
    647             return 
    648         self._action = "" 
    649         if "cancel" in params: 
    650             self._action = "CANCEL" 
    651             return 
    652  
    653         params["type"]=self._conf.getContribTypeById(params.get("type", "")) 
    654         self._abstractData = AbstractData( self._conf.getAbstractMgr(), params ) 
    655         self._doNotSanitizeFields = self._abstractData.getFieldNames() 
    656         self._doNotSanitizeFields.append('title') 
    657         if "add_primary_author" in params: 
    658             self._abstractData.authors.addPrimaryAuthor( focus=True ) 
    659         elif "add_secondary_author" in params: 
    660             self._abstractData.authors.addSecondaryAuthor( focus=True ) 
    661         elif "remove_primary_authors" in params: 
    662             tmp = self._normaliseListParam( params.get("selected_primary_authors", []) ) 
    663             for id in tmp: 
    664                 self._abstractData.authors.removePrimaryAuthor( id ) 
    665         elif "remove_secondary_authors" in params: 
    666             tmp = self._normaliseListParam( params.get("selected_secondary_authors", []) ) 
    667             for id in tmp: 
    668                 self._abstractData.authors.removeSecondaryAuthor( id ) 
    669         elif "validate" in params: 
    670             self._action = "VALIDATE" 
    671         else: 
    672             #First call 
    673             afm = self._conf.getAbstractMgr().getAbstractFieldsMgr() 
    674             self._abstractData.title = self._abstract.getTitle() 
    675             for f in afm.getFields(): 
    676                 id = f.getId() 
    677                 self._abstractData.setFieldValue(id, self._abstract.getField(id)) 
    678             for author in self._abstract.getPrimaryAuthorList(): 
    679                 data = { "title": author.getTitle(), \ 
    680                         "firstName": author.getFirstName(), \ 
    681                         "surName": author.getSurName(), \ 
    682                         "affiliation": author.getAffiliation(), \ 
    683                         "email": author.getEmail(), \ 
    684                         "phone": author.getTelephone(), \ 
    685                         "address": author.getAddress(), \ 
    686                         "primary": self._abstract.isPrimaryAuthor( author ), \ 
    687                         "speaker": self._abstract.isSpeaker( author ) } 
    688                 self._abstractData.authors.addPrimaryAuthor( **data ) 
    689             for author in self._abstract.getCoAuthorList(): 
    690                 data = { "title": author.getTitle(), \ 
    691                         "firstName": author.getFirstName(), \ 
    692                         "surName": author.getSurName(), \ 
    693                         "affiliation": author.getAffiliation(), \ 
    694                         "email": author.getEmail(), \ 
    695                         "phone": author.getTelephone(), \ 
    696                         "address": author.getAddress(), \ 
    697                         "primary": self._abstract.isPrimaryAuthor( author ), \ 
    698                         "speaker": self._abstract.isSpeaker( author ) } 
    699                 self._abstractData.authors.addSecondaryAuthor( **data ) 
    700             self._abstractData.type=self._abstract.getContribType() 
    701             trackIds = [] 
    702             for track in self._abstract.getTrackListSorted(): 
    703                 trackIds.append( track.getId() ) 
    704             self._abstractData.tracks = trackIds 
    705             self._abstractData.comments = self._abstract.getComments() 
    706  
    707     def _doValidate( self ): 
    708         #First, one must validate that the information is fine 
    709         errors = self._abstractData.check() 
    710         if errors: 
    711             p = abstracts.WPAbstractModify( self, self._target ) 
    712             pars = self._abstractData.toDict() 
    713             pars["errors"] = errors 
    714             pars["action"] = self._action 
    715             return p.display( **pars ) 
    716         #Then, we create the abstract object and set its data to the one 
    717         #   received 
    718         self._abstract.setTitle( self._abstractData.title ) 
    719         afm = self._conf.getAbstractMgr().getAbstractFieldsMgr() 
    720         for f in afm.getFields(): 
    721             id = f.getId() 
    722             self._abstract.setField( id, self._abstractData.getFieldValue(id)) 
    723         self._abstract.clearAuthors() 
    724         #for authData in self._abstractData.authors.getList(): 
    725         #    auth = self._abstract.newAuthor( title = authData["auth_title"], \ 
    726         #                        firstName = authData["auth_firstName"], \ 
    727         #                        surName = authData["auth_surName"], \ 
    728         #                        email = authData["auth_email"], \ 
    729         #                        affiliation = authData["auth_affiliation"], \ 
    730         #                        address = authData["auth_address"], \ 
    731         #                        telephone = authData["auth_phone"] ) 
    732         #    if authData["auth_speaker"]: 
    733         #        self._abstract.addSpeaker( auth ) 
    734         #    if authData["auth_primary"]: 
    735         #        self._abstract.addPrimaryAuthor( auth ) 
    736         for authData in self._abstractData.authors.getPrimaryList(): 
    737             auth=self._abstract.newPrimaryAuthor(title=authData["auth_title"], \ 
    738                                 firstName = authData["auth_firstName"], \ 
    739                                 surName = authData["auth_surName"], \ 
    740                                 email = authData["auth_email"], \ 
    741                                 affiliation = authData["auth_affiliation"], \ 
    742                                 address = authData["auth_address"], \ 
    743                                 telephone = authData["auth_phone"] ) 
    744             if authData["auth_speaker"]: 
    745                 self._abstract.addSpeaker( auth ) 
    746         for authData in self._abstractData.authors.getSecondaryList(): 
    747             auth=self._abstract.newCoAuthor(title=authData["auth_title"], \ 
    748                                 firstName = authData["auth_firstName"], \ 
    749                                 surName = authData["auth_surName"], \ 
    750                                 email = authData["auth_email"], \ 
    751                                 affiliation = authData["auth_affiliation"], \ 
    752                                 address = authData["auth_address"], \ 
    753                                 telephone = authData["auth_phone"] ) 
    754             if authData["auth_speaker"]: 
    755                 self._abstract.addSpeaker( auth ) 
    756         self._abstract.setContribType( self._abstractData.type ) 
    757         #self._abstract.clearTracks() 
    758         tracks = [] 
    759         for trackId in self._abstractData.tracks: 
    760             tracks.append( self._conf.getTrackById( trackId ) ) 
    761         self._abstract.setTracks( tracks ) 
    762         self._abstract.setComments(self._abstractData.comments) 
    763         #We must perform some actions: email warning to the authors 
    764         #Finally, we display a confirmation form 
    765         self._redirect( urlHandlers.UHAbstractDisplay.getURL( self._abstract ) ) 
    766  
    767     def _processIfOpened( self ): 
    768         #check if the modification period is not over or if the abstract 
    769         #   is in a different status than Submitted 
    770         if not self._conf.getAbstractMgr().inModificationPeriod() or \ 
    771                 not isinstance( self._abstract.getCurrentStatus(), \ 
    772                                                 AbstractStatusSubmitted ): 
    773             wp = abstracts.WPAbstractCannotBeModified( self, self._abstract ) 
    774             return wp.display() 
    775         if self._action == "CANCEL": 
    776             self._redirect( urlHandlers.UHAbstractDisplay.getURL( self._abstract ) ) 
    777         elif self._action == "VALIDATE": 
    778             return self._doValidate() 
    779         else: 
    780             p = abstracts.WPAbstractModify( self, self._target ) 
    781             pars = self._abstractData.toDict() 
    782             pars["action"] = self._action 
    783             return p.display( **pars ) 
    784  
    785  
    786482class RHAbstractWithdraw( RHAbstractModificationBase ): 
    787483    _uh = urlHandlers.UHAbstractWithdraw 
Note: See TracChangeset for help on using the changeset viewer.