Skip to content

Commit 500231f

Browse files
committed
updating call for bib update to have list - fixing tests
1 parent 56595bf commit 500231f

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

mod_app/models/feedback_model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ def __str__(self):
3030
def save(self, *args, **kwargs):
3131
super().save(*args, **kwargs)
3232

33-
update_bibliography(self, self.content)
33+
update_bibliography(self, [self.content])

mod_app/models/project_note_model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ def __str__(self):
3030
def save(self, *args, **kwargs):
3131
super().save(*args, **kwargs)
3232

33-
update_bibliography(self, self.content)
33+
update_bibliography(self, [self.content])

mod_app/models/teaching_analysis_models.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def default_title():
5555
def save(self, *args, **kwargs):
5656
super().save(*args, **kwargs)
5757

58-
update_bibliography(self, self.content)
58+
update_bibliography(self, [self.content])
5959

6060

6161
class TeachingResources(models.Model):
@@ -96,4 +96,4 @@ def default_title():
9696
def save(self, *args, **kwargs):
9797
super().save(*args, **kwargs)
9898

99-
update_bibliography(self, self.material)
99+
update_bibliography(self, [self.material])

mod_app/utils/extract_citations.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33

44

55
def update_bibliography(self, fields):
6-
bib_items = []
7-
for field in fields:
8-
bib_items.extend(get_bibliography_items(field))
9-
10-
# for each pk found add the bib item to the bibliography if it's changed
11-
if list(self.bibliography.all()) != bib_items:
12-
self.bibliography.set(bib_items)
6+
# fields should be a list
7+
if fields:
8+
bib_items = []
9+
for field in fields:
10+
if field:
11+
bib_items.extend(get_bibliography_items(field))
12+
13+
# for each pk found add the bib item to the bibliography if it's changed
14+
if list(self.bibliography.all()) != bib_items:
15+
self.bibliography.set(bib_items)
1316

1417

1518
def get_bibliography_items(field):

0 commit comments

Comments
 (0)