diff --git a/physionet-django/console/forms.py b/physionet-django/console/forms.py index 74f86d7923..c1713cde28 100644 --- a/physionet-django/console/forms.py +++ b/physionet-django/console/forms.py @@ -27,6 +27,7 @@ PublishedAffiliation, PublishedAuthor, PublishedProject, + PublishedPublication, exists_project_slug, ) from project.projectfiles import ProjectFiles @@ -705,6 +706,22 @@ def save(self): return contact +class PublishedProjectAddPublication(forms.ModelForm): + class Meta: + model = PublishedPublication + fields = ('citation', 'url') + + def __init__(self, project, *args, **kwargs): + super().__init__(*args, **kwargs) + self.project = project + + def save(self): + publication = super().save(commit=False) + publication.project = self.project + publication.save() + return publication + + class CreateLegacyAuthorForm(forms.ModelForm): """ Create an author for a legacy project. diff --git a/physionet-django/console/templates/console/manage_published_project.html b/physionet-django/console/templates/console/manage_published_project.html index 7b3902ea2e..de933752d6 100644 --- a/physionet-django/console/templates/console/manage_published_project.html +++ b/physionet-django/console/templates/console/manage_published_project.html @@ -49,6 +49,7 @@

@@ -67,6 +68,28 @@

Add an author

{% endif %} + +
+
+ Associated publication +
+
+ {% if project.publications.all %} + {% for publication in project.publications.all %} +

Citation: {{ publication.citation }}
+ URL: {{ publication.url }}

+ {% endfor %} + {% else %} +
+ {% include "inline_form_snippet.html" with form=publication_form %} + +
+ {% endif %} + +
+
+ +
Contact information diff --git a/physionet-django/console/views.py b/physionet-django/console/views.py index c7a370354d..880f34a1e1 100644 --- a/physionet-django/console/views.py +++ b/physionet-django/console/views.py @@ -833,6 +833,7 @@ def manage_published_project(request, project_slug, version): contact_form = forms.PublishedProjectContactForm(project=project, instance=project.contact) legacy_author_form = forms.CreateLegacyAuthorForm(project=project) + publication_form = forms.PublishedProjectAddPublication(project=project) if request.method == 'POST': if any(x in request.POST for x in ['create_doi_core', @@ -914,6 +915,12 @@ def manage_published_project(request, project_slug, version): if contact_form.is_valid(): contact_form.save() messages.success(request, 'The contact information has been updated') + elif 'set_publication' in request.POST: + publication_form = forms.PublishedProjectAddPublication( + project=project, data=request.POST) + if publication_form.is_valid(): + publication_form.save() + messages.success(request, 'The associated publication has been added') elif 'set_legacy_author' in request.POST: legacy_author_form = forms.CreateLegacyAuthorForm(project=project, data=request.POST) @@ -957,6 +964,7 @@ def manage_published_project(request, project_slug, version): 'bulk_url_prefix': bulk_url_prefix, 'contact_form': contact_form, 'legacy_author_form': legacy_author_form, + 'publication_form': publication_form, 'can_make_zip': ProjectFiles().can_make_zip(), 'can_make_checksum': ProjectFiles().can_make_checksum(), },