SciPost Code Repository

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

Improve Organization list display

parent 366c9b89
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2018-07-11 04:23
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('partners', '0007_partner_organization'),
]
operations = [
migrations.AlterModelOptions(
name='organization',
options={'ordering': ['country', 'name']},
),
migrations.AlterField(
model_name='partner',
name='organization',
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='partners.Organization'),
),
]
...@@ -105,6 +105,15 @@ class Organization(models.Model): ...@@ -105,6 +105,15 @@ class Organization(models.Model):
return self.publicationauthorstable_set.select_related( return self.publicationauthorstable_set.select_related(
'unregistered_author').order_by('unregistered_author__last_name') 'unregistered_author').order_by('unregistered_author__last_name')
@property
def has_current_agreement(self):
"""
Check if this organization has a current Partnership agreement.
"""
if not self.partner:
return False
return self.partner.agreements.now_active().exists()
######################## ########################
# Prospective Partners # # Prospective Partners #
...@@ -293,8 +302,8 @@ class Partner(models.Model): ...@@ -293,8 +302,8 @@ class Partner(models.Model):
""" """
institution = models.ForeignKey('partners.Institution', on_delete=models.CASCADE, institution = models.ForeignKey('partners.Institution', on_delete=models.CASCADE,
blank=True, null=True) blank=True, null=True)
organization = models.ForeignKey('partners.Organization', on_delete=models.CASCADE, organization = models.OneToOneField('partners.Organization', on_delete=models.CASCADE,
blank=True, null=True) blank=True, null=True)
status = models.CharField(max_length=16, choices=PARTNER_STATUS, default=PARTNER_INITIATED) status = models.CharField(max_length=16, choices=PARTNER_STATUS, default=PARTNER_INITIATED)
main_contact = models.ForeignKey('partners.Contact', on_delete=models.SET_NULL, main_contact = models.ForeignKey('partners.Contact', on_delete=models.SET_NULL,
blank=True, null=True, related_name='partner_main_contact') blank=True, null=True, related_name='partner_main_contact')
...@@ -309,6 +318,9 @@ class Partner(models.Model): ...@@ -309,6 +318,9 @@ class Partner(models.Model):
def get_absolute_url(self): def get_absolute_url(self):
return reverse('partners:partner_view', args=(self.id,)) return reverse('partners:partner_view', args=(self.id,))
def get_latest_active_agreement(self):
return self.agreements.now_active().order_by('start_date').first()
@property @property
def has_all_contacts(self): def has_all_contacts(self):
""" """
......
...@@ -5,9 +5,11 @@ ...@@ -5,9 +5,11 @@
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<ul class="nav nav-tabs" id="organization-{{ org.id }}-tab" role="tablist"> <ul class="nav nav-tabs" id="organization-{{ org.id }}-tab" role="tablist">
{% if perms.scipost.can_manage_organizations %}
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" id="details-{{ org.id }}-tab" data-toggle="tab" href="#details-{{ org.id }}" role="tab" aria-controls="details-{{ org.id }}" aria-selected="true">Details</a> <a class="nav-link" id="details-{{ org.id }}-tab" data-toggle="tab" href="#details-{{ org.id }}" role="tab" aria-controls="details-{{ org.id }}" aria-selected="true">Details</a>
</li> </li>
{% endif %}
<li class="nav-item"> <li class="nav-item">
<a class="nav-link active" id="publications-{{ org.id }}-tab" data-toggle="tab" href="#publications-{{ org.id }}" role="tab" aria-controls="publications-{{ org.id }}" aria-selected="true">Associated Publications</a> <a class="nav-link active" id="publications-{{ org.id }}-tab" data-toggle="tab" href="#publications-{{ org.id }}" role="tab" aria-controls="publications-{{ org.id }}" aria-selected="true">Associated Publications</a>
</li> </li>
...@@ -25,10 +27,13 @@ ...@@ -25,10 +27,13 @@
</ul> </ul>
<div class="tab-content" id="organization-{{ org.id }}-tab"> <div class="tab-content" id="organization-{{ org.id }}-tab">
{% if perms.scipost.can_manage_organizations %}
<div class="tab-pane pt-4" id="details-{{ org.id }}" role="tabpanel" aria-labelledby="details-{{ org.id }}-tab"> <div class="tab-pane pt-4" id="details-{{ org.id }}" role="tabpanel" aria-labelledby="details-{{ org.id }}-tab">
<h3>Details:</h3> <h3>Details:</h3>
{% include 'partners/_organization_details_contents.html' with org=org %} {% include 'partners/_organization_details_contents.html' with org=org %}
</div> </div>
{% endif %}
<div class="tab-pane show active pt-4" id="publications-{{ org.id }}" role="tabpanel" aria-labelledby="publications-{{ org.id }}-tab"> <div class="tab-pane show active pt-4" id="publications-{{ org.id }}" role="tabpanel" aria-labelledby="publications-{{ org.id }}-tab">
<h3>Publications associated to this Organization:</h3> <h3>Publications associated to this Organization:</h3>
...@@ -71,12 +76,12 @@ ...@@ -71,12 +76,12 @@
<div class="tab-pane pt-4" id="partnership-{{ org.id }}" role="tabpanel" aria-labelledby="partnership-{{ org.id }}-tab"> <div class="tab-pane pt-4" id="partnership-{{ org.id }}" role="tabpanel" aria-labelledby="partnership-{{ org.id }}-tab">
<h3>Partnership history:</h3> <h3>Partnership history:</h3>
{% if org.partner.agreements %} {% with agreement=org.partner.get_latest_active_agreement %}
{% if org.partner.agreements.now_active %} {% if agreement %}
<p>This organization is currently a SciPost Supporting Partner.</p> <p>This organization is currently a SciPost Supporting Partner.</p>
{% else %}
<p>This organization is currently <span class="text-danger">not</span> a SciPost Supporting Partner.</p>
{% endif %} {% endif %}
{% endwith %}
{% if org.partner.agreements %}
<table class="table"> <table class="table">
<thead> <thead>
<th>Status</th> <th>Status</th>
...@@ -85,7 +90,7 @@ ...@@ -85,7 +90,7 @@
<th>Contribution/year</th> <th>Contribution/year</th>
</thead> </thead>
<tbody> <tbody>
{% for agreement in org.partner.agreements %} {% for agreement in org.partner.agreements.all %}
<tr> <tr>
<td>{{ agreement.get_status_display }}</td> <td>{{ agreement.get_status_display }}</td>
<td>{{ agreement.get_duration_display }}</td> <td>{{ agreement.get_duration_display }}</td>
...@@ -96,7 +101,7 @@ ...@@ -96,7 +101,7 @@
</tbody> </tbody>
</table> </table>
{% else %} {% else %}
<p>This organization has not yet become a SciPost Supporting Partner.</p> <p>This organization has <span class="text-danger">not yet</span> been as a SciPost Supporting Partner.</p>
{% endif %} {% endif %}
</div> </div>
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
{% block pagetitle %}: Organizations{% endblock pagetitle %} {% block pagetitle %}: Organizations{% endblock pagetitle %}
{% load staticfiles %} {% load staticfiles %}
{% load partners_extras %}
{% block content %} {% block content %}
<div class="row"> <div class="row">
...@@ -24,6 +25,7 @@ ...@@ -24,6 +25,7 @@
<th>Acronym</th> <th>Acronym</th>
<th>Name</th> <th>Name</th>
<th>Type</th> <th>Type</th>
<th>Partner?</th>
</tr> </tr>
</thead> </thead>
<tbody id="accordion" role="tablist" aria-multiselectable="true"> <tbody id="accordion" role="tablist" aria-multiselectable="true">
...@@ -33,9 +35,17 @@ ...@@ -33,9 +35,17 @@
<td>{{ org.acronym }}</td> <td>{{ org.acronym }}</td>
<td>{{ org.name }}</td> <td>{{ org.name }}</td>
<td>{{ org.get_orgtype_display }}</td> <td>{{ org.get_orgtype_display }}</td>
{% if org.has_current_agreement %}
<td style="background-color: #32cd32;">Yes</td>
{% elif org.partner.agreements %}
<td style="background-color: #ff8c00;">Was</td>
{% else %}
<td style="background-color: #ee0000;">Not yet</td>
{% endif %}
<td></td>
</tr> </tr>
<tr id="collapse{{ org.id }}" class="collapse" role="tabpanel" aria-labbeledby="heading{{ org.id }}" style="background-color: #fff;"> <tr id="collapse{{ org.id }}" class="collapse" role="tabpanel" aria-labbeledby="heading{{ org.id }}" style="background-color: #fff;">
<td colspan="4"> <td colspan="5">
{% include 'partners/_organization_card.html' with org=org %} {% include 'partners/_organization_card.html' with org=org %}
</td> </td>
</tr> </tr>
......
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