feat: add ssl_verify parameter
This commit is contained in:
parent
364c6391c9
commit
3dab312a74
@ -23,7 +23,8 @@ app:
|
|||||||
name: THSF
|
name: THSF
|
||||||
real_url: https://www.thsf.net
|
real_url: https://www.thsf.net
|
||||||
pretalx:
|
pretalx:
|
||||||
url: https://23.thsf.net
|
url: https://thsf.tetaneutral.net
|
||||||
|
ssl_verify: False
|
||||||
apiprefix: api
|
apiprefix: api
|
||||||
apikey: bb770a53b15467dfb67c03d178004aca9e4819d6
|
apikey: bb770a53b15467dfb67c03d178004aca9e4819d6
|
||||||
event: thsf-2023
|
event: thsf-2023
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
import re
|
|
||||||
import sys
|
import sys
|
||||||
import json
|
|
||||||
import logging
|
import logging
|
||||||
from logging import config
|
from logging import config
|
||||||
import yaml
|
import yaml
|
||||||
from flask import Flask, render_template, redirect, request, url_for
|
from flask import Flask, render_template, redirect, url_for
|
||||||
from flask_minify import minify
|
from flask_minify import minify
|
||||||
from thsf.backend import Backend
|
from thsf.backend import Backend
|
||||||
from thsf.schedule import Schedule
|
from thsf.schedule import Schedule
|
||||||
@ -37,7 +35,8 @@ try:
|
|||||||
config.dictConfig(app.local_config["log"])
|
config.dictConfig(app.local_config["log"])
|
||||||
backend = Backend(url=app.local_config["pretalx"]["url"],
|
backend = Backend(url=app.local_config["pretalx"]["url"],
|
||||||
apiprefix=app.local_config["pretalx"]["apiprefix"],
|
apiprefix=app.local_config["pretalx"]["apiprefix"],
|
||||||
apikey=app.local_config["pretalx"]["apikey"])
|
apikey=app.local_config["pretalx"]["apikey"],
|
||||||
|
ssl_verify=app.local_config["pretalx"]["ssl_verify"])
|
||||||
schedule = Schedule()
|
schedule = Schedule()
|
||||||
navbar = Navbar(config=app.local_config["navbar"])
|
navbar = Navbar(config=app.local_config["navbar"])
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
@ -47,6 +46,7 @@ except Exception as err:
|
|||||||
if app.local_config["log"]["root"]["level"] != "DEBUG":
|
if app.local_config["log"]["root"]["level"] != "DEBUG":
|
||||||
minify(app=app, html=True, js=True, cssless=True)
|
minify(app=app, html=True, js=True, cssless=True)
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# -- Tools
|
# -- Tools
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@ -63,7 +63,7 @@ def get_speaker_biography(code):
|
|||||||
try:
|
try:
|
||||||
speaker_info = backend.get(endpoint=f"events/{app.local_config['pretalx']['event']}/speakers/{code}/").json()
|
speaker_info = backend.get(endpoint=f"events/{app.local_config['pretalx']['event']}/speakers/{code}/").json()
|
||||||
return speaker_info.get("biography").strip()
|
return speaker_info.get("biography").strip()
|
||||||
except Exception as err:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@ -125,9 +125,10 @@ def planning():
|
|||||||
for slot in slots.get("slots"):
|
for slot in slots.get("slots"):
|
||||||
for speaker in slot.get("speakers"):
|
for speaker in slot.get("speakers"):
|
||||||
speaker["biography"] = get_speaker_biography(speaker.get("code"))
|
speaker["biography"] = get_speaker_biography(speaker.get("code"))
|
||||||
return render_template("planning.html",
|
|
||||||
slots = sorted(slots.get("slots"),
|
slots = sorted(slots.get("slots"),
|
||||||
key=lambda slot: slot.get("slot").get("start")),
|
key=lambda slot: slot.get("slot").get("start"))
|
||||||
|
return render_template("planning.html",
|
||||||
|
slots=slots,
|
||||||
navbar=navbar.get_from_page(page="/planning"),
|
navbar=navbar.get_from_page(page="/planning"),
|
||||||
filter=["concert", "dj set", "panel discussion", "talk", "screening"])
|
filter=["concert", "dj set", "panel discussion", "talk", "screening"])
|
||||||
|
|
||||||
@ -153,9 +154,10 @@ def goodies():
|
|||||||
@app.route('/concerts', methods=['GET'])
|
@app.route('/concerts', methods=['GET'])
|
||||||
def concerts():
|
def concerts():
|
||||||
slots = get_slots()
|
slots = get_slots()
|
||||||
return render_template("planning.html",
|
|
||||||
slots = sorted(slots.get("slots"),
|
slots = sorted(slots.get("slots"),
|
||||||
key=lambda slot: slot.get("slot").get("start")),
|
key=lambda slot: slot.get("slot").get("start"))
|
||||||
|
return render_template("planning.html",
|
||||||
|
slots=slots,
|
||||||
navbar=navbar.get_from_page(page="/concerts"),
|
navbar=navbar.get_from_page(page="/concerts"),
|
||||||
filter=["concert", "dj set"])
|
filter=["concert", "dj set"])
|
||||||
|
|
||||||
@ -163,9 +165,10 @@ def concerts():
|
|||||||
@app.route('/workshops', methods=['GET'])
|
@app.route('/workshops', methods=['GET'])
|
||||||
def workshops():
|
def workshops():
|
||||||
slots = get_slots()
|
slots = get_slots()
|
||||||
return render_template("planning.html",
|
|
||||||
slots = sorted(slots.get("slots"),
|
slots = sorted(slots.get("slots"),
|
||||||
key=lambda slot: slot.get("slot").get("start")),
|
key=lambda slot: slot.get("slot").get("start"))
|
||||||
|
return render_template("planning.html",
|
||||||
|
slots=slots,
|
||||||
navbar=navbar.get_from_page(page="/workshops"),
|
navbar=navbar.get_from_page(page="/workshops"),
|
||||||
filter=["workshop"])
|
filter=["workshop"])
|
||||||
|
|
||||||
@ -173,9 +176,10 @@ def workshops():
|
|||||||
@app.route('/screenings', methods=['GET'])
|
@app.route('/screenings', methods=['GET'])
|
||||||
def screenings():
|
def screenings():
|
||||||
slots = get_slots()
|
slots = get_slots()
|
||||||
return render_template("planning.html",
|
|
||||||
slots = sorted(slots.get("slots"),
|
slots = sorted(slots.get("slots"),
|
||||||
key=lambda slot: slot.get("slot").get("start")),
|
key=lambda slot: slot.get("slot").get("start"))
|
||||||
|
return render_template("planning.html",
|
||||||
|
slots=slots,
|
||||||
navbar=navbar.get_from_page(page="/screenings"),
|
navbar=navbar.get_from_page(page="/screenings"),
|
||||||
filter=["screening"])
|
filter=["screening"])
|
||||||
|
|
||||||
@ -183,9 +187,10 @@ def screenings():
|
|||||||
@app.route('/discussions', methods=['GET'])
|
@app.route('/discussions', methods=['GET'])
|
||||||
def discussions():
|
def discussions():
|
||||||
slots = get_slots()
|
slots = get_slots()
|
||||||
return render_template("planning.html",
|
|
||||||
slots = sorted(slots.get("slots"),
|
slots = sorted(slots.get("slots"),
|
||||||
key=lambda slot: slot.get("slot").get("start")),
|
key=lambda slot: slot.get("slot").get("start"))
|
||||||
|
return render_template("planning.html",
|
||||||
|
slots=slots,
|
||||||
navbar=navbar.get_from_page(page="/discussions"),
|
navbar=navbar.get_from_page(page="/discussions"),
|
||||||
filter=["panel discussion"])
|
filter=["panel discussion"])
|
||||||
|
|
||||||
@ -193,9 +198,10 @@ def discussions():
|
|||||||
@app.route('/exhibitions', methods=['GET'])
|
@app.route('/exhibitions', methods=['GET'])
|
||||||
def exhibitions():
|
def exhibitions():
|
||||||
slots = get_slots()
|
slots = get_slots()
|
||||||
return render_template("planning.html",
|
|
||||||
slots = sorted(slots.get("slots"),
|
slots = sorted(slots.get("slots"),
|
||||||
key=lambda slot: slot.get("slot").get("start")),
|
key=lambda slot: slot.get("slot").get("start"))
|
||||||
|
return render_template("planning.html",
|
||||||
|
slots=slots,
|
||||||
navbar=navbar.get_from_page(page="/exhibitions"),
|
navbar=navbar.get_from_page(page="/exhibitions"),
|
||||||
filter=["installation"])
|
filter=["installation"])
|
||||||
|
|
||||||
@ -203,9 +209,10 @@ def exhibitions():
|
|||||||
@app.route('/talks', methods=['GET'])
|
@app.route('/talks', methods=['GET'])
|
||||||
def talks():
|
def talks():
|
||||||
slots = get_slots()
|
slots = get_slots()
|
||||||
return render_template("planning.html",
|
|
||||||
slots = sorted(slots.get("slots"),
|
slots = sorted(slots.get("slots"),
|
||||||
key=lambda slot: slot.get("slot").get("start")),
|
key=lambda slot: slot.get("slot").get("start"))
|
||||||
|
return render_template("planning.html",
|
||||||
|
slots=slots,
|
||||||
navbar=navbar.get_from_page(page="/talks"),
|
navbar=navbar.get_from_page(page="/talks"),
|
||||||
filter=["talk", "light talk"])
|
filter=["talk", "light talk"])
|
||||||
|
|
||||||
|
@ -1,15 +1,19 @@
|
|||||||
import requests
|
import requests
|
||||||
import logging
|
|
||||||
|
|
||||||
class Backend:
|
class Backend:
|
||||||
def __init__(self, url, apiprefix, apikey):
|
def __init__(self, url, apiprefix, apikey, ssl_verify):
|
||||||
self.url = url
|
self.url = url
|
||||||
self.apiprefix = apiprefix
|
self.apiprefix = apiprefix
|
||||||
self.apikey = apikey
|
self.apikey = apikey
|
||||||
|
self.ssl_verify = ssl_verify
|
||||||
self.session = requests.Session()
|
self.session = requests.Session()
|
||||||
|
|
||||||
def get(self, endpoint, params=None):
|
def get(self, endpoint, params=None):
|
||||||
url = f"{self.url}/{self.apiprefix}/{endpoint}"
|
url = f"{self.url}/{self.apiprefix}/{endpoint}"
|
||||||
headers = {"Authorization": f"Token {self.apikey}",
|
headers = {"Authorization": f"Token {self.apikey}",
|
||||||
"Accept": "application/json"}
|
"Accept": "application/json"}
|
||||||
return self.session.get(url, params=params, headers=headers)
|
return self.session.get(url,
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
verify=self.ssl_verify)
|
||||||
|
Loading…
Reference in New Issue
Block a user