Errata backend#5249
Conversation
a91fe97 to
21289b6
Compare
|
@mauromsl we have been notified of a small incoherence in the XML deposit specs (see https://github.com/orgs/openlibhums/discussions/5238#discussioncomment-16599730 ). I've moved this MR to "draft". I'll complete it after we publish our first erratum and ping again. |
21289b6 to
ab30aa4
Compare
1047bef to
9c75895
Compare
from crossref support staff: > [...] > You can't totally omit the <crossmark_policy> element. For historical reasons, it's strictly required by the schema. But, as a workaround, you can just repeat the DOI of the original paper in that field. It's not used for anything, but it has to have a valid DOI in it.
9c75895 to
796c658
Compare
| @@ -54,6 +54,31 @@ | |||
| <item_number item_number_type="article_number">{{ article.object.pk }}</item_number> | |||
| </publisher_item> | |||
|
|
|||
| {% if article.erratum_of %} | |||
| <crossmark> | |||
| <crossmark_policy>{{ article.object.journal|setting:'crossref_prefix' }}/not-used</crossmark_policy> | |||
There was a problem hiding this comment.
<update>, then a <crossmark_policy> DOI should also be provided, but, according to crossref support, that element is not used and any DOI would do. They suggested to use the article DOI, but I'm hardcoding a 10.11111/no-used fake DOI (I feel it's less confusing...)
mauromsl
left a comment
There was a problem hiding this comment.
Thank you @gamboz great work. I've proposed two main changes inline:
- Avoid using the section names as the mechanism for serializing the relationship type of "errata"
- Use a linker table with a
throughmodel relationship, ideally repurposing the model that already lives in the hydra plugin.
| if self.section.name != "Erratum": | ||
| return None | ||
| if not self.ancestors.exists(): | ||
| return None |
There was a problem hiding this comment.
While it makes sense on the context of this PR, section.name is a customizable (and translatable) entry. Since we are adding a new model to register the relationships between articles, it would make sense to codify this (and other relationships) as part of that model, rather than relying on the indirection of the section name.
| class Genealogy(models.Model): | ||
| """ | ||
| Maintain relations of type parent/children between articles. | ||
|
|
||
| This can be used, for instance, to link erratum to the original paper. | ||
| """ | ||
|
|
||
| parent = models.OneToOneField( | ||
| Article, | ||
| verbose_name=_("Original or main paper"), | ||
| on_delete=models.CASCADE, | ||
| related_name="genealogy", | ||
| ) | ||
| children = SortedManyToManyField( | ||
| Article, | ||
| related_name="ancestors", | ||
| ) | ||
|
|
||
| def __str__(self): | ||
| return f"Genealogy: {self.parent} has {self.children.count()} kids" | ||
|
|
||
|
|
There was a problem hiding this comment.
I think the community are asking for a few more relationship types such as addendum, correction and so on. We also have a model on the hydra plugin for registering relationships such as translations.
Would it work for your use case if we were to port the LinkedArticle model from Hydra plugin instead?
It behaves as a linking table, so there is one less join required when querying both sides of the relationship.
| @@ -59,6 +59,7 @@ python-magic==0.4.27 | |||
| pytz==2024.1 | |||
| requests==2.32.4 | |||
| six==1.16.0 | |||
| django-sortedm2m~=3.1 | |||
There was a problem hiding this comment.
If we go with the approach I proposed about registering a model that behaves as a linking table, we could also use our M2MOrderedThroughField. It would avoid the additional dependency and also maintain consistency with other ordered many to many relationships in the codebase.
Add the possibility of linking an erratum to an article and register this relation with Crossref.
See also discussion 5238
ATM, errata are so rare that no front-end or manager interface is changed here, but an "admin" is provided.
Please note the new dependency.