Projet

Général

Profil

Development #48372

doublon de permission, get() returned more than one Permission -- it returned 2

Ajouté par Frédéric Péters il y a plus de 3 ans. Mis à jour il y a plus de 3 ans.

Statut:
Fermé
Priorité:
Normal
Assigné à:
Catégorie:
-
Version cible:
-
Début:
06 novembre 2020
Echéance:
% réalisé:

0%

Temps estimé:
Patch proposed:
Oui
Planning:
Non

Description

File "/usr/lib/python3/dist-packages/authentic2/manager/views.py" in dispatch
  190.         return super(SearchFormMixin, self).dispatch(request, *args, **kwargs)

File "/usr/lib/python3/dist-packages/django/views/generic/base.py" in dispatch
  88.         return handler(request, *args, **kwargs)

File "/usr/lib/python3/dist-packages/django/views/generic/edit.py" in get
  174.         return self.render_to_response(self.get_context_data())

File "/usr/lib/python3/dist-packages/authentic2/manager/role_views.py" in get_context_data
  226.                                                self.object.get_admin_role().children(include_self=False,

File "/usr/lib/python3/dist-packages/authentic2/a2_rbac/models.py" in get_admin_role
  252.             operation=MANAGE_MEMBERS_OP)

File "/usr/lib/python3/dist-packages/authentic2/a2_rbac/managers.py" in get_admin_role
  60.                 **kwargs)

File "/usr/lib/python3/dist-packages/django/db/models/manager.py" in manager_method
  85.                 return getattr(self.get_queryset(), name)(*args, **kwargs)

File "/usr/lib/python3/dist-packages/django/db/models/query.py" in update_or_create
  480.                 obj = self.select_for_update().get(**lookup)

File "/usr/lib/python3/dist-packages/django/db/models/query.py" in get
  384.             (self.model._meta.object_name, num)

Exception Type: MultipleObjectsReturned at /manage/roles/6051/
Exception Value: get() returned more than one Permission -- it returned 2!

À inspecter,

>>> [x.__dict__ for x in Permission.objects.filter(target_id=role.pk)]

[{'_state': <django.db.models.base.ModelState object at 0x7ffb352d1748>, 'id': 10327, 'operation_id': 11, 'ou_id': 8, 'target_ct_id': 33, 'target_id': 6051}, {'_state': <django.db.models.base.ModelState object at 0x7ffb352d1f98>, 'id': 10343, 'operation_id': 11, 'ou_id': 1, 'target_ct_id': 33, 'target_id': 6051}]

Différence sur l'OU.


Fichiers

0003-misc-move-check-of-manager-s-roles-48372.patch (1012 octets) 0003-misc-move-check-of-manager-s-roles-48372.patch Benjamin Dauvergne, 01 décembre 2020 22:48
0004-misc-format-long-line-48372.patch (1,52 ko) 0004-misc-format-long-line-48372.patch Benjamin Dauvergne, 01 décembre 2020 22:48
0002-misc-does-not-check-global-email-uniqueness-48372.patch (1,07 ko) 0002-misc-does-not-check-global-email-uniqueness-48372.patch Benjamin Dauvergne, 01 décembre 2020 22:48
0006-misc-add-checks-and-repairs-on-admin-roles-permissio.patch (8,58 ko) 0006-misc-add-checks-and-repairs-on-admin-roles-permissio.patch Benjamin Dauvergne, 01 décembre 2020 22:48
0005-misc-fix-check-of-manager-s-roles-ou-48372.patch (1,44 ko) 0005-misc-fix-check-of-manager-s-roles-ou-48372.patch Benjamin Dauvergne, 01 décembre 2020 22:48
0001-misc-change-registration-of-check-and-repair-methods.patch (3,23 ko) 0001-misc-change-registration-of-check-and-repair-methods.patch Benjamin Dauvergne, 01 décembre 2020 22:48
0003-misc-move-check-of-manager-s-roles-48372.patch (1012 octets) 0003-misc-move-check-of-manager-s-roles-48372.patch Benjamin Dauvergne, 04 décembre 2020 17:56
0007-misc-remove-update_roles_admins-post_migrate-48372.patch (4,38 ko) 0007-misc-remove-update_roles_admins-post_migrate-48372.patch Benjamin Dauvergne, 04 décembre 2020 17:56
0004-misc-format-long-line-48372.patch (1,52 ko) 0004-misc-format-long-line-48372.patch Benjamin Dauvergne, 04 décembre 2020 17:56
0008-tests-update-test_check_and_repair_managers_of_roles.patch (2,87 ko) 0008-tests-update-test_check_and_repair_managers_of_roles.patch Benjamin Dauvergne, 04 décembre 2020 17:56
0002-misc-does-not-check-global-email-uniqueness-48372.patch (1,07 ko) 0002-misc-does-not-check-global-email-uniqueness-48372.patch Benjamin Dauvergne, 04 décembre 2020 17:56
0006-misc-add-checks-and-repairs-on-admin-roles-permissio.patch (8,58 ko) 0006-misc-add-checks-and-repairs-on-admin-roles-permissio.patch Benjamin Dauvergne, 04 décembre 2020 17:56
0005-misc-fix-check-of-manager-s-roles-ou-48372.patch (1,44 ko) 0005-misc-fix-check-of-manager-s-roles-ou-48372.patch Benjamin Dauvergne, 04 décembre 2020 17:56
0009-tests-update-test_check_identifiers_uniqueness-48372.patch (1,49 ko) 0009-tests-update-test_check_identifiers_uniqueness-48372.patch Benjamin Dauvergne, 04 décembre 2020 17:56
0001-misc-change-registration-of-check-and-repair-methods.patch (3,23 ko) 0001-misc-change-registration-of-check-and-repair-methods.patch Benjamin Dauvergne, 04 décembre 2020 17:56

