Commit 6a4c244f authored by Ludovic LANGE's avatar Ludovic LANGE Committed by Vincent A

[pajemploi] Detect documents that are not available

Some documents may not be available yet, or may have been modified and are not
available.
Trying to download such documents results in a 500 error.
Thus we detect if the documents are available, using the same (javascript) logic
as the main site.
parent 56e9b273
Pipeline #3522 passed with stages
in 17 minutes and 39 seconds
......@@ -40,8 +40,10 @@ from weboob.browser.filters.standard import (
Format,
Field,
Eval,
ItemNotFound,
)
from weboob.browser.filters.html import Attr, Link, TableCell, FormValue
from weboob.browser.filters.javascript import JSVar
from weboob.tools.date import parse_french_date
......@@ -270,9 +272,17 @@ class DeclarationDetailPage(PajemploiPage):
def iter_documents(self, proto_doc, subscription):
date = self.get_date()
script = CleanText('//script[not(@src)][contains(text(), "traitementEffectue")]')
try:
traitementEffectue = JSVar(script, var='traitementEffectue')(self.doc)
presAnnule = JSVar(script, var='presAnnule')(self.doc)
except ItemNotFound:
traitementEffectue = True
presAnnule = 0
# Bulletin de salaire
frm = self.doc.xpath('//form[@name="formBulletinSalaire"]')
if frm:
if frm and traitementEffectue and (presAnnule == 0):
bs = Document()
bs.id = "%s_%s" % (proto_doc.id, "bs")
bs.date = date
......@@ -285,7 +295,7 @@ class DeclarationDetailPage(PajemploiPage):
# Relevé mensuel
frm = self.doc.xpath('//form[@name="formReleveMensuel"]')
if frm:
if frm and traitementEffectue and (presAnnule == 0):
rm = Document()
rm.id = "%s_%s" % (proto_doc.id, "rm")
rm.date = date
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment