SciPost Code Repository

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

move html from Contributor to partial templates

parent a0c18b45
No related branches found
No related tags found
No related merge requests found
...@@ -122,6 +122,7 @@ SHELL_PLUS_POST_IMPORTS = ( ...@@ -122,6 +122,7 @@ SHELL_PLUS_POST_IMPORTS = (
'VettedCommentaryFactory', 'VettedCommentaryFactory',
'UnvettedCommentaryFactory', 'UnvettedCommentaryFactory',
'UnpublishedVettedCommentaryFactory',)), 'UnpublishedVettedCommentaryFactory',)),
('scipost.factories', ('ContributorFactory')),
) )
MATHJAX_ENABLED = True MATHJAX_ENABLED = True
......
...@@ -22,6 +22,8 @@ class ContributorFactory(factory.django.DjangoModelFactory): ...@@ -22,6 +22,8 @@ class ContributorFactory(factory.django.DjangoModelFactory):
country_of_employment = factory.Iterator(list(COUNTRIES)) country_of_employment = factory.Iterator(list(COUNTRIES))
affiliation = factory.Faker('company') affiliation = factory.Faker('company')
expertises = factory.Iterator(SCIPOST_SUBJECT_AREAS[0][1], getter=lambda c: [c[0]]) expertises = factory.Iterator(SCIPOST_SUBJECT_AREAS[0][1], getter=lambda c: [c[0]])
personalwebpage = factory.Faker('domain_name')
address = factory.Faker('address')
class Meta: class Meta:
model = Contributor model = Contributor
......
...@@ -108,64 +108,6 @@ class Contributor(models.Model): ...@@ -108,64 +108,6 @@ class Contributor(models.Model):
self.key_expires = datetime.datetime.now() + datetime.timedelta(days=2) self.key_expires = datetime.datetime.now() + datetime.timedelta(days=2)
self.save() self.save()
def private_info_as_table(self):
template = Template('''
<table>
<tr><td>Title: </td><td>&nbsp;</td><td>{{ title }}</td></tr>
<tr><td>First name: </td><td>&nbsp;</td><td>{{ first_name }}</td></tr>
<tr><td>Last name: </td><td>&nbsp;</td><td>{{ last_name }}</td></tr>
<tr><td>Email: </td><td>&nbsp;</td><td>{{ email }}</td></tr>
<tr><td>ORCID id: </td><td>&nbsp;</td><td>{{ orcid_id }}</td></tr>
<tr><td>Country of employment: </td><td>&nbsp;</td>
<td>{{ country_of_employment }}</td></tr>
<tr><td>Affiliation: </td><td>&nbsp;</td><td>{{ affiliation }}</td></tr>
<tr><td>Address: </td><td>&nbsp;</td><td>{{ address }}</td></tr>
<tr><td>Personal web page: </td><td>&nbsp;</td><td>{{ personalwebpage }}</td></tr>
<tr><td>Accept SciPost emails: </td><td>&nbsp;</td><td>{{ accepts_SciPost_emails }}</td></tr>
</table>
''')
context = Context({
'title': self.get_title_display(),
'first_name': self.user.first_name,
'last_name': self.user.last_name,
'email': self.user.email,
'orcid_id': self.orcid_id,
'country_of_employment': str(self.country_of_employment.name),
'affiliation': self.affiliation,
'address': self.address,
'personalwebpage': self.personalwebpage,
'accepts_SciPost_emails': self.accepts_SciPost_emails,
})
return template.render(context)
def public_info_as_table(self):
"""Prints out all publicly-accessible info as a table."""
template = Template('''
<table>
<tr><td>Title: </td><td>&nbsp;</td><td>{{ title }}</td></tr>
<tr><td>First name: </td><td>&nbsp;</td><td>{{ first_name }}</td></tr>
<tr><td>Last name: </td><td>&nbsp;</td><td>{{ last_name }}</td></tr>
<tr><td>ORCID id: </td><td>&nbsp;</td><td>{{ orcid_id }}</td></tr>
<tr><td>Country of employment: </td><td>&nbsp;</td>
<td>{{ country_of_employment }}</td></tr>
<tr><td>Affiliation: </td><td>&nbsp;</td><td>{{ affiliation }}</td></tr>
<tr><td>Personal web page: </td><td>&nbsp;</td><td>{{ personalwebpage }}</td></tr>
</table>
''')
context = Context({
'title': self.get_title_display(),
'first_name': self.user.first_name,
'last_name': self.user.last_name,
'email': self.user.email,
'orcid_id': self.orcid_id,
'country_of_employment': str(self.country_of_employment.name),
'affiliation': self.affiliation,
'address': self.address,
'personalwebpage': self.personalwebpage
})
return template.render(context)
def discipline_as_string(self): def discipline_as_string(self):
# Redundant, to be removed in future # Redundant, to be removed in future
return self.get_discipline_display() return self.get_discipline_display()
......
<table>
<tr><td>Title: </td><td>&nbsp;</td><td>{{ contributor.get_title_display }}</td></tr>
<tr><td>First name: </td><td>&nbsp;</td><td>{{ contributor.user.first_name }}</td></tr>
<tr><td>Last name: </td><td>&nbsp;</td><td>{{ contributor.user.last_name }}</td></tr>
<tr><td>Email: </td><td>&nbsp;</td><td>{{ contributor.user.email }}</td></tr>
<tr><td>ORCID id: </td><td>&nbsp;</td><td>{{ contributor.orcid_id }}</td></tr>
<tr><td>Country of employment: </td><td>&nbsp;</td>
<td>{{ contributor.country_of_employment.name }}</td></tr>
<tr><td>Affiliation: </td><td>&nbsp;</td><td>{{ contributor.affiliation }}</td></tr>
<tr><td>Address: </td><td>&nbsp;</td><td>{{ contributor.address }}</td></tr>
<tr><td>Personal web page: </td><td>&nbsp;</td><td>{{ contributor.personalwebpage }}</td></tr>
<tr><td>Accept SciPost emails: </td><td>&nbsp;</td><td>{{ contributor.accepts_SciPost_emails }}</td></tr>
</table>
<table>
<tr><td>Title: </td><td>&nbsp;</td><td>{{ contributor.get_title_display }}</td></tr>
<tr><td>First name: </td><td>&nbsp;</td><td>{{ contributor.user.first_name }}</td></tr>
<tr><td>Last name: </td><td>&nbsp;</td><td>{{ contributor.user.last_name }}</td></tr>
<tr><td>ORCID id: </td><td>&nbsp;</td><td>{{ contributor.orcid_id }}</td></tr>
<tr><td>Country of employment: </td><td>&nbsp;</td>
<td>{{ contributor.country_of_employment.name }}</td></tr>
<tr><td>Affiliation: </td><td>&nbsp;</td><td>{{ contributor.affiliation }}</td></tr>
<tr><td>Personal web page: </td><td>&nbsp;</td><td>{{ contributor.personalwebpage }}</td></tr>
</table>
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
</div> </div>
</div> </div>
{{ contributor.public_info_as_table }} {% include "scipost/_public_info_as_table.html" with contributor=contributor %}
<br> <br>
{% if contributor_publications %} {% if contributor_publications %}
{# <hr>#} {# <hr>#}
......
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<h3>Your personal details:</h3> <h3>Your personal details:</h3>
{{ contributor.private_info_as_table }} {% include "scipost/_private_info_as_table.html" with contributor=contributor %}
<h3 class="mt-3">Your main discipline:</h3> <h3 class="mt-3">Your main discipline:</h3>
<ul><li>{{ contributor.discipline_as_string }}</li></ul> <ul><li>{{ contributor.discipline_as_string }}</li></ul>
......
...@@ -41,7 +41,7 @@ $(function() { ...@@ -41,7 +41,7 @@ $(function() {
{% if not forloop.first %}<hr class="small">{% endif %} {% if not forloop.first %}<hr class="small">{% endif %}
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-md-4">
{{ contributor_to_vet.private_info_as_table }} {% include "scipost/_private_info_as_table.html" with contributor=contributor %}
</div> </div>
<div class="col-md-8"> <div class="col-md-8">
<form action="{% url 'scipost:vet_registration_request_ack' contributor_id=contributor_to_vet.id %}" method="post"> <form action="{% url 'scipost:vet_registration_request_ack' contributor_id=contributor_to_vet.id %}" method="post">
......
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