diff --git a/partners/constants.py b/partners/constants.py index 148ac6556ebd5852c5aeaaac739086933b4ad51f..af2004f47e0b888363405424b59a352ae06e5802 100644 --- a/partners/constants.py +++ b/partners/constants.py @@ -70,6 +70,13 @@ PARTNER_EVENTS = ( ('comment', 'Comment added'), ) + +CONTACT_TYPES = ( + ('tech', 'Technical Contact'), + ('fin', 'Financial Contact'), +) + + MEMBERSHIP_SUBMITTED = 'Submitted' MEMBERSHIP_AGREEMENT_STATUS = ( (MEMBERSHIP_SUBMITTED, 'Request submitted by Partner'), diff --git a/partners/migrations/0012_auto_20170620_1526.py b/partners/migrations/0012_auto_20170620_1526.py new file mode 100644 index 0000000000000000000000000000000000000000..302836f563c2eedbd345f067bc90e5fbf896ee3e --- /dev/null +++ b/partners/migrations/0012_auto_20170620_1526.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.3 on 2017-06-20 13:26 +from __future__ import unicode_literals + +from django.db import migrations, models +import scipost.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('partners', '0011_auto_20170609_2234'), + ] + + operations = [ + migrations.RemoveField( + model_name='partner', + name='financial_contact', + ), + migrations.RemoveField( + model_name='partner', + name='technical_contact', + ), + migrations.AddField( + model_name='contact', + name='consortia', + field=models.ManyToManyField(help_text='All Consortia for which the Contact has explicit permission to view/edit its data.', to='partners.Consortium'), + ), + migrations.AddField( + model_name='contact', + name='partners', + field=models.ManyToManyField(help_text='All Partners (+related Institutions) the Contact is related to.', to='partners.Partner'), + ), + migrations.AlterField( + model_name='contact', + name='kind', + field=scipost.fields.ChoiceArrayField(base_field=models.CharField(choices=[('tech', 'Technical Contact'), ('fin', 'Financial Contact')], max_length=4), size=None), + ), + migrations.AlterField( + model_name='prospectivepartnerevent', + name='event', + field=models.CharField(choices=[('requested', 'Requested (from online form)'), ('comment', 'Comment added'), ('email_sent', 'Email sent'), ('negotiating', 'Initiated negotiation'), ('marked_as_uninterested', 'Marked as uninterested'), ('promoted', 'Promoted to Partner')], max_length=64), + ), + ] diff --git a/partners/models.py b/partners/models.py index 723b0316c8b761045dd9d00e47322d198db597ea..0ab566ee0f518f976d8da96a58800dac18e98054 100644 --- a/partners/models.py +++ b/partners/models.py @@ -14,11 +14,12 @@ from .constants import PROSPECTIVE_PARTNER_EVENT_EMAIL_SENT,\ PROSPECTIVE_PARTNER_EVENT_MARKED_AS_UNINTERESTED,\ PROSPECTIVE_PARTNER_UNINTERESTED,\ PROSPECTIVE_PARTNER_EVENT_PROMOTED,\ - PROSPECTIVE_PARTNER_PROCESSED + PROSPECTIVE_PARTNER_PROCESSED, CONTACT_TYPES from .managers import MembershipAgreementManager from scipost.constants import TITLE_CHOICES +from scipost.fields import ChoiceArrayField from scipost.models import get_sentinel_user @@ -112,8 +113,14 @@ class Contact(models.Model): Contacts and Contributors have different rights. """ user = models.OneToOneField(User, on_delete=models.CASCADE, unique=True) - kind = models.CharField(max_length=128) + kind = ChoiceArrayField(models.CharField(max_length=4, choices=CONTACT_TYPES)) title = models.CharField(max_length=4, choices=TITLE_CHOICES) + partners = models.ManyToManyField('partners.Partner', + help_text=('All Partners (+related Institutions)' + ' the Contact is related to.')) + consortia = models.ManyToManyField('partners.Consortium', + help_text=('All Consortia for which the Contact has' + ' explicit permission to view/edit its data.')) def __str__(self): return '%s %s, %s' % (self.get_title_display(), self.user.last_name, self.user.first_name) @@ -130,12 +137,6 @@ class Partner(models.Model): main_contact = models.ForeignKey('partners.Contact', on_delete=models.CASCADE, blank=True, null=True, related_name='partner_main_contact') - financial_contact = models.ForeignKey('partners.Contact', on_delete=models.CASCADE, - blank=True, null=True, - related_name='partner_financial_contact') - technical_contact = models.ForeignKey('partners.Contact', on_delete=models.CASCADE, - blank=True, null=True, - related_name='partner_technical_contact') def __str__(self): if self.institution: