Test if cv2parser module is present.

This commit is contained in:
Mikaël Ates 2015-01-13 16:40:09 +01:00
parent fce3e1e61d
commit 233fda5f43
3 changed files with 20 additions and 3 deletions

View File

@ -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<patientrecord_id>\d+)/protection/new$', 'new_protection'),
url(r'^(?P<patientrecord_id>\d+)/protection/(?P<pk>\d+)/update$', 'update_protection'),
url(r'^(?P<patientrecord_id>\d+)/protection/(?P<pk>\d+)/del$', 'delete_protection'),
url(r'^(?P<patientrecord_id>\d+)/read-cv2$', 'read_cv2'),
)
if settings.CV2PARSER:
cv2_read_url = patterns('calebasse.dossiers.views',
url(r'^(?P<patientrecord_id>\d+)/read-cv2$', 'read_cv2'),
)
urlpatterns += cv2_read_url

View File

@ -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

View File

@ -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'