diff --git a/calebasse/dossiers/urls.py b/calebasse/dossiers/urls.py index e2d91e27..b5a09a89 100644 --- a/calebasse/dossiers/urls.py +++ b/calebasse/dossiers/urls.py @@ -1,4 +1,5 @@ from django.conf.urls import patterns, url +from django.conf import settings urlpatterns = patterns('calebasse.dossiers.views', url(r'^$', 'patientrecord_home'), @@ -50,5 +51,10 @@ urlpatterns = patterns('calebasse.dossiers.views', url(r'^(?P\d+)/protection/new$', 'new_protection'), url(r'^(?P\d+)/protection/(?P\d+)/update$', 'update_protection'), url(r'^(?P\d+)/protection/(?P\d+)/del$', 'delete_protection'), - url(r'^(?P\d+)/read-cv2$', 'read_cv2'), ) + +if settings.CV2PARSER: + cv2_read_url = patterns('calebasse.dossiers.views', + url(r'^(?P\d+)/read-cv2$', 'read_cv2'), + ) + urlpatterns += cv2_read_url diff --git a/calebasse/dossiers/views.py b/calebasse/dossiers/views.py index 90b8b9bf..70f6e73a 100644 --- a/calebasse/dossiers/views.py +++ b/calebasse/dossiers/views.py @@ -38,6 +38,9 @@ from calebasse.decorators import validator_only from ..utils import get_service_setting, is_validator, get_last_file +if settings.CV2PARSER: + import cv2parser + class NewPatientRecordView(cbv.FormView, cbv.ServiceViewMixin): form_class = forms.NewPatientRecordForm template_name = 'dossiers/patientrecord_new.html' @@ -347,7 +350,7 @@ class PatientRecordAddrView(cbv.ServiceViewMixin, cbv.NotificationDisplayView, c ctx['nb_place_of_lifes'] = ctx['object'].addresses.filter(place_of_life=True).count() ctx['addresses'] = ctx['object'].addresses.order_by('-place_of_life', 'id') cv_files_path = get_service_setting('cv_files_path') - if is_validator(self.request.user) and cv_files_path and os.path.isdir(cv_files_path): + if settings.CV2PARSER and is_validator(self.request.user) and cv_files_path and os.path.isdir(cv_files_path): ctx['cv2_reading'] = True return ctx @@ -373,7 +376,8 @@ class ReadCV2View(cbv.FormView): ctx['carte_vitale'] = filename return ctx -read_cv2 = validator_only(ReadCV2View.as_view()) +if settings.CV2PARSER: + read_cv2 = validator_only(ReadCV2View.as_view()) class PatientRecordNotifsView(cbv.DetailView): model = PatientRecord diff --git a/calebasse/settings.py b/calebasse/settings.py index 4f87565d..e790d361 100644 --- a/calebasse/settings.py +++ b/calebasse/settings.py @@ -308,6 +308,13 @@ SERVICE_SETTINGS = {} # - cv_files_path : Set a path where xml files of CV2 cards are read # (activate CV2 reading btw). +CV2PARSER = False +try: + import cv2parser + CV2PARSER = True +except: + pass + # Pdftk binary path (pdftk is used to complete CERFA) PDFTK_PATH = '/usr/bin/pdftk'