-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As discussed in #2128, currently the submitting author of a project cannot be changed. There are times when it would be helpful to allow submitting authors to transfer this status to co-authors. e.g. when: * A co-author would like to take responsibility for editing content or uploading files. * A project requires updating and the original submitting author is no longer available. This change adds a 'transfer project' button to the author page of the project submission system.
- Loading branch information
Showing
7 changed files
with
192 additions
and
9 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
physionet-django/notification/templates/notification/email/notify_submitting_author.html
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,11 @@ | ||
{% load i18n %}{% autoescape off %}{% filter wordwrap:70 %} | ||
Dear {{ name }}, | ||
|
||
You have been made submitting author of the project entitled "{{ project.title }}" on {{ SITE_NAME }}. | ||
|
||
You can view and edit the project on your project homepage: {{ url_prefix }}{% url "project_home" %}. | ||
|
||
{{ signature }} | ||
|
||
{{ footer }} | ||
{% endfilter %}{% endautoescape %} |
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
22 changes: 22 additions & 0 deletions
22
physionet-django/project/static/project/js/transfer-author.js
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,22 @@ | ||
$(document).ready(function() { | ||
// Function to update the displayed author name when a new author is selected | ||
function set_transfer_author() { | ||
var selectedAuthorName = $("#transfer_author_id option:selected").text(); | ||
$('#project_author').text(selectedAuthorName); | ||
} | ||
|
||
// Attach the change event to the author select dropdown to update the name on change | ||
$("#transfer_author_id").change(set_transfer_author); | ||
|
||
// Prevent the default form submission and show the confirmation modal | ||
$('#authorTransferForm').on('submit', function(e) { | ||
e.preventDefault(); | ||
$('#transfer_author_modal').modal('show'); | ||
}); | ||
|
||
// When the confirmation button is clicked, submit the form | ||
$('#confirmAuthorTransfer').on('click', function() { | ||
$('#authorTransferForm').off('submit').submit(); | ||
}); | ||
}); | ||
|
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 |
---|---|---|
|
@@ -553,6 +553,45 @@ def test_content(self): | |
self.assertFalse(project.is_submittable()) | ||
|
||
|
||
class TestProjectTransfer(TestCase): | ||
""" | ||
Tests that submitting author status can be transferred to a co-author | ||
""" | ||
AUTHOR_EMAIL = '[email protected]' | ||
COAUTHOR_EMAIL = '[email protected]' | ||
PASSWORD = 'Tester11!' | ||
PROJECT_SLUG = 'T108xFtYkRAxiRiuOLEJ' | ||
|
||
def setUp(self): | ||
self.client.login(username=self.AUTHOR_EMAIL, password=self.PASSWORD) | ||
self.project = ActiveProject.objects.get(slug=self.PROJECT_SLUG) | ||
self.submitting_author = self.project.authors.filter(is_submitting=True).first() | ||
self.coauthor = self.project.authors.filter(is_submitting=False).first() | ||
|
||
def test_transfer_author(self): | ||
""" | ||
Test that an activate project can be transferred to a co-author. | ||
""" | ||
self.assertEqual(self.submitting_author.user.email, self.AUTHOR_EMAIL) | ||
self.assertEqual(self.coauthor.user.email, self.COAUTHOR_EMAIL) | ||
|
||
response = self.client.post( | ||
reverse('project_authors', args=(self.project.slug,)), | ||
data={ | ||
'transfer_author': self.coauthor.user.id, | ||
}) | ||
|
||
# Check if redirect happens, implying successful transfer | ||
self.assertEqual(response.status_code, 302) | ||
|
||
# Fetch the updated project data | ||
updated_project = ActiveProject.objects.get(slug=self.PROJECT_SLUG) | ||
|
||
# Verify that the author has been transferred | ||
self.assertFalse(updated_project.authors.get(user=self.submitting_author.user).is_submitting) | ||
self.assertTrue(updated_project.authors.get(user=self.coauthor.user).is_submitting) | ||
|
||
|
||
class TestAccessPublished(TestMixin): | ||
""" | ||
Test that certain views or content in their various states can only | ||
|
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