Compare commits
No commits in common. "6d4326e30c1aea29d847c7d048240ebd2fffbc2e" and "159ff9bcf728bedd3d87ed079eb60aa7b655a008" have entirely different histories.
6d4326e30c
...
159ff9bcf7
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,5 +4,3 @@ __pycache__/
|
||||
cache/
|
||||
push_to_server.sh
|
||||
log.json
|
||||
venv
|
||||
venv/*
|
||||
|
11
app.py
11
app.py
@ -16,7 +16,6 @@ import datetime as dti
|
||||
import pytz
|
||||
import json
|
||||
import os
|
||||
import traceback
|
||||
|
||||
from flask import Flask
|
||||
from flask import render_template
|
||||
@ -189,9 +188,6 @@ def free_rooms(api = False, rq = None) :
|
||||
else :
|
||||
date_uf = date_uf.split("-")
|
||||
|
||||
if date_uf != [""] and not (date_tools.check_date(date_uf)) :
|
||||
return render_template("error.html", error="Date incorrecte !")
|
||||
|
||||
time_uf = str(rq.args.get("time"))
|
||||
time_uf_sav = time_uf
|
||||
if time_uf == "None" :
|
||||
@ -199,9 +195,6 @@ def free_rooms(api = False, rq = None) :
|
||||
else :
|
||||
time_uf = time_uf.split(":")
|
||||
|
||||
if time_uf != [""] and not (date_tools.check_time(time_uf)) :
|
||||
return render_template("error.html", error="Heure incorrecte !")
|
||||
|
||||
|
||||
date = dti.datetime.now()
|
||||
|
||||
@ -250,11 +243,7 @@ def free_rooms(api = False, rq = None) :
|
||||
|
||||
ignore_list = ["salle non définie", "salle en Distanciel"]
|
||||
|
||||
try :
|
||||
free_rooms = ro.getrooms(date, depts, ignore_list)
|
||||
except ValueError as err :
|
||||
return render_template("error.html", error="Le serveur Unistra a rencontré une erreur ! Veuillez réessayer plus tard.")
|
||||
#return render_template("error.html", error="Le serveur Unistra a rencontré une erreur ! Détails de l'erreur : " + str(''.join(traceback.format_exception(None, err, err.__traceback__))))
|
||||
|
||||
# Création d'un dictionnaire avec les infos des salles :
|
||||
frooms_disp = dict() # Mise en forme des infos pour la page Web
|
||||
|
@ -176,79 +176,3 @@ def remain_time(date, rdate) :
|
||||
remain_time_str += " " + str(deltasec[1]) + " minutes"
|
||||
|
||||
return remain_time_str
|
||||
|
||||
def check_date(date) :
|
||||
"""
|
||||
Vérifie que la date est correcte.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
date : list
|
||||
Date à vérifier.
|
||||
|
||||
Returns
|
||||
-------
|
||||
bool
|
||||
'True' si la date est correcte, 'False' sinon.
|
||||
"""
|
||||
year = 1
|
||||
month = 1
|
||||
day = 1
|
||||
|
||||
if len(date) != 3 :
|
||||
return False
|
||||
|
||||
try :
|
||||
year = int(date[0])
|
||||
month = int(date[1])
|
||||
day = int(date[2])
|
||||
except ValueError :
|
||||
return False
|
||||
|
||||
if year < 2 or month < 1 or day < 1 :
|
||||
return False
|
||||
|
||||
if month > 12 :
|
||||
return False
|
||||
|
||||
if day > month_days(month, year) :
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def check_time(time) :
|
||||
"""
|
||||
Vérifie que l'heure est correcte.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
time : list
|
||||
Heure à vérifier.
|
||||
|
||||
Returns
|
||||
-------
|
||||
bool
|
||||
'True' si l'heure est correcte, 'False' sinon.
|
||||
"""
|
||||
hour = 0
|
||||
minute = 0
|
||||
|
||||
if len(time) != 2 :
|
||||
return False
|
||||
|
||||
try :
|
||||
hour = int(time[0])
|
||||
minute = int(time[1])
|
||||
except ValueError :
|
||||
return False
|
||||
|
||||
if hour < 0 or minute < 0 :
|
||||
return False
|
||||
|
||||
if hour > 23 :
|
||||
return False
|
||||
|
||||
if minute > 59 :
|
||||
return False
|
||||
|
||||
return True
|
@ -94,4 +94,4 @@ class Dept :
|
||||
self.rooms = rooms
|
||||
|
||||
def genlink(self,link):
|
||||
return "https://adecons.unistra.fr/jsp/custom/modules/plannings/anonymous_cal.jsp?resources="+link.strip()+"&projectId=1&calType=ical"
|
||||
return "https://adecons.unistra.fr/jsp/custom/modules/plannings/anonymous_cal.jsp?resources="+link.strip()+"&projectId=5&calType=ical"
|
||||
|
Loading…
Reference in New Issue
Block a user