Skip to content

Commit

Permalink
Support #368
Browse files Browse the repository at this point in the history
  • Loading branch information
nutjob4life committed Sep 11, 2024
1 parent 630749a commit 87b3fff
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -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)",
),
),
]
7 changes: 3 additions & 4 deletions src/edrn.collabgroups/src/edrn/collabgroups/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,19 @@ <h3>Project Scientist{{count|pluralize}}</h3>
{% endif %}
{% endwith %}

{% with count=page.co_chairs.all|length %}
{% if count %}
<h3>Co-Chair{{count|pluralize}}</h3>
<ul class='list-unstyled'>
{% for person in page.co_chairs.all %}
<li><a href='{{person.url}}'>{{person.title}}</a></li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}



{% if page.chair %}
<h3>Chair</h3>
<p><a href='{{page.chair.url}}'>{{page.chair.title}}</a></p>
{% endif %}
{% if page.co_chair %}
<h3 class='mt-2'>Co-Chair</h3>
<p><a href='{{page.co_chair.url}}'>{{page.co_chair.title}}</a></p>
Expand Down
9 changes: 4 additions & 5 deletions src/eke.knowledge/src/eke/knowledge/committees.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 87b3fff

Please sign in to comment.