This commit is contained in:
nessar committed 2023-09-10 15:39:24 +02:00
1 parent bdcd6631e3
commit d5bdf2db0e
4 files changed
+42 -34

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
import sys
sys.path.insert(0,"/var/www/html")
sys.path.insert(0,"/var/www/html/flask")
from flaskapp import app as application
+21 -24
View File
@@ -4,8 +4,8 @@ import os
import time
app = Flask(__name__)
app.config['SECRET_KEY'] = '***REMOVED***'
app.secret_key = b"***REMOVED***"
app.config['SECRET_KEY'] = '6KN7u!H2HFpD3V7fk&Q#E'
app.secret_key = b"6KN7u!H2HFpD3V7fk&Q#E"
def exist(tab, test):
@@ -58,30 +58,27 @@ def quatrecentquatre():
def calUni(group=None):
if group == None:
return redirect(url_for('quatrecentquatre'))
try:
for i in os.listdir("/var/www/html/static/ics/"):
if i == 'calUni ' + group + ' ' + str(request.args)[20:-2].replace("(", "").replace(" ", "_").replace("',", ":").replace("'", "").replace(
")", "") + '.ics':
if (time.time() - int(
os.path.getmtime('/var/www/html/static/ics/calUni ' + group + ' ' +
str(request.args)[20:-2].replace("(", "").replace(" ", "_").replace("',", ":").replace("'", "").replace(")", "") + '.ics'))
> 21600):
cal(group, request.args)
return send_from_directory(
'/var/www/html/static/ics/',
path='calUni ' + group + ' ' +
str(request.args)[20:-2].replace("(", "").replace(" ", "_").replace("',", ":").replace("'", "").replace(")", "") + '.ics')
return send_from_directory('/var/www/html/static/ics/',
for i in os.listdir("/var/www/html/flask/static/ics/"):
if i == 'calUni ' + group + ' ' + str(request.args)[20:-2].replace("(", "").replace(" ", "_").replace("',", ":").replace("'", "").replace(")",
"") + '.ics':
if (time.time() - int(
os.path.getmtime('/var/www/html/flask/static/ics/calUni ' + group + ' ' +
str(request.args)[20:-2].replace("(", "").replace(" ", "_").replace("',", ":").replace("'", "").replace(")", "") + '.ics'))
> 21600):
cal(group, request.args)
return send_from_directory('/var/www/html/flask/static/ics/',
path='calUni ' + group + ' ' +
str(request.args)[20:-2].replace("(", "").replace(" ", "_").replace("',", ":").replace("'", "").replace(")", "") +
'.ics')
print(group, request.args)
cal(group, request.args)
return send_from_directory('/var/www/html/static/ics/',
path='calUni ' + group + ' ' +
str(request.args)[20:-2].replace("(", "").replace(" ", "_").replace("',", ":").replace("'", "").replace(")", "") + '.ics')
except FileNotFoundError:
abort(404)
return send_from_directory('/var/www/html/flask/static/ics/',
path='calUni ' + group + ' ' +
str(request.args)[20:-2].replace("(", "").replace(" ", "_").replace("',", ":").replace("'", "").replace(")", "") +
'.ics')
print(group, request.args)
cal(group, request.args)
return send_from_directory('/var/www/html/flask/static/ics/',
path='calUni ' + group + ' ' +
str(request.args)[20:-2].replace("(", "").replace(" ", "_").replace("',", ":").replace("'", "").replace(")", "") + '.ics')
@app.route("/admin", methods=['GET', 'POST'])
@@ -92,4 +89,4 @@ def admin():
if __name__ == '__main__':
app.run()
app.run()
+10 -5
View File
@@ -38,10 +38,15 @@ class WebApiURL:
SIDEBAR = 'GetSideBarEvent'
def get_calendar(group: str) -> dict:
def get_calendar(group: str, year: str, semester: bool) -> dict:
monthStart = '9'
monthEnd = '12'
if semester:
monthStart = '1'
monthEnd = '7'
data = {
'start': '2023-01-01',
'end': '2023-07-01',
'start': year + '-' + monthStart + '-01',
'end': year + '-' + monthEnd + '-31',
'resType': '103',
'calView': 'agendaDay',
'federationIds[]': group,
@@ -93,8 +98,8 @@ def parse_event(event: dict) -> dict:
return parsed_event
def getcalendar(group):
id_cal = get_calendar(group)
def getcalendar(group, year: str, semester: bool):
id_cal = get_calendar(group, year, semester)
sche_id_dict = {}
for id, event in id_cal.items():
if event['eventCategory'] != 'Vacances':
+10 -4
View File
@@ -5,10 +5,16 @@ from getcalendar import getcalendar
def cal(group, args):
year = datetime.datetime.now().year
month = datetime.datetime.now().month
semester = False
if month < 9:
year -= 1
semester = True
cal = Calendar()
cal.add('prodid', 'EDT Université 2022-2023 ' + group)
cal.add('prodid', 'EDT Université ' + str(year) + '-' + str(year + 1) + ' ' + group)
cal.add('version', '2.0')
calendarinfo = getcalendar(group)
calendarinfo = getcalendar(group, str(year), semester)
for i in range(len(calendarinfo)):
ignore = False
if calendarinfo[i]["module"] != None:
@@ -43,7 +49,7 @@ def cal(group, args):
addevent("[" + calendarinfo[i]["category"] + "] " + calendarinfo[i]["module"], calendarinfo[i]["startint"], calendarinfo[i]["endint"], loc, desc,
cal)
f = open(
'/var/www/html/static/ics/calUni ' + group + ' ' +
'/var/www/html/flask/static/ics/calUni ' + group + ' ' +
str(args)[20:-2].replace("(", "").replace(" ", "_").replace("',", ":").replace("'", "").replace(")", "") + '.ics', 'wb')
f.write(cal.to_ical())
f.close()
@@ -70,4 +76,4 @@ def addevent(summary, startint, endint, location, description, cal):
tzinfo=ZoneInfo("Europe/Paris")))
event['location'] = vText(location)
event['description'] = vText(description)
cal.add_component(event)
cal.add_component(event)