Correctifs sur les adhésions glissantes.
This commit is contained in:
parent
7f1ffbeed5
commit
50f91c63e0
4 changed files with 32 additions and 27 deletions
20
attributs.py
20
attributs.py
|
@ -90,7 +90,7 @@ soi = u"soi"
|
|||
respo = u"responsable"
|
||||
|
||||
#: Liste de tous les droits
|
||||
TOUS_DROITS = [nounou, apprenti, bureau, tresorier, imprimeur, moderateur, multimachines, cableur, webmaster]
|
||||
TOUS_DROITS = [nounou, apprenti, bureau, tresorier, imprimeur, moderateur, multimachines, cableur, webmaster, webradio]
|
||||
#: Liste des droits forts
|
||||
DROITS_ELEVES = [nounou, bureau, tresorier]
|
||||
#: Liste des droits intérmédiaires
|
||||
|
@ -588,6 +588,12 @@ class generalizedTimeFormat(Attr):
|
|||
resource = generalizedTimeFormat(othertime, conn=None, Parent=None)
|
||||
return self._stamp < resource._stamp
|
||||
|
||||
def __le__(self, othertime):
|
||||
return not (self > othertime)
|
||||
|
||||
def __ge__(self, othertime):
|
||||
return not (self < othertime)
|
||||
|
||||
def __gt__(self, othertime):
|
||||
return not (self < othertime) and not (self == othertime)
|
||||
|
||||
|
@ -1337,18 +1343,10 @@ class homeDirectory(Attr):
|
|||
modifiables = list(modifiables)
|
||||
|
||||
for droit in self.parent.get('droits', []):
|
||||
if droit not in modifiables:
|
||||
if droit not in modifiables and droit in TOUS_DROITS:
|
||||
return False
|
||||
return super(homeDirectory, self).is_modifiable(liste_droits)
|
||||
|
||||
def parse_value(self, home):
|
||||
uid = unicode(self.parent['uid'][0])
|
||||
if uid.startswith(u'club-'):
|
||||
uid = uid.split('-', 1)[1]
|
||||
if home != u'/home/%s' % uid and home != u'/home/club/%s' % uid:
|
||||
raise ValueError("Le répertoire personnel n'est pas bon: %r (devrait être %r ou %r)" % (home, '/home/%s' % self.parent['uid'][0], '/home/club/%s' % self.parent['uid'][0]))
|
||||
self.value = home
|
||||
|
||||
@crans_attribute
|
||||
class loginShell(Attr):
|
||||
singlevalue = True
|
||||
|
@ -1539,6 +1537,7 @@ class modePaiement(Attr):
|
|||
category = 'factures'
|
||||
optional = False
|
||||
singlevalue = True
|
||||
can_modify = [cableur, nounou]
|
||||
ldap_name = "modePaiement"
|
||||
|
||||
def parse_value(self, mode):
|
||||
|
@ -1549,6 +1548,7 @@ class modePaiement(Attr):
|
|||
@crans_attribute
|
||||
class recuPaiement(Attr):
|
||||
ldap_name = "recuPaiement"
|
||||
can_modify = [cableur, nounou]
|
||||
|
||||
@crans_attribute
|
||||
class article(Attr):
|
||||
|
|
|
@ -309,9 +309,9 @@ def ip4_addresses():
|
|||
def extractTz(thetz):
|
||||
abstz = 100*abs(thetz)
|
||||
if thetz == 0:
|
||||
return "Z"
|
||||
return u"Z"
|
||||
else:
|
||||
return "%s%04d" % ("+"*(thetz < 0) + "-"*(thetz > 0), abstz)
|
||||
return u"%s%04d" % ("+"*(thetz < 0) + "-"*(thetz > 0), abstz)
|
||||
|
||||
def toGeneralizedTimeFormat(stamp):
|
||||
"""Converts a timestamp (local) in a generalized time format
|
||||
|
@ -322,7 +322,7 @@ def toGeneralizedTimeFormat(stamp):
|
|||
|
||||
"""
|
||||
|
||||
return "%s%s" % (time.strftime("%Y%m%d%H%M%S", time.localtime(stamp)), extractTz(time.altzone/3600))
|
||||
return u"%s%s" % (time.strftime("%Y%m%d%H%M%S", time.localtime(stamp)), extractTz(time.altzone/3600))
|
||||
|
||||
def fromGeneralizedTimeFormat(gtf):
|
||||
"""Converts a GTF stamp to unix timestamp
|
||||
|
|
23
objets.py
23
objets.py
|
@ -862,11 +862,11 @@ class proprio(CransLdapObject):
|
|||
|
||||
def fin_adhesion(self):
|
||||
"""Retourne la date de fin d'adhésion"""
|
||||
return max([float(facture.get('finAdhesion', [crans_utils.fromGeneralizedTimeFormat(attributs.finAdhesion.default)])[0]) for facture in self.factures() if facture.get('controle', [''])[0] != u"FALSE"] + [0.0])
|
||||
return max([float(facture.get('finAdhesion', [crans_utils.fromGeneralizedTimeFormat(attributs.finAdhesion.default)])[0]) for facture in self.factures(refresh=True, mode="ro") if facture.get('controle', [''])[0] != u"FALSE"] + [0.0])
|
||||
|
||||
def fin_connexion(self):
|
||||
"""Retourne la date de fin de connexion"""
|
||||
return max([float(facture.get('finConnexion', [crans_utils.fromGeneralizedTimeFormat(attributs.finConnexion.default)])[0]) for facture in self.factures() if facture.get('controle', [''])[0] != u"FALSE"] + [0.0])
|
||||
return max([float(facture.get('finConnexion', [crans_utils.fromGeneralizedTimeFormat(attributs.finConnexion.default)])[0]) for facture in self.factures(refresh=True, mode="ro") if facture.get('controle', [''])[0] != u"FALSE"] + [0.0])
|
||||
|
||||
def paiement_ok(self, no_bl=False):
|
||||
u"""
|
||||
|
@ -918,18 +918,23 @@ class proprio(CransLdapObject):
|
|||
self.history_add(login, u"%s %.2f Euros [%s]" % (transaction, abs(diff), comment))
|
||||
self["solde"] = new_solde
|
||||
|
||||
def machines(self, mode=None):
|
||||
def machines(self, mode=None, refresh=False):
|
||||
"""Renvoie la liste des machines"""
|
||||
if self._machines is None:
|
||||
if self._machines is None or refresh:
|
||||
self._machines = self.conn.search(u'mid=*', dn = self.dn, scope = 1, mode=self.mode if mode is None else mode)
|
||||
for m in self._machines:
|
||||
m._proprio = self
|
||||
return self._machines
|
||||
|
||||
def factures(self):
|
||||
def factures(self, refresh=False, mode=None):
|
||||
"""Renvoie la liste des factures"""
|
||||
if self._factures is None:
|
||||
self._factures = self.conn.search(u'fid=*', dn = self.dn, scope = 1, mode=self.mode)
|
||||
if mode is None:
|
||||
mode = self.mode
|
||||
if self._factures:
|
||||
if self._factures[0].mode != mode:
|
||||
refresh = True
|
||||
if self._factures is None or refresh:
|
||||
self._factures = self.conn.search(u'fid=*', dn = self.dn, scope = 1, mode=mode)
|
||||
for m in self._factures:
|
||||
m._proprio = self
|
||||
return self._factures
|
||||
|
@ -982,9 +987,9 @@ class machine(CransLdapObject):
|
|||
if domain in certificat['hostCert']:
|
||||
raise EnvironmentError("Vous devez d'abord supprimer ou éditer les certificats utilisant le nom de domaine %s avant de le retirer de la machine" % domain)
|
||||
|
||||
def proprio(self, mode=None):
|
||||
def proprio(self, mode=None, refresh=False):
|
||||
u"""Renvoie le propriétaire de la machine"""
|
||||
if not self._proprio:
|
||||
if not hasattr(self, '_proprio') or not self._proprio or refresh:
|
||||
self._proprio = new_cransldapobject(self.conn, self.parent_dn, self.mode if mode is None else mode)
|
||||
return self._proprio
|
||||
|
||||
|
|
|
@ -97,20 +97,20 @@ def template(dialog=False):
|
|||
import jinja2
|
||||
oldstyle = style
|
||||
oldtableau = tableau
|
||||
tableau = lambda *args,**kwargs: oldtableau(*args,dialog=dialog,**kwargs)
|
||||
style = lambda *args,**kwargs:oldstyle(*args,dialog=dialog,**kwargs)
|
||||
newTableau = lambda *args,**kwargs: oldtableau(*args,dialog=dialog,**kwargs)
|
||||
newStyle = lambda *args,**kwargs:oldstyle(*args,dialog=dialog,**kwargs)
|
||||
template_path = '/usr/scripts/lc_ldap/printing/templates/'
|
||||
templateLoader = jinja2.FileSystemLoader( searchpath=["/", template_path] )
|
||||
templateEnv = jinja2.Environment( loader=templateLoader, trim_blocks=True )
|
||||
templateEnv.add_extension('jinja2.ext.do')
|
||||
templateEnv.filters['coul'] = style
|
||||
templateEnv.filters['coul'] = newStyle
|
||||
templateEnv.filters['blacklists'] = blacklists
|
||||
templateEnv.filters['prise_etat'] = prise_etat
|
||||
templateEnv.filters['timeformat'] = timeformat
|
||||
templateEnv.filters['split'] = split
|
||||
templateEnv.filters['telephone'] = telephone
|
||||
templateEnv.filters['const_of_mac'] = const_of_mac
|
||||
templateEnv.filters['tableau'] = tableau
|
||||
templateEnv.filters['tableau'] = newTableau
|
||||
return templateEnv
|
||||
|
||||
def machine(machine, params):
|
||||
|
@ -201,7 +201,7 @@ def proprio(proprio, params):
|
|||
params["cetud"] = cetud
|
||||
params['etat_administratif']=etat_administratif
|
||||
if proprio["chbre"][0].value not in ["????", "EXT"]:
|
||||
params['brassage'] = style("Cr@ns", "bleu") if gestion.annuaires_pg.is_crans(proprio["chbre"][0].value[0], proprio["chbre"][0].value[1:]) else style("CROUS", "jaune")
|
||||
params['brassage'] = style("Cr@ns", "bleu")# if gestion.annuaires_pg.is_crans(proprio["chbre"][0].value[0], proprio["chbre"][0].value[1:]) else style("CROUS", "jaune")
|
||||
|
||||
try:
|
||||
if proprio.machines():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue