1
0
forked from ScoDoc/ScoDoc

Detecte et supprime doublons dans les préférences

This commit is contained in:
Emmanuel Viennet 2021-10-25 15:49:56 +02:00
parent 66d443944a
commit 5268ea4f13
2 changed files with 10 additions and 3 deletions

View File

@ -1949,6 +1949,15 @@ class BasePreferences(object):
"name": name, "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: if not pdb:
# crée préférence # crée préférence
log("create pref sem=%s %s=%s" % (formsemestre_id, name, value)) log("create pref sem=%s %s=%s" % (formsemestre_id, name, value))
@ -1962,10 +1971,8 @@ class BasePreferences(object):
}, },
) )
modif = True modif = True
log("create pref sem=%s %s=%s" % (formsemestre_id, name, value))
else: else:
# edit existing value # edit existing value
existing_value = pdb[0]["value"] # old stored value existing_value = pdb[0]["value"] # old stored value
if ( if (
(existing_value != value) (existing_value != value)

View File

@ -1,7 +1,7 @@
# -*- mode: python -*- # -*- mode: python -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
SCOVERSION = "9.0.55" SCOVERSION = "9.0.56"
SCONAME = "ScoDoc" SCONAME = "ScoDoc"