Migration fixes
This commit is contained in:
parent
adb42ce1be
commit
74f503926d
|
@ -34,6 +34,8 @@ class Migrate(BrowserView):
|
|||
workflow_tool = getToolByName(self.context, 'portal_workflow')
|
||||
plone_tool = getToolByName(self.context, 'plone_utils')
|
||||
|
||||
maildir = getattr(self.context, 'all')
|
||||
|
||||
print 'Processing', doc.get('id')
|
||||
print >> self.logfile, 'I: Processing', doc.get('id')
|
||||
|
||||
|
@ -45,19 +47,18 @@ class Migrate(BrowserView):
|
|||
typename = 'courrier_entrant'
|
||||
factory = DexterityFactory(portal_type=typename)
|
||||
|
||||
if not hasattr(self.context, doc.get('id')):
|
||||
if not hasattr(maildir, doc.get('id')):
|
||||
ob = factory(id=doc.get('id'), title=doc.get('title'))
|
||||
self.context._setObject(ob.id, ob)
|
||||
maildir._setObject(ob.id, ob)
|
||||
|
||||
ob = getattr(self.context, doc.get('id'))
|
||||
ob = getattr(maildir, doc.get('id'))
|
||||
|
||||
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?)
|
||||
# done.
|
||||
doc['state'] = 'filed'
|
||||
|
||||
ob.fichier = NamedFile(fd.read(), filename=unicode(doc.get('filename')))
|
||||
|
@ -140,32 +141,21 @@ class Migrate(BrowserView):
|
|||
'PFBCurrentEventsQuestion': 'questionactualiteD',
|
||||
'PFBOralRequest': 'QuestionoraleD',
|
||||
'PFBProject': 'ProjetD',
|
||||
'PFBProposal': 'PropositionD',
|
||||
}.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 >> self.logfile, 'W: proposal of unknown type'
|
||||
|
||||
if not doc.get('authors') and doc.get('state') == 'initial':
|
||||
# this document was not completed, do not create a secondary object
|
||||
second_object_typename = None
|
||||
|
||||
if second_object_typename and not ob.mailnumber:
|
||||
if second_object_typename and not ob.numero_courrier:
|
||||
# if there's no mailnumber, do not create a secondary object
|
||||
print >> self.logfile, 'W: document without a mail number'
|
||||
second_object_typename = None
|
||||
|
||||
if second_object_typename:
|
||||
# XXX: this is a temporary location, no decision has been taken yet
|
||||
# on the location of those documents
|
||||
docdir = getattr(self.context.aq_parent, 'documents-diffusables')
|
||||
docdir = getattr(docdir, 'all')
|
||||
|
||||
if not hasattr(docdir, doc.get('id')):
|
||||
factory = DexterityFactory(portal_type=second_object_typename)
|
||||
|
@ -195,13 +185,12 @@ class Migrate(BrowserView):
|
|||
if len(doc.get('authors')) > 1:
|
||||
print >> self.logfile, 'W: project with more than one author'
|
||||
ob2.auteur = [self.get_ministry(x) for x in doc.get('authors')][0]
|
||||
elif second_object_typename in ('proposition_decret_reglementD',
|
||||
'proposition_resolution_modificationD'):
|
||||
elif second_object_typename == 'PropositionD':
|
||||
ob2.type_de_proposition = ob.sous_categorie_de_courrier
|
||||
if doc.get('authors'):
|
||||
ob2.auteurs = [self.get_deputy(x) for x in doc.get('authors')]
|
||||
|
||||
if doc.get('state') in ('filed', 'preDocumented'):
|
||||
if False and doc.get('state') in ('filed', 'preDocumented'):
|
||||
try:
|
||||
workflow_tool.doActionFor(ob2, 'publish')
|
||||
except WorkflowException:
|
||||
|
|
Reference in New Issue