Only change group membership if cert changes

This commit is contained in:
Tanner Collin 2020-09-15 19:52:09 +00:00
parent 440d389f16
commit ddb83a1b58

View File

@ -197,12 +197,16 @@ class AdminMemberSerializer(MemberSerializer):
def update(self, instance, validated_data):
if 'rabbit_cert_date' in validated_data:
changed = validated_data['rabbit_cert_date'] != instance.rabbit_cert_date
if changed:
if validated_data['rabbit_cert_date']:
utils_ldap.add_to_group(instance, 'Laser Users')
else:
utils_ldap.remove_from_group(instance, 'Laser Users')
if 'trotec_cert_date' in validated_data:
changed = validated_data['trotec_cert_date'] != instance.trotec_cert_date
if changed:
if validated_data['trotec_cert_date']:
utils_ldap.add_to_group(instance, 'Trotec Users')
else: