Commit 0cd0f2c2a3d7e598f31d5ade5f476bfb87ce0148
1 parent
e9c8f9bc
Exists in
dev
add automation of updating version number of pyros
Showing
3 changed files
with
22 additions
and
4 deletions
Show diff stats
src/core/pyros_django/dashboard/templatetags/tags.py
@@ -3,6 +3,7 @@ from django.contrib.auth.models import User | @@ -3,6 +3,7 @@ from django.contrib.auth.models import User | ||
3 | #from common.models import Config, PyrosUser, PyrosState | 3 | #from common.models import Config, PyrosUser, PyrosState |
4 | from common.models import Config, PyrosUser, UserLevel | 4 | from common.models import Config, PyrosUser, UserLevel |
5 | from datetime import date | 5 | from datetime import date |
6 | +from django.conf import settings | ||
6 | 7 | ||
7 | register = template.Library() | 8 | register = template.Library() |
8 | 9 | ||
@@ -65,6 +66,11 @@ def user_level(request): | @@ -65,6 +66,11 @@ def user_level(request): | ||
65 | return str(UserLevel.objects.get(priority=request.user.get_priority()).name) | 66 | return str(UserLevel.objects.get(priority=request.user.get_priority()).name) |
66 | else: | 67 | else: |
67 | return UserLevel.objects.get(name="Visitor").name | 68 | return UserLevel.objects.get(name="Visitor").name |
69 | + | ||
70 | +@register.simple_tag | ||
71 | +def get_version_number(): | ||
72 | + return settings.VERSION_NUMBER | ||
73 | + | ||
68 | @register.simple_tag() | 74 | @register.simple_tag() |
69 | def can_view_settings(request): | 75 | def can_view_settings(request): |
70 | if request.user.is_authenticated : | 76 | if request.user.is_authenticated : |
src/core/pyros_django/misc/templates/base.html
@@ -20,7 +20,8 @@ | @@ -20,7 +20,8 @@ | ||
20 | 20 | ||
21 | <!-- Page Specific CSS --> | 21 | <!-- Page Specific CSS --> |
22 | <!-- <link rel="stylesheet" href="http://cdn.oesmith.co.uk/morris-0.4.3.min.css"> --> | 22 | <!-- <link rel="stylesheet" href="http://cdn.oesmith.co.uk/morris-0.4.3.min.css"> --> |
23 | - | 23 | + <link rel="stylesheet" type="text/css" href="{% static '/css/global.css' %}"> |
24 | + <script src="{% static "/js/global.js" %}" defer></script> | ||
24 | <!-- JsTree --> | 25 | <!-- JsTree --> |
25 | <link rel="stylesheet" href={% static "bootstrap/dist/themes/default/style.min.css" %}> | 26 | <link rel="stylesheet" href={% static "bootstrap/dist/themes/default/style.min.css" %}> |
26 | <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet"> | 27 | <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet"> |
@@ -221,6 +222,7 @@ footer{ | @@ -221,6 +222,7 @@ footer{ | ||
221 | {% load tags %} | 222 | {% load tags %} |
222 | {% user_level request as USER_LEVEL %} | 223 | {% user_level request as USER_LEVEL %} |
223 | {% can_view_settings request as CAN_VIEW_SETTINGS %} | 224 | {% can_view_settings request as CAN_VIEW_SETTINGS %} |
225 | +{% get_version_number as version_number %} | ||
224 | {% comment %} | 226 | {% comment %} |
225 | 227 | ||
226 | {% get_level "TAC" as USER_LEVEL_TAC %} | 228 | {% get_level "TAC" as USER_LEVEL_TAC %} |
@@ -588,7 +590,7 @@ footer{ | @@ -588,7 +590,7 @@ footer{ | ||
588 | <footer class="sticky-footer"> | 590 | <footer class="sticky-footer"> |
589 | <div> | 591 | <div> |
590 | <div class="text-right my-auto"> | 592 | <div class="text-right my-auto"> |
591 | - <span>VERSION 0.2.5.0_2.0_3.6_2021-10-08</span> | 593 | + <span>VERSION {{ version_number }}</span> |
592 | </div> | 594 | </div> |
593 | </div> | 595 | </div> |
594 | </footer> | 596 | </footer> |
src/core/pyros_django/pyros/settings.py
@@ -44,7 +44,10 @@ MODULES_VERSIONS = { | @@ -44,7 +44,10 @@ MODULES_VERSIONS = { | ||
44 | 44 | ||
45 | 45 | ||
46 | 46 | ||
47 | -import os,re,platform | 47 | +import os,re,platform, subprocess |
48 | +from datetime import date, datetime | ||
49 | + | ||
50 | +import django | ||
48 | # duplicate from the same function in pyros.py ... | 51 | # duplicate from the same function in pyros.py ... |
49 | def set_environment_variables_if_not_configured(env_path: str,env_sample_path: str)->None: | 52 | def set_environment_variables_if_not_configured(env_path: str,env_sample_path: str)->None: |
50 | """ | 53 | """ |
@@ -392,4 +395,11 @@ else: | @@ -392,4 +395,11 @@ else: | ||
392 | # from django.core.cache import cache | 395 | # from django.core.cache import cache |
393 | # cache.clear() | 396 | # cache.clear() |
394 | 397 | ||
395 | -EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' | ||
396 | \ No newline at end of file | 398 | \ No newline at end of file |
399 | +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' | ||
400 | + | ||
401 | +python_version = subprocess.run( "python --version | cut -d ' ' -f 2 | cut -d '.' -f 1,2",shell=True,stdout=subprocess.PIPE,universal_newlines=True) | ||
402 | +python_version = python_version.stdout | ||
403 | +today = datetime.utcnow().date() | ||
404 | +django_version_major,django_version_minor = django.VERSION[:2][0],django.VERSION[:2][1] | ||
405 | +pyros_version = "0.2.5.0" | ||
406 | +VERSION_NUMBER = f"{pyros_version}_{django_version_major}.{django_version_minor}_{python_version}_{today}" | ||
397 | \ No newline at end of file | 407 | \ No newline at end of file |