Commit 0cd0f2c2a3d7e598f31d5ade5f476bfb87ce0148

Authored by Alexis Koralewski
1 parent e9c8f9bc
Exists in dev

add automation of updating version number of pyros

src/core/pyros_django/dashboard/templatetags/tags.py
... ... @@ -3,6 +3,7 @@ from django.contrib.auth.models import User
3 3 #from common.models import Config, PyrosUser, PyrosState
4 4 from common.models import Config, PyrosUser, UserLevel
5 5 from datetime import date
  6 +from django.conf import settings
6 7  
7 8 register = template.Library()
8 9  
... ... @@ -65,6 +66,11 @@ def user_level(request):
65 66 return str(UserLevel.objects.get(priority=request.user.get_priority()).name)
66 67 else:
67 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 74 @register.simple_tag()
69 75 def can_view_settings(request):
70 76 if request.user.is_authenticated :
... ...
src/core/pyros_django/misc/templates/base.html
... ... @@ -20,7 +20,8 @@
20 20  
21 21 <!-- Page Specific CSS -->
22 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 25 <!-- JsTree -->
25 26 <link rel="stylesheet" href={% static "bootstrap/dist/themes/default/style.min.css" %}>
26 27 <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
... ... @@ -221,6 +222,7 @@ footer{
221 222 {% load tags %}
222 223 {% user_level request as USER_LEVEL %}
223 224 {% can_view_settings request as CAN_VIEW_SETTINGS %}
  225 +{% get_version_number as version_number %}
224 226 {% comment %}
225 227  
226 228 {% get_level "TAC" as USER_LEVEL_TAC %}
... ... @@ -588,7 +590,7 @@ footer{
588 590 <footer class="sticky-footer">
589 591 <div>
590 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 594 </div>
593 595 </div>
594 596 </footer>
... ...
src/core/pyros_django/pyros/settings.py
... ... @@ -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 51 # duplicate from the same function in pyros.py ...
49 52 def set_environment_variables_if_not_configured(env_path: str,env_sample_path: str)->None:
50 53 """
... ... @@ -392,4 +395,11 @@ else:
392 395 # from django.core.cache import cache
393 396 # cache.clear()
394 397  
395   -EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
396 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 407 \ No newline at end of file
... ...