From 6ad312e29c1c11c2e948586da976a47d42e1d86e Mon Sep 17 00:00:00 2001 From: mcarloni Date: Wed, 24 Jul 2024 14:03:32 -0400 Subject: [PATCH] update import config logic --- roundabout/ooi_ci_tools/forms.py | 2 +- roundabout/ooi_ci_tools/views.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/roundabout/ooi_ci_tools/forms.py b/roundabout/ooi_ci_tools/forms.py index dee42054..2ff4c0b1 100644 --- a/roundabout/ooi_ci_tools/forms.py +++ b/roundabout/ooi_ci_tools/forms.py @@ -860,7 +860,7 @@ def validate_cal_files(csv_files,ext_files): try: import_config = ImportConfig.objects.get(id=1) except ImportConfig.DoesNotExist: - import_config = None + import_config = ImportConfig.objects.create(id=1) for cal_csv in csv_files: counter += 1 cal_csv_filename = cal_csv.name[:-4] diff --git a/roundabout/ooi_ci_tools/views.py b/roundabout/ooi_ci_tools/views.py index 5a30b6f9..cfc8094b 100644 --- a/roundabout/ooi_ci_tools/views.py +++ b/roundabout/ooi_ci_tools/views.py @@ -255,9 +255,12 @@ class ImportConfigUpdate(LoginRequiredMixin, AjaxFormMixin, UpdateView): def get(self, request, *args, **kwargs): if ImportConfig.objects.exists(): - self.object = self.get_object() + try: + self.object = ImportConfig.objects.get(id=1) + except: + self.object = ImportConfig.objects.create(id=1) else: - self.object = ImportConfig.objects.create() + self.object = ImportConfig.objects.create(id=1) form_class = self.get_form_class() form = self.get_form(form_class) return self.render_to_response(