Commit 4faed28164db51126484248859208f4a0b7994ea

Authored by Alexis Koralewski
1 parent bce6ef19
Exists in dev

Catch integretyerror (sequence name unique) when submitting seq file

CHANGELOG
1   -05-12-2022 (AKo): v0.6.15.2
  1 +08-12-2022 (AKo): v0.6.15.3
  2 + - Catch integretyerror (sequence name unique) when submitting seq file
  3 +
  4 +07-12-2022 (AKo): v0.6.15.2
2 5 - Improve api send sequence file (no longer reading file to transform it into json), act like the website
3 6 - Fix dockercompose to change ports
4 7  
... ...
VERSION
1   -0.6.15.2
2 1 \ No newline at end of file
  2 +0.6.15.3
3 3 \ No newline at end of file
... ...
src/core/pyros_django/routine_manager/functions.py
... ... @@ -7,7 +7,7 @@ import os, yaml
7 7 from user_manager.models import PyrosUser, ScientificProgram, Period
8 8 from routine_manager.models import Sequence, Album, Plan
9 9 from .forms import SequenceForm, PlanForm #, AlbumForm
10   -
  10 +from django.db import IntegrityError
11 11 # Project imports
12 12 from src.core.pyros_django.obsconfig.obsconfig_class import OBSConfig
13 13  
... ... @@ -166,7 +166,10 @@ def check_sequence_file_validity_and_save(yaml_content,request):
166 166 if Period.objects.next_period() != None and Period.objects.next_period().start_date < seq.start_date.date():
167 167 period = Period.objects.next_period()
168 168 seq.period = period
169   - seq.save()
  169 + try:
  170 + seq.save()
  171 + except IntegrityError as e:
  172 + result["errors"].append(str(e))
170 173 if len(result["errors"]) != 0:
171 174 result["succeed"] = False
172 175 seq.delete()
... ...