Skip to content

Commit

Permalink
Print semver instead of githash on welcome
Browse files Browse the repository at this point in the history
  • Loading branch information
hackenbergstefan committed Jul 24, 2024
1 parent 6e350a8 commit 099a681
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
14 changes: 8 additions & 6 deletions coffeebuddy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.exc import OperationalError

__version__ = "1.1.0"

db = SQLAlchemy()
login_manager = flask_login.LoginManager()

Expand Down Expand Up @@ -46,7 +48,7 @@ def create_app(config=None):
if config:
app.config.update(config)

if app.config.get("ENV") in ("development", "prefilled") or app.testing:
if app.config.get("PREFILLED") or app.testing:
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///:memory:"

@app.teardown_appcontext
Expand All @@ -68,7 +70,7 @@ def init_db(app):
flask.current_app.config["DB_BACKEND"] == "sqlite"
and not os.path.exists("coffee.db")
)
or flask.current_app.config.get("ENV") in ("development", "prefilled")
or flask.current_app.config.get("PREFILLED")
or flask.current_app.testing
):
try:
Expand All @@ -78,7 +80,10 @@ def init_db(app):
os._exit(1)

# Default database content
if flask.current_app.config.get("ENV") == "development":
if not flask.current_app.testing and flask.current_app.config.get("PREFILLED"):
flask.current_app.debug = True
prefill()
elif flask.current_app.debug:
flask.current_app.db.session.add(
coffeebuddy.model.User(
tag=bytes.fromhex("01020304"),
Expand All @@ -88,9 +93,6 @@ def init_db(app):
)
)
flask.current_app.db.session.commit()
elif flask.current_app.config.get("ENV") == "prefilled":
flask.current_app.debug = True
prefill()

if flask.current_app.config["GUEST"]:
if not coffeebuddy.model.User.query.filter(
Expand Down
6 changes: 2 additions & 4 deletions coffeebuddy/route_welcome.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import datetime
import socket
import subprocess

import flask

import coffeebuddy
from coffeebuddy.model import Drink


Expand All @@ -18,7 +18,5 @@ def welcome():
"welcome.html",
dataset=data,
hostname=socket.gethostname(),
githash=subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])
.decode("ascii")
.strip(),
version=coffeebuddy.__version__,
)
2 changes: 1 addition & 1 deletion coffeebuddy/templates/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ <h3>Tap your card to continue</h3>
<div class="info-label">Hostname</div>
<div class="info-field">{{ hostname }}</div>
<div class="info-label">Version</div>
<div class="info-field">{{ githash }}</div>
<div class="info-field">{{ version }}</div>
{% if config['GUEST'] %}
<button class="btn btn-primary mt-3 d-block"
onclick="window.location.href = '../coffee.html?tag=ffffffff'">Guest</button>
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "coffeebuddy"
version = "1.0.0"
dynamic = ["version"]
description = "WebApp for Raspi to track your teams' coffee consumption digitally."
authors = [{ name = "Stefan Hackenberg", email = "[email protected]" }]
dependencies = [
Expand Down

0 comments on commit 099a681

Please sign in to comment.