feat: add build date to template context
This commit is contained in:
@@ -18,6 +18,6 @@ COPY --chmod=700 ./scripts /scripts
|
|||||||
|
|
||||||
# finally copy app (likely will invalidate cache)
|
# finally copy app (likely will invalidate cache)
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN (date +'%Y-%m-%d %R') > build_date.txt
|
RUN (date -u +'%Y-%m-%d %H:%M:%S') > build_date.txt
|
||||||
|
|
||||||
CMD ["on-deploy.sh"]
|
CMD ["on-deploy.sh"]
|
||||||
|
|||||||
7
app/base/context.py
Executable file
7
app/base/context.py
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
|
def custom_context(request):
|
||||||
|
return {
|
||||||
|
'BUILD_DATE': settings.BUILD_DATE,
|
||||||
|
}
|
||||||
@@ -282,8 +282,8 @@ table.clickable tbody>tr:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#sidebar-wrapper {
|
#sidebar-wrapper {
|
||||||
font-family: 'Dosis', sans-serif;
|
display: flex;
|
||||||
font-size: 1.2rem;
|
flex-direction: column;
|
||||||
-webkit-transition: margin .25s ease-out;
|
-webkit-transition: margin .25s ease-out;
|
||||||
-moz-transition: margin .25s ease-out;
|
-moz-transition: margin .25s ease-out;
|
||||||
-o-transition: margin .25s ease-out;
|
-o-transition: margin .25s ease-out;
|
||||||
@@ -295,6 +295,8 @@ table.clickable tbody>tr:hover {
|
|||||||
|
|
||||||
#sidebar-wrapper .list-group {
|
#sidebar-wrapper .list-group {
|
||||||
width: max-content;
|
width: max-content;
|
||||||
|
font-family: 'Dosis', sans-serif;
|
||||||
|
font-size: 1.2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-list i {
|
.icon-list i {
|
||||||
|
|||||||
@@ -51,6 +51,12 @@
|
|||||||
<a href="{% url 'transaction:list' %}" class="list-group-item list-group-item-action bg-dim"><i class="fas fa-euro-sign"></i> Transaktionen</a>
|
<a href="{% url 'transaction:list' %}" class="list-group-item list-group-item-action bg-dim"><i class="fas fa-euro-sign"></i> Transaktionen</a>
|
||||||
<a href="{% url 'trait:list' %}" class="list-group-item list-group-item-action bg-dim"><i class="fas fa-tags"></i> Attribute</a>
|
<a href="{% url 'trait:list' %}" class="list-group-item list-group-item-action bg-dim"><i class="fas fa-tags"></i> Attribute</a>
|
||||||
</div>
|
</div>
|
||||||
|
{% if BUILD_DATE %}
|
||||||
|
<i class="flex-fill"></i>
|
||||||
|
<p class="small text-center font-weight-lighter">
|
||||||
|
v{{ BUILD_DATE|date:'Y-m-d H:i' }}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div id="page-content-wrapper" class="container-fluid position-relative">
|
<div id="page-content-wrapper" class="container-fluid position-relative">
|
||||||
{% breadcrumbs %}
|
{% breadcrumbs %}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ https://docs.djangoproject.com/en/4.2/ref/settings/
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from datetime import datetime, timezone as TZ
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
@@ -26,6 +27,12 @@ SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'insecure-+3@1h+@wz%6m*dpx0e')
|
|||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = os.environ.get('DEBUG', 'yes').lower() not in ['false', 'no', '0']
|
DEBUG = os.environ.get('DEBUG', 'yes').lower() not in ['false', 'no', '0']
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(BASE_DIR / 'build_date.txt', 'r') as fp:
|
||||||
|
BUILD_DATE = datetime.fromisoformat(fp.read()).replace(tzinfo=TZ.utc)
|
||||||
|
except FileNotFoundError:
|
||||||
|
BUILD_DATE = None
|
||||||
|
|
||||||
ALLOWED_HOSTS = []
|
ALLOWED_HOSTS = []
|
||||||
|
|
||||||
ALLOWED_HOSTS.extend(
|
ALLOWED_HOSTS.extend(
|
||||||
@@ -70,6 +77,7 @@ TEMPLATES = [
|
|||||||
'django.template.context_processors.request',
|
'django.template.context_processors.request',
|
||||||
'django.contrib.auth.context_processors.auth',
|
'django.contrib.auth.context_processors.auth',
|
||||||
'django.contrib.messages.context_processors.messages',
|
'django.contrib.messages.context_processors.messages',
|
||||||
|
'app.base.context.custom_context',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user