Projet

Général

Profil

« Précédent | Suivant » 

Révision 233fda5f

Ajouté par Mikaël Ates il y a plus de 9 ans

Test if cv2parser module is present.

Voir les différences:

calebasse/dossiers/urls.py
1 1
from django.conf.urls import patterns, url
2
from django.conf import settings
2 3

  
3 4
urlpatterns = patterns('calebasse.dossiers.views',
4 5
        url(r'^$', 'patientrecord_home'),
......
50 51
        url(r'^(?P<patientrecord_id>\d+)/protection/new$', 'new_protection'),
51 52
        url(r'^(?P<patientrecord_id>\d+)/protection/(?P<pk>\d+)/update$', 'update_protection'),
52 53
        url(r'^(?P<patientrecord_id>\d+)/protection/(?P<pk>\d+)/del$', 'delete_protection'),
53
        url(r'^(?P<patientrecord_id>\d+)/read-cv2$', 'read_cv2'),
54 54
        )
55

  
56
if settings.CV2PARSER:
57
    cv2_read_url = patterns('calebasse.dossiers.views',
58
            url(r'^(?P<patientrecord_id>\d+)/read-cv2$', 'read_cv2'),
59
            )
60
    urlpatterns += cv2_read_url
calebasse/dossiers/views.py
38 38

  
39 39
from ..utils import get_service_setting, is_validator, get_last_file
40 40

  
41
if settings.CV2PARSER:
42
    import cv2parser
43

  
41 44
class NewPatientRecordView(cbv.FormView, cbv.ServiceViewMixin):
42 45
    form_class = forms.NewPatientRecordForm
43 46
    template_name = 'dossiers/patientrecord_new.html'
......
347 350
        ctx['nb_place_of_lifes'] = ctx['object'].addresses.filter(place_of_life=True).count()
348 351
        ctx['addresses'] = ctx['object'].addresses.order_by('-place_of_life', 'id')
349 352
        cv_files_path = get_service_setting('cv_files_path')
350
        if is_validator(self.request.user) and cv_files_path and os.path.isdir(cv_files_path):
353
        if settings.CV2PARSER and is_validator(self.request.user) and cv_files_path and os.path.isdir(cv_files_path):
351 354
            ctx['cv2_reading'] = True
352 355
        return ctx
353 356

  
......
373 376
        ctx['carte_vitale'] = filename
374 377
        return ctx
375 378

  
376
read_cv2 = validator_only(ReadCV2View.as_view())
379
if settings.CV2PARSER:
380
    read_cv2 = validator_only(ReadCV2View.as_view())
377 381

  
378 382
class PatientRecordNotifsView(cbv.DetailView):
379 383
    model = PatientRecord
calebasse/settings.py
308 308
# - cv_files_path : Set a path where xml files of CV2 cards are read
309 309
#   (activate CV2 reading btw).
310 310

  
311
CV2PARSER = False
312
try:
313
    import cv2parser
314
    CV2PARSER = True
315
except:
316
    pass
317

  
311 318
# Pdftk binary path (pdftk is used to complete CERFA)
312 319
PDFTK_PATH = '/usr/bin/pdftk'
313 320

  

Formats disponibles : Unified diff