Project

General

Profile

Bug #48615

Crash à l'import si des Exceptions similiaires sont positionnées sur un guichet

Added by Emmanuel Cazenave 18 days ago. Updated 11 days ago.

Status:
Solution proposée
Priority:
Normal
Category:
-
Target version:
-
Start date:
17 Nov 2020
Due date:
% Done:

0%

Estimated time:
Patch proposed:
Yes
Planning:
No

Description

Genre quelqu'un qui aurait mis un jour un agenda par un import avant #48095, il aura dupliqué sans le savoir des exceptions, et aujourd'hui nouvelle mise a jour via un import, crash.

Traceback:

File "/home/cazino/envs/publik-env-py3/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/home/cazino/envs/publik-env-py3/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/home/cazino/envs/publik-env-py3/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/cazino/envs/publik-env-py3/lib/python3.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  23.                 return view_func(request, *args, **kwargs)

File "/home/cazino/envs/publik-env-py3/lib/python3.7/site-packages/django/views/generic/base.py" in view
  68.             return self.dispatch(request, *args, **kwargs)

File "/home/cazino/src/chrono/chrono/manager/views.py" in dispatch
  603.         return super(AgendasImportView, self).dispatch(request, *args, **kwargs)

File "/home/cazino/envs/publik-env-py3/lib/python3.7/site-packages/django/views/generic/base.py" in dispatch
  88.         return handler(request, *args, **kwargs)

File "/home/cazino/envs/publik-env-py3/lib/python3.7/site-packages/django/views/generic/edit.py" in post
  183.             return self.form_valid(form)

File "/home/cazino/src/chrono/chrono/manager/views.py" in form_valid
  613.             results = import_site(agendas_json, overwrite=False)

File "/home/cazino/src/chrono/chrono/manager/utils.py" in import_site
  69.                 created = cls.import_json(data, overwrite=overwrite)

File "/home/cazino/src/chrono/chrono/agendas/models.py" in import_json
  380.                 Desk.import_json(desk)

File "/home/cazino/src/chrono/chrono/agendas/models.py" in import_json
  1157.             TimePeriodException.import_json(exception)

File "/home/cazino/src/chrono/chrono/agendas/models.py" in import_json
  1682.             exception, _ = cls.objects.update_or_create(defaults=data, **query_data)

File "/home/cazino/envs/publik-env-py3/lib/python3.7/site-packages/django/db/models/manager.py" in manager_method
  85.                 return getattr(self.get_queryset(), name)(*args, **kwargs)

File "/home/cazino/envs/publik-env-py3/lib/python3.7/site-packages/django/db/models/query.py" in update_or_create
  480.                 obj = self.select_for_update().get(**lookup)

File "/home/cazino/envs/publik-env-py3/lib/python3.7/site-packages/django/db/models/query.py" in get
  384.             (self.model._meta.object_name, num)

Exception Type: MultipleObjectsReturned at /manage/agendas/import/
Exception Value: get() returned more than one TimePeriodException -- it returned 3!

Files

History

#1

Updated by Emmanuel Cazenave 18 days ago

  • Subject changed from Crash à l'import sur des Excrptions similiaires sont positionnées sur un guichet to Crash à l'import si des Exceptions similiaires sont positionnées sur un guichet
#2

Updated by Lauréline Guerin 12 days ago

  • Assignee set to Lauréline Guerin

On pourrait, dans le cas où on a une MultipleObjectsReturned, au choix:
- updater toutes les exceptions qui matchent (label, start_datetime, end_datetime, recurrence_id)
- supprimer toutes les exceptions qui matchent et n'en recréer qu'une seule

Manu tu en penses quoi ?

#3

Updated by Emmanuel Cazenave 12 days ago

Supprimer ça fait quand même un peu peur dès fois qu'on se loupe, tout mettre à jour ça me parait pas mal.

#4

Updated by Lauréline Guerin 12 days ago

Also available in: Atom PDF