From ba3898f26d894fbe3aa1f6c054cf15fb151a5a38 Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Fri, 11 Oct 2013 18:46:26 +0200 Subject: [PATCH] =?UTF-8?q?[attributs,=20objets,=20lc=5Fldap]=20Cr=C3=A9at?= =?UTF-8?q?ion=20de=20factures?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- attributs.py | 4 ++++ lc_ldap.py | 11 +++++++++-- objets.py | 3 ++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/attributs.py b/attributs.py index 6b9f74c..0344e81 100644 --- a/attributs.py +++ b/attributs.py @@ -1225,6 +1225,10 @@ class modePaiement(Attr): class recuPaiement(Attr): ldap_name = "recuPaiement" +@crans_attribute +class article(Attr): + ldap_name = "article" + @crans_attribute class dnsIpv6(boolAttr): ldap_name = "dnsIpv6" diff --git a/lc_ldap.py b/lc_ldap.py index eeed8b4..f381278 100644 --- a/lc_ldap.py +++ b/lc_ldap.py @@ -295,11 +295,18 @@ class lc_ldap(ldap.ldapobject.LDAPObject, object): else: raise EnvironmentError("Vous n'avez pas le droit de créer cet adhérent.") - def newFacture(self, fldif): + def newFacture(self, parent, fldif): """Crée une nouvelle facture --Non implémenté !""" uldif = copy.deepcopy(fldif) - raise NotImplementedError() + # fid + uldif['fid'] = [ unicode(self._find_id('fid')) ] + uldif['objectClass'] = [u'facture'] + facture = self._create_entity('fid=%s,%s' % (uldif['fid'][0], parent), uldif) + if facture.may_be(variables.created, self.droits + self._check_parent(facture.dn)): + return facture + else: + raise EnvironmentError("Vous n'avez pas le droit de créer cette facture.") def _create_entity(self, dn, uldif): '''Crée une nouvelle entité ldap avec le dn ``dn`` et les diff --git a/objets.py b/objets.py index d513515..784ebd8 100644 --- a/objets.py +++ b/objets.py @@ -930,7 +930,8 @@ class facture(CransLdapObject): variables.modified: [attributs.nounou, attributs.bureau, attributs.cableur], variables.deleted: [attributs.nounou, attributs.bureau, attributs.cableur], } - attribs = [attributs.fid, attributs.modePaiement, attributs.recuPaiement] + attribs = [attributs.fid, attributs.modePaiement, attributs.recuPaiement, + attributs.historique, attributs.article] ldap_name = "facture" @crans_object