diff --git a/DOSPORTAL/apps.py b/DOSPORTAL/apps.py new file mode 100644 index 0000000..c014f7e --- /dev/null +++ b/DOSPORTAL/apps.py @@ -0,0 +1,8 @@ +from django.apps import AppConfig + + +class DosportalConfig(AppConfig): + name = 'DOSPORTAL' + + def ready(self): + import DOSPORTAL.signals \ No newline at end of file diff --git a/DOSPORTAL/settings.py b/DOSPORTAL/settings.py index f90cef4..dd53230 100644 --- a/DOSPORTAL/settings.py +++ b/DOSPORTAL/settings.py @@ -39,6 +39,7 @@ 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.postgres', + 'django.contrib.gis', 'bootstrap5', #'background_task', #'django_json_widget', @@ -105,7 +106,8 @@ # 'NAME': BASE_DIR / 'db.sqlite3', # } "default": { - "ENGINE": "django.db.backends.postgresql", + #"ENGINE": "django.db.backends.postgresql", + "ENGINE": "django.contrib.gis.db.backends.postgis", "NAME": "dosportal", "USER": "dosportal_user", "PASSWORD": "dosportal_password", @@ -147,15 +149,6 @@ USE_TZ = True - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/4.2/howto/static-files/ - -STATIC_URL = 'static/' - -# Default primary key field type -# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field - DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' @@ -168,6 +161,9 @@ STATIC_ROOT = BASE_DIR / 'static' STATIC_URL = 'static/' +MEDIA_ROOT = BASE_DIR / 'data/media' +MEDIA_URL = 'media/' + REST_FRAMEWORK = { # Use Django's standard `django.contrib.auth` permissions, # or allow read-only access for unauthenticated users. @@ -211,9 +207,10 @@ 'save_limit': 250, 'queue_limit': 500, 'cpu_affinity': 1, - 'label': 'Django Q', - #'redis': { - # 'host': '127.0.0.1', + 'label': 'Worker', + 'redis': { + 'host': 'redis', # 'port': 6379, # 'db': 0, } + } } diff --git a/DOSPORTAL/signals.py b/DOSPORTAL/signals.py new file mode 100644 index 0000000..ac30546 --- /dev/null +++ b/DOSPORTAL/signals.py @@ -0,0 +1,37 @@ +from django.db.models.signals import post_save +from django.contrib.auth.models import User +from django.dispatch import receiver +from .models import Profile, record + + +@receiver(post_save, sender=User) +def create_profile(sender, instance, created, **kwargs): + if created: + Profile.objects.create(user=instance) + + +@receiver(post_save, sender=User) +def save_profile(sender, instance, **kwargs): + instance.profile.save() + + + +@receiver(post_save, sender=record) +def save_record(sender, instance, **kwargs): + print("AFTER SAVE.... ") + print(sender) + print(instance) + print(kwargs) + + filepath = 'data/media/'+instance.log_file + print(filepath) + + metadata = instance.metadata + + if 'device_info' not in metadata: + metadata['device_info'] = {} + + with open(filepath, 'r') as file: + for line in file: + print(line) + diff --git a/DOSPORTAL/templates/detectors/detector_edit.html b/DOSPORTAL/templates/detectors/detector_edit.html new file mode 100644 index 0000000..ec119a7 --- /dev/null +++ b/DOSPORTAL/templates/detectors/detector_edit.html @@ -0,0 +1,24 @@ + + +{% extends "base.html" %} +{% load crispy_forms_tags %} + +{% block content %} + +