Révisions associées

Révision 42b3ab4b (diff)
Ajouté par Benjamin Dauvergne il y a plus de 3 ans

misc: change registration of check-and-repair methods (#48372)

Révision 00d2f258 (diff)
Ajouté par Benjamin Dauvergne il y a plus de 3 ans

misc: does not check global email uniqueness (#48372)

Révision 09c7bd18 (diff)
Ajouté par Benjamin Dauvergne il y a plus de 3 ans

misc: move check of manager's roles (#48372)

Révision e7a64776 (diff)
Ajouté par Benjamin Dauvergne il y a plus de 3 ans

misc: format long line (#48372)

Révision c0c98c2d (diff)
Ajouté par Benjamin Dauvergne il y a plus de 3 ans

misc: fix check of manager's roles ou (#48372)

Révision bdb80f27 (diff)
Ajouté par Benjamin Dauvergne il y a plus de 3 ans

misc: add checks and repairs on admin roles permissions and ou (#48372)

Révision 95b45282 (diff)
Ajouté par Benjamin Dauvergne il y a plus de 3 ans

misc: remove update_roles_admins post_migrate (#48372)

Révision ea62c3f8 (diff)
Ajouté par Benjamin Dauvergne il y a plus de 3 ans

tests: update test_check_and_repair_managers_of_roles (#48372)

Historique

#2

Mis à jour par Frédéric Péters il y a plus de 3 ans

Localement corrigé via,

Permission.objects.filter(target_id=role.pk).exclude(ou=role.ou).delete()
#4

Mis à jour par Benjamin Dauvergne il y a plus de 3 ans

  • Assigné à mis à Benjamin Dauvergne
#16

Mis à jour par Valentin Deniaud il y a plus de 3 ans

  • Statut changé de Solution proposée à Solution validée

La mise à jour des tests de 0009 ne peut pas être mise dans son patch correspondant ? (0002 ?) et pareil pour 0008

0004, mettre la parenthèse fermante sur une nouvelle ligne

0006, ligne 296, pourquoi passer par une liste, et se priver d'un qs.exclude(pk=first_perm.pk).delete() derrière au lieu de la boucle for ?

ack de toute manière comme tout ça c'est de la forme.

#17

Mis à jour par Benjamin Dauvergne il y a plus de 3 ans

  • Statut changé de Solution validée à Résolu (à déployer)
commit ea62c3f8caf14a82568792383127f6e36ac7a7cf
Author: Benjamin Dauvergne <bdauvergne@entrouvert.com>
Date:   Fri Dec 4 17:45:01 2020 +0100

    tests: update test_check_and_repair_managers_of_roles (#48372)

commit 95b4528228cb504c69cd999adbf235542965e58f
Author: Benjamin Dauvergne <bdauvergne@entrouvert.com>
Date:   Tue Dec 1 22:50:30 2020 +0100

    misc: remove update_roles_admins post_migrate (#48372)

commit bdb80f27e8218f106fa030613f79f46f69679186
Author: Benjamin Dauvergne <bdauvergne@entrouvert.com>
Date:   Tue Dec 1 22:48:02 2020 +0100

    misc: add checks and repairs on admin roles permissions and ou (#48372)

commit c0c98c2da557402b48f4c5b0806550fce30517f2
Author: Benjamin Dauvergne <bdauvergne@entrouvert.com>
Date:   Tue Dec 1 22:47:07 2020 +0100

    misc: fix check of manager's roles ou (#48372)

commit e7a6477635013b933d8e82f7579785a8f8f7d4df
Author: Benjamin Dauvergne <bdauvergne@entrouvert.com>
Date:   Tue Dec 1 22:46:32 2020 +0100

    misc: format long line (#48372)

commit 09c7bd1882a7acdfc5597178045edb16ba380727
Author: Benjamin Dauvergne <bdauvergne@entrouvert.com>
Date:   Tue Dec 1 22:45:45 2020 +0100

    misc: move check of manager's roles (#48372)

commit 00d2f2584a746468bde21ac961961da28a80c1a3
Author: Benjamin Dauvergne <bdauvergne@entrouvert.com>
Date:   Tue Dec 1 22:45:24 2020 +0100

    misc: does not check global email uniqueness (#48372)

commit 42b3ab4b29a454c138d7caa80bb0079eb2a8887e
Author: Benjamin Dauvergne <bdauvergne@entrouvert.com>
Date:   Tue Dec 1 22:44:50 2020 +0100

    misc: change registration of check-and-repair methods (#48372)
#18

Mis à jour par Frédéric Péters il y a plus de 3 ans

  • Statut changé de Résolu (à déployer) à Solution déployée

Formats disponibles : Atom PDF