Skip to content

Commit

Permalink
clean up version check, bump to 1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdabtieu committed Jan 30, 2021
1 parent 5ad4a39 commit f4d13e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 1 addition & 5 deletions application.py
Original file line number Diff line number Diff line change
Expand Up @@ -1090,11 +1090,7 @@ def delete_problem(problem_id):
@app.route("/admin/console")
@admin_required
def admin_console():
version_info = latest_version()
if version_info[0] != version_info[1]:
flash(("You are not up-to-date! Please notify the site administrator. "
f"Current version: {version_info[0]}, Latest version: {version_info[1]}"),
"danger")
check_version()
return render_template("admin/console.html", maintenance_mode=maintenance_mode)


Expand Down
16 changes: 10 additions & 6 deletions helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import requests
from functools import wraps

from flask import redirect, request, session
from flask import redirect, request, session, flash
from flask_mail import Message


Expand Down Expand Up @@ -82,15 +82,19 @@ def check_captcha(secret, response, sitekey):
return True


def latest_version():
def check_version():
"""
Checks if CTFOJ is up to date with the latest version on GitHub
"""
curr_version = "v1.4.1"
curr_version = "v1.5.0"
try:
latest_version = requests.get(
"https://api.github.com/repos/jdabtieu/CTFOJ/releases/latest").json()["name"]
if curr_version != latest_version:
flash(("You are not up-to-date! Please notify the site administrator. "
f"Current version: {curr_version}, Latest version: {latest_version}"),
"danger")
except Exception:
latest_version = ("Couldn't be detected. "
"Please make sure https://api.github.com isn't blocked.")
return [curr_version, latest_version]
flash(("Latest version could not be detected. Please make sure "
"https://api.github.com isn't blocked by a firewall."), "warning")
return

0 comments on commit f4d13e2

Please sign in to comment.