From 3eeb6b5191355879b47c7db91ca3a750fc93e8e2 Mon Sep 17 00:00:00 2001 From: Ryunosuke O'Neil Date: Wed, 3 Dec 2025 11:57:10 +0100 Subject: [PATCH] feat: handle adding user AffiliationEnds section in the CS when modifying the user fix: follow more closely the rest of the code --- src/DIRAC/ConfigurationSystem/Client/CSAPI.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/DIRAC/ConfigurationSystem/Client/CSAPI.py b/src/DIRAC/ConfigurationSystem/Client/CSAPI.py index 6a1c4d7a366..94c8a85183e 100644 --- a/src/DIRAC/ConfigurationSystem/Client/CSAPI.py +++ b/src/DIRAC/ConfigurationSystem/Client/CSAPI.py @@ -456,13 +456,23 @@ def modifyUser(self, username, properties, createIfNonExistant=False): gLogger.error("User is not registered: ", repr(username)) return S_OK(False) for prop in properties: - if prop == "Groups": + if prop in ["Groups", "AffiliationEnds"]: continue prevVal = self.__csMod.getValue(f"{self.__baseSecurity}/Users/{username}/{prop}") if not prevVal or prevVal != properties[prop]: gLogger.info(f"Setting {prop} property for user {username} to {properties[prop]}") self.__csMod.setOptionValue(f"{self.__baseSecurity}/Users/{username}/{prop}", properties[prop]) modifiedUser = True + if properties.get("AffiliationEnds", None): + user_affiliationends_section = f"{self.__baseSecurity}/Users/{username}/AffiliationEnds" + # add the section for AffiliationEnds + res = gConfig.getSections(user_affiliationends_section) + if not res["OK"]: + self.__csMod.createSection(user_affiliationends_section) + # now set value VO = end date + for vo, end_date in properties["AffiliationEnds"].items(): + self.__csMod.setOptionValue(f"{user_affiliationends_section}/{vo}", end_date) + modifiedUser = True if "Groups" in properties: result = self.listGroups() if not result["OK"]: