update: format
This commit is contained in:
parent
c210f27f68
commit
0926e8084c
5 changed files with 28 additions and 12 deletions
2
api42.py
2
api42.py
|
|
@ -149,7 +149,7 @@ class Api:
|
|||
return {"error": r.text}, r.status_code, dict(r.headers)
|
||||
|
||||
def get_unknown_user(self, user_name: str) -> tuple[int, dict]:
|
||||
data, status, header = self.get(f"/users/{user_name}")
|
||||
data, status, _ = self.get(f"/users/{user_name}")
|
||||
if status == 200:
|
||||
return 200, data
|
||||
return status, data
|
||||
|
|
|
|||
16
db.py
16
db.py
|
|
@ -521,19 +521,25 @@ class Db:
|
|||
def get_all_admins(self):
|
||||
req = self.cur.execute("SELECT * FROM PERMISSIONS")
|
||||
return req.fetchall()
|
||||
|
||||
|
||||
#
|
||||
# CUSTOM IMAGE
|
||||
# CUSTOM IMAGE
|
||||
#
|
||||
|
||||
def get_custom_image(self, userid: int):
|
||||
req = self.cur.execute("SELECT custom_image_link FROM USERS WHERE id = ?", [userid])
|
||||
req = self.cur.execute(
|
||||
"SELECT custom_image_link FROM USERS WHERE id = ?", [userid]
|
||||
)
|
||||
return req.fetchone()
|
||||
|
||||
def set_custom_image(self, userid: int, link: str):
|
||||
req = self.cur.execute("UPDATE USERS SET custom_image_link = ? WHERE id = ?", [link, userid])
|
||||
req = self.cur.execute(
|
||||
"UPDATE USERS SET custom_image_link = ? WHERE id = ?", [link, userid]
|
||||
)
|
||||
return req.fetchall()
|
||||
|
||||
def get_all_custom_images(self):
|
||||
req = self.cur.execute("SELECT * FROM USERS WHERE custom_image_link IS NOT NULL")
|
||||
req = self.cur.execute(
|
||||
"SELECT * FROM USERS WHERE custom_image_link IS NOT NULL"
|
||||
)
|
||||
return req.fetchall()
|
||||
|
|
|
|||
|
|
@ -106,7 +106,9 @@ def index(userid):
|
|||
piscines = [x["cluster"] for x in db.get_piscines(userid["campus"])]
|
||||
silents = [x["cluster"] for x in db.get_silents(userid["campus"])]
|
||||
piscine_date = [(x["month"], x["year"]) for x in db.get_all_piscine_dates()]
|
||||
custom_images = {x["name"]: x["custom_image_link"] for x in db.get_all_custom_images()}
|
||||
custom_images = {
|
||||
x["name"]: x["custom_image_link"] for x in db.get_all_custom_images()
|
||||
}
|
||||
|
||||
tutor_stations = [
|
||||
x["station"]
|
||||
|
|
@ -137,7 +139,9 @@ def index(userid):
|
|||
admin = user_id in admin_ids
|
||||
whitelist = user_id in whitelist_ids
|
||||
if user["user"]["login"] in custom_images:
|
||||
user["user"]["image"]["versions"]["small"] = custom_images[user["user"]["login"]]
|
||||
user["user"]["image"]["versions"]["small"] = custom_images[
|
||||
user["user"]["login"]
|
||||
]
|
||||
location_map[user["host"]] = {
|
||||
**user,
|
||||
"me": user_id == userid["userid"],
|
||||
|
|
|
|||
|
|
@ -16,10 +16,16 @@ def proxy_images(url: str, light=False):
|
|||
if not url:
|
||||
return "/static/img/unknown.jpg"
|
||||
if light:
|
||||
return url.replace("https://cdn.intra.42.fr/", f"https://{config.proxy_domain}/proxy/70x70/")
|
||||
return url.replace(
|
||||
"https://cdn.intra.42.fr/", f"https://{config.proxy_domain}/proxy/70x70/"
|
||||
)
|
||||
if "small" in url or "medium" in url:
|
||||
return url.replace("https://cdn.intra.42.fr/", f"https://{config.proxy_domain}/proxy/256x256/")
|
||||
return url.replace("https://cdn.intra.42.fr/", f"https://{config.proxy_domain}/proxy/512x512/")
|
||||
return url.replace(
|
||||
"https://cdn.intra.42.fr/", f"https://{config.proxy_domain}/proxy/256x256/"
|
||||
)
|
||||
return url.replace(
|
||||
"https://cdn.intra.42.fr/", f"https://{config.proxy_domain}/proxy/512x512/"
|
||||
)
|
||||
|
||||
|
||||
def auth_required(function):
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ for cluster in clusters:
|
|||
soup = BeautifulSoup(doc.text, "html.parser")
|
||||
dead = soup.find_all("td", class_="dead")
|
||||
issue = soup.find_all("td", class_="attention")
|
||||
|
||||
|
||||
for e in dead:
|
||||
all_issues[e.attrs["data-pos"]] = 1
|
||||
for e in issue:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue