SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit fdea3168 authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Reference HTML tweaks

parent 905bb367
No related branches found
No related tags found
No related merge requests found
......@@ -113,16 +113,15 @@ class BaseReferenceFormSet(BaseModelFormSet):
except KeyError:
author_list.append(author['name'])
if len(author_list) > 3:
authors = author_list[0] + ' et al.'
elif len(author_list) == 3:
authors = '{}, {} and {}'.format(
author_list[0], author_list[1], author_list[2])
if len(author_list) > 2:
authors = ', '.join(author_list[:-1])
authors += ' and ' + author_list[-1]
else:
authors = ' and '.join(author_list)
# Citation
citation = '{} <b>{}</b>, {} ({})'.format(
citation = '<em>{}</em> {} <b>{}</b>, {} ({})'.format(
caller.data['title'],
caller.data['journal'],
caller.data['volume'],
caller.data['pages'],
......@@ -131,16 +130,15 @@ class BaseReferenceFormSet(BaseModelFormSet):
self.initial_references.append({
'reference_number': cite['key'][3:],
'authors': authors,
'title': caller.data['title'],
'citation': citation,
'vor': cite['doi'],
'vor_url': 'https://doi.org/{}'.format(cite['doi']),
'identifier': cite['doi'],
'link': 'https://doi.org/{}'.format(cite['doi']),
})
else:
self.initial_references.append({
'reference_number': cite['key'][3:],
'vor': cite['doi'],
'vor_url': 'https://doi.org/{}'.format(cite['doi']),
'identifier': cite['doi'],
'link': 'https://doi.org/{}'.format(cite['doi']),
})
# Add prefill information to the form
......@@ -157,10 +155,9 @@ class ReferenceForm(forms.ModelForm):
fields = [
'reference_number',
'authors',
'title',
'citation',
'vor',
'vor_url',
'identifier',
'link',
]
def __init__(self, *args, **kwargs):
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2018-02-03 11:29
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('journals', '0007_auto_20180129_1814'),
]
operations = [
migrations.RenameField(
model_name='reference',
old_name='vor',
new_name='identifier',
),
migrations.RenameField(
model_name='reference',
old_name='vor_url',
new_name='link',
),
migrations.RemoveField(
model_name='reference',
name='title',
),
migrations.AlterField(
model_name='reference',
name='authors',
field=models.CharField(max_length=1028),
),
migrations.AlterField(
model_name='reference',
name='citation',
field=models.CharField(blank=True, max_length=1028),
),
]
......@@ -331,12 +331,10 @@ class Reference(models.Model):
reference_number = models.IntegerField()
publication = models.ForeignKey('journals.Publication', on_delete=models.CASCADE)
authors = models.CharField(max_length=512)
title = models.CharField(max_length=512)
citation = models.CharField(max_length=512, blank=True)
vor = models.CharField(blank=True, max_length=128)
vor_url = models.URLField(blank=True)
authors = models.CharField(max_length=1028)
citation = models.CharField(max_length=1028, blank=True)
identifier = models.CharField(blank=True, max_length=128)
link = models.URLField(blank=True)
class Meta:
unique_together = ('reference_number', 'publication')
......
......@@ -3,15 +3,27 @@
<a class="mb-2 d-block" href="javascript:;" data-toggle="toggle" data-target="#reference_list">Click to expand</a>
<ul class="references" id="reference_list" style="display:none;">
{% for reference in publication.references.all %}
<li>
<span class="counter">[{{ reference.reference_number }}]</span>
<span class="authors">{{ reference.authors }}</span>,
<span class="title">{{ reference.title }}</span>{% if reference.citation %}, <span class="citation">{{ reference.citation|safe }}</span>{% endif %}
{% if reference.vor_url and reference.vor %}
<span class="doi">doi: <a href="{{ reference.vor_url }}" target="_blank">{{ reference.vor }}</a></span>
{% elif reference.vor_url %}
<span class="doi"><a href="{{ reference.vor_url }}" target="_blank">link</a></span>
{% endif %}
<li class="mt-1">
<div class="d-flex flex-row">
<div class="px-1">
<span class="counter">[{{ reference.reference_number }}]</span>
</div>
<div class="px-1">
<div class="authors">{{ reference.authors }}</div>
{% if reference.citation %}
<div class="citation">{{ reference.citation|safe }}</div>
{% endif %}
<div class="reference">
{% if reference.link and reference.identifier %}
<a href="{{ reference.link }}" target="_blank">{{ reference.identifier }}</a>
{% elif reference.link %}
<a href="{{ reference.link }}" target="_blank">link</a>
{% elif reference.identifier %}
<span>{{ reference.identifier }}</span>
{% endif %}
</div>
</div>
</div>
</li>
{% endfor %}
</ul>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment