From 093d51876ef07c5c52e50270d8118f1d77bd4d56 Mon Sep 17 00:00:00 2001
From: Carlos Vega <carlos.vega@uni.lu>
Date: Wed, 21 Nov 2018 14:30:17 +0100
Subject: [PATCH] To avoid the following error:

======================================================================
ERROR: web.tests.test_holidays (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
ImportError: Failed to import test module: web.tests.test_holidays
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 254, in _find_tests
    module = self._get_module_from_name(name)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 232, in _get_module_from_name
    __import__(name)
  File "/Users/carlos.vega/dev/scheduling-system/smash/web/tests/test_holidays.py", line 3, in <module>
    from web.management.commands.holidays import get_easter_sunday_date, get_ascension_day, get_pentecost_day
  File "/Users/carlos.vega/dev/scheduling-system/smash/web/management/commands/holidays.py", line 7, in <module>
    appointment_type_other = AppointmentType.objects.filter(code='OTHER').first()
  File "/Users/carlos.vega/dev/scheduling-system/env/lib/python2.7/site-packages/django/db/models/query.py", line 564, in first
    objects = list((self if self.ordered else self.order_by('pk'))[:1])
  File "/Users/carlos.vega/dev/scheduling-system/env/lib/python2.7/site-packages/django/db/models/query.py", line 250, in __iter__
    self._fetch_all()
  File "/Users/carlos.vega/dev/scheduling-system/env/lib/python2.7/site-packages/django/db/models/query.py", line 1118, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/Users/carlos.vega/dev/scheduling-system/env/lib/python2.7/site-packages/django/db/models/query.py", line 53, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
  File "/Users/carlos.vega/dev/scheduling-system/env/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 894, in execute_sql
    raise original_exception
ProgrammingError: relation "web_appointmenttype" does not exist
LINE 1: ...ed", "web_appointmenttype"."required_worker" FROM "web_appoi...
---
 smash/web/management/commands/holidays.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/smash/web/management/commands/holidays.py b/smash/web/management/commands/holidays.py
index 7c01d080..6206b760 100644
--- a/smash/web/management/commands/holidays.py
+++ b/smash/web/management/commands/holidays.py
@@ -4,9 +4,6 @@ from django.core.management.base import BaseCommand
 
 from ...models import Appointment, Location, AppointmentType, AppointmentTypeLink
 
-appointment_type_other = AppointmentType.objects.filter(code='OTHER').first()
-
-
 def get_easter_monday(easter_sunday):
     return next_weekday(easter_sunday, 0)
 
@@ -64,6 +61,7 @@ class Command(BaseCommand):
         holiday.comment = comment
         holiday.visit_id = None
         holiday.save()
+        appointment_type_other = AppointmentType.objects.filter(code='OTHER').first()
         link = AppointmentTypeLink(appointment=holiday, appointment_type=appointment_type_other)
         link.save()
 
-- 
GitLab