impression_hp: utilisation de lc_ldap
This commit is contained in:
parent
2993f31fd8
commit
746e5db7b8
2 changed files with 24 additions and 15 deletions
|
@ -990,6 +990,14 @@ class BaseClasseCrans(CransLdap):
|
||||||
retourne True s'il s'agit du même club/adhérent/machine, False sinon """
|
retourne True s'il s'agit du même club/adhérent/machine, False sinon """
|
||||||
return self.__class__ == autre.__class__ and self.id() == autre.id()
|
return self.__class__ == autre.__class__ and self.id() == autre.id()
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
"""Dummy"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def __exit__(self, type, value, traceback):
|
||||||
|
"""Dummy"""
|
||||||
|
pass
|
||||||
|
|
||||||
def id(self):
|
def id(self):
|
||||||
""" Retourne la valeur de l'attribut caractéristique de la classe (aid,mid,cid)"""
|
""" Retourne la valeur de l'attribut caractéristique de la classe (aid,mid,cid)"""
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -21,11 +21,13 @@ import math
|
||||||
if '/usr/scripts' not in sys.path:
|
if '/usr/scripts' not in sys.path:
|
||||||
sys.path.append('/usr/scripts')
|
sys.path.append('/usr/scripts')
|
||||||
|
|
||||||
from base import FichierInvalide, SoldeInsuffisant, PrintError, SettingsError
|
from base import FichierInvalide, PrintError, SettingsError
|
||||||
|
|
||||||
from gestion.config import impression as config_impression
|
from gestion.config import impression as config_impression
|
||||||
from subprocess import Popen, PIPE, check_output
|
from subprocess import Popen, PIPE, check_output
|
||||||
import livret
|
import livret
|
||||||
|
import lc_ldap.shortcuts
|
||||||
|
import lc_ldap.crans_utils as crans_utils
|
||||||
|
|
||||||
## Pour les codes qui se connectent direct à l'imprimante en http
|
## Pour les codes qui se connectent direct à l'imprimante en http
|
||||||
BASE_URL = 'https://imprimante.adm.crans.org'
|
BASE_URL = 'https://imprimante.adm.crans.org'
|
||||||
|
@ -357,15 +359,11 @@ class impression(object):
|
||||||
self._jid = self._uniq_jid()
|
self._jid = self._uniq_jid()
|
||||||
|
|
||||||
# debite l'adhérent si adherent il y a
|
# debite l'adhérent si adherent il y a
|
||||||
if not DEBUG and (self._adh != None):
|
if self._adh != None:
|
||||||
adh = self._adh.split('@')
|
adh = self._get_adh_write()
|
||||||
if len(adh) > 1:
|
|
||||||
adh = adh[1:]
|
|
||||||
adh = self._get_adh(adh[0])
|
|
||||||
self._calcule_prix() # Normalement inutile, mais évite les races
|
self._calcule_prix() # Normalement inutile, mais évite les races
|
||||||
if (self._prix > (adh.solde() - config_impression.decouvert)):
|
with adh:
|
||||||
raise SoldeInsuffisant
|
adh.solde(-self._prix, u"impression(%d): %s par %s" % (self._jid,self._fichier, self._adh))
|
||||||
adh.solde(-self._prix, "impression(%d): %s par %s" % (self._jid,self._fichier,self._adh))
|
|
||||||
adh.save()
|
adh.save()
|
||||||
del adh
|
del adh
|
||||||
# imprime le document
|
# imprime le document
|
||||||
|
@ -424,11 +422,14 @@ class impression(object):
|
||||||
self._prix = float(c_total)/100
|
self._prix = float(c_total)/100
|
||||||
return self._prix
|
return self._prix
|
||||||
|
|
||||||
def _get_adh(self, adh):
|
@lc_ldap.shortcuts.with_ldap_conn(retries=2, delay=5,
|
||||||
if type(adh) == str:
|
constructor=lc_ldap.shortcuts.lc_ldap_admin)
|
||||||
#from ldap_crans_test import crans_ldap
|
def _get_adh_write(self, ldap):
|
||||||
from gestion.ldap_crans import CransLdap
|
"""Récupère l'adhérent en lecture-écriture"""
|
||||||
adh = CransLdap().getProprio(adh, 'w')
|
uid = self._adh
|
||||||
|
if type(uid) in [str, unicode]:
|
||||||
|
uid = uid.split('@')[0]
|
||||||
|
adh = ldap.search(u'uid=%s' % crans_utils.escape(uid), mode='rw')[0]
|
||||||
return adh
|
return adh
|
||||||
|
|
||||||
## ################################# ##
|
## ################################# ##
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue