Skip to content

Commit 88c6ca7

Browse files
authored
Revert "[REVERT][OSF-3622] Disallow user to choose citation styles with no bibliography section.""
1 parent f2cef48 commit 88c6ca7

4 files changed

Lines changed: 43 additions & 2 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.11.7 on 2017-12-04 14:53
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('osf', '0072_merge_20171128_1018'),
12+
]
13+
14+
operations = [
15+
migrations.AddField(
16+
model_name='citationstyle',
17+
name='has_bibliography',
18+
field=models.BooleanField(default=False),
19+
),
20+
]

osf/models/citation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class CitationStyle(BaseModel):
2323

2424
short_title = models.CharField(max_length=2048, null=True, blank=True)
2525
summary = models.CharField(max_length=4200, null=True, blank=True) # longest value was 3,812 8/23/2016
26+
has_bibliography = models.BooleanField(default=False)
2627

2728
class Meta:
2829
ordering = ['_id']
@@ -33,4 +34,5 @@ def to_json(self):
3334
'title': self.title,
3435
'short_title': self.short_title,
3536
'summary': self.summary,
37+
'has_bibliography': self.has_bibliography
3638
}

scripts/parse_citation_styles.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
#!/usr/bin/env python
22
# encoding: utf-8
33

4+
"""
5+
This script is modified in this PR (https://github.com/CenterForOpenScience/osf.io/pull/7595)
6+
to set the corresponding `has_bibliography` flag to `False` for all citation formats whose CSL file do not
7+
include a bibliography section. As a result, all such citation formats would not show up in OSF
8+
citation widgets for users to choose.
9+
10+
NOTE:
11+
As of August 25th, 2017, there are however THREE EXCEPTIONS:
12+
"Bluebook Law Review", "Bluebook Law Review(2)" and "Bluebook Inline" shares a
13+
special CSL file ('website/static/bluebook.cls'), in which a bibliography section is defined,
14+
for rendering bibliographies even though their official CSL files (located in assets folder)
15+
do not contain a bibliography section.
16+
The side effect is that, upon parsing all the CSL files in the assets folder, these three citation
17+
formats are marked as `has_bibliography=False`, preventing them from user selection on the front end.
18+
Therefore, intervention is needed to manually "turn on" their 'has_bibliography' flag for them to show
19+
on the citation widget.
20+
"""
21+
422
import os
523

624
from lxml import etree
@@ -10,7 +28,6 @@
1028
setup_django()
1129
from osf.models.citation import CitationStyle
1230

13-
1431
def main():
1532

1633
# drop all styles
@@ -32,6 +49,8 @@ def main():
3249
fields = {
3350
'_id': os.path.splitext(os.path.basename(style_file))[0],
3451
'title': root.find(selector + 'title').text,
52+
'has_bibliography': True if root.find(
53+
'{{{ns}}}{tag}'.format(ns=namespace, tag='bibliography')) is not None else False
3554
}
3655

3756
# Optional

website/citations/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def list_citation_styles():
2121
Q(short_title__icontains=query)
2222
)
2323
return {
24-
'styles': [style.to_json() for style in citation_styles]
24+
'styles': [style.to_json() for style in citation_styles if style.has_bibliography]
2525
}
2626

2727

0 commit comments

Comments
 (0)