[Scodoc-devel] [SVN] Scolar : [1554] Evite erreur bloquante si date incorrecte debut/ fin de semestre

eviennet at lipn.univ-paris13.fr eviennet at lipn.univ-paris13.fr
Ven 2 Sep 22:39:39 CEST 2016


Une pièce jointe HTML a été nettoyée...
URL: <https://www-rt.iutv.univ-paris13.fr/pipermail/scodoc-devel/attachments/20160902/ab87c2d0/attachment-0001.html>
-------------- section suivante --------------
Modified: branches/ScoDoc7/ZAbsences.py
===================================================================
--- branches/ScoDoc7/ZAbsences.py	2016-09-02 20:29:04 UTC (rev 1553)
+++ branches/ScoDoc7/ZAbsences.py	2016-09-02 20:39:39 UTC (rev 1554)
@@ -114,16 +114,16 @@
         # accept years YYYY or YY, uses 1970 as pivot
         if self.year < 1970:
             if self.year > 100:
-                raise ScoValueError('Année invalide: %s' % self.year)
+                raise ScoInvalidDateError('Année invalide: %s' % self.year)
             if self.year < 70:
                 self.year = self.year + 2000
             else:
                 self.year = self.year + 1900
         if self.month < 1 or self.month > 12:
-            raise ScoValueError('Mois invalide: %s' % self.month)
+            raise ScoInvalidDateError('Mois invalide: %s' % self.month)
         
         if self.day < 1 or self.day > MonthNbDays(self.month,self.year):
-            raise ScoValueError('Jour invalide: %s' % self.day)
+            raise ScoInvalidDateError('Jour invalide: %s' % self.day)
         
         # weekday in 0-6, where 0 is monday
         self.weekday = calendar.weekday(self.year,self.month,self.day)

Modified: branches/ScoDoc7/ZScolar.py
===================================================================
--- branches/ScoDoc7/ZScolar.py	2016-09-02 20:29:04 UTC (rev 1553)
+++ branches/ScoDoc7/ZScolar.py	2016-09-02 20:39:39 UTC (rev 1554)
@@ -500,27 +500,30 @@
         formsemestre_id = sem['formsemestre_id']
         
         # calcule dates 1er jour semaine pour absences
-        if with_absences:
-            first_monday = ZAbsences.ddmmyyyy(sem['date_debut']).prev_monday()
-            FA = [] # formulaire avec menu saisi absences
-            FA.append('<td><form action="Absences/SignaleAbsenceGrSemestre" method="get">')
-            FA.append('<input type="hidden" name="datefin" value="%(date_fin)s"/>'
-                             % sem )
-            FA.append('<input type="hidden" name="group_ids" value="%(group_id)s"/>')
+        try:
+            if with_absences:
+                first_monday = ZAbsences.ddmmyyyy(sem['date_debut']).prev_monday()
+                FA = [] # formulaire avec menu saisi absences
+                FA.append('<td><form action="Absences/SignaleAbsenceGrSemestre" method="get">')
+                FA.append('<input type="hidden" name="datefin" value="%(date_fin)s"/>'
+                                 % sem )
+                FA.append('<input type="hidden" name="group_ids" value="%(group_id)s"/>')
 
-            FA.append('<input type="hidden" name="destination" value="%s"/>'
-                      % destination)
-            FA.append('<input type="submit" value="Saisir absences du" />')
-            FA.append('<select name="datedebut" class="noprint">')
-            date = first_monday
-            for jour in self.Absences.day_names():
-                FA.append('<option value="%s">%s</option>' % (date, jour) )
-                date = date.next()
-            FA.append('</select>')
-            FA.append('<a href="Absences/EtatAbsencesGr?group_ids=%%(group_id)s&debut=%(date_debut)s&fin=%(date_fin)s">état</a>' % sem )
-            FA.append('</form></td>')
-            FormAbs = '\n'.join(FA)
-        else:
+                FA.append('<input type="hidden" name="destination" value="%s"/>'
+                          % destination)
+                FA.append('<input type="submit" value="Saisir absences du" />')
+                FA.append('<select name="datedebut" class="noprint">')
+                date = first_monday
+                for jour in self.Absences.day_names():
+                    FA.append('<option value="%s">%s</option>' % (date, jour) )
+                    date = date.next()
+                FA.append('</select>')
+                FA.append('<a href="Absences/EtatAbsencesGr?group_ids=%%(group_id)s&debut=%(date_debut)s&fin=%(date_fin)s">état</a>' % sem )
+                FA.append('</form></td>')
+                FormAbs = '\n'.join(FA)
+            else:
+                FormAbs = ''
+        except ScoInvalidDateError: # dates incorrectes dans semestres ?
             FormAbs = ''
         #
         H.append('<div id="grouplists">')

Modified: branches/ScoDoc7/sco_exceptions.py
===================================================================
--- branches/ScoDoc7/sco_exceptions.py	2016-09-02 20:29:04 UTC (rev 1553)
+++ branches/ScoDoc7/sco_exceptions.py	2016-09-02 20:39:39 UTC (rev 1554)
@@ -67,3 +67,6 @@
     "exception avec affichage d'une page explicative ad-hoc"
     def __init__(self, msg='', REQUEST=None):
         ScoException.__init__(self,msg)
+
+class ScoInvalidDateError(ScoValueError):
+    pass


Plus d'informations sur la liste de diffusion Scodoc-devel