diff --git a/src/edrn.collabgroups/src/edrn/collabgroups/migrations/0006_remove_committee_co_chair_committee_co_chairs.py b/src/edrn.collabgroups/src/edrn/collabgroups/migrations/0006_remove_committee_co_chair_committee_co_chairs.py new file mode 100644 index 00000000..31b3dcd9 --- /dev/null +++ b/src/edrn.collabgroups/src/edrn/collabgroups/migrations/0006_remove_committee_co_chair_committee_co_chairs.py @@ -0,0 +1,29 @@ +# Generated by Django 4.2.14 on 2024-09-10 18:17 + +from django.db import migrations +import modelcluster.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ("ekeknowledge", "0019_remove_protocol_fieldofresearch_and_more"), + ("edrncollabgroups", "0005_committee_documents_heading"), + ] + + operations = [ + migrations.RemoveField( + model_name="committee", + name="co_chair", + ), + migrations.AddField( + model_name="committee", + name="co_chairs", + field=modelcluster.fields.ParentalManyToManyField( + blank=True, + related_name="committees_I_co_chair", + to="ekeknowledge.person", + verbose_name="Co-Chair(s)", + ), + ), + ] diff --git a/src/edrn.collabgroups/src/edrn/collabgroups/models.py b/src/edrn.collabgroups/src/edrn/collabgroups/models.py index 713e7e19..f5018776 100644 --- a/src/edrn.collabgroups/src/edrn/collabgroups/models.py +++ b/src/edrn.collabgroups/src/edrn/collabgroups/models.py @@ -125,9 +125,8 @@ class Committee(Page): Person, null=True, blank=True, verbose_name='Chair', related_name='committees_I_chair', on_delete=models.SET_NULL ) - co_chair = models.ForeignKey( - Person, null=True, blank=True, verbose_name='Co-Chair', related_name='committees_I_co_chair', - on_delete=models.SET_NULL + co_chairs = ParentalManyToManyField( + Person, blank=True, verbose_name='Co-Chair(s)', related_name='committees_I_co_chair' ) members = ParentalManyToManyField( Person, blank=True, verbose_name='Members', related_name='committees_I_belong_to' @@ -144,7 +143,7 @@ class Committee(Page): FieldPanel('description'), FieldPanel('documents_heading'), FieldPanel('chair'), - FieldPanel('co_chair'), + FieldPanel('co_chairs'), FieldPanel('members'), FieldPanel('program_officers'), FieldPanel('project_scientists'), diff --git a/src/edrn.collabgroups/src/edrn/collabgroups/templates/edrn.collabgroups/committee.html b/src/edrn.collabgroups/src/edrn/collabgroups/templates/edrn.collabgroups/committee.html index 35053f6b..6f213241 100644 --- a/src/edrn.collabgroups/src/edrn/collabgroups/templates/edrn.collabgroups/committee.html +++ b/src/edrn.collabgroups/src/edrn/collabgroups/templates/edrn.collabgroups/committee.html @@ -89,11 +89,19 @@

Project Scientist{{count|pluralize}}

{% endif %} {% endwith %} + {% with count=page.co_chairs.all|length %} + {% if count %} +

Co-Chair{{count|pluralize}}

+ + {% endif %} + {% endwith %} + + - {% if page.chair %} -

Chair

-

{{page.chair.title}}

- {% endif %} {% if page.co_chair %}

Co-Chair

{{page.co_chair.title}}

diff --git a/src/eke.knowledge/src/eke/knowledge/committees.py b/src/eke.knowledge/src/eke/knowledge/committees.py index 0e31c6ca..b84d2db5 100644 --- a/src/eke.knowledge/src/eke/knowledge/committees.py +++ b/src/eke.knowledge/src/eke/knowledge/committees.py @@ -49,11 +49,10 @@ def ingest(self): person = Person.objects.filter(identifier=new_chair).first() if person: committee.chair = person - new_co_chair = predicates.get(_co_chair, [None])[0] - if new_co_chair: - person = Person.objects.filter(identifier=new_co_chair).first() - if person: - committee.co_chair = person + + new_co_chairs = set(predicates.get(_co_chair, [])) + co_chairs = Person.objects.filter(identifier__in=new_co_chairs).order_by('title') + committee.co_chairs.set(co_chairs, bulk=True, clear=True) new_members = set(predicates.get(_member, [])) | set(predicates.get(_consultant, [])) members = Person.objects.filter(identifier__in=new_members).order_by('title') committee.members.set(members, bulk=True, clear=True)