-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Added support for the CRediT Taxonomy for contributors #4512
Open
MartinPaulEve
wants to merge
27
commits into
master
Choose a base branch
from
b-credit-taxonomy
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
8d8d740
Initial work on CRediT
MartinPaulEve ec37b88
Templates to display CRediT
MartinPaulEve 53a813f
More work on CRediT interface
MartinPaulEve ea47914
Fix duplicate ID
MartinPaulEve 9589493
Layout
MartinPaulEve 51205f3
Add CRediT to review metadata page
MartinPaulEve e2ab527
Add CRediT to review metadata page using frozen data
MartinPaulEve ea01600
Fix CREDIT_ROLE_CHOICES
MartinPaulEve 071c30a
Add CRediT info link
MartinPaulEve fbd1a19
Add edit CRediT to edit metadata page
MartinPaulEve 81358e2
Handle blank entry for add_credit
MartinPaulEve d9c5730
Add logic
MartinPaulEve 1a4020d
Add logic to add, remove, and view CRediT records
MartinPaulEve 084e0b0
Undo migrations
MartinPaulEve debcdee
Migrations
MartinPaulEve 764cb8c
Revert templates/admin and submission/views.py to master
MartinPaulEve de81dc5
fix: change indentation to only run CRediT update when force_update i…
MartinPaulEve 26cad02
fix: long lines
MartinPaulEve 2bae120
fix: long lines of python
MartinPaulEve 1522142
fix: add CRediT URLs
MartinPaulEve b484cca
fix: replace emoji with font-awesome
MartinPaulEve fa4f26d
fix: hide CRediT sections if not used
MartinPaulEve 879ae54
feat: add CRediT to JATS
MartinPaulEve 4687842
fix: DRY for credit roles and credit roles with URLs
MartinPaulEve 1a83e9f
fix: add comments
MartinPaulEve ccc9d3b
Add flag to toggle CRediT
MartinPaulEve 2b7e64d
Add option to toggle credit
MartinPaulEve File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -479,6 +479,25 @@ def article(request, identifier_type, identifier): | |
file__mime_type='text/html', | ||
) | ||
|
||
credit_roles = {} | ||
show_credit = False | ||
|
||
use_credit = setting_handler.get_setting( | ||
"general", "use_credit", | ||
journal=request.journal | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't working yet because it needs to get the associated setting value. |
||
|
||
if use_credit: | ||
for frozen_author in article_object.frozen_authors(): | ||
credit_role_qs = submission_models.CreditRecord.objects.filter( | ||
article=article_object, frozen_author=frozen_author | ||
).order_by("role") | ||
|
||
credit_roles[frozen_author] = credit_role_qs | ||
|
||
if len(credit_role_qs) > 0: | ||
show_credit = True | ||
|
||
template = 'journal/article.html' | ||
context = { | ||
'article': article_object, | ||
|
@@ -487,6 +506,8 @@ def article(request, identifier_type, identifier): | |
'identifier': identifier, | ||
'article_content': content, | ||
'tables_in_galley': tables_in_galley, | ||
'credit_roles': credit_roles, | ||
'show_credit': show_credit, | ||
} | ||
|
||
return render(request, template, context) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/submission/migrations/0085_alter_article_jats_article_type_override_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Generated by Django 4.2.16 on 2024-12-04 15:55 | ||
|
||
import core.model_utils | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('repository', '0045_historicalrepository_display_public_metrics_and_more'), | ||
('submission', '0084_remove_article_jats_article_type_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='article', | ||
name='jats_article_type_override', | ||
field=core.model_utils.DynamicChoiceField(blank=True, choices=[], default=None, help_text='The type of article as per the JATS standard. This field allows you to override the default for the section.', max_length=255, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='section', | ||
name='jats_article_type', | ||
field=core.model_utils.DynamicChoiceField(blank=True, choices=[], help_text='The default JATS article type for articles in this section. This can be overridden on a per-article basis.', max_length=255, null=True, verbose_name='JATS default article type'), | ||
), | ||
migrations.CreateModel( | ||
name='CreditRecord', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('last_modified', models.DateTimeField(auto_now=True)), | ||
('role', models.CharField(blank=True, choices=[('Conceptualization', 'Conceptualization'), ('Data Curation', 'Data Curation'), ('Formal Analysis', 'Formal Analysis'), ('Funding Acquisition', 'Funding Acquisition'), ('Investigation', 'Investigation'), ('Methodology', 'Methodology'), ('Project Administration', 'Project Administration'), ('Resources', 'Resources'), ('Software', 'Software'), ('Supervision', 'Supervision'), ('Validation', 'Validation'), ('Visualization', 'Visualization'), ('Writing - Original Draft', 'Writing - Original Draft'), ('Writing - Review & Editing', 'Writing - Review & Editing')], max_length=100, null=True)), | ||
('article', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='submission.article')), | ||
('author', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), | ||
('frozen_author', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='submission.frozenauthor')), | ||
('preprint_author', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='repository.preprintauthor')), | ||
], | ||
options={ | ||
'verbose_name': 'CRediT record', | ||
'verbose_name_plural': 'CRediT records', | ||
}, | ||
), | ||
] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an indentation problem here. This code is inline with line 564, outside the
if
, meaning theelse
on 576 will be a syntax error. It needs to be indented so that it is part of the if clause started on 564, right?I think this will also need to remove roles from the frozen author that have been removed on the author, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so I wasn't sure what force_update meant in "if frozen_author and force_update", and assumed it was a unique case, but that we would always want to save the credit_records when we freeze an article. Is that not right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree it's a good idea to update credit records in this spot, it just needs to be inside the first
if
clause / indented four spaces.WRT to
force_update
, it is defined onsnapshot_authors
if you search for it (granted, it should be defined onsnapshot_self
). It is "Whether or not to update existing records". So thisif
block is supposed to run when there are existing frozen authors and when they need to be updated, which is a lot of the time, like in the pre-publication stage, IIRC.With the current indentation, you are changing the code below from
if / else
tofor / else
, which is not what we want, because theelse
will always run. We only want lines 577 etc. to run if the conditions on line 564 are not met.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Martin has now fixed the indentation and syntax bugs here.
But I still think this needs to remove past CRediT roles from the FrozenAuthor during a forced update. As mentioned on 5 Dec above: "I think this will also need to remove roles from the frozen author that have been removed on the author, right?"
Currently I do not think the interface would invite users to edit credit roles on the author after submission, but still it makes sense to keep the function straightforward and idempotent because it may be a bug for other places that create these records. Think about importers, plugins, etc.