Only change group membership if cert changes
This commit is contained in:
parent
440d389f16
commit
ddb83a1b58
|
@ -197,16 +197,20 @@ class AdminMemberSerializer(MemberSerializer):
|
||||||
|
|
||||||
def update(self, instance, validated_data):
|
def update(self, instance, validated_data):
|
||||||
if 'rabbit_cert_date' in validated_data:
|
if 'rabbit_cert_date' in validated_data:
|
||||||
if validated_data['rabbit_cert_date']:
|
changed = validated_data['rabbit_cert_date'] != instance.rabbit_cert_date
|
||||||
utils_ldap.add_to_group(instance, 'Laser Users')
|
if changed:
|
||||||
else:
|
if validated_data['rabbit_cert_date']:
|
||||||
utils_ldap.remove_from_group(instance, 'Laser Users')
|
utils_ldap.add_to_group(instance, 'Laser Users')
|
||||||
|
else:
|
||||||
|
utils_ldap.remove_from_group(instance, 'Laser Users')
|
||||||
|
|
||||||
if 'trotec_cert_date' in validated_data:
|
if 'trotec_cert_date' in validated_data:
|
||||||
if validated_data['trotec_cert_date']:
|
changed = validated_data['trotec_cert_date'] != instance.trotec_cert_date
|
||||||
utils_ldap.add_to_group(instance, 'Trotec Users')
|
if changed:
|
||||||
else:
|
if validated_data['trotec_cert_date']:
|
||||||
utils_ldap.remove_from_group(instance, 'Trotec Users')
|
utils_ldap.add_to_group(instance, 'Trotec Users')
|
||||||
|
else:
|
||||||
|
utils_ldap.remove_from_group(instance, 'Trotec Users')
|
||||||
|
|
||||||
return super().update(instance, validated_data)
|
return super().update(instance, validated_data)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user