inspirehep / inspire-next

The INSPIRE repo.
https://inspirehep.net
GNU General Public License v3.0
59 stars 69 forks source link

wrong files get attached to holding pen records #2238

Closed michamos closed 7 years ago

michamos commented 7 years ago

https://labs.inspirehep.net/holdingpen/619315 has an attached PDF, which is the PDF from a different record, namely https://labs.inspirehep.net/holdingpen/619303. Looks like the problem is on our side, as the submitters are different, and there is no PDF in the formdata.

jacquerie commented 7 years ago

That's interesting. I actually see different PDFs in the two records. I definitely remember seeing two equal PDFs on your screen, so what's going on? Maybe wrong caching from the Angular application?

michamos commented 7 years ago

That one was fixed by @annetteholtkamp, we will keep our eyes peeled for more examples.

jmartinm commented 7 years ago

Just managed to reproduce this locally. Will dig deeper to see what is the cause.

jmartinm commented 7 years ago

Problem seems to be in the workflows Python code btw, in the submit view every time we create the Workflow object, it is reusing the previous extra_data. To reproduce:

In [1]: from invenio_db import db

In [2]: from invenio_workflows import workflow_object_class

In [3]: workflow_object = workflow_object_class.create(
   ...:         data={},
   ...:         id_user=1,
   ...:         data_type="hep"
   ...:     )

In [4]: workflow_object.extra_data['foo'] = 'bar'

In [5]: workflow_object.save()
--------------------------------------------------------------------------------
DEBUG in api [/Users/jmartinm/.virtualenvs/inspirehep/src/invenio-workflows/invenio_workflows/api.py:133]:
Saved object: 3 at []
--------------------------------------------------------------------------------

In [6]: db.session.commit()

In [7]: workflow_object
Out[7]: <WorkflowObject(id = 3, id_workflow = None, status = ObjectStatus.INITIAL, id_parent = None, created = 2017-05-01 15:06:50.728624, )

In [9]: workflow_object.extra_data
Out[9]: {u'foo': u'bar'}

In [10]: workflow_object = workflow_object_class.create(
    ...:         data={},
    ...:         id_user=1,
    ...:         data_type="hep"
    ...:     )

In [11]: workflow_object.extra_data
Out[11]: {'foo': 'bar'}
jmartinm commented 7 years ago

Fixed in https://github.com/inveniosoftware-contrib/invenio-workflows/pull/40