completed migration of remaining types
This commit is contained in:
parent
2ccaf04c83
commit
033e7840b2
|
@ -27,10 +27,10 @@ class Migrate(BrowserView):
|
|||
workflow_tool = getToolByName(self.context, 'portal_workflow')
|
||||
plone_tool = getToolByName(self.context, 'plone_utils')
|
||||
|
||||
if doc.get('state') not in ('filed', 'preDocumented'):
|
||||
return 'Unhandled state (%s)\n' % (doc.get('state'))
|
||||
print 'I: Processing', doc.get('id')
|
||||
|
||||
if doc.get('meta_type') == 'PFBArbitralCourt' and doc.get('id').startswith('cour-d-arbitrage'):
|
||||
print 'I: skipped, arbitral court document'
|
||||
return 'Arbitral Court documents are not to be imported\n'
|
||||
|
||||
# first step is to create a "courrier entrant" object
|
||||
|
@ -46,24 +46,36 @@ class Migrate(BrowserView):
|
|||
ob.date_reception = datetime.datetime.strptime(doc.get('deliverydate'), '%Y-%m-%d').date()
|
||||
ob.numero_courrier = doc.get('mailnumber')
|
||||
|
||||
if ob.date_reception < (datetime.datetime.today()-datetime.timedelta(days=90)).date():
|
||||
# all documents created more than three months ago are considered
|
||||
# done. (XXX: maybe this should not happen for published
|
||||
# documents?)
|
||||
doc['state'] = 'filed'
|
||||
|
||||
ob.fichier = NamedFile(fd.read(), filename=unicode(doc.get('filename')))
|
||||
|
||||
ob.categorie_de_courrier = [{
|
||||
'PFBAddressChange': u'Changement de coordonnées',
|
||||
'PFBGeneralMail': u'Courrier général divers',
|
||||
'PFBArbitralCourt': u'Relations publiques',
|
||||
'PFBSubventionRequest': u'Demande de subvention',
|
||||
'PFBActivityAndExpertReport': u'''Rapport d'activités/d'experts''',
|
||||
'PFBCollegialNotification': u'Notifications du Collège',
|
||||
'PFBMeetingExcuses': u'Excusés',
|
||||
'PFBAddressChange': u'Changement de coordonnées',
|
||||
'PFBArbitralCourt': u'Relations publiques',
|
||||
'PFBAuditingCommitteeCommunication': u'Communication gouvernementale',
|
||||
'PFBGeneralCommission': u'Commissions divers',
|
||||
'PFBChallenge': u'Interpellation',
|
||||
'PFBWriteAnswer': u'Réponse écrite',
|
||||
'PFBCollegialNotification': u'Notifications du Collège',
|
||||
'PFBCurrentEventsQuestion': u'''Question d'actualité''',
|
||||
'PFBGeneralCommission': u'Commissions divers',
|
||||
'PFBGeneralMail': u'Courrier général divers',
|
||||
'PFBMeetingExcuses': u'Excusés',
|
||||
'PFBOralRequest': u'Question orale',
|
||||
'PFBProject': u'Projet',
|
||||
'PFBProposal': u'Proposition',
|
||||
'PFBSubventionRequest': u'Demande de subvention',
|
||||
'PFBWriteAnswer': u'Réponse écrite',
|
||||
'PFBWriteRequest': u'Question écrite',
|
||||
}.get(doc.get('meta_type'))]
|
||||
|
||||
if ob.categorie_de_courrier is None:
|
||||
print 'W: failed to get a category'
|
||||
|
||||
ob.expediteur = []
|
||||
shipper_id = None
|
||||
if doc.get('shippers'):
|
||||
|
@ -73,28 +85,63 @@ class Migrate(BrowserView):
|
|||
portal.contacts.invokeFactory('themis.datatypes.contact', shipper_id, title=shipper)
|
||||
shipper_id = 'contact:' + shipper_id
|
||||
else:
|
||||
if doc.get('meta_type') == 'PFBWriteAnswer':
|
||||
if doc.get('meta_type') in ('PFBWriteAnswer', 'PFBProject'):
|
||||
# shipper is a ministry
|
||||
shipper_id = self.get_ministry(doc.get('authors')[0])
|
||||
if doc.get('authors'):
|
||||
shipper_id = self.get_ministry(doc.get('authors')[0])
|
||||
else:
|
||||
print 'W: document without an author'
|
||||
elif doc.get('meta_type') in ('PFBChallenge',
|
||||
'PFBCurrentEventsQuestion', 'PFBOralRequest'):
|
||||
'PFBCurrentEventsQuestion', 'PFBOralRequest',
|
||||
'PFBProposal', 'PFBWriteRequest'):
|
||||
# shipper is a deputy
|
||||
shipper_id = self.get_deputy(doc.get('authors')[0])
|
||||
if doc.get('authors'):
|
||||
shipper_id = self.get_deputy(doc.get('authors')[0])
|
||||
else:
|
||||
print 'W: document without an author'
|
||||
|
||||
if shipper_id:
|
||||
ob.expediteur.append(shipper_id)
|
||||
|
||||
try:
|
||||
workflow_tool.doActionFor(ob, 'publish')
|
||||
except WorkflowException:
|
||||
pass
|
||||
if doc.get('type'):
|
||||
ob.sous_categorie_de_courrier = {
|
||||
'proj_decret': u'Projet de décret',
|
||||
'proj_reglement': u'Projet de règlement',
|
||||
'prop_decret': u'Proposition de décret',
|
||||
'prop_reglement': u'Proposition de règlement',
|
||||
'prop_resolution': u'Proposition de résolution',
|
||||
'prop_modif_regl': u'Proposition de modification du Règlement du PFB',
|
||||
'prop_modif_statut': u'Proposition de modification du statut du personnel'
|
||||
}.get(doc.get('type'))
|
||||
|
||||
if doc.get('state') in ('filed', 'preDocumented'):
|
||||
try:
|
||||
workflow_tool.doActionFor(ob, 'publish')
|
||||
except WorkflowException:
|
||||
pass
|
||||
except Exception, e:
|
||||
print 'E: Exception %r' % e
|
||||
raise
|
||||
|
||||
second_object_typename = {
|
||||
'PFBChallenge': 'interpellationD',
|
||||
'PFBWriteAnswer': 'reponse_a_question_ecriteD',
|
||||
'PFBCurrentEventsQuestion': 'questionactualiteD',
|
||||
'PFBOralRequest': 'QuestionoraleD',
|
||||
'PFBProject': 'ProjetD',
|
||||
}.get(doc.get('meta_type'))
|
||||
|
||||
if doc.get('meta_type') == 'PFBProposal':
|
||||
second_object_typename = {
|
||||
'prop_decret': 'proposition_decret_reglementD',
|
||||
'prop_reglement': 'proposition_decret_reglementD',
|
||||
'prop_resolution': 'proposition_resolution_modificationD',
|
||||
'prop_modif_regl': 'proposition_resolution_modificationD',
|
||||
'prop_modif_statut': 'proposition_resolution_modificationD'
|
||||
}.get(doc.get('type'))
|
||||
if second_object_typename is None:
|
||||
print 'W: proposal of unknown type'
|
||||
|
||||
if second_object_typename:
|
||||
# XXX: this is a temporary location, no decision has been taken yet
|
||||
# on the location of those documents
|
||||
|
@ -120,6 +167,26 @@ class Migrate(BrowserView):
|
|||
ob2.auteur = [self.get_deputy(x) for x in doc.get('authors')]
|
||||
if doc.get('recipients'):
|
||||
ob2.ministres_concernes = [self.get_ministry(x) for x in doc.get('recipients')]
|
||||
elif second_object_typename == 'ProjetD':
|
||||
ob2.type_de_projet = ob.sous_categorie_de_courrier
|
||||
if doc.get('authors'):
|
||||
ob2.auteur = [self.get_ministry(x) for x in doc.get('authors')]
|
||||
elif second_object_typename in ('proposition_decret_reglementD',
|
||||
'proposition_resolution_modificationD'):
|
||||
ob2.type_de_proposition = ob.sous_categorie_de_courrier
|
||||
if doc.get('authors'):
|
||||
ob2.auteur = [self.get_deputy(x) for x in doc.get('authors')]
|
||||
|
||||
if doc.get('state') in ('filed', 'preDocumented'):
|
||||
try:
|
||||
workflow_tool.doActionFor(ob2, 'publish')
|
||||
except WorkflowException:
|
||||
pass
|
||||
except Exception, e:
|
||||
print 'E: Exception(b) %r' % e
|
||||
raise
|
||||
|
||||
|
||||
|
||||
return u'→ OK\n'
|
||||
|
||||
|
@ -150,6 +217,8 @@ class Migrate(BrowserView):
|
|||
plone_tool = getToolByName(self.context, 'plone_utils')
|
||||
portal = getToolByName(self.context, 'portal_url').getPortalObject()
|
||||
author = unicode(author, 'utf-8')
|
||||
if len(author.split()) > 3:
|
||||
print 'W: author with (too?) many parts:', author
|
||||
author_id = plone_tool.normalizeString(author)
|
||||
if not portal.deputes.has_key(author_id):
|
||||
workflow_tool = getToolByName(self.context, 'portal_workflow')
|
||||
|
|
Reference in New Issue