aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Lepori <alepori@student.ethz.ch>2022-01-05 20:35:09 +0100
committerAndrea Lepori <alepori@student.ethz.ch>2022-01-05 20:35:52 +0100
commit5ffcd6d9bb07a1ce37740dbdf501d68966467ee9 (patch)
treef4df7229249608f899850532f9c597d00852dcab
parentadd radio buttons to custom parameters (diff)
downloadscout-subs-5ffcd6d9bb07a1ce37740dbdf501d68966467ee9.tar.gz
scout-subs-5ffcd6d9bb07a1ce37740dbdf501d68966467ee9.zip
get version, commit_id and branch only at startup
Diffstat (limited to '')
-rw-r--r--client/views.py11
-rw-r--r--manager/settings.py7
-rw-r--r--version.txt2
3 files changed, 12 insertions, 8 deletions
diff --git a/client/views.py b/client/views.py
index 4813e8f..992f7dd 100644
--- a/client/views.py
+++ b/client/views.py
@@ -6,6 +6,7 @@ from django.http import HttpResponseRedirect, FileResponse
from django.contrib.auth.decorators import login_required
from django.shortcuts import render
from accounts.views import copy_from_midata
+from django.conf import settings
from io import BytesIO
import pdfkit
@@ -317,24 +318,20 @@ def edit_wrapper(request, context):
def about(request):
# very simple about page, get version from text file
- version = ""
-
- with open("version.txt", 'r') as f:
- version = f.read()
+ version = settings.VERSION
# parse file
version = version[version.find("=")+1:]
version = version.replace("\n", " ").replace("=", " ")
# get branch
- branch = check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).decode()
+ branch = settings.BRANCH
version += " (" + branch[:-1] + ")"
if version.startswith("0"):
version = "Beta " + version
# get commitid using git command, a bit hacky but works
- commitid = check_output(["git", "rev-parse", "HEAD"]).decode()
- context = {"version": version, "commitid": commitid}
+ context = {"version": version, "commitid": settings.COMMIT_ID}
return render(request, 'client/about.html', context)
diff --git a/manager/settings.py b/manager/settings.py
index 904600b..7649631 100644
--- a/manager/settings.py
+++ b/manager/settings.py
@@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/3.0/ref/settings/
"""
import os
+from subprocess import check_output
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -44,6 +45,12 @@ EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'mafaldo@hotmail.it'
SERVER_EMAIL = 'mafaldo@hotmail.it'
+VERSION = ""
+with open("version.txt", 'r') as f:
+ VERSION = f.read()
+
+BRANCH = check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).decode()
+COMMIT_ID = check_output(["git", "rev-parse", "HEAD"]).decode()
# Application definition
diff --git a/version.txt b/version.txt
index dd7b026..8c31964 100644
--- a/version.txt
+++ b/version.txt
@@ -1,2 +1,2 @@
version=0.4
-rev=19
+rev=21