35 lines
890 B
Python
35 lines
890 B
Python
import re
|
|
|
|
import requests
|
|
from django import template
|
|
|
|
from wcs.qommon import misc
|
|
from wcs.qommon.templatetags.qommon import unlazy
|
|
|
|
register = template.Library()
|
|
|
|
|
|
@register.filter
|
|
def is_valid_belgian_nrn(value):
|
|
return misc.validate_belgian_nrn(unlazy(value))
|
|
|
|
|
|
@register.filter
|
|
def is_strong_authentication(session_user):
|
|
return bool('_niss' in session_user.verified_fields)
|
|
|
|
|
|
@ register.filter
|
|
def liste_type_rdv_plusieurs_personnes(value):
|
|
headers = {'Accept': 'application/json'}
|
|
liste = requests.get(value, headers=headers).json()
|
|
return list(set([re.sub(r" (pour|-) [0-9]+ personne(s)?$", "", x["text"]) for x in liste["data"]]))
|
|
|
|
|
|
@register.filter
|
|
def liste_type_rdv_nombres_personnes(value, arg):
|
|
headers = {'Accept': 'application/json'}
|
|
liste = requests.get(value, headers=headers).json()
|
|
|
|
return [x for x in liste["data"] if arg in x["text"]]
|