SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit ddb775b4 authored by Geert Kapteijns's avatar Geert Kapteijns
Browse files

write RequestArxivPreprint view

parent 35aba111
No related branches found
No related tags found
No related merge requests found
......@@ -64,6 +64,10 @@ class ArxivQueryForm(forms.Form):
return identifier
def request_arxiv_preprint_form_prefill_data(self):
additional_form_data = {'arxiv_identifier': self.cleaned_data['identifier']}
return {**self.arxiv_data, **additional_form_data}
# class IdentifierToQueryForm(forms.Form):
# identifier = forms.CharField(widget=forms.TextInput(
......@@ -98,7 +102,7 @@ class RequestCommentaryForm(forms.ModelForm):
class Meta:
model = Commentary
fields = [
'discipline', 'domain', 'subject_area', 'pub_title', 'author_list', 'pub_date', 'pub_DOI', 'pub_abstract'
'discipline', 'domain', 'subject_area', 'pub_title', 'author_list', 'pub_date', 'pub_abstract'
]
placeholders = {
'pub_date': 'Format: YYYY-MM-DD'
......
......@@ -15,7 +15,7 @@
</div>
<div class="row">
<form id="requestForm" action="{% url 'commentaries:request_published_article' %}" method="post">
<form id="requestForm" action="{% url 'commentaries:request_arxiv_preprint' %}" method="post">
{% csrf_token %}
{{ form|bootstrap }}
<input class="btn btn-primary" type="submit" value="Submit"/>
......
......@@ -119,7 +119,8 @@ def prefill_using_arxiv_identifier(request):
if request.method == "POST":
arxiv_query_form = ArxivQueryForm(request.POST)
if arxiv_query_form.is_valid():
raise NotImplementedError
prefill_data = arxiv_query_form.request_arxiv_preprint_form_prefill_data()
form = RequestArxivPreprintForm(initial=prefill_data)
else:
form = RequestArxivPreprintForm()
......
......@@ -3,6 +3,7 @@ import feedparser
import requests
import re
import datetime
import dateutil.parser
from django.template import Template, Context
from .behaviors import ArxivCallable
......@@ -90,12 +91,14 @@ class ArxivCaller:
author_list = [author['name'] for author in data['authors']]
arxiv_link = data['id']
abstract = data['summary']
pub_date = dateutil.parser.parse(data['published']).date()
self.data = {
'pub_title': pub_title,
'author_list': author_list,
'arxiv_link': arxiv_link,
'pub_abstract': abstract,
'pub_date': pub_date,
}
def _search_result_present(self, data):
......
import datetime
from django.test import TestCase
from .services import ArxivCaller, DOICaller
......@@ -10,15 +12,16 @@ class ArxivCallerTest(TestCase):
caller = ArxivCaller('1612.07611v1')
self.assertTrue(caller.is_valid)
correct_data = {
'pub_abstract': 'The Berezinskii-Kosterlitz-Thouless (BKT) transitions of the six-state clock\nmodel on the square lattice are investigated by means of the corner-transfer\nmatrix renormalization group method. The classical analogue of the entanglement\nentropy $S( L, T )$ is calculated for $L$ by $L$ square system up to $L = 129$,\nas a function of temperature $T$. The entropy has a peak at $T = T^{*}_{~}( L\n)$, where the temperature depends on both $L$ and boundary conditions. Applying\nthe finite-size scaling to $T^{*}_{~}( L )$ and assuming the presence of BKT\ntransitions, the transition temperature is estimated to be $T_1^{~} = 0.70$ and\n$T_2^{~} = 0.88$. The obtained results agree with previous analyses. It should\nbe noted that no thermodynamic function is used in this study.', 'author_list': ['Roman Krčmár', 'Andrej Gendiar', 'Tomotoshi Nishino'], 'arxiv_link': 'http://arxiv.org/abs/1612.07611v1', 'pub_title': 'Phase transition of the six-state clock model observed from the\n entanglement entropy'
'pub_abstract': 'The Berezinskii-Kosterlitz-Thouless (BKT) transitions of the six-state clock\nmodel on the square lattice are investigated by means of the corner-transfer\nmatrix renormalization group method. The classical analogue of the entanglement\nentropy $S( L, T )$ is calculated for $L$ by $L$ square system up to $L = 129$,\nas a function of temperature $T$. The entropy has a peak at $T = T^{*}_{~}( L\n)$, where the temperature depends on both $L$ and boundary conditions. Applying\nthe finite-size scaling to $T^{*}_{~}( L )$ and assuming the presence of BKT\ntransitions, the transition temperature is estimated to be $T_1^{~} = 0.70$ and\n$T_2^{~} = 0.88$. The obtained results agree with previous analyses. It should\nbe noted that no thermodynamic function is used in this study.', 'author_list': ['Roman Krčmár', 'Andrej Gendiar', 'Tomotoshi Nishino'], 'arxiv_link': 'http://arxiv.org/abs/1612.07611v1', 'pub_title': 'Phase transition of the six-state clock model observed from the\n entanglement entropy', 'pub_date': datetime.date(2016, 12, 22)
}
self.assertEqual(caller.data, correct_data)
def test_identifier_old_style(self):
caller = ArxivCaller('cond-mat/0612480')
self.assertTrue(caller.is_valid)
print(caller.data)
correct_data = {
'pub_title': 'Least Action Principle for the Real-Time Density Matrix Renormalization\n Group', 'arxiv_link': 'http://arxiv.org/abs/cond-mat/0612480v2', 'author_list': ['Kouji Ueda', 'Chenglong Jin', 'Naokazu Shibata', 'Yasuhiro Hieida', 'Tomotoshi Nishino'], 'pub_abstract': 'A kind of least action principle is introduced for the discrete time\nevolution of one-dimensional quantum lattice models. Based on this principle,\nwe obtain an optimal condition for the matrix product states on succeeding time\nslices generated by the real-time density matrix renormalization group method.\nThis optimization can also be applied to classical simulations of quantum\ncircuits. We discuss the time reversal symmetry in the fully optimized MPS.'
'author_list': ['Kouji Ueda', 'Chenglong Jin', 'Naokazu Shibata', 'Yasuhiro Hieida', 'Tomotoshi Nishino'], 'pub_date': datetime.date(2006, 12, 19), 'arxiv_link': 'http://arxiv.org/abs/cond-mat/0612480v2', 'pub_abstract': 'A kind of least action principle is introduced for the discrete time\nevolution of one-dimensional quantum lattice models. Based on this principle,\nwe obtain an optimal condition for the matrix product states on succeeding time\nslices generated by the real-time density matrix renormalization group method.\nThis optimization can also be applied to classical simulations of quantum\ncircuits. We discuss the time reversal symmetry in the fully optimized MPS.', 'pub_title': 'Least Action Principle for the Real-Time Density Matrix Renormalization\n Group'
}
self.assertEqual(caller.data, correct_data)
......
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