From c6728f6f0305febb7dd4711b43bca2d1ecaea13f Mon Sep 17 00:00:00 2001 From: Jorran de Wit <jorrandewit@outlook.com> Date: Mon, 23 Apr 2018 10:52:24 +0200 Subject: [PATCH] List *all* prospect Partners --- partners/models.py | 40 ++++++++++--------- .../partners/_prospective_partner_card.html | 10 +++-- partners/views.py | 9 +++-- 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/partners/models.py b/partners/models.py index 966a78231..d8c0b21da 100644 --- a/partners/models.py +++ b/partners/models.py @@ -14,22 +14,20 @@ from django.urls import reverse from django_countries.fields import CountryField -from .constants import PARTNER_KINDS, PARTNER_STATUS, CONSORTIUM_STATUS, MEMBERSHIP_DURATION,\ - PROSPECTIVE_PARTNER_STATUS, PROSPECTIVE_PARTNER_EVENTS, PARTNER_EVENTS,\ - MEMBERSHIP_AGREEMENT_STATUS, PROSPECTIVE_PARTNER_ADDED,\ - PARTNER_KIND_UNI_LIBRARY -from .constants import PROSPECTIVE_PARTNER_EVENT_EMAIL_SENT,\ - PROSPECTIVE_PARTNER_APPROACHED,\ - PROSPECTIVE_PARTNER_EVENT_INITIATE_NEGOTIATION,\ - PROSPECTIVE_PARTNER_NEGOTIATING,\ - PROSPECTIVE_PARTNER_EVENT_MARKED_AS_UNINTERESTED,\ - PROSPECTIVE_PARTNER_UNINTERESTED,\ - PROSPECTIVE_PARTNER_EVENT_PROMOTED,\ - PROSPECTIVE_PARTNER_PROCESSED, CONTACT_TYPES,\ - PARTNER_INITIATED, REQUEST_STATUSES, REQUEST_INITIATED - -from .managers import MembershipAgreementManager, ProspectivePartnerManager, PartnerManager,\ - ContactRequestManager, PartnersAttachmentManager +from .constants import ( + PARTNER_KINDS, PARTNER_STATUS, CONSORTIUM_STATUS, MEMBERSHIP_DURATION, PARTNER_EVENTS, + PROSPECTIVE_PARTNER_STATUS, PROSPECTIVE_PARTNER_EVENTS, MEMBERSHIP_AGREEMENT_STATUS, + PROSPECTIVE_PARTNER_ADDED, PARTNER_KIND_UNI_LIBRARY) +from .constants import ( + PROSPECTIVE_PARTNER_EVENT_EMAIL_SENT, PROSPECTIVE_PARTNER_APPROACHED, PARTNER_INITIATED, + PROSPECTIVE_PARTNER_EVENT_INITIATE_NEGOTIATION, PROSPECTIVE_PARTNER_PROCESSED, CONTACT_TYPES, + PROSPECTIVE_PARTNER_NEGOTIATING, PROSPECTIVE_PARTNER_EVENT_MARKED_AS_UNINTERESTED, + REQUEST_STATUSES, PROSPECTIVE_PARTNER_UNINTERESTED, PROSPECTIVE_PARTNER_EVENT_PROMOTED, + REQUEST_INITIATED) + +from .managers import ( + MembershipAgreementManager, ProspectivePartnerManager, PartnerManager, ContactRequestManager, + PartnersAttachmentManager) from scipost.constants import TITLE_CHOICES from scipost.fields import ChoiceArrayField @@ -44,9 +42,8 @@ now = timezone.now() ######################## class ProspectivePartner(models.Model): - """ - Created from the membership_request page, after submitting a query form. - """ + """A prospect Partner is a Partner without explicit contract with SciPost yet.""" + kind = models.CharField(max_length=32, choices=PARTNER_KINDS, default=PARTNER_KIND_UNI_LIBRARY) institution_name = models.CharField(max_length=256) country = CountryField() @@ -62,6 +59,11 @@ class ProspectivePartner(models.Model): self.date_received.strftime("%Y-%m-%d"), self.get_status_display()) + @property + def is_promoted_to_partner(self): + """Check if Prospect is already known to be a Partner.""" + return self.status == PROSPECTIVE_PARTNER_PROCESSED + def update_status_from_event(self, event): if event == PROSPECTIVE_PARTNER_EVENT_EMAIL_SENT: self.status = PROSPECTIVE_PARTNER_APPROACHED diff --git a/partners/templates/partners/_prospective_partner_card.html b/partners/templates/partners/_prospective_partner_card.html index 48c903504..9a56f10cd 100644 --- a/partners/templates/partners/_prospective_partner_card.html +++ b/partners/templates/partners/_prospective_partner_card.html @@ -70,10 +70,12 @@ <input type="submit" name="submit" value="Submit" class="btn btn-outline-secondary"> </form> - <h3>Partner status</h3> - <ul> - <li><a href="{% url 'partners:promote_prospartner' pp.id %}">Upgrade prospect to partner</a></li> - </ul> + {% if not pp.is_promoted_to_partner %} + <h3>Partner status</h3> + <ul> + <li><a href="{% url 'partners:promote_prospartner' pp.id %}">Upgrade prospect to partner</a></li> + </ul> + {% endif %} </div> </div> </div> diff --git a/partners/views.py b/partners/views.py index a17405729..9c5bf531d 100644 --- a/partners/views.py +++ b/partners/views.py @@ -47,10 +47,11 @@ def supporting_partners(request): @login_required @permission_required('scipost.can_read_partner_page', return_403=True) def dashboard(request): - ''' + """Administration page for Partners and Prospective Partners. + This page is meant as a personal page for Partners, where they will for example be able to read their personal data and agreements. - ''' + """ context = {} try: context['personal_agreements'] = (MembershipAgreement.objects.open_to_partner() @@ -62,8 +63,8 @@ def dashboard(request): context['contact_requests_count'] = ContactRequest.objects.awaiting_processing().count() context['inactivate_contacts_count'] = Contact.objects.filter(user__is_active=False).count() context['partners'] = Partner.objects.all() - context['prospective_partners'] = (ProspectivePartner.objects.not_yet_partner() - .order_by('country', 'institution_name')) + context['prospective_partners'] = ProspectivePartner.objects.order_by( + 'country', 'institution_name') context['ppevent_form'] = ProspectivePartnerEventForm() context['agreements'] = MembershipAgreement.objects.order_by('date_requested') return render(request, 'partners/dashboard.html', context) -- GitLab