Update CNC-Precix-Users LDAP group based on certifications
This commit is contained in:
parent
18c8ab1ea9
commit
feff5914ff
|
@ -231,6 +231,14 @@ class AdminMemberSerializer(MemberSerializer):
|
||||||
]
|
]
|
||||||
|
|
||||||
def update(self, instance, validated_data):
|
def update(self, instance, validated_data):
|
||||||
|
if 'precix_cnc_cert_date' in validated_data:
|
||||||
|
changed = validated_data['precix_cnc_cert_date'] != instance.precix_cnc_cert_date
|
||||||
|
if changed:
|
||||||
|
if validated_data['precix_cnc_cert_date']:
|
||||||
|
utils_ldap.add_to_group(instance, 'CNC-Precix-Users')
|
||||||
|
else:
|
||||||
|
utils_ldap.remove_from_group(instance, 'CNC-Precix-Users')
|
||||||
|
|
||||||
if 'rabbit_cert_date' in validated_data:
|
if 'rabbit_cert_date' in validated_data:
|
||||||
changed = validated_data['rabbit_cert_date'] != instance.rabbit_cert_date
|
changed = validated_data['rabbit_cert_date'] != instance.rabbit_cert_date
|
||||||
if changed:
|
if changed:
|
||||||
|
|
|
@ -265,7 +265,11 @@ class TrainingViewSet(Base, Retrieve, Create, Update):
|
||||||
elif session.course.id == 428:
|
elif session.course.id == 428:
|
||||||
member.precix_cnc_cert_date = utils.today_alberta_tz() if status == 'Attended' else None
|
member.precix_cnc_cert_date = utils.today_alberta_tz() if status == 'Attended' else None
|
||||||
|
|
||||||
# TODO: change group membership
|
if utils_ldap.is_configured():
|
||||||
|
if status == 'Attended':
|
||||||
|
utils_ldap.add_to_group(member, 'CNC-Precix-Users')
|
||||||
|
else:
|
||||||
|
utils_ldap.remove_from_group(member, 'CNC-Precix-Users')
|
||||||
elif session.course.id == 247:
|
elif session.course.id == 247:
|
||||||
member.rabbit_cert_date = utils.today_alberta_tz() if status == 'Attended' else None
|
member.rabbit_cert_date = utils.today_alberta_tz() if status == 'Attended' else None
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user