SciPost Code Repository

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

Remove html from models (Journals)

parent 613b6ea6
No related branches found
No related tags found
No related merge requests found
from .base import *
# THE MAIN THING HERE
DEBUG = True
# Debug toolbar settings
INSTALLED_APPS += (
'debug_toolbar',
)
MIDDLEWARE_CLASSES += (
'debug_toolbar.middleware.DebugToolbarMiddleware',
)
INTERNAL_IPS = ['127.0.0.1', '::1']
# Static and media
STATIC_ROOT = '/Users/jorranwit/Develop/SciPost/scipost_v1/local_files/static/'
MEDIA_ROOT = '/Users/jorranwit/Develop/SciPost/scipost_v1/local_files/media/'
WEBPACK_LOADER['DEFAULT']['BUNDLE_DIR_NAME'] =\
'/Users/jorranwit/Develop/SciPost/scipost_v1/local_files/static/bundles/'
MAILCHIMP_API_USER = get_secret("MAILCHIMP_API_USER")
MAILCHIMP_API_KEY = get_secret("MAILCHIMP_API_KEY")
...@@ -177,41 +177,6 @@ class Publication(models.Model): ...@@ -177,41 +177,6 @@ class Publication(models.Model):
+ ', ' + self.get_paper_nr() + ', ' + self.get_paper_nr()
+ ' (' + self.publication_date.strftime('%Y') + ')') + ' (' + self.publication_date.strftime('%Y') + ')')
def citations_as_ul(self):
output = '<ul>'
context = Context({})
nr = 0
for cit in self.citedby:
output += '<li>{{ auth_' + str(nr) + ' }}'
context['auth_' + str(nr)] = (cit['first_author_given_name']
+ ' ' + cit['first_author_surname'])
if cit['multiauthors']:
output += ' <em>et al.</em>'
output += (', <em>{{ title_' + str(nr) + ' }}</em>, <br/>'
'{{ journal_abbrev_' + str(nr) + ' }}')
context['title_' + str(nr)] = cit['article_title']
context['journal_abbrev_' + str(nr)] = cit['journal_abbreviation']
if cit['volume']:
context['volume_' + str(nr)] = cit['volume']
output += ' <strong>{{ volume_' + str(nr) + ' }}</strong>'
output += ', '
if cit['first_page']:
output += '{{ first_page_' + str(nr) + ' }}'
context['first_page_' + str(nr)] = cit['first_page']
elif cit['item_number']:
output += '{{ item_number_' + str(nr) + ' }}'
context['item_number_' + str(nr)] = cit['item_number']
output += (' ({{ year_' + str(nr) + ' }}) '
'<a href="https://doi.org/{{ doi_' + str(nr) + ' }}" '
'target="_blank">[Crossref]</a>')
context['year_' + str(nr)] = cit['year']
context['doi_' + str(nr)] = cit['doi']
output += '</li>'
nr += 1
output += '</ul>'
template = Template(output)
return template.render(context)
class Deposit(models.Model): class Deposit(models.Model):
""" """
......
{# TO BE USED IN FUTURE #} <ul>
{% for cite in publication.citedby %}
<li>
{{cite.first_author_given_name}} {{cite.first_author_surname}}{% if cite.multiauthors %} <em>et al.</em>{% endif %}, <em>{{cite.article_title}}</em><br>
{% comment %} {{cite.journal_abbreviation}}{% if cite.volume %} <strong>{{cite.volume}}</strong>{% endif %}, {{cite.first_page|default_if_none:''}} {{cite.item_number|default_if_none:''}} ({{cite.year}}) <a href="https://doi.org/{{cite.doi}}" target="_blank">[Crossref]</a>
output = '<ul>' </li>
context = Context({}) {% endfor %}
nr = 0 </ul>
{
first_author_given_name: 'John',
first_author_surname: 'Doe',
multiauthors: true
article_title: 'Phase transitions on 2D Ising model',
journal_abbreviation: 'SciPostPhys',
vol: ''
}
for cit in self.citedby:
output += '<li>{{ auth_' + str(nr) + ' }}'
context['auth_' + str(nr)] = (cit['first_author_given_name']
+ ' ' + cit['first_author_surname'])
if cit['multiauthors']:
output += ' <em>et al.</em>'
output += (', <em>{{ title_' + str(nr) + ' }}</em>, <br/>'
'{{ journal_abbrev_' + str(nr) + ' }}')
context['title_' + str(nr)] = cit['article_title']
context['journal_abbrev_' + str(nr)] = cit['journal_abbreviation']
if cit['volume']:
context['volume_' + str(nr)] = cit['volume']
output += ' <strong>{{ volume_' + str(nr) + ' }}</strong>'
output += ', '
if cit['first_page']:
output += '{{ first_page_' + str(nr) + ' }}'
context['first_page_' + str(nr)] = cit['first_page']
elif cit['item_number']:
output += '{{ item_number_' + str(nr) + ' }}'
context['item_number_' + str(nr)] = cit['item_number']
output += (' ({{ year_' + str(nr) + ' }}) '
'<a href="https://doi.org/{{ doi_' + str(nr) + ' }}" '
'target="_blank">[Crossref]</a>')
context['year_' + str(nr)] = cit['year']
context['doi_' + str(nr)] = cit['doi']
output += '</li>'
nr += 1
output += '</ul>'
template = Template(output)
return template.render(context)
{% endcomment %}
...@@ -31,42 +31,31 @@ ...@@ -31,42 +31,31 @@
<meta name="citation_firstpage" content="{{ publication.paper_nr|paper_nr_string_filter }}"/> <meta name="citation_firstpage" content="{{ publication.paper_nr|paper_nr_string_filter }}"/>
<meta name="citation_pdf_url" content="https://scipost.org/{{ publication.doi_string }}/pdf"/> <meta name="citation_pdf_url" content="https://scipost.org/{{ publication.doi_string }}/pdf"/>
<script>
$(document).ready(function(){
$("#citationslist").hide();
$("#citationslistbutton").click(function(){
$("#citationslist").toggle();
});
});
</script>
{% endblock headsup %} {% endblock headsup %}
{% block content %} {% block content %}
{% include 'journals/_publication_details.html' with publication=publication %} {% include 'journals/_publication_details.html' with publication=publication %}
<hr>
{% if publication.citedby|length >= 1 %} {% if publication.citedby|length >= 1 %}
<hr>
<div class="row"> <div class="row">
<div class="col-6 col-md-2"> <div class="col-6 col-md-2">
<h3 class="mb-2">Cited by {{ publication.citedby|length }}</h3> <h3 class="mb-2">Cited by {{ publication.citedby|length }}</h3>
<button class="btn btn-sm btn-secondary" id="citationslistbutton">Toggle view</button> <a href="javascript:;" data-toggle="toggle" data-target="#citationslist">Toggle view</a>
</div> </div>
<div class="col-6 col-md-2"> <div class="col-6 col-md-2">
<img src="{% static 'scipost/images/citedby.gif' %}" alt="Crossref Cited-by" width="64" /> <img src="{% static 'scipost/images/citedby.gif' %}" alt="Crossref Cited-by" width="64" />
</div> </div>
</div> </div>
<div class="row" id="citationslist"> <div class="row" id="citationslist" style="display: none;">
<div class="col-12"> <div class="col-12">
{# {% include 'journals/_publication_citations.html' with publication=publication %}#} {% include 'journals/_publication_citations.html' with publication=publication %}
{{ publication.citations_as_ul }}
</div> </div>
</div> </div>
{% endif %} {% endif %}
<hr>
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<h3>View more material from these authors:</h3> <h3>View more material from these authors:</h3>
......
...@@ -60,6 +60,8 @@ ul.publicationClickables { ...@@ -60,6 +60,8 @@ ul.publicationClickables {
list-style-type: none; list-style-type: none;
margin: 0; margin: 0;
padding: 2px 0; padding: 2px 0;
border: 1px solid #eee;
border-bottom: 1px solid #ddd;
li { li {
display: inline-block; display: inline-block;
......
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