From 5268ea4f135244de7ee285fb17fe062f82efd216 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 25 Oct 2021 15:49:56 +0200 Subject: [PATCH] =?UTF-8?q?Detecte=20et=20supprime=20doublons=20dans=20les?= =?UTF-8?q?=20pr=C3=A9f=C3=A9rences?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_preferences.py | 11 +++++++++-- sco_version.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/scodoc/sco_preferences.py b/app/scodoc/sco_preferences.py index 2935bdb3a..92b00a67d 100644 --- a/app/scodoc/sco_preferences.py +++ b/app/scodoc/sco_preferences.py @@ -1949,6 +1949,15 @@ class BasePreferences(object): "name": name, }, ) + if len(pdb) > 1: + # suppress buggy duplicates (may come from corrupted database for ice ages) + log( + f"**oups** detected duplicated preference !\n({self.dept_id}, {formsemestre_id}, {name}, {value})" + ) + for obj in pdb[1:]: + self._editor.delete(cnx, obj["id"]) + pdb = [pdb[0]] + if not pdb: # crée préférence log("create pref sem=%s %s=%s" % (formsemestre_id, name, value)) @@ -1962,10 +1971,8 @@ class BasePreferences(object): }, ) modif = True - log("create pref sem=%s %s=%s" % (formsemestre_id, name, value)) else: # edit existing value - existing_value = pdb[0]["value"] # old stored value if ( (existing_value != value) diff --git a/sco_version.py b/sco_version.py index b464e1d19..120cecdf3 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.0.55" +SCOVERSION = "9.0.56" SCONAME = "ScoDoc"