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 %} + +
Edit detector
+ +
+
+
+
+ {% csrf_token %} + {{ detectorEditForm | crispy }} + +
+
+
+
+
+ + +{% endblock %} diff --git a/DOSPORTAL/templates/organizations/organization_profile.html b/DOSPORTAL/templates/organizations/organization_profile.html new file mode 100644 index 0000000..1224f1f --- /dev/null +++ b/DOSPORTAL/templates/organizations/organization_profile.html @@ -0,0 +1,46 @@ + +{% extends "base.html" %} +{% load martortags %} + +{% block content %} + +Organizace {{ organization.name }} {% if user.is_authenticated %} {%endif%} + +
+ +
+{% for a in organization.user_organizations.all %} + +
+ {{a.user.full_name }} + {{a.user}} +
+
+{% endfor %} +
+ + + + + +
+ +

Detectors

+{% for detector in organization.detectors.all %} + + + {{detector}}
+{% endfor %} +
+

Maintainer of detectors:

+ +TODO: + +

Author of measurements

+ +TODO: + + + + +{% endblock %} diff --git a/DOSPORTAL/templates/records/record_detail.html b/DOSPORTAL/templates/records/record_detail.html index 5131307..cec51b8 100644 --- a/DOSPORTAL/templates/records/record_detail.html +++ b/DOSPORTAL/templates/records/record_detail.html @@ -36,7 +36,7 @@
  • Advanced metadata:
  • {{record.metadata }}
  • Description: {{record}} -
  • File size: {{record.log_file.size}} + {#
  • File size: {{record.log_file.size}} #} diff --git a/DOSPORTAL/templates/records/record_new.html b/DOSPORTAL/templates/records/record_new.html index 7194c3a..52706f1 100644 --- a/DOSPORTAL/templates/records/record_new.html +++ b/DOSPORTAL/templates/records/record_new.html @@ -7,7 +7,7 @@ {% block content %}
    -
    + {% csrf_token %} {{ form | crispy }} diff --git a/DOSPORTAL/templates/records/records_list.html b/DOSPORTAL/templates/records/records_list.html index 7f51f1e..e481cc9 100644 --- a/DOSPORTAL/templates/records/records_list.html +++ b/DOSPORTAL/templates/records/records_list.html @@ -4,6 +4,8 @@ {% block content %}
    Recorded data
    + {{ records_list|length}} + {% if user.is_authenticated %} New record {% endif %} @@ -16,18 +18,17 @@ # Name Type - Autor - Popis + Author {% for record in record_list.reverse %} - {{ forloop.counter }} - {{ record.name }} + {{ forloop.counter }} + {{ record | truncatechars:50 }} {{ record.record_type }} {{record.author}} -
    {{record.description | safe_markdown }}
    +
    {{ record }}
    {% endfor %} diff --git a/DOSPORTAL/templates/user/user_profile.html b/DOSPORTAL/templates/user/user_profile.html index 5fdad83..a2f64b2 100644 --- a/DOSPORTAL/templates/user/user_profile.html +++ b/DOSPORTAL/templates/user/user_profile.html @@ -4,7 +4,7 @@ {% block content %} -

    Username: {{ user.username }} {% if user.is_authenticated %} {%endif%}

    +

    Username: {{ user.username }} {% if user.is_authenticated %} {%endif%}

    Email: {{ user.email }}

    First Name: {{ user.first_name }}

    Last Name: {{ user.last_name }}

    @@ -15,7 +15,7 @@

    Organisations:

    {% for a in user.organization_users.all %} -{{a}}
    +{{a}}
    {% endfor %}