Commit 1aadba30 authored by Gabriel Detraz's avatar Gabriel Detraz
Browse files

Dirty fix des acl needed pour créer la facture

parent fe87e0a2
......@@ -25,6 +25,7 @@ from dateutil.relativedelta import relativedelta
from passlib.apps import ldap_context
import lc_ldap.crans_utils
from lc_ldap import shortcuts
from intranet import settings
from gestion.config import factures, cotisation
......@@ -49,10 +50,17 @@ class RedirectHomeMixin(object):
return super(RedirectHomeMixin, self).dispatch(request, uid=uid, next=next, ptype = ptype, *args, **kwargs)
def get_luser(request, uid, ptype, mode='ro'):
if ptype == 'adh':
return conn_pool.get_conn(request.user).search(u'aid=%s' % uid, mode=mode)[0]
elif ptype == 'club':
return conn_pool.get_conn(request.user).search(u'cid=%s' % uid, mode=mode)[0]
if ptype == 'adh':
return conn_pool.get_conn(request.user).search(u'aid=%s' % uid, mode=mode)[0]
elif ptype == 'club':
return conn_pool.get_conn(request.user).search(u'cid=%s' % uid, mode=mode)[0]
def get_admin_luser(request, uid, ptype, mode='ro'):
ldap = shortcuts.lc_ldap_admin()
if ptype == 'adh':
return ldap.search(u'aid=%s' % uid, mode=mode)[0]
elif ptype == 'club':
return ldap.search(u'cid=%s' % uid, mode=mode)[0]
class ClubView(CableurOrSelfMixin, View):
"""
......@@ -449,7 +457,7 @@ class AdhesionView(CableurOrSelfMixin, RedirectHomeMixin, View):
# On traite le post
form = AdhesionForm(request.POST, is_cableur=cablage)
luser = get_luser(request, uid, ptype, 'w')
luser = get_admin_luser(request, uid, ptype, 'w')
if form.is_valid():
#EN 2 etapes, on renvoie
if 'confirm' in request.POST.keys():
......@@ -486,7 +494,7 @@ class AdhesionView(CableurOrSelfMixin, RedirectHomeMixin, View):
messages.error(request, _(u"La réadhésion n'est possible que moins d'un mois avant l'expiration, merci de repasser"))
return redirect(next)
####### Ecriture de la facture ############
with conn_pool.get_conn(request.user).newFacture(luser.dn, fact) as facture:
with shortcuts.lc_ldap_admin().newFacture(luser.dn, fact) as facture:
try:
facture.adhesion_connexion()
except ValueError as e:
......@@ -501,7 +509,7 @@ class AdhesionView(CableurOrSelfMixin, RedirectHomeMixin, View):
fin_conn = unicode(facture['finConnexion'][0])
debut_conn = unicode(facture['debutConnexion'][0])
#Hack : on recharge l'objet ldap
luser = get_luser(request, uid, ptype, 'w')
luser = get_admin_luser(request, uid, ptype, 'w')
######## Mise à jour des attributs adhérent #########
# On met à jour les valeurs fin_adh et fin_conn de l'adhérent
with luser as adh:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment