Changeset 617c7f in indico


Ignore:
Timestamp:
02/07/11 18:42:49 (2 years ago)
Author:
Pedro Ferreira <jose.pedro.ferreira@…>
Branches:
master, burotel, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, d9941f8582b36b24821a11ea5ba16fda6a457fb1
Children:
3f6b20
Parents:
2ed6e4
git-author:
Pedro Ferreira <jose.pedro.ferreira@…> (02/04/11 16:08:23)
git-committer:
Pedro Ferreira <jose.pedro.ferreira@…> (02/07/11 18:42:49)
Message:

[FIX] Adapted script to current version

  • some formatting fixes too
File:
1 edited

Legend:

Unmodified
Added
Removed
  • bin/utils/syncFromAbstractToContribs.py

    rbdd862 r617c7f  
    1919## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 
    2020 
     21""" 
     22Synchronizes contributions with the corresponding abstracts 
     23""" 
     24 
     25 
     26import sys 
    2127from MaKaC.common import DBMgr 
    2228from MaKaC.conference import ConferenceHolder, ContributionParticipation 
    2329from MaKaC.review import AbstractStatusAccepted 
    2430 
    25 conferenceId="" 
    2631 
    27 DBMgr.getInstance().startRequest() 
    28 conf=ConferenceHolder().getById(conferenceId) 
    29 counter=[] 
    30 if conf is None: 
    31     print "Error fetching conference" 
    32 else: 
    33     for abstract in conf.getAbstractMgr().getAbstractList(): 
    34         if isinstance(abstract.getCurrentStatus(), AbstractStatusAccepted): 
    35             contrib=abstract.getContribution() 
    36             contrib.setTitle( abstract.getTitle() ) 
    37             contrib.setDescription( abstract.getContent() ) 
    38             contrib.setSummary( abstract.getSummary() ) 
    39             contrib.setTrack( abstract.getCurrentStatus().getTrack() ) 
    40             contrib.setType( abstract.getCurrentStatus().getType() ) 
    41             for auth1 in contrib.getPrimaryAuthorList()[:]: 
    42                 contrib.removePrimaryAuthor(auth1) 
    43             for auth2 in contrib.getCoAuthorList()[:]: 
    44                 contrib.removeCoAuthor(auth2) 
    45             for auth3 in contrib.getSpeakerList()[:]: 
    46                 contrib.removeSpeaker(auth3) 
    47             for auth in abstract.getAuthorList(): 
    48                 c_auth = ContributionParticipation() 
    49                 contrib._setAuthorValuesFromAbstract( c_auth, auth ) 
    50                 if abstract.isPrimaryAuthor( auth ): 
    51                     contrib.addPrimaryAuthor( c_auth ) 
    52                 else: 
    53                     contrib.addCoAuthor( c_auth ) 
    54                 if abstract.isSpeaker( auth ): 
    55                     contrib.addSpeaker( c_auth ) 
    56             # TODO: remove the previous submitter...how??? 
    57             contrib._grantSubmission(contrib.getAbstract().getSubmitter().getUser()) 
    58             counter.append(contrib.getId()) 
    59 DBMgr.getInstance().endRequest() 
    60 print "contribs ids:%s"%counter 
    61 print "" 
    62 print "%s contribs sync"%(len(counter)) 
     32def sync(confId): 
     33    DBMgr.getInstance().startRequest() 
     34    conf = ConferenceHolder().getById(confId) 
     35    counter = [] 
    6336 
     37    if conf is None: 
     38        raise Exception("Error fetching conference") 
     39    else: 
     40        for abstract in conf.getAbstractMgr().getAbstractList(): 
     41            if isinstance(abstract.getCurrentStatus(), AbstractStatusAccepted): 
     42                contrib = abstract.getContribution() 
     43                contrib.setTitle(abstract.getTitle()) 
     44                contrib.setDescription(abstract.getField('content')) 
     45                contrib.setField('summary', abstract.getField('summary')) 
     46                contrib.setTrack(abstract.getCurrentStatus().getTrack()) 
     47                contrib.setType(abstract.getCurrentStatus().getType()) 
     48 
     49                for auth1 in contrib.getPrimaryAuthorList()[:]: 
     50                    contrib.removePrimaryAuthor(auth1) 
     51                for auth2 in contrib.getCoAuthorList()[:]: 
     52                    contrib.removeCoAuthor(auth2) 
     53                for auth3 in contrib.getSpeakerList()[:]: 
     54                    contrib.removeSpeaker(auth3) 
     55                for auth in abstract.getAuthorList(): 
     56                    c_auth = ContributionParticipation() 
     57                    contrib._setAuthorValuesFromAbstract(c_auth, auth) 
     58                    if abstract.isPrimaryAuthor(auth): 
     59                        contrib.addPrimaryAuthor(c_auth) 
     60                    else: 
     61                        contrib.addCoAuthor(c_auth) 
     62                    if abstract.isSpeaker(auth): 
     63                        contrib.addSpeaker(c_auth) 
     64 
     65                # TODO: remove the previous submitter...how??? 
     66                submitter = contrib.getAbstract().getSubmitter().getUser() 
     67                contrib._grantSubmission(submitter) 
     68                counter.append(contrib.getId()) 
     69 
     70    DBMgr.getInstance().endRequest() 
     71    print "%s contributions synchronized (%s)" % (len(counter), 
     72                                                  ', '.join(counter)) 
     73 
     74if __name__ == '__main__': 
     75 
     76    if len(sys.argv) == 2: 
     77        sync(sys.argv[1]) 
     78        sys.exit(0) 
     79    else: 
     80        print "Usage: %s [conf_id]" % sys.argv[0] 
     81        sys.exit(1) 
Note: See TracChangeset for help on using the changeset viewer.