SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit d9d97ad6 authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Improve Profile detail views

parent ccddb9e2
No related branches found
No related tags found
No related merge requests found
......@@ -11,8 +11,10 @@ from scipost.constants import (
TITLE_CHOICES, SCIPOST_DISCIPLINES, DISCIPLINE_PHYSICS, SCIPOST_SUBJECT_AREAS)
from scipost.fields import ChoiceArrayField
from comments.models import Comment
from journals.models import Publication, PublicationAuthorsTable
from ontology.models import Topic
from journals.models import PublicationAuthorsTable
from theses.models import ThesisLink
from .managers import ProfileQuerySet
......@@ -74,6 +76,26 @@ class Profile(models.Model):
def get_absolute_url(self):
return reverse('profiles:profile_detail', kwargs={'pk': self.id})
def publications(self):
"""
Returns all the publications associated to this Profile.
"""
return Publication.objects.published().filter(
models.Q(authors__unregistered_author__profile=self) |
models.Q(authors__contributor__profile=self))
def comments(self):
"""
Returns all the Comments associated to this Profile.
"""
return Comment.objects.filter(author__profile=self)
def theses(self):
"""
Returns all the Theses associated to this Profile.
"""
return ThesisLink.objects.filter(author_as_cont__profile=self)
class ProfileEmail(models.Model):
"""Any email related to a Profile instance."""
......
{% load bootstrap %}
{% load scipost_extras %}
<div class="card-body">
<div class="row">
<div class="col-6">
<div class="card">
<div class="card-header">
Details
</div>
<div class="card-body">
<table class="table">
<tr>
<td>Name:</td><td>{{ profile.last_name }}, {{ profile.get_title_display }} {{ profile.first_name }}</td>
......@@ -11,7 +15,7 @@
<tr>
<td>Email(s)</td>
<td>
<table class="table table-sm table-borderless">
<table class="table">
<thead>
<tr>
<th colspan="2">Email</th>
......@@ -51,22 +55,17 @@
<tr><td>Accepts SciPost emails</td><td>{{ profile.accepts_SciPost_emails }}</td></tr>
<tr><td>Accepts refereeing requests</td><td>{{ profile.accepts_refereeing_requests }}</td></tr>
<tr><td>Contributor</td><td>{% if profile.contributor %}Yes (<a href="{% url 'scipost:contributor_info' contributor_id=profile.contributor.id %}" target="_blank">info link</a>){% else %}No{% endif %}</td></tr>
<tr>
<td>Referee Invitations</td>
<td>
<ul>
{% for inv in profile.refereeinvitation_set.all %}
<li>{{ inv.submission.title }}<br/>(invited {{ inv.date_invited }}; fulfilled: {% if inv.fulfilled %}<i class="fa fa-check-square text-success"></i>{% else %}<i class="fa fa-times-circle"></i>{% endif %})</li>
{% empty %}
<li>No refereeing invitation found</li>
{% endfor %}
</ul>
</td>
</tr>
</table>
</div>
<div class="col-6">
<h4>Actions:</h4>
</div>
<div class="card-columns">
<div class="card">
<div class="card-header">
Actions
</div>
<div class="card-body">
<ul>
<li><a href="{% url 'profiles:profile_update' pk=profile.id %}">Update</a> this Profile</li>
<li><a href="{% url 'profiles:profile_delete' pk=profile.id %}">Delete</a> this Profile</li>
......@@ -85,4 +84,62 @@
</ul>
</div>
</div>
<div class="card">
<div class="card-header">
Refereeing invitations
</div>
<div class="card-body">
<ul>
{% for inv in profile.refereeinvitation_set.all %}
<li>{{ inv.submission.title }}<br/>(invited {{ inv.date_invited }}; fulfilled: {% if inv.fulfilled %}<i class="fa fa-check-square text-success"></i>{% else %}<i class="fa fa-times-circle"></i>{% endif %})</li>
{% empty %}
<li>No refereeing invitation found</li>
{% endfor %}
</ul>
</div>
</div>
<div class="card">
<div class="card-header">
Publications
</div>
<div class="card-body">
<ul>
{% for pub in profile.publications.all %}
<li><a href="{{ pub.get_absolute_url }}">{{ pub.citation }}</a></li>
{% empty %}
<li>No Publication found</li>
{% endfor %}
</ul>
</div>
</div>
<div class="card">
<div class="card-header">
Comments
</div>
<div class="card-body">
{% for comment in profile.comments.all %}
<li><a href="{{ comment.get_absolute_url }}">{{ comment }}</a></li>
{% empty %}
<li>No Comment found</li>
{% endfor %}
</div>
</div>
<div class="card">
<div class="card-header">
Theses
</div>
<div class="card-body">
{% for thesis in profile.theses.all %}
<li><a href="{{ thesis.get_absolute_url }}">{{ thesis }}</a></li>
{% empty %}
<li>No Thesis found</li>
{% endfor %}
</div>
</div>
</div>
......@@ -2,13 +2,22 @@
{% load bootstrap %}
{% load add_get_parameters %}
{% load scipost_extras %}
{% block breadcrumb_items %}
{{ block.super }}
<span class="breadcrumb-item">Profiles</span>
{% endblock %}
{% load scipost_extras %}
{% block headsup %}
<script type="text/javascript">
$(document).ready(function($) {
$(".table-row").click(function() {
window.document.location = $(this).data("href");
});
});
</script>
{% endblock headsup %}
{% block pagetitle %}: Profiles{% endblock pagetitle %}
......@@ -95,6 +104,38 @@
<div class="col-12">
<h3>Profiles {% if request.GET.text %}with last name starting with {{ request.GET.text }}{% endif %} {% if request.GET.discipline %}in {{ request.GET.discipline }}{% if request.GET.expertise %}, {{ request.GET.expertise }}{% endif %}{% endif %} ({% if request.GET.contributor == "True" %}registered Contributors{% elif request.GET.contributor == "False" %}unregistered as Contributors{% else %}all registered/unregistered{% endif %}): {{ page_obj.paginator.count }} found</h3>
<br/>
<table class="table table-hover mb-5">
<thead class="thead-default">
<tr>
<th>Name</th>
<th>Discipline</th>
<th>Expertises</th>
<th>Contributor?</th>
</tr>
</thead>
<tbody>
{% for profile in object_list %}
<tr class="table-row" data-href="{% url 'profiles:profile_detail' pk=profile.id %}" target="_blank" style="cursor: pointer;">
<td>{{ profile.last_name }}, {{ profile.get_title_display }} {{ profile.first_name }}</td>
<td>{{ profile.get_discipline_display }}</td>
<td>
{% for expertise in profile.expertises %}
<div class="single d-inline" data-specialization="{{expertise|lower}}" data-toggle="tooltip" data-placement="bottom" title="{{expertise|get_specialization_display}}">{{expertise|get_specialization_code}}</div>
{% endfor %}
</td>
<td>{% if profile.contributor %}<i class="fa fa-check-circle text-success"></i>{% else %}<i class="fa fa-times-circle text-danger"></i>{% endif %}</td>
</tr>
{% empty %}
<tr>
<td colspan="4">No Profiles found</td>
</tr>
{% endfor %}
</tbody>
</table>
<table class="table table-hover mb-5">
<thead class="thead-default">
<tr>
......
......@@ -180,6 +180,11 @@ class ProfileDetailView(PermissionsMixin, DetailView):
permission_required = 'scipost.can_view_profiles'
model = Profile
def get_context_data(self, *args, **kwargs):
context = super().get_context_data(*args, **kwargs)
context['email_form'] = ProfileEmailForm()
return context
class ProfileListView(PermissionsMixin, PaginationMixin, ListView):
"""
......
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