Skip to content

Commit

Permalink
Merge pull request #343 from mdzik/mdzik-fix-publicationadd
Browse files Browse the repository at this point in the history
Dont add not-selected publications
  • Loading branch information
aebruno authored Jan 11, 2022
2 parents 01e244a + dc03273 commit a9d04e4
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions coldfront/core/publication/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,21 +215,23 @@ def post(self, request, *args, **kwargs):
if formset.is_valid():
for form in formset:
form_data = form.cleaned_data
source_obj = PublicationSource.objects.get(
pk=form_data.get('source_pk'))
publication_obj, created = Publication.objects.get_or_create(
project=project_obj,
title=form_data.get('title'),
author=form_data.get('author'),
year=form_data.get('year'),
journal=form_data.get('journal'),
unique_id=form_data.get('unique_id'),
source=source_obj
)
if created:
publications_added += 1
else:
publications_skipped.append(form_data.get('unique_id'))

if form_data['selected']:
source_obj = PublicationSource.objects.get(
pk=form_data.get('source_pk'))
publication_obj, created = Publication.objects.get_or_create(
project=project_obj,
title=form_data.get('title'),
author=form_data.get('author'),
year=form_data.get('year'),
journal=form_data.get('journal'),
unique_id=form_data.get('unique_id'),
source=source_obj
)
if created:
publications_added += 1
else:
publications_skipped.append(form_data.get('unique_id'))

msg = ''
if publications_added:
Expand Down

0 comments on commit a9d04e4

Please sign in to comment.